xfs
[Top] [All Lists]

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

To: xfs@xxxxxxxxxxx
Subject: [PATCH v6 09/10] xfs: add minimum file size filtering to eofblocks scan
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Tue, 6 Nov 2012 09:50:46 -0500
In-reply-to: <1352213447-59791-1-git-send-email-bfoster@xxxxxxxxxx>
References: <1352213447-59791-1-git-send-email-bfoster@xxxxxxxxxx>
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@xxxxxxxxxx>
---
 fs/xfs/xfs_fs.h     |    6 ++++--
 fs/xfs/xfs_icache.c |   11 +++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
index 88eb1bc..082b743 100644
--- a/fs/xfs/xfs_fs.h
+++ b/fs/xfs/xfs_fs.h
@@ -348,7 +348,8 @@ struct xfs_eofblocks {
        uid_t           eof_uid;
        gid_t           eof_gid;
        prid_t          eof_prid;
-       __u32           pad[27];
+       __u64           eof_min_file_size;
+       __u32           pad[25];
 };
 
 /* eof_flags values */
@@ -356,9 +357,10 @@ struct xfs_eofblocks {
 #define XFS_EOF_FLAGS_UID              (1 << 1) /* filter by uid */
 #define XFS_EOF_FLAGS_GID              (1 << 2) /* filter by gid */
 #define XFS_EOF_FLAGS_PRID             (1 << 3) /* filter by project id */
+#define XFS_EOF_FLAGS_MINFILESIZE      (1 << 4) /* filter by min file size */
 #define XFS_EOF_FLAGS_VALID    \
        (XFS_EOF_FLAGS_SYNC|XFS_EOF_FLAGS_UID|XFS_EOF_FLAGS_GID| \
-        XFS_EOF_FLAGS_PRID)
+        XFS_EOF_FLAGS_PRID|XFS_EOF_FLAGS_MINFILESIZE)
 
 
 /*
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index d7372b1..6e63228 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1215,8 +1215,15 @@ xfs_inode_free_eofblocks(
            mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY))
                return 0;
 
-       if (eofb && !xfs_inode_match_id(ip, eofb))
-               return 0;
+       if (eofb) {
+               if (!xfs_inode_match_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

<Prev in Thread] Current Thread [Next in Thread>