From: Christoph Hellwig Date: Fri, 17 Nov 2017 04:11:33 +0000 (-0600) Subject: xfs: remove if_rdev X-Git-Tag: v4.15.0-rc1~143^2~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=551174eb7a8397b4fcb202ec950db11c9cec541e;p=thirdparty%2Fxfsprogs-dev.git xfs: remove if_rdev Source kernel commit: 66f364649d870c7541c30a2f02a32fd4c88684f0 We can simply use the i_rdev field in the Linux inode and just convert to and from the XFS dev_t when reading or logging/writing the inode. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong [sandeen: add i_rdev to our mocked up inode in userspace] [djwong: use IRIX_DEV macros, assign in i_rdev in libxfs_ialloc] Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- diff --git a/include/xfs_inode.h b/include/xfs_inode.h index 05adea59f..005a5b26f 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -36,6 +36,7 @@ struct xfs_dir_ops; struct inode { mode_t i_mode; uint32_t i_nlink; + dev_t i_rdev; uint32_t i_generation; uint64_t i_version; struct timespec i_atime; diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index ca7e3241c..709b4b81e 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -87,6 +87,15 @@ extern char *progname; #undef ASSERT #define ASSERT(ex) assert(ex) +#define MKDEV(major, minor) IRIX_MKDEV(major, minor) +#define sysv_major(dev) IRIX_DEV_MAJOR(dev) +#define sysv_minor(dev) IRIX_DEV_MINOR(dev) + +static inline uint32_t sysv_encode_dev(dev_t dev) +{ + return IRIX_DEV_MINOR(dev) | (IRIX_DEV_MAJOR(dev) << 18); +} + #ifndef EWRONGFS #define EWRONGFS EINVAL #endif diff --git a/libxfs/util.c b/libxfs/util.c index fc96b3309..cc0791e4c 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -335,8 +335,8 @@ libxfs_ialloc( case S_IFCHR: case S_IFBLK: ip->i_d.di_format = XFS_DINODE_FMT_DEV; - ip->i_df.if_u2.if_rdev = rdev; flags |= XFS_ILOG_DEV; + VFS_I(ip)->i_rdev = rdev; break; case S_IFREG: case S_IFDIR: diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c index 045fd7aaa..01d1f8995 100644 --- a/libxfs/xfs_inode_fork.c +++ b/libxfs/xfs_inode_fork.c @@ -39,21 +39,27 @@ STATIC int xfs_iformat_local(xfs_inode_t *, xfs_dinode_t *, int, int); STATIC int xfs_iformat_extents(xfs_inode_t *, xfs_dinode_t *, int); STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int); +static inline dev_t xfs_to_linux_dev_t(xfs_dev_t dev) +{ + return MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev)); +} + /* - * Move inode type and inode format specific information from the - * on-disk inode to the in-core inode. For fifos, devs, and sockets - * this means set if_rdev to the proper value. For files, directories, - * and symlinks this means to bring in the in-line data or extent - * pointers. For a file in B-tree format, only the root is immediately - * brought in-core. The rest will be in-lined in if_extents when it - * is first referenced (see xfs_iread_extents()). + * Copy inode type and data and attr format specific information from the + * on-disk inode to the in-core inode and fork structures. For fifos, devices, + * and sockets this means set i_rdev to the proper value. For files, + * directories, and symlinks this means to bring in the in-line data or extent + * pointers as well as the attribute fork. For a fork in B-tree format, only + * the root is immediately brought in-core. The rest will be read in later when + * first referenced (see xfs_iread_extents()). */ int xfs_iformat_fork( - xfs_inode_t *ip, - xfs_dinode_t *dip) + struct xfs_inode *ip, + struct xfs_dinode *dip) { - xfs_attr_shortform_t *atp; + struct inode *inode = VFS_I(ip); + struct xfs_attr_shortform *atp; int size; int error = 0; xfs_fsize_t di_size; @@ -92,8 +98,7 @@ xfs_iformat_fork( return -EFSCORRUPTED; } - if (unlikely(xfs_is_reflink_inode(ip) && - (VFS_I(ip)->i_mode & S_IFMT) != S_IFREG)) { + if (unlikely(xfs_is_reflink_inode(ip) && !S_ISREG(inode->i_mode))) { xfs_warn(ip->i_mount, "corrupt dinode %llu, wrong file type for reflink.", ip->i_ino); @@ -112,7 +117,7 @@ xfs_iformat_fork( return -EFSCORRUPTED; } - switch (VFS_I(ip)->i_mode & S_IFMT) { + switch (inode->i_mode & S_IFMT) { case S_IFIFO: case S_IFCHR: case S_IFBLK: @@ -123,7 +128,7 @@ xfs_iformat_fork( return -EFSCORRUPTED; } ip->i_d.di_size = 0; - ip->i_df.if_u2.if_rdev = xfs_dinode_get_rdev(dip); + inode->i_rdev = xfs_to_linux_dev_t(xfs_dinode_get_rdev(dip)); break; case S_IFREG: @@ -181,8 +186,7 @@ xfs_iformat_fork( return error; /* Check inline dir contents. */ - if (S_ISDIR(VFS_I(ip)->i_mode) && - dip->di_format == XFS_DINODE_FMT_LOCAL) { + if (S_ISDIR(inode->i_mode) && dip->di_format == XFS_DINODE_FMT_LOCAL) { error = xfs_dir2_sf_verify(ip); if (error) { xfs_idestroy_fork(ip, XFS_DATA_FORK); @@ -895,7 +899,7 @@ xfs_iflush_fork( case XFS_DINODE_FMT_DEV: if (iip->ili_fields & XFS_ILOG_DEV) { ASSERT(whichfork == XFS_DATA_FORK); - xfs_dinode_put_rdev(dip, ip->i_df.if_u2.if_rdev); + xfs_dinode_put_rdev(dip, sysv_encode_dev(VFS_I(ip)->i_rdev)); } break; diff --git a/libxfs/xfs_inode_fork.h b/libxfs/xfs_inode_fork.h index 064babdc3..e0c42ea9b 100644 --- a/libxfs/xfs_inode_fork.h +++ b/libxfs/xfs_inode_fork.h @@ -69,7 +69,6 @@ typedef struct xfs_ifork { /* very small file extents */ char if_inline_data[XFS_INLINE_DATA]; /* very small file data */ - xfs_dev_t if_rdev; /* dev number if special */ } if_u2; } xfs_ifork_t;