Btrfs: Invalidate dcache entry after creating snapshot and
We need to invalidate an existing dcache entry after creating a new snapshot or subvolume, because a negative dache entry will stop us from accessing the new snapshot or subvolume. --- ctree.h | 23 +++++++++++++++++++++++ inode.c | 4 ++++ transaction.c | 4 ++++ 3 files changed, 31 insertions(+) Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
committed by
Chris Mason
parent
48ec2cf873
commit
3b96362cc8
@@ -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)
|
||||
{
|
||||
@@ -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);
|
||||
|
Reference in New Issue
Block a user