]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: bump XFS_IOC_FSGEOMETRY to v5 structures
authorDave Chinner <dchinner@redhat.com>
Wed, 24 Jul 2019 19:53:56 +0000 (15:53 -0400)
committerEric Sandeen <sandeen@redhat.com>
Wed, 24 Jul 2019 19:53:56 +0000 (15:53 -0400)
Source kernel commit: 1b6d968de22bffd85a60538d2628185b17228291

Unfortunately, the V4 XFS_IOC_FSGEOMETRY structure is out of space so we
can't just add a new field to it. Hence we need to bump the definition
to V5 and and treat the V4 ioctl and structure similar to v1 to v3.

While doing this, clean up all the definitions associated with the
XFS_IOC_FSGEOMETRY ioctl.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: forward port to 5.1, expand structure size to 256 bytes]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
fsr/xfs_fsr.c
libxfs/xfs_fs.h
libxfs/xfs_sb.c
rtcp/xfs_rtcp.c

index fef6262c8fd489b6c06799cf677c4e2c57bcd115..e0e73c5521c50fc85e66f05012ccc587b69e36d0 100644 (file)
@@ -83,9 +83,9 @@ int cmp(const void *, const void *);
 static void tmp_init(char *mnt);
 static char * tmp_next(char *mnt);
 static void tmp_close(char *mnt);
-int xfs_getgeom(int , xfs_fsop_geom_v1_t * );
+int xfs_getgeom(int , struct xfs_fsop_geom_v1 * );
 
-static xfs_fsop_geom_v1_t fsgeom;      /* geometry of active mounted system */
+static struct xfs_fsop_geom_v1 fsgeom; /* geometry of active mounted system */
 
 #define NMOUNT 64
 static int numfs;
@@ -103,7 +103,7 @@ static int  nfrags = 0;     /* Debug option: Coerse into specific number
 static int     openopts = O_CREAT|O_EXCL|O_RDWR|O_DIRECT;
 
 static int
-xfs_fsgeometry(int fd, xfs_fsop_geom_v1_t *geom)
+xfs_fsgeometry(int fd, struct xfs_fsop_geom_v1 *geom)
 {
     return ioctl(fd, XFS_IOC_FSGEOMETRY_V1, geom);
 }
@@ -1616,7 +1616,7 @@ getnextents(int fd)
  * Get the fs geometry
  */
 int
-xfs_getgeom(int fd, xfs_fsop_geom_v1_t * fsgeom)
+xfs_getgeom(int fd, struct xfs_fsop_geom_v1 *fsgeom)
 {
        if (xfs_fsgeometry(fd, fsgeom) < 0) {
                return -1;
index c8a3b12591a21c38ba2675ac6c6d497ae4c8a4cf..85c99d25090ee42687d45e8a5568075d7cac3ca4 100644 (file)
@@ -145,7 +145,7 @@ typedef struct xfs_flock64 {
 /*
  * Output for XFS_IOC_FSGEOMETRY_V1
  */
-typedef struct xfs_fsop_geom_v1 {
+struct xfs_fsop_geom_v1 {
        __u32           blocksize;      /* filesystem (data) block size */
        __u32           rtextsize;      /* realtime extent size         */
        __u32           agblocks;       /* fsblocks in an AG            */
@@ -166,12 +166,39 @@ typedef struct xfs_fsop_geom_v1 {
        __u32           logsectsize;    /* log sector size, bytes       */
        __u32           rtsectsize;     /* realtime sector size, bytes  */
        __u32           dirblocksize;   /* directory block size, bytes  */
-} xfs_fsop_geom_v1_t;
+};
+
+/*
+ * Output for XFS_IOC_FSGEOMETRY_V4
+ */
+struct xfs_fsop_geom_v4 {
+       __u32           blocksize;      /* filesystem (data) block size */
+       __u32           rtextsize;      /* realtime extent size         */
+       __u32           agblocks;       /* fsblocks in an AG            */
+       __u32           agcount;        /* number of allocation groups  */
+       __u32           logblocks;      /* fsblocks in the log          */
+       __u32           sectsize;       /* (data) sector size, bytes    */
+       __u32           inodesize;      /* inode size in bytes          */
+       __u32           imaxpct;        /* max allowed inode space(%)   */
+       __u64           datablocks;     /* fsblocks in data subvolume   */
+       __u64           rtblocks;       /* fsblocks in realtime subvol  */
+       __u64           rtextents;      /* rt extents in realtime subvol*/
+       __u64           logstart;       /* starting fsblock of the log  */
+       unsigned char   uuid[16];       /* unique id of the filesystem  */
+       __u32           sunit;          /* stripe unit, fsblocks        */
+       __u32           swidth;         /* stripe width, fsblocks       */
+       __s32           version;        /* structure version            */
+       __u32           flags;          /* superblock version flags     */
+       __u32           logsectsize;    /* log sector size, bytes       */
+       __u32           rtsectsize;     /* realtime sector size, bytes  */
+       __u32           dirblocksize;   /* directory block size, bytes  */
+       __u32           logsunit;       /* log stripe unit, bytes       */
+};
 
 /*
  * Output for XFS_IOC_FSGEOMETRY
  */
-typedef struct xfs_fsop_geom {
+struct xfs_fsop_geom {
        __u32           blocksize;      /* filesystem (data) block size */
        __u32           rtextsize;      /* realtime extent size         */
        __u32           agblocks;       /* fsblocks in an AG            */
@@ -192,8 +219,9 @@ typedef struct xfs_fsop_geom {
        __u32           logsectsize;    /* log sector size, bytes       */
        __u32           rtsectsize;     /* realtime sector size, bytes  */
        __u32           dirblocksize;   /* directory block size, bytes  */
-       __u32           logsunit;       /* log stripe unit, bytes */
-} xfs_fsop_geom_t;
+       __u32           logsunit;       /* log stripe unit, bytes       */
+       __u64           reserved[18];   /* reserved space               */
+};
 
 /* Output for XFS_FS_COUNTS */
 typedef struct xfs_fsop_counts {
@@ -209,28 +237,30 @@ typedef struct xfs_fsop_resblks {
        __u64  resblks_avail;
 } xfs_fsop_resblks_t;
 
-#define XFS_FSOP_GEOM_VERSION  0
-
-#define XFS_FSOP_GEOM_FLAGS_ATTR       0x0001  /* attributes in use    */
-#define XFS_FSOP_GEOM_FLAGS_NLINK      0x0002  /* 32-bit nlink values  */
-#define XFS_FSOP_GEOM_FLAGS_QUOTA      0x0004  /* quotas enabled       */
-#define XFS_FSOP_GEOM_FLAGS_IALIGN     0x0008  /* inode alignment      */
-#define XFS_FSOP_GEOM_FLAGS_DALIGN     0x0010  /* large data alignment */
-#define XFS_FSOP_GEOM_FLAGS_SHARED     0x0020  /* read-only shared     */
-#define XFS_FSOP_GEOM_FLAGS_EXTFLG     0x0040  /* special extent flag  */
-#define XFS_FSOP_GEOM_FLAGS_DIRV2      0x0080  /* directory version 2  */
-#define XFS_FSOP_GEOM_FLAGS_LOGV2      0x0100  /* log format version 2 */
-#define XFS_FSOP_GEOM_FLAGS_SECTOR     0x0200  /* sector sizes >1BB    */
-#define XFS_FSOP_GEOM_FLAGS_ATTR2      0x0400  /* inline attributes rework */
-#define XFS_FSOP_GEOM_FLAGS_PROJID32   0x0800  /* 32-bit project IDs   */
-#define XFS_FSOP_GEOM_FLAGS_DIRV2CI    0x1000  /* ASCII only CI names  */
-#define XFS_FSOP_GEOM_FLAGS_LAZYSB     0x4000  /* lazy superblock counters */
-#define XFS_FSOP_GEOM_FLAGS_V5SB       0x8000  /* version 5 superblock */
-#define XFS_FSOP_GEOM_FLAGS_FTYPE      0x10000 /* inode directory types */
-#define XFS_FSOP_GEOM_FLAGS_FINOBT     0x20000 /* free inode btree */
-#define XFS_FSOP_GEOM_FLAGS_SPINODES   0x40000 /* sparse inode chunks  */
-#define XFS_FSOP_GEOM_FLAGS_RMAPBT     0x80000 /* reverse mapping btree */
-#define XFS_FSOP_GEOM_FLAGS_REFLINK    0x100000 /* files can share blocks */
+#define XFS_FSOP_GEOM_VERSION          0
+#define XFS_FSOP_GEOM_VERSION_V5       5
+
+#define XFS_FSOP_GEOM_FLAGS_ATTR       (1 << 0)  /* attributes in use     */
+#define XFS_FSOP_GEOM_FLAGS_NLINK      (1 << 1)  /* 32-bit nlink values   */
+#define XFS_FSOP_GEOM_FLAGS_QUOTA      (1 << 2)  /* quotas enabled        */
+#define XFS_FSOP_GEOM_FLAGS_IALIGN     (1 << 3)  /* inode alignment       */
+#define XFS_FSOP_GEOM_FLAGS_DALIGN     (1 << 4)  /* large data alignment  */
+#define XFS_FSOP_GEOM_FLAGS_SHARED     (1 << 5)  /* read-only shared      */
+#define XFS_FSOP_GEOM_FLAGS_EXTFLG     (1 << 6)  /* special extent flag   */
+#define XFS_FSOP_GEOM_FLAGS_DIRV2      (1 << 7)  /* directory version 2   */
+#define XFS_FSOP_GEOM_FLAGS_LOGV2      (1 << 8)  /* log format version 2  */
+#define XFS_FSOP_GEOM_FLAGS_SECTOR     (1 << 9)  /* sector sizes >1BB     */
+#define XFS_FSOP_GEOM_FLAGS_ATTR2      (1 << 10) /* inline attributes rework */
+#define XFS_FSOP_GEOM_FLAGS_PROJID32   (1 << 11) /* 32-bit project IDs    */
+#define XFS_FSOP_GEOM_FLAGS_DIRV2CI    (1 << 12) /* ASCII only CI names   */
+       /*  -- Do not use --            (1 << 13)    SGI parent pointers   */
+#define XFS_FSOP_GEOM_FLAGS_LAZYSB     (1 << 14) /* lazy superblock counters */
+#define XFS_FSOP_GEOM_FLAGS_V5SB       (1 << 15) /* version 5 superblock  */
+#define XFS_FSOP_GEOM_FLAGS_FTYPE      (1 << 16) /* inode directory types */
+#define XFS_FSOP_GEOM_FLAGS_FINOBT     (1 << 17) /* free inode btree      */
+#define XFS_FSOP_GEOM_FLAGS_SPINODES   (1 << 18) /* sparse inode chunks   */
+#define XFS_FSOP_GEOM_FLAGS_RMAPBT     (1 << 19) /* reverse mapping btree */
+#define XFS_FSOP_GEOM_FLAGS_REFLINK    (1 << 20) /* files can share blocks */
 
 /*
  * Minimum and maximum sizes need for growth checks.
@@ -640,8 +670,9 @@ struct xfs_scrub_metadata {
 #define XFS_IOC_FSSETDM_BY_HANDLE    _IOW ('X', 121, struct xfs_fsop_setdm_handlereq)
 #define XFS_IOC_ATTRLIST_BY_HANDLE   _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
 #define XFS_IOC_ATTRMULTI_BY_HANDLE  _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq)
-#define XFS_IOC_FSGEOMETRY          _IOR ('X', 124, struct xfs_fsop_geom)
+#define XFS_IOC_FSGEOMETRY_V4       _IOR ('X', 124, struct xfs_fsop_geom_v4)
 #define XFS_IOC_GOINGDOWN           _IOR ('X', 125, uint32_t)
+#define XFS_IOC_FSGEOMETRY          _IOR ('X', 126, struct xfs_fsop_geom)
 /*     XFS_IOC_GETFSUUID ---------- deprecated 140      */
 
 /* reflink ioctls; these MUST match the btrfs ioctl definitions */
index b2c1421be9f86d404d5cd8bd81661c8ecef4db85..63025016623cd66b61effe898ebb2da47f06631e 100644 (file)
@@ -1143,6 +1143,11 @@ xfs_fs_geometry(
 
        geo->logsunit = sbp->sb_logsunit;
 
+       if (struct_version < 5)
+               return 0;
+
+       geo->version = XFS_FSOP_GEOM_VERSION_V5;
+
        return 0;
 }
 
index f928a86ac7032ca13b2f6686184374f389e3ad9b..1027c913f2edbc64101fce6648f00f6d2b71bb39 100644 (file)
@@ -369,7 +369,7 @@ int
 xfsrtextsize( char *path)
 {
        int fd, rval, rtextsize;
-       xfs_fsop_geom_v1_t geo;
+       struct xfs_fsop_geom_v1 geo;
 
        fd = open( path, O_RDONLY );
        if ( fd < 0 ) {