@@ -193,7 +193,7 @@ static int setup_new_group_blocks(struct super_block *sb,
193193 if (IS_ERR (handle ))
194194 return PTR_ERR (handle );
195195
196- lock_super ( sb );
196+ mutex_lock ( & sbi -> s_resize_lock );
197197 if (input -> group != sbi -> s_groups_count ) {
198198 err = - EBUSY ;
199199 goto exit_journal ;
@@ -302,7 +302,7 @@ static int setup_new_group_blocks(struct super_block *sb,
302302 brelse (bh );
303303
304304exit_journal :
305- unlock_super ( sb );
305+ mutex_unlock ( & sbi -> s_resize_lock );
306306 if ((err2 = ext4_journal_stop (handle )) && !err )
307307 err = err2 ;
308308
@@ -643,11 +643,12 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
643643 * important part is that the new block and inode counts are in the backup
644644 * superblocks, and the location of the new group metadata in the GDT backups.
645645 *
646- * We do not need lock_super() for this, because these blocks are not
647- * otherwise touched by the filesystem code when it is mounted. We don't
648- * need to worry about last changing from sbi->s_groups_count, because the
649- * worst that can happen is that we do not copy the full number of backups
650- * at this time. The resize which changed s_groups_count will backup again.
646+ * We do not need take the s_resize_lock for this, because these
647+ * blocks are not otherwise touched by the filesystem code when it is
648+ * mounted. We don't need to worry about last changing from
649+ * sbi->s_groups_count, because the worst that can happen is that we
650+ * do not copy the full number of backups at this time. The resize
651+ * which changed s_groups_count will backup again.
651652 */
652653static void update_backups (struct super_block * sb ,
653654 int blk_off , char * data , int size )
@@ -809,7 +810,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
809810 goto exit_put ;
810811 }
811812
812- lock_super ( sb );
813+ mutex_lock ( & sbi -> s_resize_lock );
813814 if (input -> group != sbi -> s_groups_count ) {
814815 ext4_warning (sb , __func__ ,
815816 "multiple resizers run on filesystem!" );
@@ -840,7 +841,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
840841 /*
841842 * OK, now we've set up the new group. Time to make it active.
842843 *
843- * Current kernels don't lock all allocations via lock_super(),
844+ * We do not lock all allocations via s_resize_lock
844845 * so we have to be safe wrt. concurrent accesses the group
845846 * data. So we need to be careful to set all of the relevant
846847 * group descriptor data etc. *before* we enable the group.
@@ -900,12 +901,12 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
900901 *
901902 * The precise rules we use are:
902903 *
903- * * Writers of s_groups_count *must* hold lock_super
904+ * * Writers of s_groups_count *must* hold s_resize_lock
904905 * AND
905906 * * Writers must perform a smp_wmb() after updating all dependent
906907 * data and before modifying the groups count
907908 *
908- * * Readers must hold lock_super() over the access
909+ * * Readers must hold s_resize_lock over the access
909910 * OR
910911 * * Readers must perform an smp_rmb() after reading the groups count
911912 * and before reading any dependent data.
@@ -948,7 +949,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
948949 sb -> s_dirt = 1 ;
949950
950951exit_journal :
951- unlock_super ( sb );
952+ mutex_unlock ( & sbi -> s_resize_lock );
952953 if ((err2 = ext4_journal_stop (handle )) && !err )
953954 err = err2 ;
954955 if (!err ) {
@@ -986,7 +987,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
986987
987988 /* We don't need to worry about locking wrt other resizers just
988989 * yet: we're going to revalidate es->s_blocks_count after
989- * taking lock_super() below. */
990+ * taking the s_resize_lock below. */
990991 o_blocks_count = ext4_blocks_count (es );
991992 o_groups_count = EXT4_SB (sb )-> s_groups_count ;
992993
@@ -1056,11 +1057,11 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
10561057 goto exit_put ;
10571058 }
10581059
1059- lock_super ( sb );
1060+ mutex_lock ( & EXT4_SB ( sb ) -> s_resize_lock );
10601061 if (o_blocks_count != ext4_blocks_count (es )) {
10611062 ext4_warning (sb , __func__ ,
10621063 "multiple resizers run on filesystem!" );
1063- unlock_super ( sb );
1064+ mutex_unlock ( & EXT4_SB ( sb ) -> s_resize_lock );
10641065 ext4_journal_stop (handle );
10651066 err = - EBUSY ;
10661067 goto exit_put ;
@@ -1070,14 +1071,14 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
10701071 EXT4_SB (sb )-> s_sbh ))) {
10711072 ext4_warning (sb , __func__ ,
10721073 "error %d on journal write access" , err );
1073- unlock_super ( sb );
1074+ mutex_unlock ( & EXT4_SB ( sb ) -> s_resize_lock );
10741075 ext4_journal_stop (handle );
10751076 goto exit_put ;
10761077 }
10771078 ext4_blocks_count_set (es , o_blocks_count + add );
10781079 ext4_handle_dirty_metadata (handle , NULL , EXT4_SB (sb )-> s_sbh );
10791080 sb -> s_dirt = 1 ;
1080- unlock_super ( sb );
1081+ mutex_unlock ( & EXT4_SB ( sb ) -> s_resize_lock );
10811082 ext4_debug ("freeing blocks %llu through %llu\n" , o_blocks_count ,
10821083 o_blocks_count + add );
10831084 /* We add the blocks to the bitmap and set the group need init bit */
0 commit comments