Btrfs: update directory's size when creating subvol/snapshot
authorYan Zheng <zheng.yan@oracle.com>
Mon, 5 Jan 2009 20:43:43 +0000 (15:43 -0500)
committerChris Mason <chris.mason@oracle.com>
Mon, 5 Jan 2009 20:43:43 +0000 (15:43 -0500)
Make sure directory's size properly updated when creating
subvol/snapshot.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
fs/btrfs/ioctl.c
fs/btrfs/transaction.c

index 150784e936e6cb1da1e7f63200a5e9ebe069d6f0..ba484aac1b9c38a6ea8942bf15d0f11cc9d47b41 100644 (file)
@@ -147,6 +147,10 @@ static noinline int create_subvol(struct btrfs_root *root,
        if (ret)
                goto fail;
 
+       btrfs_i_size_write(dir, dir->i_size + namelen * 2);
+       ret = btrfs_update_inode(trans, root, dir);
+       BUG_ON(ret);
+
        /* add the backref first */
        ret = btrfs_add_root_ref(trans, root->fs_info->tree_root,
                                 objectid, BTRFS_ROOT_BACKREF_KEY,
index 4604178a43a9d829bd02b36fdae5679f43da9887..4e7b56e9d3a552be6ff47bc9fb0f30d9380392bf 100644 (file)
@@ -819,6 +819,10 @@ static noinline int finish_pending_snapshot(struct btrfs_fs_info *fs_info,
        if (ret)
                goto fail;
 
+       btrfs_i_size_write(parent_inode, parent_inode->i_size + namelen * 2);
+       ret = btrfs_update_inode(trans, parent_root, parent_inode);
+       BUG_ON(ret);
+
        /* add the backref first */
        ret = btrfs_add_root_ref(trans, parent_root->fs_info->tree_root,
                                 pending->root_key.objectid,