@@ -209,7 +209,7 @@ static int setup_new_group_blocks(struct super_block *sb,
209209 if (IS_ERR (handle ))
210210 return PTR_ERR (handle );
211211
212- lock_super ( sb );
212+ mutex_lock ( & sbi -> s_resize_lock );
213213 if (input -> group != sbi -> s_groups_count ) {
214214 err = - EBUSY ;
215215 goto exit_journal ;
@@ -324,7 +324,7 @@ static int setup_new_group_blocks(struct super_block *sb,
324324 brelse (bh );
325325
326326exit_journal :
327- unlock_super ( sb );
327+ mutex_unlock ( & sbi -> s_resize_lock );
328328 if ((err2 = ext3_journal_stop (handle )) && !err )
329329 err = err2 ;
330330
@@ -662,11 +662,12 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
662662 * important part is that the new block and inode counts are in the backup
663663 * superblocks, and the location of the new group metadata in the GDT backups.
664664 *
665- * We do not need lock_super() for this, because these blocks are not
666- * otherwise touched by the filesystem code when it is mounted. We don't
667- * need to worry about last changing from sbi->s_groups_count, because the
668- * worst that can happen is that we do not copy the full number of backups
669- * at this time. The resize which changed s_groups_count will backup again.
665+ * We do not need take the s_resize_lock for this, because these
666+ * blocks are not otherwise touched by the filesystem code when it is
667+ * mounted. We don't need to worry about last changing from
668+ * sbi->s_groups_count, because the worst that can happen is that we
669+ * do not copy the full number of backups at this time. The resize
670+ * which changed s_groups_count will backup again.
670671 */
671672static void update_backups (struct super_block * sb ,
672673 int blk_off , char * data , int size )
@@ -825,7 +826,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
825826 goto exit_put ;
826827 }
827828
828- lock_super ( sb );
829+ mutex_lock ( & sbi -> s_resize_lock );
829830 if (input -> group != sbi -> s_groups_count ) {
830831 ext3_warning (sb , __func__ ,
831832 "multiple resizers run on filesystem!" );
@@ -856,7 +857,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
856857 /*
857858 * OK, now we've set up the new group. Time to make it active.
858859 *
859- * Current kernels don't lock all allocations via lock_super(),
860+ * We do not lock all allocations via s_resize_lock
860861 * so we have to be safe wrt. concurrent accesses the group
861862 * data. So we need to be careful to set all of the relevant
862863 * group descriptor data etc. *before* we enable the group.
@@ -900,12 +901,12 @@ int ext3_group_add(struct super_block *sb, struct ext3_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.
@@ -936,7 +937,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
936937 ext3_journal_dirty_metadata (handle , sbi -> s_sbh );
937938
938939exit_journal :
939- unlock_super ( sb );
940+ mutex_unlock ( & sbi -> s_resize_lock );
940941 if ((err2 = ext3_journal_stop (handle )) && !err )
941942 err = err2 ;
942943 if (!err ) {
@@ -973,7 +974,7 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
973974
974975 /* We don't need to worry about locking wrt other resizers just
975976 * yet: we're going to revalidate es->s_blocks_count after
976- * taking lock_super() below. */
977+ * taking the s_resize_lock below. */
977978 o_blocks_count = le32_to_cpu (es -> s_blocks_count );
978979 o_groups_count = EXT3_SB (sb )-> s_groups_count ;
979980
@@ -1045,11 +1046,11 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
10451046 goto exit_put ;
10461047 }
10471048
1048- lock_super ( sb );
1049+ mutex_lock ( & EXT3_SB ( sb ) -> s_resize_lock );
10491050 if (o_blocks_count != le32_to_cpu (es -> s_blocks_count )) {
10501051 ext3_warning (sb , __func__ ,
10511052 "multiple resizers run on filesystem!" );
1052- unlock_super ( sb );
1053+ mutex_unlock ( & EXT3_SB ( sb ) -> s_resize_lock );
10531054 ext3_journal_stop (handle );
10541055 err = - EBUSY ;
10551056 goto exit_put ;
@@ -1059,13 +1060,13 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
10591060 EXT3_SB (sb )-> s_sbh ))) {
10601061 ext3_warning (sb , __func__ ,
10611062 "error %d on journal write access" , err );
1062- unlock_super ( sb );
1063+ mutex_unlock ( & EXT3_SB ( sb ) -> s_resize_lock );
10631064 ext3_journal_stop (handle );
10641065 goto exit_put ;
10651066 }
10661067 es -> s_blocks_count = cpu_to_le32 (o_blocks_count + add );
10671068 ext3_journal_dirty_metadata (handle , EXT3_SB (sb )-> s_sbh );
1068- unlock_super ( sb );
1069+ mutex_unlock ( & EXT3_SB ( sb ) -> s_resize_lock );
10691070 ext3_debug ("freeing blocks %lu through " E3FSBLK "\n" , o_blocks_count ,
10701071 o_blocks_count + add );
10711072 ext3_free_blocks_sb (handle , sb , o_blocks_count , add , & freed_blocks );
0 commit comments