diff options
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 115bc05e42b0..61b16c641ce0 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -1947,7 +1947,7 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end, | |||
1947 | * extent_io.c will try to find good copies for us. | 1947 | * extent_io.c will try to find good copies for us. |
1948 | */ | 1948 | */ |
1949 | static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end, | 1949 | static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end, |
1950 | struct extent_state *state) | 1950 | struct extent_state *state, int mirror) |
1951 | { | 1951 | { |
1952 | size_t offset = start - ((u64)page->index << PAGE_CACHE_SHIFT); | 1952 | size_t offset = start - ((u64)page->index << PAGE_CACHE_SHIFT); |
1953 | struct inode *inode = page->mapping->host; | 1953 | struct inode *inode = page->mapping->host; |
@@ -4069,7 +4069,7 @@ static struct inode *new_simple_dir(struct super_block *s, | |||
4069 | BTRFS_I(inode)->dummy_inode = 1; | 4069 | BTRFS_I(inode)->dummy_inode = 1; |
4070 | 4070 | ||
4071 | inode->i_ino = BTRFS_EMPTY_SUBVOL_DIR_OBJECTID; | 4071 | inode->i_ino = BTRFS_EMPTY_SUBVOL_DIR_OBJECTID; |
4072 | inode->i_op = &simple_dir_inode_operations; | 4072 | inode->i_op = &btrfs_dir_ro_inode_operations; |
4073 | inode->i_fop = &simple_dir_operations; | 4073 | inode->i_fop = &simple_dir_operations; |
4074 | inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO; | 4074 | inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO; |
4075 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 4075 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
@@ -4140,14 +4140,18 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) | |||
4140 | static int btrfs_dentry_delete(const struct dentry *dentry) | 4140 | static int btrfs_dentry_delete(const struct dentry *dentry) |
4141 | { | 4141 | { |
4142 | struct btrfs_root *root; | 4142 | struct btrfs_root *root; |
4143 | struct inode *inode = dentry->d_inode; | ||
4143 | 4144 | ||
4144 | if (!dentry->d_inode && !IS_ROOT(dentry)) | 4145 | if (!inode && !IS_ROOT(dentry)) |
4145 | dentry = dentry->d_parent; | 4146 | inode = dentry->d_parent->d_inode; |
4146 | 4147 | ||
4147 | if (dentry->d_inode) { | 4148 | if (inode) { |
4148 | root = BTRFS_I(dentry->d_inode)->root; | 4149 | root = BTRFS_I(inode)->root; |
4149 | if (btrfs_root_refs(&root->root_item) == 0) | 4150 | if (btrfs_root_refs(&root->root_item) == 0) |
4150 | return 1; | 4151 | return 1; |
4152 | |||
4153 | if (btrfs_ino(inode) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID) | ||
4154 | return 1; | ||
4151 | } | 4155 | } |
4152 | return 0; | 4156 | return 0; |
4153 | } | 4157 | } |
@@ -4188,7 +4192,6 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, | |||
4188 | struct btrfs_path *path; | 4192 | struct btrfs_path *path; |
4189 | struct list_head ins_list; | 4193 | struct list_head ins_list; |
4190 | struct list_head del_list; | 4194 | struct list_head del_list; |
4191 | struct qstr q; | ||
4192 | int ret; | 4195 | int ret; |
4193 | struct extent_buffer *leaf; | 4196 | struct extent_buffer *leaf; |
4194 | int slot; | 4197 | int slot; |
@@ -4279,7 +4282,6 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, | |||
4279 | 4282 | ||
4280 | while (di_cur < di_total) { | 4283 | while (di_cur < di_total) { |
4281 | struct btrfs_key location; | 4284 | struct btrfs_key location; |
4282 | struct dentry *tmp; | ||
4283 | 4285 | ||
4284 | if (verify_dir_item(root, leaf, di)) | 4286 | if (verify_dir_item(root, leaf, di)) |
4285 | break; | 4287 | break; |
@@ -4300,35 +4302,15 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, | |||
4300 | d_type = btrfs_filetype_table[btrfs_dir_type(leaf, di)]; | 4302 | d_type = btrfs_filetype_table[btrfs_dir_type(leaf, di)]; |
4301 | btrfs_dir_item_key_to_cpu(leaf, di, &location); | 4303 | btrfs_dir_item_key_to_cpu(leaf, di, &location); |
4302 | 4304 | ||
4303 | q.name = name_ptr; | 4305 | |
4304 | q.len = name_len; | ||
4305 | q.hash = full_name_hash(q.name, q.len); | ||
4306 | tmp = d_lookup(filp->f_dentry, &q); | ||
4307 | if (!tmp) { | ||
4308 | struct btrfs_key *newkey; | ||
4309 | |||
4310 | newkey = kzalloc(sizeof(struct btrfs_key), | ||
4311 | GFP_NOFS); | ||
4312 | if (!newkey) | ||
4313 | goto no_dentry; | ||
4314 | tmp = d_alloc(filp->f_dentry, &q); | ||
4315 | if (!tmp) { | ||
4316 | kfree(newkey); | ||
4317 | dput(tmp); | ||
4318 | goto no_dentry; | ||
4319 | } | ||
4320 | memcpy(newkey, &location, | ||
4321 | sizeof(struct btrfs_key)); | ||
4322 | tmp->d_fsdata = newkey; | ||
4323 | tmp->d_flags |= DCACHE_NEED_LOOKUP; | ||
4324 | d_rehash(tmp); | ||
4325 | dput(tmp); | ||
4326 | } else { | ||
4327 | dput(tmp); | ||
4328 | } | ||
4329 | no_dentry: | ||
4330 | /* is this a reference to our own snapshot? If so | 4306 | /* is this a reference to our own snapshot? If so |
4331 | * skip it | 4307 | * skip it. |
4308 | * | ||
4309 | * In contrast to old kernels, we insert the snapshot's | ||
4310 | * dir item and dir index after it has been created, so | ||
4311 | * we won't find a reference to our own snapshot. We | ||
4312 | * still keep the following code for backward | ||
4313 | * compatibility. | ||
4332 | */ | 4314 | */ |
4333 | if (location.type == BTRFS_ROOT_ITEM_KEY && | 4315 | if (location.type == BTRFS_ROOT_ITEM_KEY && |
4334 | location.objectid == root->root_key.objectid) { | 4316 | location.objectid == root->root_key.objectid) { |