]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: remove if_rdev
authorChristoph Hellwig <hch@lst.de>
Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)
committerEric Sandeen <sandeen@redhat.com>
Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)
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 <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[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 <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/xfs_inode.h
libxfs/libxfs_priv.h
libxfs/util.c
libxfs/xfs_inode_fork.c
libxfs/xfs_inode_fork.h

index 05adea59f967f725e6fb5e36a31daa0ff7b0a867..005a5b26f7d47d27b83e63fd50901f8ff15e7a4f 100644 (file)
@@ -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;
index ca7e3241cf4b32edda1844281153100cf004c3e9..709b4b81e72c984099e6464da013508704750654 100644 (file)
@@ -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
index fc96b3309c2461caf3a42c4b3476ef89f4c86d44..cc0791e4cc976ea457ca7db9921b66f2f82d3892 100644 (file)
@@ -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:
index 045fd7aaab37c8db913f0c7912342453650ae900..01d1f8995c6e27929fff5a1f0d9eace8e8d8d713 100644 (file)
@@ -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;
 
index 064babdc373c9b7577bca93868c5ae335fa655a3..e0c42ea9b8d0c189e54089909c4a986c37229034 100644 (file)
@@ -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;