[PATCH v5 09/10] xfs: add minimum file size filtering to eofblocks scan

Brian Foster
2012-10-05T14:14:11Z

Support minimum file size filtering in the eofblocks scan. The
caller must set the XFS_EOF_FLAGS_MINFILESIZE flags bit and minimum
file size value in bytes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/xfs/xfs_fs.h | 2 ++
fs/xfs/xfs_icache.c | 5 +++++
2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
index 6ef9111..6d42b0d 100644
--- a/fs/xfs/xfs_fs.h
+++ b/fs/xfs/xfs_fs.h
@@ -347,12 +347,14 @@ struct xfs_eofblocks {
__u32 eof_flags;
__u32 eof_q_id;
__u32 eof_q_type;
+ __u32 eof_min_file_size;
unsigned char pad[12];
};

/* eof_flags values */
#define XFS_EOF_FLAGS_SYNC 0x01 /* sync/wait mode scan */
#define XFS_EOF_FLAGS_QUOTA 0x02 /* filter by quota id */
+#define XFS_EOF_FLAGS_MINFILESIZE 0x04 /* filter by min file size */

/*
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index b39970b..ffd7f86 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1216,6 +1216,11 @@ xfs_inode_free_eofblocks(
if (eofb->eof_flags & XFS_EOF_FLAGS_QUOTA &&
!xfs_inode_match_quota_id(ip, eofb))
return 0;
+
+ /* skip the inode if the file size is too small */
+ if (eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE &&
+ XFS_ISIZE(ip) < eofb->eof_min_file_size)
+ return 0;
}

ret = xfs_free_eofblocks(ip->i_mount, ip, true);
--
1.7.7.6