]> granicus.if.org Git - zfs/commitdiff
Change boolean-like uint8_t fields in znode_t to boolean_t
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 13 Aug 2019 13:58:02 +0000 (22:58 +0900)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 13 Aug 2019 13:58:02 +0000 (07:58 -0600)
Given znode_t is an in-core structure, it's more readable to have
them as boolean. Also co-locate existing boolean fields with them
for space efficiency (expecting 8 booleans to be packed/aligned).

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Closes #9092

include/sys/zfs_znode.h
module/zfs/zfs_ctldir.c
module/zfs/zfs_vnops.c
module/zfs/zfs_znode.c

index d4a3ea769331794ef9124765c1615998605439cb..ef53684f739646baff231ebe62c22eef7036fad1 100644 (file)
@@ -192,10 +192,14 @@ typedef struct znode {
        krwlock_t       z_name_lock;    /* "master" lock for dirent locks */
        zfs_dirlock_t   *z_dirlocks;    /* directory entry lock list */
        rangelock_t     z_rangelock;    /* file range locks */
-       uint8_t         z_unlinked;     /* file has been unlinked */
-       uint8_t         z_atime_dirty;  /* atime needs to be synced */
-       uint8_t         z_zn_prefetch;  /* Prefetch znodes? */
-       uint8_t         z_moved;        /* Has this znode been moved? */
+       boolean_t       z_unlinked;     /* file has been unlinked */
+       boolean_t       z_atime_dirty;  /* atime needs to be synced */
+       boolean_t       z_zn_prefetch;  /* Prefetch znodes? */
+       boolean_t       z_moved;        /* Has this znode been moved? */
+       boolean_t       z_is_sa;        /* are we native sa? */
+       boolean_t       z_is_mapped;    /* are we mmap'ed */
+       boolean_t       z_is_ctldir;    /* are we .zfs entry */
+       boolean_t       z_is_stale;     /* are we stale due to rollback? */
        uint_t          z_blksz;        /* block size in bytes */
        uint_t          z_seq;          /* modification sequence number */
        uint64_t        z_mapcnt;       /* number of pages mapped to file */
@@ -212,10 +216,6 @@ typedef struct znode {
        uint64_t        z_projid;       /* project ID */
        list_node_t     z_link_node;    /* all znodes in fs link */
        sa_handle_t     *z_sa_hdl;      /* handle to sa data */
-       boolean_t       z_is_sa;        /* are we native sa? */
-       boolean_t       z_is_mapped;    /* are we mmap'ed */
-       boolean_t       z_is_ctldir;    /* are we .zfs entry */
-       boolean_t       z_is_stale;     /* are we stale due to rollback? */
        struct inode    z_inode;        /* generic vfs inode */
 } znode_t;
 
index 8acbbb61ca9d996d51d000b9be40b2244a1ad88a..b3cbc7d7e5fa85b67782d49cfa2f7913328f1b45 100644 (file)
@@ -463,10 +463,14 @@ zfsctl_inode_alloc(zfsvfs_t *zfsvfs, uint64_t id,
        ASSERT3P(zp->z_acl_cached, ==, NULL);
        ASSERT3P(zp->z_xattr_cached, ==, NULL);
        zp->z_id = id;
-       zp->z_unlinked = 0;
-       zp->z_atime_dirty = 0;
-       zp->z_zn_prefetch = 0;
-       zp->z_moved = 0;
+       zp->z_unlinked = B_FALSE;
+       zp->z_atime_dirty = B_FALSE;
+       zp->z_zn_prefetch = B_FALSE;
+       zp->z_moved = B_FALSE;
+       zp->z_is_sa = B_FALSE;
+       zp->z_is_mapped = B_FALSE;
+       zp->z_is_ctldir = B_TRUE;
+       zp->z_is_stale = B_FALSE;
        zp->z_sa_hdl = NULL;
        zp->z_blksz = 0;
        zp->z_seq = 0;
@@ -475,10 +479,6 @@ zfsctl_inode_alloc(zfsvfs_t *zfsvfs, uint64_t id,
        zp->z_pflags = 0;
        zp->z_mode = 0;
        zp->z_sync_cnt = 0;
-       zp->z_is_mapped = B_FALSE;
-       zp->z_is_ctldir = B_TRUE;
-       zp->z_is_sa = B_FALSE;
-       zp->z_is_stale = B_FALSE;
        ip->i_generation = 0;
        ip->i_ino = id;
        ip->i_mode = (S_IFDIR | S_IRWXUGO);
index 7f33aea43d484a5700e538b27c38efe4131b18cd..595bebc78df7fd4df2500d1fd62e32477557a6b2 100644 (file)
@@ -1655,7 +1655,7 @@ top:
                zfs_fuid_sync(zfsvfs, tx);
 
        /* Add to unlinked set */
-       zp->z_unlinked = 1;
+       zp->z_unlinked = B_TRUE;
        zfs_unlinked_add(zp, tx);
        zfs_acl_ids_free(&acl_ids);
        dmu_tx_commit(tx);
@@ -1854,7 +1854,7 @@ top:
                if (xattr_obj_unlinked) {
                        ASSERT3U(ZTOI(xzp)->i_nlink, ==, 2);
                        mutex_enter(&xzp->z_lock);
-                       xzp->z_unlinked = 1;
+                       xzp->z_unlinked = B_TRUE;
                        clear_nlink(ZTOI(xzp));
                        links = 0;
                        error = sa_update(xzp->z_sa_hdl, SA_ZPL_LINKS(zfsvfs),
@@ -3406,7 +3406,7 @@ top:
        }
 
        if ((mask & ATTR_ATIME) || zp->z_atime_dirty) {
-               zp->z_atime_dirty = 0;
+               zp->z_atime_dirty = B_FALSE;
                ZFS_TIME_ENCODE(&ip->i_atime, atime);
                SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zfsvfs), NULL,
                    &atime, sizeof (atime));
@@ -4370,7 +4370,7 @@ top:
        }
        /* unmark z_unlinked so zfs_link_create will not reject */
        if (is_tmpfile)
-               szp->z_unlinked = 0;
+               szp->z_unlinked = B_FALSE;
        error = zfs_link_create(dl, szp, tx, 0);
 
        if (error == 0) {
@@ -4392,7 +4392,7 @@ top:
                }
        } else if (is_tmpfile) {
                /* restore z_unlinked since when linking failed */
-               szp->z_unlinked = 1;
+               szp->z_unlinked = B_TRUE;
        }
        txg = dmu_tx_get_txg(tx);
        dmu_tx_commit(tx);
@@ -4590,7 +4590,7 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc)
        /* Preserve the mtime and ctime provided by the inode */
        ZFS_TIME_ENCODE(&ip->i_mtime, mtime);
        ZFS_TIME_ENCODE(&ip->i_ctime, ctime);
-       zp->z_atime_dirty = 0;
+       zp->z_atime_dirty = B_FALSE;
        zp->z_seq++;
 
        err = sa_bulk_update(zp->z_sa_hdl, bulk, cnt, tx);
@@ -4644,7 +4644,7 @@ zfs_dirty_inode(struct inode *ip, int flags)
         * only need to dirty atime.
         */
        if (flags == I_DIRTY_TIME) {
-               zp->z_atime_dirty = 1;
+               zp->z_atime_dirty = B_TRUE;
                goto out;
        }
 #endif
@@ -4661,7 +4661,7 @@ zfs_dirty_inode(struct inode *ip, int flags)
        }
 
        mutex_enter(&zp->z_lock);
-       zp->z_atime_dirty = 0;
+       zp->z_atime_dirty = B_FALSE;
 
        SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_MODE(zfsvfs), NULL, &mode, 8);
        SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_ATIME(zfsvfs), NULL, &atime, 16);
@@ -4706,7 +4706,7 @@ zfs_inactive(struct inode *ip)
                return;
        }
 
-       if (zp->z_atime_dirty && zp->z_unlinked == 0) {
+       if (zp->z_atime_dirty && zp->z_unlinked == B_FALSE) {
                dmu_tx_t *tx = dmu_tx_create(zfsvfs->z_os);
 
                dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
@@ -4719,7 +4719,7 @@ zfs_inactive(struct inode *ip)
                        mutex_enter(&zp->z_lock);
                        (void) sa_update(zp->z_sa_hdl, SA_ZPL_ATIME(zfsvfs),
                            (void *)&atime, sizeof (atime), tx);
-                       zp->z_atime_dirty = 0;
+                       zp->z_atime_dirty = B_FALSE;
                        mutex_exit(&zp->z_lock);
                        dmu_tx_commit(tx);
                }
index 3dd2999422025fc67983c01efed91b3453a8c022..498547758b1b00e4c73ef0cd77184d0f3fb58d12 100644 (file)
@@ -135,7 +135,7 @@ zfs_znode_cache_constructor(void *buf, void *arg, int kmflags)
        zp->z_acl_cached = NULL;
        zp->z_xattr_cached = NULL;
        zp->z_xattr_parent = 0;
-       zp->z_moved = 0;
+       zp->z_moved = B_FALSE;
        return (0);
 }
 
@@ -539,18 +539,18 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
        ASSERT(zp->z_dirlocks == NULL);
        ASSERT3P(zp->z_acl_cached, ==, NULL);
        ASSERT3P(zp->z_xattr_cached, ==, NULL);
-       zp->z_moved = 0;
+       zp->z_unlinked = B_FALSE;
+       zp->z_atime_dirty = B_FALSE;
+       zp->z_moved = B_FALSE;
+       zp->z_is_mapped = B_FALSE;
+       zp->z_is_ctldir = B_FALSE;
+       zp->z_is_stale = B_FALSE;
        zp->z_sa_hdl = NULL;
-       zp->z_unlinked = 0;
-       zp->z_atime_dirty = 0;
        zp->z_mapcnt = 0;
        zp->z_id = db->db_object;
        zp->z_blksz = blksz;
        zp->z_seq = 0x7A4653;
        zp->z_sync_cnt = 0;
-       zp->z_is_mapped = B_FALSE;
-       zp->z_is_ctldir = B_FALSE;
-       zp->z_is_stale = B_FALSE;
 
        zfs_znode_sa_init(zfsvfs, zp, db, obj_type, hdl);
 
@@ -1263,7 +1263,7 @@ zfs_rezget(znode_t *zp)
        zfs_set_inode_flags(zp, ZTOI(zp));
 
        zp->z_blksz = doi.doi_data_block_size;
-       zp->z_atime_dirty = 0;
+       zp->z_atime_dirty = B_FALSE;
        zfs_inode_update(zp);
 
        /*
@@ -1883,9 +1883,9 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
        vattr.va_gid = crgetgid(cr);
 
        rootzp = kmem_cache_alloc(znode_cache, KM_SLEEP);
-       rootzp->z_moved = 0;
-       rootzp->z_unlinked = 0;
-       rootzp->z_atime_dirty = 0;
+       rootzp->z_unlinked = B_FALSE;
+       rootzp->z_atime_dirty = B_FALSE;
+       rootzp->z_moved = B_FALSE;
        rootzp->z_is_sa = USE_SA(version, os);
        rootzp->z_pflags = 0;