mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 04:06:22 +00:00
GFS2: Fix locking issue mounting gfs2meta fs
This patch uses sget() to get a reference to the existing gfs2 sb when mouting the gfs2meta filesystem (in fact thats just another mount of the gfs2 filesystem with a different root and this interface is for backward compatibility). Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> Reported-by: Benjamin Marzinski <bmarzins@redhat.com> Tested-by: Benjamin Marzinski <bmarzins@redhat.com> Cc: Christoph Hellwig <hch@infradead.org>
This commit is contained in:
parent
e09f9446b9
commit
f6d03139d7
1 changed files with 22 additions and 14 deletions
|
@ -1273,9 +1273,20 @@ static int gfs2_get_sb(struct file_system_type *fs_type, int flags,
|
||||||
return get_sb_bdev(fs_type, flags, dev_name, data, fill_super, mnt);
|
return get_sb_bdev(fs_type, flags, dev_name, data, fill_super, mnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int test_meta_super(struct super_block *s, void *ptr)
|
||||||
|
{
|
||||||
|
struct block_device *bdev = ptr;
|
||||||
|
return (bdev == s->s_bdev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int set_meta_super(struct super_block *s, void *ptr)
|
||||||
|
{
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
static struct super_block *get_gfs2_sb(const char *dev_name)
|
static struct super_block *get_gfs2_sb(const char *dev_name)
|
||||||
{
|
{
|
||||||
struct super_block *sb;
|
struct super_block *s;
|
||||||
struct path path;
|
struct path path;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
@ -1283,30 +1294,27 @@ static struct super_block *get_gfs2_sb(const char *dev_name)
|
||||||
if (error) {
|
if (error) {
|
||||||
printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n",
|
printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n",
|
||||||
dev_name, error);
|
dev_name, error);
|
||||||
return NULL;
|
return ERR_PTR(-ENOENT);
|
||||||
}
|
}
|
||||||
sb = path.dentry->d_inode->i_sb;
|
s = sget(&gfs2_fs_type, test_meta_super, set_meta_super,
|
||||||
if (sb && (sb->s_type == &gfs2_fs_type))
|
path.dentry->d_inode->i_sb->s_bdev);
|
||||||
atomic_inc(&sb->s_active);
|
|
||||||
else
|
|
||||||
sb = NULL;
|
|
||||||
path_put(&path);
|
path_put(&path);
|
||||||
return sb;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags,
|
static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags,
|
||||||
const char *dev_name, void *data, struct vfsmount *mnt)
|
const char *dev_name, void *data, struct vfsmount *mnt)
|
||||||
{
|
{
|
||||||
struct super_block *sb = NULL;
|
struct super_block *s;
|
||||||
struct gfs2_sbd *sdp;
|
struct gfs2_sbd *sdp;
|
||||||
|
|
||||||
sb = get_gfs2_sb(dev_name);
|
s = get_gfs2_sb(dev_name);
|
||||||
if (!sb) {
|
if (IS_ERR(s)) {
|
||||||
printk(KERN_WARNING "GFS2: gfs2 mount does not exist\n");
|
printk(KERN_WARNING "GFS2: gfs2 mount does not exist\n");
|
||||||
return -ENOENT;
|
return PTR_ERR(s);
|
||||||
}
|
}
|
||||||
sdp = sb->s_fs_info;
|
sdp = s->s_fs_info;
|
||||||
mnt->mnt_sb = sb;
|
mnt->mnt_sb = s;
|
||||||
mnt->mnt_root = dget(sdp->sd_master_dir);
|
mnt->mnt_root = dget(sdp->sd_master_dir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue