aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDwight Engen <dwight.engen@oracle.com>2013-08-15 14:08:02 -0400
committerBen Myers <bpm@sgi.com>2013-08-15 15:24:10 -0400
commitb9fe505258375b98519493a41a8088e384965aa9 (patch)
tree8c4f5adfde9a76e0b547b683724ac1b9dac9d1ef /fs/xfs
parent7aab1b28879d2280c9a0e50000e4ae153cfac55a (diff)
xfs: create internal eofblocks structure with kuid_t types
Have eofblocks ioctl convert uid_t to kuid_t into internal structure. Update internal filter matching to compare ids with kuid_t types. Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_fs.h2
-rw-r--r--fs/xfs/xfs_icache.c12
-rw-r--r--fs/xfs/xfs_icache.h43
-rw-r--r--fs/xfs/xfs_ioctl.c18
4 files changed, 56 insertions, 19 deletions
diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
index 53e33c26f53e..1edb5cc3e5f4 100644
--- a/fs/xfs/xfs_fs.h
+++ b/fs/xfs/xfs_fs.h
@@ -357,7 +357,7 @@ typedef struct xfs_error_injection {
357 * Speculative preallocation trimming. 357 * Speculative preallocation trimming.
358 */ 358 */
359#define XFS_EOFBLOCKS_VERSION 1 359#define XFS_EOFBLOCKS_VERSION 1
360struct xfs_eofblocks { 360struct xfs_fs_eofblocks {
361 __u32 eof_version; 361 __u32 eof_version;
362 __u32 eof_flags; 362 __u32 eof_flags;
363 uid_t eof_uid; 363 uid_t eof_uid;
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 2abc9450ce20..16219b9c6790 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -620,7 +620,7 @@ restart:
620 620
621/* 621/*
622 * Background scanning to trim post-EOF preallocated space. This is queued 622 * Background scanning to trim post-EOF preallocated space. This is queued
623 * based on the 'background_prealloc_discard_period' tunable (5m by default). 623 * based on the 'speculative_prealloc_lifetime' tunable (5m by default).
624 */ 624 */
625STATIC void 625STATIC void
626xfs_queue_eofblocks( 626xfs_queue_eofblocks(
@@ -1204,15 +1204,15 @@ xfs_inode_match_id(
1204 struct xfs_inode *ip, 1204 struct xfs_inode *ip,
1205 struct xfs_eofblocks *eofb) 1205 struct xfs_eofblocks *eofb)
1206{ 1206{
1207 if (eofb->eof_flags & XFS_EOF_FLAGS_UID && 1207 if ((eofb->eof_flags & XFS_EOF_FLAGS_UID) &&
1208 ip->i_d.di_uid != eofb->eof_uid) 1208 !uid_eq(VFS_I(ip)->i_uid, eofb->eof_uid))
1209 return 0; 1209 return 0;
1210 1210
1211 if (eofb->eof_flags & XFS_EOF_FLAGS_GID && 1211 if ((eofb->eof_flags & XFS_EOF_FLAGS_GID) &&
1212 ip->i_d.di_gid != eofb->eof_gid) 1212 !gid_eq(VFS_I(ip)->i_gid, eofb->eof_gid))
1213 return 0; 1213 return 0;
1214 1214
1215 if (eofb->eof_flags & XFS_EOF_FLAGS_PRID && 1215 if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) &&
1216 xfs_get_projid(ip) != eofb->eof_prid) 1216 xfs_get_projid(ip) != eofb->eof_prid)
1217 return 0; 1217 return 0;
1218 1218
diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h
index e3f2ee04000b..8a89f7d791bd 100644
--- a/fs/xfs/xfs_icache.h
+++ b/fs/xfs/xfs_icache.h
@@ -21,6 +21,14 @@
21struct xfs_mount; 21struct xfs_mount;
22struct xfs_perag; 22struct xfs_perag;
23 23
24struct xfs_eofblocks {
25 __u32 eof_flags;
26 kuid_t eof_uid;
27 kgid_t eof_gid;
28 prid_t eof_prid;
29 __u64 eof_min_file_size;
30};
31
24#define SYNC_WAIT 0x0001 /* wait for i/o to complete */ 32#define SYNC_WAIT 0x0001 /* wait for i/o to complete */
25#define SYNC_TRYLOCK 0x0002 /* only try to lock inodes */ 33#define SYNC_TRYLOCK 0x0002 /* only try to lock inodes */
26 34
@@ -56,4 +64,39 @@ int xfs_inode_ag_iterator_tag(struct xfs_mount *mp,
56 int flags, void *args), 64 int flags, void *args),
57 int flags, void *args, int tag); 65 int flags, void *args, int tag);
58 66
67static inline int
68xfs_fs_eofblocks_from_user(
69 struct xfs_fs_eofblocks *src,
70 struct xfs_eofblocks *dst)
71{
72 if (src->eof_version != XFS_EOFBLOCKS_VERSION)
73 return EINVAL;
74
75 if (src->eof_flags & ~XFS_EOF_FLAGS_VALID)
76 return EINVAL;
77
78 if (memchr_inv(&src->pad32, 0, sizeof(src->pad32)) ||
79 memchr_inv(src->pad64, 0, sizeof(src->pad64)))
80 return EINVAL;
81
82 dst->eof_flags = src->eof_flags;
83 dst->eof_prid = src->eof_prid;
84 dst->eof_min_file_size = src->eof_min_file_size;
85
86 dst->eof_uid = INVALID_UID;
87 if (src->eof_flags & XFS_EOF_FLAGS_UID) {
88 dst->eof_uid = make_kuid(current_user_ns(), src->eof_uid);
89 if (!uid_valid(dst->eof_uid))
90 return EINVAL;
91 }
92
93 dst->eof_gid = INVALID_GID;
94 if (src->eof_flags & XFS_EOF_FLAGS_GID) {
95 dst->eof_gid = make_kgid(current_user_ns(), src->eof_gid);
96 if (!gid_valid(dst->eof_gid))
97 return EINVAL;
98 }
99 return 0;
100}
101
59#endif 102#endif
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 999c1efd6af5..20b4c7af2928 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1720,23 +1720,17 @@ xfs_file_ioctl(
1720 return -error; 1720 return -error;
1721 1721
1722 case XFS_IOC_FREE_EOFBLOCKS: { 1722 case XFS_IOC_FREE_EOFBLOCKS: {
1723 struct xfs_eofblocks eofb; 1723 struct xfs_fs_eofblocks eofb;
1724 struct xfs_eofblocks keofb;
1724 1725
1725 if (copy_from_user(&eofb, arg, sizeof(eofb))) 1726 if (copy_from_user(&eofb, arg, sizeof(eofb)))
1726 return -XFS_ERROR(EFAULT); 1727 return -XFS_ERROR(EFAULT);
1727 1728
1728 if (eofb.eof_version != XFS_EOFBLOCKS_VERSION) 1729 error = xfs_fs_eofblocks_from_user(&eofb, &keofb);
1729 return -XFS_ERROR(EINVAL); 1730 if (error)
1730 1731 return -error;
1731 if (eofb.eof_flags & ~XFS_EOF_FLAGS_VALID)
1732 return -XFS_ERROR(EINVAL);
1733
1734 if (memchr_inv(&eofb.pad32, 0, sizeof(eofb.pad32)) ||
1735 memchr_inv(eofb.pad64, 0, sizeof(eofb.pad64)))
1736 return -XFS_ERROR(EINVAL);
1737 1732
1738 error = xfs_icache_free_eofblocks(mp, &eofb); 1733 return -xfs_icache_free_eofblocks(mp, &keofb);
1739 return -error;
1740 } 1734 }
1741 1735
1742 default: 1736 default: