Patchwork [3/8] ext3: remove lock/unlock super

login
register
mail settings
Submitter Marco Stornelli
Date Aug. 16, 2012, 10 a.m.
Message ID <502CC4BA.3040702@gmail.com>
Download mbox | patch
Permalink /patch/177939/
State Not Applicable
Headers show

Comments

Marco Stornelli - Aug. 16, 2012, 10 a.m.
From: Marco Stornelli <marco.stornelli@gmail.com>

Replaced lock and unlock super with a new fs mutex s_lock.

Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
---

 static int ext3_unfreeze(struct super_block *sb)
 {
 	if (!(sb->s_flags & MS_RDONLY)) {
-		lock_super(sb);
+		mutex_lock(&EXT3_SB(sb)->s_lock);
 		/* Reser the needs_recovery flag before the fs is unlocked. */
 		EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
 		ext3_commit_super(sb, EXT3_SB(sb)->s_es, 1);
-		unlock_super(sb);
+		mutex_unlock(&EXT3_SB(sb)->s_lock);
 		journal_unlock_updates(EXT3_SB(sb)->s_journal);
 	}
 	return 0;
@@ -2606,7 +2607,7 @@ static int ext3_remount (struct super_bl
 #endif
  	/* Store the original options */
-	lock_super(sb);
+	mutex_lock(&EXT3_SB(sb)->s_lock);
 	old_sb_flags = sb->s_flags;
 	old_opts.s_mount_opt = sbi->s_mount_opt;
 	old_opts.s_resuid = sbi->s_resuid;
@@ -2712,7 +2713,7 @@ static int ext3_remount (struct super_bl
 		    old_opts.s_qf_names[i] != sbi->s_qf_names[i])
 			kfree(old_opts.s_qf_names[i]);
 #endif
-	unlock_super(sb);
+	mutex_unlock(&EXT3_SB(sb)->s_lock);
  	if (enable_quota)
 		dquot_resume(sb, -1);
@@ -2732,7 +2733,7 @@ restore_opts:
 		sbi->s_qf_names[i] = old_opts.s_qf_names[i];
 	}
 #endif
-	unlock_super(sb);
+	mutex_unlock(&EXT3_SB(sb)->s_lock);
 	return err;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Kara - Aug. 16, 2012, 4:39 p.m.
On Thu 16-08-12 12:00:26, Marco Stornelli wrote:
> From: Marco Stornelli <marco.stornelli@gmail.com>
> 
> Replaced lock and unlock super with a new fs mutex s_lock.
  Hum, is the lock needed at all? Remount & unfreeze both run with s_umount
held for writing. Thus we already have exclusion between these two calls.
The same seems to hold for ext4 BTW.

								Honza
> 
> Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
> ---
> 
> diff -Nurp linux-3.6-rc1-orig/fs/ext3/ext3.h linux-3.6-rc1/fs/ext3/ext3.h
> --- linux-3.6-rc1-orig/fs/ext3/ext3.h	2012-08-16 09:37:31.000000000 +0200
> +++ linux-3.6-rc1/fs/ext3/ext3.h	2012-08-16 09:46:39.000000000 +0200
> @@ -672,6 +672,7 @@ struct ext3_sb_info {
>  	char *s_qf_names[MAXQUOTAS];		/* Names of quota files with journalled quota */
>  	int s_jquota_fmt;			/* Format of quota to use */
>  #endif
> +	struct mutex s_lock;
>  };
>   static inline spinlock_t *
> diff -Nurp linux-3.6-rc1-orig/fs/ext3/super.c linux-3.6-rc1/fs/ext3/super.c
> --- linux-3.6-rc1-orig/fs/ext3/super.c	2012-08-16 09:37:31.000000000 +0200
> +++ linux-3.6-rc1/fs/ext3/super.c	2012-08-16 09:49:11.000000000 +0200
> @@ -1939,6 +1939,7 @@ static int ext3_fill_super (struct super
>  	sbi->s_gdb_count = db_count;
>  	get_random_bytes(&sbi->s_next_generation, sizeof(u32));
>  	spin_lock_init(&sbi->s_next_gen_lock);
> +	mutex_init(&sbi->s_lock);
>   	/* per fileystem reservation list head & lock */
>  	spin_lock_init(&sbi->s_rsv_window_lock);
> @@ -2582,11 +2583,11 @@ out:
>  static int ext3_unfreeze(struct super_block *sb)
>  {
>  	if (!(sb->s_flags & MS_RDONLY)) {
> -		lock_super(sb);
> +		mutex_lock(&EXT3_SB(sb)->s_lock);
>  		/* Reser the needs_recovery flag before the fs is unlocked. */
>  		EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
>  		ext3_commit_super(sb, EXT3_SB(sb)->s_es, 1);
> -		unlock_super(sb);
> +		mutex_unlock(&EXT3_SB(sb)->s_lock);
>  		journal_unlock_updates(EXT3_SB(sb)->s_journal);
>  	}
>  	return 0;
> @@ -2606,7 +2607,7 @@ static int ext3_remount (struct super_bl
>  #endif
>   	/* Store the original options */
> -	lock_super(sb);
> +	mutex_lock(&EXT3_SB(sb)->s_lock);
>  	old_sb_flags = sb->s_flags;
>  	old_opts.s_mount_opt = sbi->s_mount_opt;
>  	old_opts.s_resuid = sbi->s_resuid;
> @@ -2712,7 +2713,7 @@ static int ext3_remount (struct super_bl
>  		    old_opts.s_qf_names[i] != sbi->s_qf_names[i])
>  			kfree(old_opts.s_qf_names[i]);
>  #endif
> -	unlock_super(sb);
> +	mutex_unlock(&EXT3_SB(sb)->s_lock);
>   	if (enable_quota)
>  		dquot_resume(sb, -1);
> @@ -2732,7 +2733,7 @@ restore_opts:
>  		sbi->s_qf_names[i] = old_opts.s_qf_names[i];
>  	}
>  #endif
> -	unlock_super(sb);
> +	mutex_unlock(&EXT3_SB(sb)->s_lock);
>  	return err;
>  }
>
Theodore Ts'o - Aug. 16, 2012, 7:19 p.m.
On Thu, Aug 16, 2012 at 06:39:04PM +0200, Jan Kara wrote:
> On Thu 16-08-12 12:00:26, Marco Stornelli wrote:
> > From: Marco Stornelli <marco.stornelli@gmail.com>
> > 
> > Replaced lock and unlock super with a new fs mutex s_lock.
>   Hum, is the lock needed at all? Remount & unfreeze both run with s_umount
> held for writing. Thus we already have exclusion between these two calls.
> The same seems to hold for ext4 BTW.

Agreed, it's not clear lock_super() is needed at all for ext4 at this
point.

	     	       		       	      - Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marco Stornelli - Aug. 17, 2012, 6:47 a.m.
Il 16/08/2012 21:19, Theodore Ts'o ha scritto:
> On Thu, Aug 16, 2012 at 06:39:04PM +0200, Jan Kara wrote:
>> On Thu 16-08-12 12:00:26, Marco Stornelli wrote:
>>> From: Marco Stornelli <marco.stornelli@gmail.com>
>>>
>>> Replaced lock and unlock super with a new fs mutex s_lock.
>>    Hum, is the lock needed at all? Remount & unfreeze both run with s_umount
>> held for writing. Thus we already have exclusion between these two calls.
>> The same seems to hold for ext4 BTW.
>
> Agreed, it's not clear lock_super() is needed at all for ext4 at this
> point.
>
> 	     	       		       	      - Ted
>

Great. I'll remove the calls for ext3/ext4 when I'll submit the second 
version of the patch.

Thanks for your feedback,

Marco
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff -Nurp linux-3.6-rc1-orig/fs/ext3/ext3.h linux-3.6-rc1/fs/ext3/ext3.h
--- linux-3.6-rc1-orig/fs/ext3/ext3.h	2012-08-16 09:37:31.000000000 +0200
+++ linux-3.6-rc1/fs/ext3/ext3.h	2012-08-16 09:46:39.000000000 +0200
@@ -672,6 +672,7 @@  struct ext3_sb_info {
 	char *s_qf_names[MAXQUOTAS];		/* Names of quota files with journalled quota */
 	int s_jquota_fmt;			/* Format of quota to use */
 #endif
+	struct mutex s_lock;
 };
  static inline spinlock_t *
diff -Nurp linux-3.6-rc1-orig/fs/ext3/super.c linux-3.6-rc1/fs/ext3/super.c
--- linux-3.6-rc1-orig/fs/ext3/super.c	2012-08-16 09:37:31.000000000 +0200
+++ linux-3.6-rc1/fs/ext3/super.c	2012-08-16 09:49:11.000000000 +0200
@@ -1939,6 +1939,7 @@  static int ext3_fill_super (struct super
 	sbi->s_gdb_count = db_count;
 	get_random_bytes(&sbi->s_next_generation, sizeof(u32));
 	spin_lock_init(&sbi->s_next_gen_lock);
+	mutex_init(&sbi->s_lock);
  	/* per fileystem reservation list head & lock */
 	spin_lock_init(&sbi->s_rsv_window_lock);
@@ -2582,11 +2583,11 @@  out: