From: NeilBrown Date: Mon, 28 Jun 2010 05:29:44 +0000 (+1000) Subject: Report directory size without holes. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=5aa6ca41c50a02c07298faab77e7f4b9fd154d78;p=LaFS.git Report directory size without holes. 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 --- diff --git a/README b/README index dd8986b..692711a 100644 --- 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 da2b4f5..5ed82f0 100644 --- 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, };