Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

znode_t::z_{unlinked,zn_prefetch} are not boolean #9092

Merged
merged 1 commit into from
Aug 13, 2019

Conversation

kusumi
Copy link
Member

@kusumi kusumi commented Jul 29, 2019

Motivation and Context

Description

Several boolean-like members in znode_t (incore structure) are
of uint8_t. Change assignments to use 1/0. Majority of them are
already 1/0 with some exceptions fixed in this commit.

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist:

@@ -423,7 +423,7 @@ zfs_dirlook(znode_t *dzp, char *name, struct inode **ipp, int flags,
if (error == 0) {
*ipp = ZTOI(zp);
zfs_dirent_unlock(dl);
dzp->z_zn_prefetch = B_TRUE; /* enable prefetching */
dzp->z_zn_prefetch = 1; /* enable prefetching */
Copy link
Contributor

@behlendorf behlendorf Jul 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it would be worthwhile to convert all of these uint8_t's to boolean_t's and to co-locate them. That should save a full uint64_t per znode_t which does add up! What do you think of something like this?

diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h
index d4a3ea7..ef53684 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;
 

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.
I also prefer this way, if we want to change znode_t (increases diff vs other zfs) for non-functional stuff.

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Jul 29, 2019
@codecov
Copy link

codecov bot commented Jul 30, 2019

Codecov Report

Merging #9092 into master will decrease coverage by 12.51%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #9092       +/-   ##
===========================================
- Coverage   79.32%   66.81%   -12.52%     
===========================================
  Files         400      326       -74     
  Lines      121640   104364    -17276     
===========================================
- Hits        96493    69729    -26764     
- Misses      25147    34635     +9488
Flag Coverage Δ
#kernel ?
#user 66.81% <ø> (-0.74%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e620c9...580090a. Read the comment docs.

Given znode_t is an incore 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).

Signed-off-by: Tomohiro Kusumi <[email protected]>
@behlendorf behlendorf requested a review from tonyhutter July 30, 2019 18:19
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Aug 13, 2019
@behlendorf behlendorf merged commit a43570c into openzfs:master Aug 13, 2019
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Dec 24, 2019
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 openzfs#9092
Conflicts:
	include/sys/zfs_znode.h
	module/zfs/zfs_znode.c
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Dec 27, 2019
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 openzfs#9092
Conflicts:
	include/sys/zfs_znode.h
	module/zfs/zfs_znode.c
tonyhutter pushed a commit that referenced this pull request Jan 23, 2020
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
Conflicts:
	include/sys/zfs_znode.h
	module/zfs/zfs_znode.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants