aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2019-04-12 10:41:16 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2019-04-14 21:15:57 -0400
commit1b6d968de22bffd85a60538d2628185b17228291 (patch)
treedf40a9976b7ae8f60f203ca32bb2eeead97a2c17 /fs/xfs
parent519841c207de9926418d2f39e162097088478781 (diff)
xfs: bump XFS_IOC_FSGEOMETRY to v5 structures
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>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_fs.h87
-rw-r--r--fs/xfs/libxfs/xfs_sb.c5
-rw-r--r--fs/xfs/xfs_ioctl.c48
-rw-r--r--fs/xfs/xfs_ioctl32.c3
4 files changed, 84 insertions, 59 deletions
diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
index f3aa59302fef..cb7d0b1453cd 100644
--- a/fs/xfs/libxfs/xfs_fs.h
+++ b/fs/xfs/libxfs/xfs_fs.h
@@ -124,7 +124,7 @@ typedef struct xfs_flock64 {
124/* 124/*
125 * Output for XFS_IOC_FSGEOMETRY_V1 125 * Output for XFS_IOC_FSGEOMETRY_V1
126 */ 126 */
127typedef struct xfs_fsop_geom_v1 { 127struct xfs_fsop_geom_v1 {
128 __u32 blocksize; /* filesystem (data) block size */ 128 __u32 blocksize; /* filesystem (data) block size */
129 __u32 rtextsize; /* realtime extent size */ 129 __u32 rtextsize; /* realtime extent size */
130 __u32 agblocks; /* fsblocks in an AG */ 130 __u32 agblocks; /* fsblocks in an AG */
@@ -145,12 +145,39 @@ typedef struct xfs_fsop_geom_v1 {
145 __u32 logsectsize; /* log sector size, bytes */ 145 __u32 logsectsize; /* log sector size, bytes */
146 __u32 rtsectsize; /* realtime sector size, bytes */ 146 __u32 rtsectsize; /* realtime sector size, bytes */
147 __u32 dirblocksize; /* directory block size, bytes */ 147 __u32 dirblocksize; /* directory block size, bytes */
148} xfs_fsop_geom_v1_t; 148};
149
150/*
151 * Output for XFS_IOC_FSGEOMETRY_V4
152 */
153struct xfs_fsop_geom_v4 {
154 __u32 blocksize; /* filesystem (data) block size */
155 __u32 rtextsize; /* realtime extent size */
156 __u32 agblocks; /* fsblocks in an AG */
157 __u32 agcount; /* number of allocation groups */
158 __u32 logblocks; /* fsblocks in the log */
159 __u32 sectsize; /* (data) sector size, bytes */
160 __u32 inodesize; /* inode size in bytes */
161 __u32 imaxpct; /* max allowed inode space(%) */
162 __u64 datablocks; /* fsblocks in data subvolume */
163 __u64 rtblocks; /* fsblocks in realtime subvol */
164 __u64 rtextents; /* rt extents in realtime subvol*/
165 __u64 logstart; /* starting fsblock of the log */
166 unsigned char uuid[16]; /* unique id of the filesystem */
167 __u32 sunit; /* stripe unit, fsblocks */
168 __u32 swidth; /* stripe width, fsblocks */
169 __s32 version; /* structure version */
170 __u32 flags; /* superblock version flags */
171 __u32 logsectsize; /* log sector size, bytes */
172 __u32 rtsectsize; /* realtime sector size, bytes */
173 __u32 dirblocksize; /* directory block size, bytes */
174 __u32 logsunit; /* log stripe unit, bytes */
175};
149 176
150/* 177/*
151 * Output for XFS_IOC_FSGEOMETRY 178 * Output for XFS_IOC_FSGEOMETRY
152 */ 179 */
153typedef struct xfs_fsop_geom { 180struct xfs_fsop_geom {
154 __u32 blocksize; /* filesystem (data) block size */ 181 __u32 blocksize; /* filesystem (data) block size */
155 __u32 rtextsize; /* realtime extent size */ 182 __u32 rtextsize; /* realtime extent size */
156 __u32 agblocks; /* fsblocks in an AG */ 183 __u32 agblocks; /* fsblocks in an AG */
@@ -171,8 +198,9 @@ typedef struct xfs_fsop_geom {
171 __u32 logsectsize; /* log sector size, bytes */ 198 __u32 logsectsize; /* log sector size, bytes */
172 __u32 rtsectsize; /* realtime sector size, bytes */ 199 __u32 rtsectsize; /* realtime sector size, bytes */
173 __u32 dirblocksize; /* directory block size, bytes */ 200 __u32 dirblocksize; /* directory block size, bytes */
174 __u32 logsunit; /* log stripe unit, bytes */ 201 __u32 logsunit; /* log stripe unit, bytes */
175} xfs_fsop_geom_t; 202 __u64 reserved[18]; /* reserved space */
203};
176 204
177/* Output for XFS_FS_COUNTS */ 205/* Output for XFS_FS_COUNTS */
178typedef struct xfs_fsop_counts { 206typedef struct xfs_fsop_counts {
@@ -188,28 +216,30 @@ typedef struct xfs_fsop_resblks {
188 __u64 resblks_avail; 216 __u64 resblks_avail;
189} xfs_fsop_resblks_t; 217} xfs_fsop_resblks_t;
190 218
191#define XFS_FSOP_GEOM_VERSION 0 219#define XFS_FSOP_GEOM_VERSION 0
192 220#define XFS_FSOP_GEOM_VERSION_V5 5
193#define XFS_FSOP_GEOM_FLAGS_ATTR 0x0001 /* attributes in use */ 221
194#define XFS_FSOP_GEOM_FLAGS_NLINK 0x0002 /* 32-bit nlink values */ 222#define XFS_FSOP_GEOM_FLAGS_ATTR (1 << 0) /* attributes in use */
195#define XFS_FSOP_GEOM_FLAGS_QUOTA 0x0004 /* quotas enabled */ 223#define XFS_FSOP_GEOM_FLAGS_NLINK (1 << 1) /* 32-bit nlink values */
196#define XFS_FSOP_GEOM_FLAGS_IALIGN 0x0008 /* inode alignment */ 224#define XFS_FSOP_GEOM_FLAGS_QUOTA (1 << 2) /* quotas enabled */
197#define XFS_FSOP_GEOM_FLAGS_DALIGN 0x0010 /* large data alignment */ 225#define XFS_FSOP_GEOM_FLAGS_IALIGN (1 << 3) /* inode alignment */
198#define XFS_FSOP_GEOM_FLAGS_SHARED 0x0020 /* read-only shared */ 226#define XFS_FSOP_GEOM_FLAGS_DALIGN (1 << 4) /* large data alignment */
199#define XFS_FSOP_GEOM_FLAGS_EXTFLG 0x0040 /* special extent flag */ 227#define XFS_FSOP_GEOM_FLAGS_SHARED (1 << 5) /* read-only shared */
200#define XFS_FSOP_GEOM_FLAGS_DIRV2 0x0080 /* directory version 2 */ 228#define XFS_FSOP_GEOM_FLAGS_EXTFLG (1 << 6) /* special extent flag */
201#define XFS_FSOP_GEOM_FLAGS_LOGV2 0x0100 /* log format version 2 */ 229#define XFS_FSOP_GEOM_FLAGS_DIRV2 (1 << 7) /* directory version 2 */
202#define XFS_FSOP_GEOM_FLAGS_SECTOR 0x0200 /* sector sizes >1BB */ 230#define XFS_FSOP_GEOM_FLAGS_LOGV2 (1 << 8) /* log format version 2 */
203#define XFS_FSOP_GEOM_FLAGS_ATTR2 0x0400 /* inline attributes rework */ 231#define XFS_FSOP_GEOM_FLAGS_SECTOR (1 << 9) /* sector sizes >1BB */
204#define XFS_FSOP_GEOM_FLAGS_PROJID32 0x0800 /* 32-bit project IDs */ 232#define XFS_FSOP_GEOM_FLAGS_ATTR2 (1 << 10) /* inline attributes rework */
205#define XFS_FSOP_GEOM_FLAGS_DIRV2CI 0x1000 /* ASCII only CI names */ 233#define XFS_FSOP_GEOM_FLAGS_PROJID32 (1 << 11) /* 32-bit project IDs */
206#define XFS_FSOP_GEOM_FLAGS_LAZYSB 0x4000 /* lazy superblock counters */ 234#define XFS_FSOP_GEOM_FLAGS_DIRV2CI (1 << 12) /* ASCII only CI names */
207#define XFS_FSOP_GEOM_FLAGS_V5SB 0x8000 /* version 5 superblock */ 235 /* -- Do not use -- (1 << 13) SGI parent pointers */
208#define XFS_FSOP_GEOM_FLAGS_FTYPE 0x10000 /* inode directory types */ 236#define XFS_FSOP_GEOM_FLAGS_LAZYSB (1 << 14) /* lazy superblock counters */
209#define XFS_FSOP_GEOM_FLAGS_FINOBT 0x20000 /* free inode btree */ 237#define XFS_FSOP_GEOM_FLAGS_V5SB (1 << 15) /* version 5 superblock */
210#define XFS_FSOP_GEOM_FLAGS_SPINODES 0x40000 /* sparse inode chunks */ 238#define XFS_FSOP_GEOM_FLAGS_FTYPE (1 << 16) /* inode directory types */
211#define XFS_FSOP_GEOM_FLAGS_RMAPBT 0x80000 /* reverse mapping btree */ 239#define XFS_FSOP_GEOM_FLAGS_FINOBT (1 << 17) /* free inode btree */
212#define XFS_FSOP_GEOM_FLAGS_REFLINK 0x100000 /* files can share blocks */ 240#define XFS_FSOP_GEOM_FLAGS_SPINODES (1 << 18) /* sparse inode chunks */
241#define XFS_FSOP_GEOM_FLAGS_RMAPBT (1 << 19) /* reverse mapping btree */
242#define XFS_FSOP_GEOM_FLAGS_REFLINK (1 << 20) /* files can share blocks */
213 243
214/* 244/*
215 * Minimum and maximum sizes need for growth checks. 245 * Minimum and maximum sizes need for growth checks.
@@ -620,8 +650,9 @@ struct xfs_scrub_metadata {
620#define XFS_IOC_FSSETDM_BY_HANDLE _IOW ('X', 121, struct xfs_fsop_setdm_handlereq) 650#define XFS_IOC_FSSETDM_BY_HANDLE _IOW ('X', 121, struct xfs_fsop_setdm_handlereq)
621#define XFS_IOC_ATTRLIST_BY_HANDLE _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq) 651#define XFS_IOC_ATTRLIST_BY_HANDLE _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
622#define XFS_IOC_ATTRMULTI_BY_HANDLE _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq) 652#define XFS_IOC_ATTRMULTI_BY_HANDLE _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq)
623#define XFS_IOC_FSGEOMETRY _IOR ('X', 124, struct xfs_fsop_geom) 653#define XFS_IOC_FSGEOMETRY_V4 _IOR ('X', 124, struct xfs_fsop_geom_v4)
624#define XFS_IOC_GOINGDOWN _IOR ('X', 125, uint32_t) 654#define XFS_IOC_GOINGDOWN _IOR ('X', 125, uint32_t)
655#define XFS_IOC_FSGEOMETRY _IOR ('X', 126, struct xfs_fsop_geom)
625/* XFS_IOC_GETFSUUID ---------- deprecated 140 */ 656/* XFS_IOC_GETFSUUID ---------- deprecated 140 */
626 657
627 658
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index dc5be0c631c8..6fab49f6070b 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -1166,6 +1166,11 @@ xfs_fs_geometry(
1166 1166
1167 geo->logsunit = sbp->sb_logsunit; 1167 geo->logsunit = sbp->sb_logsunit;
1168 1168
1169 if (struct_version < 5)
1170 return 0;
1171
1172 geo->version = XFS_FSOP_GEOM_VERSION_V5;
1173
1169 return 0; 1174 return 0;
1170} 1175}
1171 1176
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 6ecdbb3af7de..ec3c6c401ee7 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -779,40 +779,27 @@ xfs_ioc_bulkstat(
779} 779}
780 780
781STATIC int 781STATIC int
782xfs_ioc_fsgeometry_v1(
783 xfs_mount_t *mp,
784 void __user *arg)
785{
786 xfs_fsop_geom_t fsgeo;
787 int error;
788
789 error = xfs_fs_geometry(&mp->m_sb, &fsgeo, 3);
790 if (error)
791 return error;
792
793 /*
794 * Caller should have passed an argument of type
795 * xfs_fsop_geom_v1_t. This is a proper subset of the
796 * xfs_fsop_geom_t that xfs_fs_geometry() fills in.
797 */
798 if (copy_to_user(arg, &fsgeo, sizeof(xfs_fsop_geom_v1_t)))
799 return -EFAULT;
800 return 0;
801}
802
803STATIC int
804xfs_ioc_fsgeometry( 782xfs_ioc_fsgeometry(
805 xfs_mount_t *mp, 783 struct xfs_mount *mp,
806 void __user *arg) 784 void __user *arg,
785 int struct_version)
807{ 786{
808 xfs_fsop_geom_t fsgeo; 787 struct xfs_fsop_geom fsgeo;
788 size_t len;
809 int error; 789 int error;
810 790
811 error = xfs_fs_geometry(&mp->m_sb, &fsgeo, 4); 791 error = xfs_fs_geometry(&mp->m_sb, &fsgeo, struct_version);
812 if (error) 792 if (error)
813 return error; 793 return error;
814 794
815 if (copy_to_user(arg, &fsgeo, sizeof(fsgeo))) 795 if (struct_version <= 3)
796 len = sizeof(struct xfs_fsop_geom_v1);
797 else if (struct_version == 4)
798 len = sizeof(struct xfs_fsop_geom_v4);
799 else
800 len = sizeof(fsgeo);
801
802 if (copy_to_user(arg, &fsgeo, len))
816 return -EFAULT; 803 return -EFAULT;
817 return 0; 804 return 0;
818} 805}
@@ -1937,10 +1924,11 @@ xfs_file_ioctl(
1937 return xfs_ioc_bulkstat(mp, cmd, arg); 1924 return xfs_ioc_bulkstat(mp, cmd, arg);
1938 1925
1939 case XFS_IOC_FSGEOMETRY_V1: 1926 case XFS_IOC_FSGEOMETRY_V1:
1940 return xfs_ioc_fsgeometry_v1(mp, arg); 1927 return xfs_ioc_fsgeometry(mp, arg, 3);
1941 1928 case XFS_IOC_FSGEOMETRY_V4:
1929 return xfs_ioc_fsgeometry(mp, arg, 4);
1942 case XFS_IOC_FSGEOMETRY: 1930 case XFS_IOC_FSGEOMETRY:
1943 return xfs_ioc_fsgeometry(mp, arg); 1931 return xfs_ioc_fsgeometry(mp, arg, 5);
1944 1932
1945 case XFS_IOC_GETVERSION: 1933 case XFS_IOC_GETVERSION:
1946 return put_user(inode->i_generation, (int __user *)arg); 1934 return put_user(inode->i_generation, (int __user *)arg);
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index 5001dca361e9..55ace6308637 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -52,7 +52,7 @@ xfs_compat_ioc_fsgeometry_v1(
52 struct xfs_mount *mp, 52 struct xfs_mount *mp,
53 compat_xfs_fsop_geom_v1_t __user *arg32) 53 compat_xfs_fsop_geom_v1_t __user *arg32)
54{ 54{
55 xfs_fsop_geom_t fsgeo; 55 struct xfs_fsop_geom fsgeo;
56 int error; 56 int error;
57 57
58 error = xfs_fs_geometry(&mp->m_sb, &fsgeo, 3); 58 error = xfs_fs_geometry(&mp->m_sb, &fsgeo, 3);
@@ -561,6 +561,7 @@ xfs_file_compat_ioctl(
561 switch (cmd) { 561 switch (cmd) {
562 /* No size or alignment issues on any arch */ 562 /* No size or alignment issues on any arch */
563 case XFS_IOC_DIOINFO: 563 case XFS_IOC_DIOINFO:
564 case XFS_IOC_FSGEOMETRY_V4:
564 case XFS_IOC_FSGEOMETRY: 565 case XFS_IOC_FSGEOMETRY:
565 case XFS_IOC_FSGETXATTR: 566 case XFS_IOC_FSGETXATTR:
566 case XFS_IOC_FSSETXATTR: 567 case XFS_IOC_FSSETXATTR: