xfs: remove XFS_HSIZE
PATCH 1/1 xfs: remove XFS_HSIZE
XFS_HSIZE is an extremly confusing way to calculate the size of handle_t. Given that handle_t always only had two sizes, and one of them isn't even covered by XFS_HSIZE to start with just remove the macro and use a constant sizeof expression.
Note that XFS_HSIZE isn't used in xfsprogs, xfsdump or xfstests either.
--- fs/xfs/libxfs/xfs_fs.h | 4 ---- fs/xfs/xfs_ioctl.c | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-)
fs/xfs/libxfs/xfs_fs.h +0 -4
@@ -446,10 +446,6 @@ typedef struct xfs_handle { } xfs_handle_t;#define ha_fsid ha_u._ha_fsid -#define XFS_HSIZE (handle) (((char *) &(handle).ha_fid.fid_pad \ - - (char *) &(handle)) \ - + (handle).ha_fid.fid_len) -/* * Structure passed to XFS_IOC_SWAPEXT */
fs/xfs/xfs_ioctl.c +1 -2
@@ -120,8 +120,7 @@ xfs_find_handle( handle.ha_fid.fid_pad =0 ; handle.ha_fid.fid_gen = inode->i_generation; handle.ha_fid.fid_ino = ip->i_ino; - - hsize =XFS_HSIZE (handle); + hsize =sizeof (xfs_handle_t); } error = -EFAULT ;
Signature · 1 line
2.11.0
Quoted 8 lines · Christoph Hellwig
XFS_HSIZEis an extremly confusing way to calculate the size ofhandle_t. Given thathandle_talways only had two sizes, and one of them isn't even covered byXFS_HSIZEto start with just remove the macro and use a constant sizeof expression.Note that
XFS_HSIZEisn't used in xfsprogs, xfsdump or xfstests either.Signed-off-by Christoph Hellwig <[email protected]>
Quoted 41 lines
--- fs/xfs/libxfs/xfs_fs.h | 4 ---- fs/xfs/xfs_ioctl.c | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-)fs/xfs/libxfs/xfs_fs.h +0
-4@@ -446,10 +446,6 @@ typedef struct xfs_handle { } xfs_handle_t;#define ha_fsid ha_u._ha_fsid -#define XFS_HSIZE (handle) (((char *) &(handle).ha_fid.fid_pad \ - - (char *) &(handle)) \ - + (handle).ha_fid.fid_len) -/* * Structure passed to XFS_IOC_SWAPEXT */ fs/xfs/xfs_ioctl.c +1
-2@@ -120,8 +120,7 @@ xfs_find_handle( handle.ha_fid.fid_pad =0 ; handle.ha_fid.fid_gen = inode->i_generation; handle.ha_fid.fid_ino = ip->i_ino; - - hsize =XFS_HSIZE (handle); + hsize =sizeof (xfs_handle_t); } error = -EFAULT ;Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 11 lines · Darrick J. Wong
Quoted 8 lines · Christoph Hellwig
XFS_HSIZEis an extremly confusing way to calculate the size ofhandle_t. Given thathandle_talways only had two sizes, and one of them isn't even covered byXFS_HSIZEto start with just remove the macro and use a constant sizeof expression.Note that
XFS_HSIZEisn't used in xfsprogs, xfsdump or xfstests either.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>
By the way, do you want me to try to slip this cleanup into 4.12, or should it wait for 4.13?
--D
Quoted 46 lines
Quoted 42 lines
--- fs/xfs/libxfs/xfs_fs.h | 4 ---- fs/xfs/xfs_ioctl.c | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-)fs/xfs/libxfs/xfs_fs.h +0
-4@@ -446,10 +446,6 @@ typedef struct xfs_handle { } xfs_handle_t;#define ha_fsid ha_u._ha_fsid -#define XFS_HSIZE (handle) (((char *) &(handle).ha_fid.fid_pad \ - - (char *) &(handle)) \ - + (handle).ha_fid.fid_len) -/* * Structure passed to XFS_IOC_SWAPEXT */ fs/xfs/xfs_ioctl.c +1
-2@@ -120,8 +120,7 @@ xfs_find_handle( handle.ha_fid.fid_pad =0 ; handle.ha_fid.fid_gen = inode->i_generation; handle.ha_fid.fid_ino = ip->i_ino; - - hsize =XFS_HSIZE (handle); + hsize =sizeof (xfs_handle_t); } error = -EFAULT ;Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
No need to expedite a simple cleanup.
Quoted 8 lines · Christoph Hellwig
XFS_HSIZEis an extremly confusing way to calculate the size ofhandle_t. Given thathandle_talways only had two sizes, and one of them isn't even covered byXFS_HSIZEto start with just remove the macro and use a constant sizeof expression.Note that
XFS_HSIZEisn't used in xfsprogs, xfsdump or xfstests either.Signed-off-by Christoph Hellwig <[email protected]>
Ok, so with this assignment a few lines before:
handle.ha_fid.fid_len = sizeof(xfs_fid_t) - sizeof(handle.ha_fid.fid_len);
(so: fid_len == size of (fid_pad + fid_gen + fid_ino))
and:
(((char *) &(handle).ha_fid.fid_pad - (char *) &(handle)) + (handle).ha_fid.fid_len)
|< -- size of ha_u + sizeof fid_len --> | |<-sizeof(pad+gen+ino)->|
this does indeed seem to come out to sizeof(xfs_handle_t).
Looks winning, minor comment below
Quoted 25 lines
--- fs/xfs/libxfs/xfs_fs.h | 4 ---- fs/xfs/xfs_ioctl.c | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-)fs/xfs/libxfs/xfs_fs.h +0
-4@@ -446,10 +446,6 @@ typedef struct xfs_handle { } xfs_handle_t;#define ha_fsid ha_u._ha_fsid -#define XFS_HSIZE (handle) (((char *) &(handle).ha_fid.fid_pad \ - - (char *) &(handle)) \ - + (handle).ha_fid.fid_len) -/* * Structure passed to XFS_IOC_SWAPEXT */ fs/xfs/xfs_ioctl.c +0
-0
fs/xfs/xfs_ioctl.c xfs_find_handle( · line 123
Quoted 6 lines
fs/xfs/xfs_ioctl.c +1
-2@@ -120,8 +120,7 @@ xfs_find_handle( handle.ha_fid.fid_pad =0 ; handle.ha_fid.fid_gen = inode->i_generation; handle.ha_fid.fid_ino = ip->i_ino; - - hsize =XFS_HSIZE (handle); + hsize =sizeof (xfs_handle_t);
at this point, no need to have the hsize assignment in if { } as well as else { }, right?
-Eric
Quoted 4 lines
fs/xfs/xfs_ioctl.c +0
-0} error = -EFAULT ;
Quoted 6 lines · Eric Sandeen
fs/xfs/xfs_ioctl.c xfs_find_handle( · line 123
Quoted 3 lines
fs/xfs/xfs_ioctl.c +1
-2- - hsize =XFS_HSIZE (handle); + hsize =sizeof (xfs_handle_t);at this point, no need to have the hsize assignment in if { } as well as else { }, right?
In the other branch hsize is smaller, it only covers the fsid.
Eric Sandeen
Reviewed-byQuoted 13 lines · Christoph Hellwig
Quoted 6 lines · Eric Sandeen
fs/xfs/xfs_ioctl.c xfs_find_handle( · line 123
Quoted 3 lines
fs/xfs/xfs_ioctl.c +1
-2- - hsize =XFS_HSIZE (handle); + hsize =sizeof (xfs_handle_t);at this point, no need to have the hsize assignment in if { } as well as else { }, right?
In the other branch hsize is smaller, it only covers the fsid.
Ugh I misread, sorry.