ceph: move directory size logic to ceph_getattr
authorSage Weil <sage@newdream.net>
Wed, 21 Oct 2009 18:21:49 +0000 (11:21 -0700)
committerSage Weil <sage@newdream.net>
Wed, 21 Oct 2009 18:24:36 +0000 (11:24 -0700)
We can't fill i_size with rbytes at the fill_file_size stage without
adding additional checks for directories.  Notably, we want st_blocks
to remain 0 on directories so that 'du' still works.

Fill in i_blocks, i_size specially in ceph_getattr instead.

Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/inode.c

index 6097af790047e1a0bf77b75a962231bda601cc7e..036873c42a78c4904a5a54d9c3fcd8b67822776e 100644 (file)
@@ -568,8 +568,6 @@ static int fill_inode(struct inode *inode,
        queue_trunc = ceph_fill_file_size(inode, issued,
                                          le32_to_cpu(info->truncate_seq),
                                          le64_to_cpu(info->truncate_size),
-                                         S_ISDIR(inode->i_mode) ?
-                                         ci->i_rbytes :
                                          le64_to_cpu(info->size));
        ceph_fill_file_time(inode, issued,
                            le32_to_cpu(info->time_warp_seq),
@@ -1603,6 +1601,7 @@ int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry,
                 struct kstat *stat)
 {
        struct inode *inode = dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
        int err;
 
        err = ceph_do_getattr(inode, CEPH_STAT_CAP_INODE_ALL);
@@ -1613,8 +1612,11 @@ int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry,
                        stat->dev = ceph_snap(inode);
                else
                        stat->dev = 0;
-               if (S_ISDIR(inode->i_mode))
+               if (S_ISDIR(inode->i_mode)) {
+                       stat->size = ci->i_rbytes;
+                       stat->blocks = 0;
                        stat->blksize = 65536;
+               }
        }
        return err;
 }