ubifs: split allocation of ubifs_info into a separate function
preparation to ubifs sget() race fixes Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -1971,17 +1971,12 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)
|
|||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
|
static struct ubifs_info *alloc_ubifs_info(struct ubi_volume_desc *ubi)
|
||||||
{
|
{
|
||||||
struct ubi_volume_desc *ubi = sb->s_fs_info;
|
|
||||||
struct ubifs_info *c;
|
struct ubifs_info *c;
|
||||||
struct inode *root;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
c = kzalloc(sizeof(struct ubifs_info), GFP_KERNEL);
|
c = kzalloc(sizeof(struct ubifs_info), GFP_KERNEL);
|
||||||
if (!c)
|
if (c) {
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
spin_lock_init(&c->cnt_lock);
|
spin_lock_init(&c->cnt_lock);
|
||||||
spin_lock_init(&c->cs_lock);
|
spin_lock_init(&c->cs_lock);
|
||||||
spin_lock_init(&c->buds_lock);
|
spin_lock_init(&c->buds_lock);
|
||||||
@@ -2014,13 +2009,27 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
|
|||||||
INIT_LIST_HEAD(&c->orph_new);
|
INIT_LIST_HEAD(&c->orph_new);
|
||||||
c->no_chk_data_crc = 1;
|
c->no_chk_data_crc = 1;
|
||||||
|
|
||||||
c->vfs_sb = sb;
|
|
||||||
c->highest_inum = UBIFS_FIRST_INO;
|
c->highest_inum = UBIFS_FIRST_INO;
|
||||||
c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM;
|
c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM;
|
||||||
|
|
||||||
ubi_get_volume_info(ubi, &c->vi);
|
ubi_get_volume_info(ubi, &c->vi);
|
||||||
ubi_get_device_info(c->vi.ubi_num, &c->di);
|
ubi_get_device_info(c->vi.ubi_num, &c->di);
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
|
{
|
||||||
|
struct ubi_volume_desc *ubi = sb->s_fs_info;
|
||||||
|
struct ubifs_info *c;
|
||||||
|
struct inode *root;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
c = alloc_ubifs_info(ubi);
|
||||||
|
if (!c)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
c->vfs_sb = sb;
|
||||||
/* Re-open the UBI device in read-write mode */
|
/* Re-open the UBI device in read-write mode */
|
||||||
c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READWRITE);
|
c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READWRITE);
|
||||||
if (IS_ERR(c->ubi)) {
|
if (IS_ERR(c->ubi)) {
|
||||||
|
Reference in New Issue
Block a user