diff options
author | Tomohiro Kusumi <[email protected]> | 2019-08-13 22:58:02 +0900 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-08-13 07:58:02 -0600 |
commit | a43570c5f3ca11957c23b4e073a520963cd9cfb2 (patch) | |
tree | a6c561ef4243cee81ad4a821ed8d62228b789630 | |
parent | fccbd1d6e2e0a95511ad3e1c743b98bf31a6b6c9 (diff) |
Change boolean-like uint8_t fields in znode_t to boolean_t
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 <[email protected]>
Signed-off-by: Tomohiro Kusumi <[email protected]>
Closes #9092
-rw-r--r-- | include/sys/zfs_znode.h | 16 | ||||
-rw-r--r-- | module/zfs/zfs_ctldir.c | 16 | ||||
-rw-r--r-- | module/zfs/zfs_vnops.c | 20 | ||||
-rw-r--r-- | module/zfs/zfs_znode.c | 22 |
4 files changed, 37 insertions, 37 deletions
diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h index d4a3ea769..ef53684f7 100644 --- a/include/sys/zfs_znode.h +++ b/include/sys/zfs_znode.h @@ -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; diff --git a/module/zfs/zfs_ctldir.c b/module/zfs/zfs_ctldir.c index 8acbbb61c..b3cbc7d7e 100644 --- a/module/zfs/zfs_ctldir.c +++ b/module/zfs/zfs_ctldir.c @@ -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); diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 7f33aea43..595bebc78 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -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); } diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c index 3dd299942..498547758 100644 --- a/module/zfs/zfs_znode.c +++ b/module/zfs/zfs_znode.c @@ -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; |