xfs: add minimum file size filtering to eofblocks scan
authorBrian Foster <bfoster@redhat.com>
Wed, 7 Nov 2012 17:21:14 +0000 (12:21 -0500)
committerBen Myers <bpm@sgi.com>
Thu, 8 Nov 2012 21:32:29 +0000 (15:32 -0600)
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>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
fs/xfs/xfs_fs.h
fs/xfs/xfs_icache.c

index a19f9b205c1599c20771f772c6d39fa3ef99c6cb..6dda3f949b04f5c8a9ad804d030c9b21f99b4d96 100644 (file)
@@ -350,7 +350,8 @@ struct xfs_eofblocks {
        gid_t           eof_gid;
        prid_t          eof_prid;
        __u32           pad32;
-       __u64           pad64[13];
+       __u64           eof_min_file_size;
+       __u64           pad64[12];
 };
 
 /* eof_flags values */
@@ -358,11 +359,13 @@ 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)
 
 
 /*
index 32908909815e2b8841cae6c156d50d64e0e0ce42..906e6dcd2c55fa51ee929cf30cb2e5cf140a0c0c 100644 (file)
@@ -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);