ceph: avoid updating directory inode's i_size accidentally
authorYan, Zheng <zyan@redhat.com>
Fri, 26 Feb 2016 09:16:32 +0000 (17:16 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Fri, 25 Mar 2016 17:51:53 +0000 (18:51 +0100)
Directory inode's i_size is used by readdir cache.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
fs/ceph/inode.c

index 495decfc4b34849bf3b401cbcc07036de5eaaa63..66edef12c6f2516f765353646f93ef8aae629831 100644 (file)
@@ -549,6 +549,10 @@ int ceph_fill_file_size(struct inode *inode, int issued,
        if (ceph_seq_cmp(truncate_seq, ci->i_truncate_seq) > 0 ||
            (truncate_seq == ci->i_truncate_seq && size > inode->i_size)) {
                dout("size %lld -> %llu\n", inode->i_size, size);
+               if (size > 0 && S_ISDIR(inode->i_mode)) {
+                       pr_err("fill_file_size non-zero size for directory\n");
+                       size = 0;
+               }
                i_size_write(inode, size);
                inode->i_blocks = (size + (1<<9) - 1) >> 9;
                ci->i_reported_size = size;