OSDN Git Service

xfs: introduce v5 inode group structure
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 4 Jul 2019 03:36:27 +0000 (20:36 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Thu, 4 Jul 2019 03:36:27 +0000 (20:36 -0700)
Introduce a new "v5" inode group structure that fixes the alignment
and padding problems of the existing structure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
fs/xfs/libxfs/xfs_fs.h
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_ioctl.h
fs/xfs/xfs_ioctl32.c
fs/xfs/xfs_itable.c
fs/xfs/xfs_itable.h
fs/xfs/xfs_ondisk.h

index 132e364..8b8fe78 100644 (file)
@@ -445,6 +445,17 @@ struct xfs_inogrp {
        __u64           xi_allocmask;   /* mask of allocated inodes     */
 };
 
+/* New inumbers structure that reports v5 features and fixes padding issues */
+struct xfs_inumbers {
+       uint64_t        xi_startino;    /* starting inode number        */
+       uint64_t        xi_allocmask;   /* mask of allocated inodes     */
+       uint8_t         xi_alloccount;  /* # bits set in allocmask      */
+       uint8_t         xi_version;     /* version                      */
+       uint8_t         xi_padding[6];  /* zero                         */
+};
+
+#define XFS_INUMBERS_VERSION_V1        (1)
+#define XFS_INUMBERS_VERSION_V5        (5)
 
 /*
  * Error injection.
index 9f1984c..cdec674 100644 (file)
@@ -729,10 +729,13 @@ xfs_fsbulkstat_one_fmt(
 
 int
 xfs_fsinumbers_fmt(
-       struct xfs_ibulk        *breq,
-       const struct xfs_inogrp *igrp)
+       struct xfs_ibulk                *breq,
+       const struct xfs_inumbers       *igrp)
 {
-       if (copy_to_user(breq->ubuffer, igrp, sizeof(*igrp)))
+       struct xfs_inogrp               ig1;
+
+       xfs_inumbers_to_inogrp(&ig1, igrp);
+       if (copy_to_user(breq->ubuffer, &ig1, sizeof(struct xfs_inogrp)))
                return -EFAULT;
        return xfs_ibulk_advance(breq, sizeof(struct xfs_inogrp));
 }
index 514d302..654c0bb 100644 (file)
@@ -83,6 +83,6 @@ struct xfs_inogrp;
 
 int xfs_fsbulkstat_one_fmt(struct xfs_ibulk *breq,
                           const struct xfs_bulkstat *bstat);
-int xfs_fsinumbers_fmt(struct xfs_ibulk *breq, const struct xfs_inogrp *igrp);
+int xfs_fsinumbers_fmt(struct xfs_ibulk *breq, const struct xfs_inumbers *igrp);
 
 #endif
index ed8e012..ca73438 100644 (file)
@@ -81,10 +81,14 @@ xfs_compat_growfs_rt_copyin(
 
 STATIC int
 xfs_fsinumbers_fmt_compat(
-       struct xfs_ibulk        *breq,
-       const struct xfs_inogrp *igrp)
+       struct xfs_ibulk                *breq,
+       const struct xfs_inumbers       *ig)
 {
-       struct compat_xfs_inogrp __user *p32 = breq->ubuffer;
+       struct compat_xfs_inogrp __user *p32 = breq->ubuffer;
+       struct xfs_inogrp               ig1;
+       struct xfs_inogrp               *igrp = &ig1;
+
+       xfs_inumbers_to_inogrp(&ig1, ig);
 
        if (put_user(igrp->xi_startino,   &p32->xi_startino) ||
            put_user(igrp->xi_alloccount, &p32->xi_alloccount) ||
index 5d40691..687c873 100644 (file)
@@ -331,10 +331,11 @@ xfs_inumbers_walk(
        const struct xfs_inobt_rec_incore *irec,
        void                    *data)
 {
-       struct xfs_inogrp       inogrp = {
+       struct xfs_inumbers     inogrp = {
                .xi_startino    = XFS_AGINO_TO_INO(mp, agno, irec->ir_startino),
                .xi_alloccount  = irec->ir_count - irec->ir_freecount,
                .xi_allocmask   = ~irec->ir_free,
+               .xi_version     = XFS_INUMBERS_VERSION_V5,
        };
        struct xfs_inumbers_chunk *ic = data;
        xfs_agino_t             agino;
@@ -381,3 +382,14 @@ xfs_inumbers(
 
        return error;
 }
+
+/* Convert an inumbers (v5) struct to a inogrp (v1) struct. */
+void
+xfs_inumbers_to_inogrp(
+       struct xfs_inogrp               *ig1,
+       const struct xfs_inumbers       *ig)
+{
+       ig1->xi_startino = ig->xi_startino;
+       ig1->xi_alloccount = ig->xi_alloccount;
+       ig1->xi_allocmask = ig->xi_allocmask;
+}
index 60e2591..fa9fb91 100644 (file)
@@ -46,8 +46,10 @@ void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1,
                const struct xfs_bulkstat *bstat);
 
 typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq,
-               const struct xfs_inogrp *igrp);
+               const struct xfs_inumbers *igrp);
 
 int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter);
+void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1,
+               const struct xfs_inumbers *ig);
 
 #endif /* __XFS_ITABLE_H__ */
index 0b4cdda..d8f941b 100644 (file)
@@ -148,6 +148,7 @@ xfs_check_ondisk_structs(void)
        XFS_CHECK_OFFSET(struct xfs_attr3_leafblock, hdr.info.hdr, 0);
 
        XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat,              192);
+       XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers,              24);
 }
 
 #endif /* __XFS_ONDISK_H */