From nobody Mon Aug 15 18:07:42 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M62Lk71c5z4Zf2q; Mon, 15 Aug 2022 18:07:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M62Lk6VhLz44Vf; Mon, 15 Aug 2022 18:07:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660586862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tBQTIwjRHN2NwNhnX3G/qVPC+o8rs5rNNcPVGkc+iME=; b=OEdfPq864ZMhRfuwHHCizkFNCFzznpqXFbsg2QAfGgIGHAQiDoeejnZSZ3Vg0UMvrGpRN7 vNsmz1uLMiGzV7zfuk7wI6kJCTcBn8dZ0Qo4NTPQCXXsIfc7iqMhetMoAFfdQdTTzaPuh+ Z+uVHHbKRPzXoHWC4JY1WL1Oa9D2toD/yCbtOilX/gbJzjFa6rmdR6JTCQNZQfbg83z2bW YBoCRO3YQBUP0aFkIbc21vG0vLDV5PEUvzJ7lPF/6WS8C8LgURoxRKGKnwgQo8ePy3K3+9 ih5HIy/+zr8/te52b1TFo/hq/u8crjryzoOSqR/B03rGhiFE+jT9eN1V5DB8CA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4M62Lk5SlpzfLL; Mon, 15 Aug 2022 18:07:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27FI7gAk071247; Mon, 15 Aug 2022 18:07:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27FI7gpM071246; Mon, 15 Aug 2022 18:07:42 GMT (envelope-from git) Date: Mon, 15 Aug 2022 18:07:42 GMT Message-Id: <202208151807.27FI7gpM071246@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Toomas Soome Subject: git: d98de7440507 - main - loader: zfs reader should only store devdesc in f_devdata List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d98de7440507aea1648c8f4bc302bf88c0eb9458 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660586862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tBQTIwjRHN2NwNhnX3G/qVPC+o8rs5rNNcPVGkc+iME=; b=O/LhwlvAY9M+tLsg8kYpTsWMsT7peIKXfthnt8H5YmuI406GkrHVDMFAJOFzTUTdiIJTgS iLszO0n6hLuUdUkS6WJywQJM/ZIEDW6JJ3M4TwjY5maugVWcF5SeqRlCJMPXg3i7gmbDdK i5XcXRuvSnXdKq7++UyOqNJhHI71182xWaFU2QB6t9fA9UMUECsOPq1y+P9Jh0LreaBeiR 7qS/KdQccoNtdnfKhPpVYos+UYNyJOuG1M7QnlCM9AoryMIO/Be+ZCwOEpqfpNW1YwrJea uPDpXHWxjwtCg7YA52lH53o30Zj0tzIGmcATTyWZQlTPvWKWso1zYC2rwVbL2Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660586862; a=rsa-sha256; cv=none; b=EsgnQsgu4TgLXyy+Flxp7hJ57h495dY1+a8NfFWnsE9onFZaGnnJRO38SyWeZh6eoAvG9g XxoZeUfuUnpB4MZ9thu8wBLoLsWMiJK0GKNhGaV8q1lMwMtNPiACAhIcEn1vo6geI5T7kL 7t4geMPHFMsqIYCC802YxsmJmQBFejFCgXI8d6VpwvcB2xEV9KIvorGdUgBPt1YmsdtzoR WFOrjpCh8qCY5lHzEJ/4OcXRpxEW2SER6cbOa0cHZmWlGjj6A1mBpHNME1oRZwWBHvy23H lC1mydLb6H9HQUOFJHd42b+unImeDHn1UyRgNKZ8TjPbH5wpZtzbqY0rEPARdQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=d98de7440507aea1648c8f4bc302bf88c0eb9458 commit d98de7440507aea1648c8f4bc302bf88c0eb9458 Author: Toomas Soome AuthorDate: 2022-08-14 21:49:50 +0000 Commit: Toomas Soome CommitDate: 2022-08-15 18:07:23 +0000 loader: zfs reader should only store devdesc in f_devdata Use d_opendata for device specific data. PR: 265825 Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D36202 --- stand/libsa/zfs/zfs.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/stand/libsa/zfs/zfs.c b/stand/libsa/zfs/zfs.c index b525858ffc3c..bee243352f78 100644 --- a/stand/libsa/zfs/zfs.c +++ b/stand/libsa/zfs/zfs.c @@ -108,7 +108,8 @@ struct zfs_be_entry { static int zfs_open(const char *upath, struct open_file *f) { - struct zfsmount *mount = (struct zfsmount *)f->f_devdata; + struct devdesc *dev = f->f_devdata; + struct zfsmount *mount = dev->d_opendata; struct file *fp; int rc; @@ -149,7 +150,8 @@ zfs_close(struct open_file *f) static int zfs_read(struct open_file *f, void *start, size_t size, size_t *resid /* out */) { - const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; + struct devdesc *dev = f->f_devdata; + const spa_t *spa = ((struct zfsmount *)dev->d_opendata)->spa; struct file *fp = (struct file *)f->f_fsdata; struct stat sb; size_t n; @@ -213,7 +215,8 @@ zfs_seek(struct open_file *f, off_t offset, int where) static int zfs_stat(struct open_file *f, struct stat *sb) { - const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; + struct devdesc *dev = f->f_devdata; + const spa_t *spa = ((struct zfsmount *)dev->d_opendata)->spa; struct file *fp = (struct file *)f->f_fsdata; return (zfs_dnode_stat(spa, &fp->f_dnode, sb)); @@ -222,7 +225,8 @@ zfs_stat(struct open_file *f, struct stat *sb) static int zfs_readdir(struct open_file *f, struct dirent *d) { - const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; + struct devdesc *dev = f->f_devdata; + const spa_t *spa = ((struct zfsmount *)dev->d_opendata)->spa; struct file *fp = (struct file *)f->f_fsdata; mzap_ent_phys_t mze; struct stat sb; @@ -1586,8 +1590,7 @@ zfs_dev_open(struct open_file *f, ...) rv = zfs_mount(devformat(&dev->dd), NULL, (void **)&mount); if (rv == 0) { - f->f_devdata = mount; - free(dev); + dev->dd.d_opendata = mount; } return (rv); } @@ -1595,25 +1598,18 @@ zfs_dev_open(struct open_file *f, ...) static int zfs_dev_close(struct open_file *f) { + struct devdesc *dev; struct zfsmount *mnt, *mount; - mnt = f->f_devdata; + dev = f->f_devdata; + mnt = dev->d_opendata; STAILQ_FOREACH(mount, &zfsmount, next) { if (mnt->spa->spa_guid == mount->spa->spa_guid) break; } - /* - * devclose() will free f->f_devdata, but since we do have - * pointer to zfsmount structure in f->f_devdata, and - * zfs_unmount() will also free the zfsmount structure, - * we will get double free. To prevent double free, - * we must set f_devdata to NULL there. - */ - if (mount != NULL) - f->f_devdata = NULL; - + /* XXX */ return (0); }