diff options
author | Brian Foster <bfoster@redhat.com> | 2012-11-07 12:21:13 -0500 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2012-11-08 16:29:14 -0500 |
commit | 3e3f9f5863548e870edfcc72e7617ac8ddcad44a (patch) | |
tree | ab1952acea4c3cad7048d6c168987ba7b7e73552 /fs | |
parent | 8ca149de80478441352a8622ea15fae7de703ced (diff) |
xfs: add inode id filtering to eofblocks scan
Support inode ID filtering in the eofblocks scan. The caller must
set the associated XFS_EOF_FLAGS_*ID bit and ID field.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_fs.h | 14 | ||||
-rw-r--r-- | fs/xfs/xfs_icache.c | 22 | ||||
-rw-r--r-- | fs/xfs/xfs_ioctl.c | 3 |
3 files changed, 36 insertions, 3 deletions
diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h index 0cfa30813b16..a19f9b205c15 100644 --- a/fs/xfs/xfs_fs.h +++ b/fs/xfs/xfs_fs.h | |||
@@ -346,13 +346,23 @@ typedef struct xfs_error_injection { | |||
346 | struct xfs_eofblocks { | 346 | struct xfs_eofblocks { |
347 | __u32 eof_version; | 347 | __u32 eof_version; |
348 | __u32 eof_flags; | 348 | __u32 eof_flags; |
349 | __u64 pad[15]; | 349 | uid_t eof_uid; |
350 | gid_t eof_gid; | ||
351 | prid_t eof_prid; | ||
352 | __u32 pad32; | ||
353 | __u64 pad64[13]; | ||
350 | }; | 354 | }; |
351 | 355 | ||
352 | /* eof_flags values */ | 356 | /* eof_flags values */ |
353 | #define XFS_EOF_FLAGS_SYNC (1 << 0) /* sync/wait mode scan */ | 357 | #define XFS_EOF_FLAGS_SYNC (1 << 0) /* sync/wait mode scan */ |
358 | #define XFS_EOF_FLAGS_UID (1 << 1) /* filter by uid */ | ||
359 | #define XFS_EOF_FLAGS_GID (1 << 2) /* filter by gid */ | ||
360 | #define XFS_EOF_FLAGS_PRID (1 << 3) /* filter by project id */ | ||
354 | #define XFS_EOF_FLAGS_VALID \ | 361 | #define XFS_EOF_FLAGS_VALID \ |
355 | (XFS_EOF_FLAGS_SYNC) | 362 | (XFS_EOF_FLAGS_SYNC | \ |
363 | XFS_EOF_FLAGS_UID | \ | ||
364 | XFS_EOF_FLAGS_GID | \ | ||
365 | XFS_EOF_FLAGS_PRID) | ||
356 | 366 | ||
357 | 367 | ||
358 | /* | 368 | /* |
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index fbb74c715266..b239da91c43b 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c | |||
@@ -1171,6 +1171,21 @@ xfs_reclaim_inodes_count( | |||
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | STATIC int | 1173 | STATIC int |
1174 | xfs_inode_match_id( | ||
1175 | struct xfs_inode *ip, | ||
1176 | struct xfs_eofblocks *eofb) | ||
1177 | { | ||
1178 | if (eofb->eof_flags & XFS_EOF_FLAGS_UID) | ||
1179 | return ip->i_d.di_uid == eofb->eof_uid; | ||
1180 | else if (eofb->eof_flags & XFS_EOF_FLAGS_GID) | ||
1181 | return ip->i_d.di_gid == eofb->eof_gid; | ||
1182 | else if (eofb->eof_flags & XFS_EOF_FLAGS_PRID) | ||
1183 | return xfs_get_projid(ip) == eofb->eof_prid; | ||
1184 | |||
1185 | return 0; | ||
1186 | } | ||
1187 | |||
1188 | STATIC int | ||
1174 | xfs_inode_free_eofblocks( | 1189 | xfs_inode_free_eofblocks( |
1175 | struct xfs_inode *ip, | 1190 | struct xfs_inode *ip, |
1176 | struct xfs_perag *pag, | 1191 | struct xfs_perag *pag, |
@@ -1178,6 +1193,7 @@ xfs_inode_free_eofblocks( | |||
1178 | void *args) | 1193 | void *args) |
1179 | { | 1194 | { |
1180 | int ret; | 1195 | int ret; |
1196 | struct xfs_eofblocks *eofb = args; | ||
1181 | 1197 | ||
1182 | if (!xfs_can_free_eofblocks(ip, false)) { | 1198 | if (!xfs_can_free_eofblocks(ip, false)) { |
1183 | /* inode could be preallocated or append-only */ | 1199 | /* inode could be preallocated or append-only */ |
@@ -1194,6 +1210,12 @@ xfs_inode_free_eofblocks( | |||
1194 | mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY)) | 1210 | mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY)) |
1195 | return 0; | 1211 | return 0; |
1196 | 1212 | ||
1213 | if (eofb && | ||
1214 | (eofb->eof_flags & (XFS_EOF_FLAGS_UID|XFS_EOF_FLAGS_GID| | ||
1215 | XFS_EOF_FLAGS_PRID)) && | ||
1216 | !xfs_inode_match_id(ip, eofb)) | ||
1217 | return 0; | ||
1218 | |||
1197 | ret = xfs_free_eofblocks(ip->i_mount, ip, true); | 1219 | ret = xfs_free_eofblocks(ip->i_mount, ip, true); |
1198 | 1220 | ||
1199 | /* don't revisit the inode if we're not waiting */ | 1221 | /* don't revisit the inode if we're not waiting */ |
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 5b20ab0b4f9d..c1c3ef88a260 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c | |||
@@ -1615,7 +1615,8 @@ xfs_file_ioctl( | |||
1615 | if (eofb.eof_flags & ~XFS_EOF_FLAGS_VALID) | 1615 | if (eofb.eof_flags & ~XFS_EOF_FLAGS_VALID) |
1616 | return -XFS_ERROR(EINVAL); | 1616 | return -XFS_ERROR(EINVAL); |
1617 | 1617 | ||
1618 | if (memchr_inv(eofb.pad, 0, sizeof(eofb.pad))) | 1618 | if (memchr_inv(&eofb.pad32, 0, sizeof(eofb.pad32)) || |
1619 | memchr_inv(eofb.pad64, 0, sizeof(eofb.pad64))) | ||
1619 | return -XFS_ERROR(EINVAL); | 1620 | return -XFS_ERROR(EINVAL); |
1620 | 1621 | ||
1621 | error = xfs_icache_free_eofblocks(mp, &eofb); | 1622 | error = xfs_icache_free_eofblocks(mp, &eofb); |