Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 262065
b: refs/heads/master
c: b4aff1f
h: refs/heads/master
i:
  262063: 54a3598
v: v3
  • Loading branch information
Josef Bacik authored and Al Viro committed Aug 1, 2011
1 parent ecc750b commit ba9fe3e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9d108d25487bf958f8093409a4c0bee6169edba6
refs/heads/master: b4aff1f874f679320c03e3d97b60fc7babfd4623
47 changes: 45 additions & 2 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4016,12 +4016,19 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
struct btrfs_root *sub_root = root;
struct btrfs_key location;
int index;
int ret;
int ret = 0;

if (dentry->d_name.len > BTRFS_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG);

ret = btrfs_inode_by_name(dir, dentry, &location);
if (unlikely(d_need_lookup(dentry))) {
memcpy(&location, dentry->d_fsdata, sizeof(struct btrfs_key));
kfree(dentry->d_fsdata);
dentry->d_fsdata = NULL;
d_clear_need_lookup(dentry);
} else {
ret = btrfs_inode_by_name(dir, dentry, &location);
}

if (ret < 0)
return ERR_PTR(ret);
Expand Down Expand Up @@ -4076,6 +4083,12 @@ static int btrfs_dentry_delete(const struct dentry *dentry)
return 0;
}

static void btrfs_dentry_release(struct dentry *dentry)
{
if (dentry->d_fsdata)
kfree(dentry->d_fsdata);
}

static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd)
{
Expand All @@ -4098,6 +4111,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
struct btrfs_path *path;
struct list_head ins_list;
struct list_head del_list;
struct qstr q;
int ret;
struct extent_buffer *leaf;
int slot;
Expand Down Expand Up @@ -4187,6 +4201,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,

while (di_cur < di_total) {
struct btrfs_key location;
struct dentry *tmp;

if (verify_dir_item(root, leaf, di))
break;
Expand All @@ -4207,6 +4222,33 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
d_type = btrfs_filetype_table[btrfs_dir_type(leaf, di)];
btrfs_dir_item_key_to_cpu(leaf, di, &location);

q.name = name_ptr;
q.len = name_len;
q.hash = full_name_hash(q.name, q.len);
tmp = d_lookup(filp->f_dentry, &q);
if (!tmp) {
struct btrfs_key *newkey;

newkey = kzalloc(sizeof(struct btrfs_key),
GFP_NOFS);
if (!newkey)
goto no_dentry;
tmp = d_alloc(filp->f_dentry, &q);
if (!tmp) {
kfree(newkey);
dput(tmp);
goto no_dentry;
}
memcpy(newkey, &location,
sizeof(struct btrfs_key));
tmp->d_fsdata = newkey;
tmp->d_flags |= DCACHE_NEED_LOOKUP;
d_rehash(tmp);
dput(tmp);
} else {
dput(tmp);
}
no_dentry:
/* is this a reference to our own snapshot? If so
* skip it
*/
Expand Down Expand Up @@ -7452,4 +7494,5 @@ static const struct inode_operations btrfs_symlink_inode_operations = {

const struct dentry_operations btrfs_dentry_operations = {
.d_delete = btrfs_dentry_delete,
.d_release = btrfs_dentry_release,
};

0 comments on commit ba9fe3e

Please sign in to comment.