mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 18:39:59 +00:00
Btrfs: use d_obtain_alias when mounting subvol/subvolid
Currently what we do is just wrong. We either 1) Alloc a new "root" dentry with sb->s_root as it's parent which is just wrong as we could walk into this subvol later on via another path and hilarity could ensue. Also we don't check the return value of d_splice_alias which isn't good either. or 2) Do a d_find_alias() which we could have lost our dentry from cache at this point and found nothing. So use d_obtain_alias(). In the case that we already have the inode/dentry in cache we will get the correct dentry. If not we will get a disconnected dentry tree so if we walk into it later on everything will be connected up properly. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
This commit is contained in:
parent
0cbbdf7c9c
commit
ba5b8958da
1 changed files with 1 additions and 24 deletions
|
@ -492,7 +492,6 @@ static struct dentry *get_default_root(struct super_block *sb,
|
|||
struct btrfs_path *path;
|
||||
struct btrfs_key location;
|
||||
struct inode *inode;
|
||||
struct dentry *dentry;
|
||||
u64 dir_id;
|
||||
int new = 0;
|
||||
|
||||
|
@ -566,29 +565,7 @@ static struct dentry *get_default_root(struct super_block *sb,
|
|||
return dget(sb->s_root);
|
||||
}
|
||||
|
||||
if (new) {
|
||||
const struct qstr name = { .name = "/", .len = 1 };
|
||||
|
||||
/*
|
||||
* New inode, we need to make the dentry a sibling of s_root so
|
||||
* everything gets cleaned up properly on unmount.
|
||||
*/
|
||||
dentry = d_alloc(sb->s_root, &name);
|
||||
if (!dentry) {
|
||||
iput(inode);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
d_splice_alias(inode, dentry);
|
||||
} else {
|
||||
/*
|
||||
* We found the inode in cache, just find a dentry for it and
|
||||
* put the reference to the inode we just got.
|
||||
*/
|
||||
dentry = d_find_alias(inode);
|
||||
iput(inode);
|
||||
}
|
||||
|
||||
return dentry;
|
||||
return d_obtain_alias(inode);
|
||||
}
|
||||
|
||||
static int btrfs_fill_super(struct super_block *sb,
|
||||
|
|
Loading…
Reference in a new issue