Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/external/cddl/osnet/dist/uts/common/fs/zfs Pull up follow...



details:   https://anonhg.NetBSD.org/src/rev/2f49013e4b4e
branches:  netbsd-9
changeset: 1001744:2f49013e4b4e
user:      martin <martin%NetBSD.org@localhost>
date:      Sat May 09 08:20:34 2020 +0000

description:
Pull up following revision(s) (requested by hannken in ticket #897):

        external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c: revision 1.33
        external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c: revision 1.65

Revert Rev. 1.63 and add a comment why we have to zil_commit() here:

Operation zfs_znode.c::zfs_zget_cleaner() depends on this
zil_commit() as a barrier to guarantee the znode cannot
get freed before its log entries are resolved.

Operation zfs_zget_cleaner() cannot fail, comment and add assertions.

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c |  13 ++++++--
 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c |  27 +++++++++--------
 2 files changed, 23 insertions(+), 17 deletions(-)

diffs (79 lines):

diff -r c561b31a9083 -r 2f49013e4b4e external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c    Sat May 09 08:16:54 2020 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c    Sat May 09 08:20:34 2020 +0000
@@ -5836,10 +5836,15 @@
                        zp->z_atime_dirty = 0;
                        dmu_tx_commit(tx);
                }
-
-               if (zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
-                       zil_commit(zfsvfs->z_log, zp->z_id);
-       }
+       }
+
+       /*
+        * Operation zfs_znode.c::zfs_zget_cleaner() depends on this
+        * zil_commit() as a barrier to guarantee the znode cannot
+        * get freed before its log entries are resolved.
+        */
+       if (zfsvfs->z_log)
+               zil_commit(zfsvfs->z_log, zp->z_id);
 
        if (zp->z_sa_hdl == NULL)
                zfs_znode_free(zp);
diff -r c561b31a9083 -r 2f49013e4b4e external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c    Sat May 09 08:16:54 2020 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c    Sat May 09 08:20:34 2020 +0000
@@ -1288,6 +1288,12 @@
        return error;
 }
 
+/*
+ * Get a known cached znode, to be used from zil_commit()->zfs_get_data()
+ * to resolve log entries.  Doesn't take a reference, will never fail and
+ * depends on zfs_vnops.c::zfs_netbsd_reclaim() running a zil_commit()
+ * before the znode gets freed.
+ */
 int
 zfs_zget_cleaner(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp)
 {
@@ -1295,31 +1301,26 @@
        sa_handle_t *hdl;
        dmu_object_info_t doi;
        znode_t *zp;
-       int err;
 
        ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num);
 
-       err = sa_buf_hold(zfsvfs->z_os, obj_num, NULL, &db);
-       if (err) {
-               ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
-               return (SET_ERROR(err));
-       }
+       VERIFY(0 == sa_buf_hold(zfsvfs->z_os, obj_num, NULL, &db));
 
        dmu_object_info_from_db(db, &doi);
-       if (doi.doi_bonus_type != DMU_OT_SA &&
-           (doi.doi_bonus_type != DMU_OT_ZNODE ||
+       ASSERT(doi.doi_bonus_type == DMU_OT_SA ||
            (doi.doi_bonus_type == DMU_OT_ZNODE &&
-           doi.doi_bonus_size < sizeof (znode_phys_t)))) {
-               sa_buf_rele(db, NULL);
-               ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
-               return (SET_ERROR(EINVAL));
-       }
+           doi.doi_bonus_size >= sizeof (znode_phys_t)));
+
        hdl = dmu_buf_get_user(db);
        ASSERT3P(hdl, !=, NULL);
+
        zp = sa_get_userdata(hdl);
        ASSERT3U(zp->z_id, ==, obj_num);
+
        sa_buf_rele(db, NULL);
+
        ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
+
        *zpp = zp;
        return (0);
 }



Home | Main Index | Thread Index | Old Index