Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128786
b: refs/heads/master
c: 3b96362
h: refs/heads/master
v: v3
  • Loading branch information
Sven Wegener authored and Chris Mason committed Sep 25, 2008
1 parent 374696c commit ff37c98
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 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: 48ec2cf8738b0db53dc8361026cb7a328f7ad386
refs/heads/master: 3b96362cc8d314c935c335d5c3c42eb93c23166b
3 changes: 3 additions & 0 deletions trunk/fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,9 @@ int btrfs_csum_truncate(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_path *path,
u64 isize);
/* inode.c */
void btrfs_invalidate_dcache_root(struct btrfs_root *root, char *name,
int namelen);

int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
size_t size, struct bio *bio);

Expand Down
29 changes: 29 additions & 0 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2642,6 +2642,31 @@ static void btrfs_truncate(struct inode *inode)
btrfs_throttle(root);
}

/*
* Invalidate a single dcache entry at the root of the filesystem.
* Needed after creation of snapshot or subvolume.
*/
void btrfs_invalidate_dcache_root(struct btrfs_root *root, char *name,
int namelen)
{
struct dentry *alias, *entry;
struct qstr qstr;

alias = d_find_alias(root->fs_info->sb->s_root->d_inode);
if (alias) {
qstr.name = name;
qstr.len = namelen;
/* change me if btrfs ever gets a d_hash operation */
qstr.hash = full_name_hash(qstr.name, qstr.len);
entry = d_lookup(alias, &qstr);
dput(alias);
if (entry) {
d_invalidate(entry);
dput(entry);
}
}
}

static int noinline create_subvol(struct btrfs_root *root, char *name,
int namelen)
{
Expand Down Expand Up @@ -2761,6 +2786,10 @@ static int noinline create_subvol(struct btrfs_root *root, char *name,
ret = btrfs_update_inode(trans, new_root, inode);
if (ret)
goto fail;

/* Invalidate existing dcache entry for new subvolume. */
btrfs_invalidate_dcache_root(root, name, namelen);

fail:
nr = trans->blocks_used;
err = btrfs_commit_transaction(trans, new_root);
Expand Down
8 changes: 7 additions & 1 deletion trunk/fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
struct btrfs_root *root = pending->root;
struct extent_buffer *tmp;
int ret;
int namelen;
u64 objectid;

new_root_item = kmalloc(sizeof(*new_root_item), GFP_NOFS);
Expand Down Expand Up @@ -595,8 +596,9 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
* insert the directory item
*/
key.offset = (u64)-1;
namelen = strlen(pending->name);
ret = btrfs_insert_dir_item(trans, root->fs_info->tree_root,
pending->name, strlen(pending->name),
pending->name, namelen,
root->fs_info->sb->s_root->d_inode->i_ino,
&key, BTRFS_FT_DIR);

Expand All @@ -606,6 +608,10 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
ret = btrfs_insert_inode_ref(trans, root->fs_info->tree_root,
pending->name, strlen(pending->name), objectid,
root->fs_info->sb->s_root->d_inode->i_ino);

/* Invalidate existing dcache entry for new snapshot. */
btrfs_invalidate_dcache_root(root, pending->name, namelen);

fail:
kfree(new_root_item);
return ret;
Expand Down

0 comments on commit ff37c98

Please sign in to comment.