]> git.neil.brown.name Git - LaFS.git/commitdiff
Report directory size without holes.
authorNeilBrown <neilb@suse.de>
Mon, 28 Jun 2010 05:29:44 +0000 (15:29 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 28 Jun 2010 05:29:44 +0000 (15:29 +1000)
Holes in a directory are an implementation details that does not need
to be exposed in i_size, and doing so is confusing and could leak info
about the hash used.
So when more than one block is used, report size as block size times
number of blocks.

Signed-off-by: NeilBrown <neilb@suse.de>
README
dir.c

diff --git a/README b/README
index dd8986b6ca2f468a14b0581dbdeec724441814f6..692711a3c7ea1aacbf4925f660afb9aad8f37817 100644 (file)
--- a/README
+++ b/README
@@ -4916,6 +4916,9 @@ DONE 13/ delete_inode should wait for pending truncate to complete.
 
 14/ Review writepage and flush and make sure we flush often enough but
     not too often.
+    Probably just remove the cluster_flush from write-page as lafs_flush
+    will do that.
+    But leave for now as it encourages heavy indexing.
 
 DONE 15/ The inode map file lost some credits.  I think it losts a PinPending because
     it isn't locked properly.  Don't clear PinPending if someone else might
@@ -4923,7 +4926,7 @@ DONE 15/ The inode map file lost some credits.  I think it losts a PinPending be
 
 15a/ Find all FIXMEs and add them here.
 
-15b/ Report directory size less confusingly
+DONE 15b/ Report directory size less confusingly
 
 15c/ roll-forward should not update index if physaddr hasn't changed (roll_block)
 
@@ -4936,6 +4939,12 @@ DONE 15d/ What does I_Dirty mean - and implement it.
 
 15g/ test directories with non-random sequential hash.
 
+15h/ orphan deadlock
+    lafs_run_orphans- lafs_orphan_release can block waiting for written
+     in erase_dblock, but that won't complete until cleaner gets to run,
+     but this is the cleaner blocked on orphans.
+
+
 16/ Update locking.doc
 
 17/ cluster_flush calls lafs_cluster_allocate calls lafs_add_block_address
diff --git a/dir.c b/dir.c
index da2b4f5fe6f7b73331c33da09ab38b8cb86616b4..5ed82f07adca2e49574935fcb2e4ac79a29cb6db 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1524,6 +1524,21 @@ lafs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
        return d_splice_alias(ino, dentry);
 }
 
+static int lafs_getattr_dir(struct vfsmount *mnt, struct dentry *dentry,
+                           struct kstat *stat)
+{
+       generic_fillattr(dentry->d_inode, stat);
+       /* hide 'holes' in directories by making the size match
+        * the number of allocated blocks.
+        */
+       if (stat->size > dentry->d_inode->i_sb->s_blocksize)
+               stat->size = (dentry->d_inode->i_sb->s_blocksize *
+                            (LAFSI(dentry->d_inode)->cblocks +
+                             LAFSI(dentry->d_inode)->pblocks +
+                             LAFSI(dentry->d_inode)->ablocks));
+       return 0;
+}
+
 const struct file_operations lafs_dir_file_operations = {
        .llseek         = generic_file_llseek,  /* Just set 'pos' */
        .read           = generic_read_dir,     /* return error */
@@ -1544,4 +1559,5 @@ struct inode_operations lafs_dir_ino_operations = {
        .rename         = lafs_rename,
        .mknod          = lafs_mknod,
        .setattr        = lafs_setattr,
+       .getattr        = lafs_getattr_dir,
 };