@@ -1971,56 +1971,65 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)
19711971 return ERR_PTR (- EINVAL );
19721972}
19731973
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+
19742021static int ubifs_fill_super (struct super_block * sb , void * data , int silent )
19752022{
19762023 struct ubi_volume_desc * ubi = sb -> s_fs_info ;
19772024 struct ubifs_info * c ;
19782025 struct inode * root ;
19792026 int err ;
19802027
1981- c = kzalloc ( sizeof ( struct ubifs_info ), GFP_KERNEL );
2028+ c = alloc_ubifs_info ( ubi );
19822029 if (!c )
19832030 return - ENOMEM ;
19842031
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-
20172032 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-
20242033 /* Re-open the UBI device in read-write mode */
20252034 c -> ubi = ubi_open_volume (c -> vi .ubi_num , c -> vi .vol_id , UBI_READWRITE );
20262035 if (IS_ERR (c -> ubi )) {
0 commit comments