diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-06-12 10:07:03 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-06-12 17:45:32 -0400 |
commit | b1c27ab3f93daede979f804afc38b189c2f17c60 (patch) | |
tree | 469479c334b7e346708b17e269e399e073a8098f /fs/ubifs/super.c | |
parent | ff78fca2a03c08436535d3f7152a30752d8131d1 (diff) |
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>
Diffstat (limited to 'fs/ubifs/super.c')
-rw-r--r-- | fs/ubifs/super.c | 87 |
1 files changed, 48 insertions, 39 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index b5aeb5a8ebed..ddc3b02e8cf0 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -1971,6 +1971,53 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode) | |||
1971 | return ERR_PTR(-EINVAL); | 1971 | return ERR_PTR(-EINVAL); |
1972 | } | 1972 | } |
1973 | 1973 | ||
1974 | static struct ubifs_info *alloc_ubifs_info(struct ubi_volume_desc *ubi) | ||
1975 | { | ||
1976 | struct ubifs_info *c; | ||
1977 | |||
1978 | c = kzalloc(sizeof(struct ubifs_info), GFP_KERNEL); | ||
1979 | if (c) { | ||
1980 | spin_lock_init(&c->cnt_lock); | ||
1981 | spin_lock_init(&c->cs_lock); | ||
1982 | spin_lock_init(&c->buds_lock); | ||
1983 | spin_lock_init(&c->space_lock); | ||
1984 | spin_lock_init(&c->orphan_lock); | ||
1985 | init_rwsem(&c->commit_sem); | ||
1986 | mutex_init(&c->lp_mutex); | ||
1987 | mutex_init(&c->tnc_mutex); | ||
1988 | mutex_init(&c->log_mutex); | ||
1989 | mutex_init(&c->mst_mutex); | ||
1990 | mutex_init(&c->umount_mutex); | ||
1991 | mutex_init(&c->bu_mutex); | ||
1992 | mutex_init(&c->write_reserve_mutex); | ||
1993 | init_waitqueue_head(&c->cmt_wq); | ||
1994 | c->buds = RB_ROOT; | ||
1995 | c->old_idx = RB_ROOT; | ||
1996 | c->size_tree = RB_ROOT; | ||
1997 | c->orph_tree = RB_ROOT; | ||
1998 | INIT_LIST_HEAD(&c->infos_list); | ||
1999 | INIT_LIST_HEAD(&c->idx_gc); | ||
2000 | INIT_LIST_HEAD(&c->replay_list); | ||
2001 | INIT_LIST_HEAD(&c->replay_buds); | ||
2002 | INIT_LIST_HEAD(&c->uncat_list); | ||
2003 | INIT_LIST_HEAD(&c->empty_list); | ||
2004 | INIT_LIST_HEAD(&c->freeable_list); | ||
2005 | INIT_LIST_HEAD(&c->frdi_idx_list); | ||
2006 | INIT_LIST_HEAD(&c->unclean_leb_list); | ||
2007 | INIT_LIST_HEAD(&c->old_buds); | ||
2008 | INIT_LIST_HEAD(&c->orph_list); | ||
2009 | INIT_LIST_HEAD(&c->orph_new); | ||
2010 | c->no_chk_data_crc = 1; | ||
2011 | |||
2012 | c->highest_inum = UBIFS_FIRST_INO; | ||
2013 | c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM; | ||
2014 | |||
2015 | ubi_get_volume_info(ubi, &c->vi); | ||
2016 | ubi_get_device_info(c->vi.ubi_num, &c->di); | ||
2017 | } | ||
2018 | return c; | ||
2019 | } | ||
2020 | |||
1974 | static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | 2021 | static int ubifs_fill_super(struct super_block *sb, void *data, int silent) |
1975 | { | 2022 | { |
1976 | struct ubi_volume_desc *ubi = sb->s_fs_info; | 2023 | struct ubi_volume_desc *ubi = sb->s_fs_info; |
@@ -1978,49 +2025,11 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
1978 | struct inode *root; | 2025 | struct inode *root; |
1979 | int err; | 2026 | int err; |
1980 | 2027 | ||
1981 | c = kzalloc(sizeof(struct ubifs_info), GFP_KERNEL); | 2028 | c = alloc_ubifs_info(ubi); |
1982 | if (!c) | 2029 | if (!c) |
1983 | return -ENOMEM; | 2030 | return -ENOMEM; |
1984 | 2031 | ||
1985 | spin_lock_init(&c->cnt_lock); | ||
1986 | spin_lock_init(&c->cs_lock); | ||
1987 | spin_lock_init(&c->buds_lock); | ||
1988 | spin_lock_init(&c->space_lock); | ||
1989 | spin_lock_init(&c->orphan_lock); | ||
1990 | init_rwsem(&c->commit_sem); | ||
1991 | mutex_init(&c->lp_mutex); | ||
1992 | mutex_init(&c->tnc_mutex); | ||
1993 | mutex_init(&c->log_mutex); | ||
1994 | mutex_init(&c->mst_mutex); | ||
1995 | mutex_init(&c->umount_mutex); | ||
1996 | mutex_init(&c->bu_mutex); | ||
1997 | mutex_init(&c->write_reserve_mutex); | ||
1998 | init_waitqueue_head(&c->cmt_wq); | ||
1999 | c->buds = RB_ROOT; | ||
2000 | c->old_idx = RB_ROOT; | ||
2001 | c->size_tree = RB_ROOT; | ||
2002 | c->orph_tree = RB_ROOT; | ||
2003 | INIT_LIST_HEAD(&c->infos_list); | ||
2004 | INIT_LIST_HEAD(&c->idx_gc); | ||
2005 | INIT_LIST_HEAD(&c->replay_list); | ||
2006 | INIT_LIST_HEAD(&c->replay_buds); | ||
2007 | INIT_LIST_HEAD(&c->uncat_list); | ||
2008 | INIT_LIST_HEAD(&c->empty_list); | ||
2009 | INIT_LIST_HEAD(&c->freeable_list); | ||
2010 | INIT_LIST_HEAD(&c->frdi_idx_list); | ||
2011 | INIT_LIST_HEAD(&c->unclean_leb_list); | ||
2012 | INIT_LIST_HEAD(&c->old_buds); | ||
2013 | INIT_LIST_HEAD(&c->orph_list); | ||
2014 | INIT_LIST_HEAD(&c->orph_new); | ||
2015 | c->no_chk_data_crc = 1; | ||
2016 | |||
2017 | c->vfs_sb = sb; | 2032 | c->vfs_sb = sb; |
2018 | c->highest_inum = UBIFS_FIRST_INO; | ||
2019 | c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM; | ||
2020 | |||
2021 | ubi_get_volume_info(ubi, &c->vi); | ||
2022 | ubi_get_device_info(c->vi.ubi_num, &c->di); | ||
2023 | |||
2024 | /* Re-open the UBI device in read-write mode */ | 2033 | /* Re-open the UBI device in read-write mode */ |
2025 | c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READWRITE); | 2034 | c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READWRITE); |
2026 | if (IS_ERR(c->ubi)) { | 2035 | if (IS_ERR(c->ubi)) { |