mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* jbd2: Convert jbd2_slab_create_sem to mutex
@ 2010-10-16 20:34 Thomas Gleixner
  2010-10-16 21:10 ` Andrew Morton
  2010-10-30 10:15 ` [tip:core/locking] " tip-bot for Thomas Gleixner
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Gleixner @ 2010-10-16 20:34 UTC (permalink / raw)
  To: Ted Ts'o; +Cc: Andrew Morton, LKML

jbd2_slab_create_sem is used as a mutex, so make it one.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 fs/jbd2/journal.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-next/fs/jbd2/journal.c
===================================================================
--- linux-next.orig/fs/jbd2/journal.c
+++ linux-next/fs/jbd2/journal.c
@@ -1838,7 +1838,7 @@ size_t journal_tag_bytes(journal_t *jour
  */
 #define JBD2_MAX_SLABS 8
 static struct kmem_cache *jbd2_slab[JBD2_MAX_SLABS];
-static DECLARE_MUTEX(jbd2_slab_create_sem);
+static DEFINE_MUTEX(jbd2_slab_create_mutex);
 
 static const char *jbd2_slab_names[JBD2_MAX_SLABS] = {
 	"jbd2_1k", "jbd2_2k", "jbd2_4k", "jbd2_8k",
@@ -1870,16 +1870,16 @@ static int jbd2_journal_create_slab(size
 
 	if (unlikely(i < 0))
 		i = 0;
-	down(&jbd2_slab_create_sem);
+	mutex_lock(&jbd2_slab_create_mutex);
 	if (jbd2_slab[i]) {
-		up(&jbd2_slab_create_sem);
+		mutex_unlock(&jbd2_slab_create_mutex);
 		return 0;	/* Already created */
 	}
 
 	slab_size = 1 << (i+10);
 	jbd2_slab[i] = kmem_cache_create(jbd2_slab_names[i], slab_size,
 					 slab_size, 0, NULL);
-	up(&jbd2_slab_create_sem);
+	mutex_unlock(&jbd2_slab_create_mutex);
 	if (!jbd2_slab[i]) {
 		printk(KERN_EMERG "JBD2: no memory for jbd2_slab cache\n");
 		return -ENOMEM;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: jbd2: Convert jbd2_slab_create_sem to mutex
  2010-10-16 20:34 jbd2: Convert jbd2_slab_create_sem to mutex Thomas Gleixner
@ 2010-10-16 21:10 ` Andrew Morton
  2010-10-30 10:15 ` [tip:core/locking] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2010-10-16 21:10 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Ted Ts'o, LKML

On Sat, 16 Oct 2010 22:34:39 +0200 (CEST) Thomas Gleixner <tglx@linutronix.de> wrote:

> jbd2_slab_create_sem is used as a mutex, so make it one.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  fs/jbd2/journal.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> Index: linux-next/fs/jbd2/journal.c
> ===================================================================
> --- linux-next.orig/fs/jbd2/journal.c
> +++ linux-next/fs/jbd2/journal.c
> @@ -1838,7 +1838,7 @@ size_t journal_tag_bytes(journal_t *jour
>   */
>  #define JBD2_MAX_SLABS 8
>  static struct kmem_cache *jbd2_slab[JBD2_MAX_SLABS];
> -static DECLARE_MUTEX(jbd2_slab_create_sem);
> +static DEFINE_MUTEX(jbd2_slab_create_mutex);
>  
>  static const char *jbd2_slab_names[JBD2_MAX_SLABS] = {
>  	"jbd2_1k", "jbd2_2k", "jbd2_4k", "jbd2_8k",
> @@ -1870,16 +1870,16 @@ static int jbd2_journal_create_slab(size
>  
>  	if (unlikely(i < 0))
>  		i = 0;
> -	down(&jbd2_slab_create_sem);
> +	mutex_lock(&jbd2_slab_create_mutex);
>  	if (jbd2_slab[i]) {
> -		up(&jbd2_slab_create_sem);
> +		mutex_unlock(&jbd2_slab_create_mutex);
>  		return 0;	/* Already created */
>  	}
>  
>  	slab_size = 1 << (i+10);
>  	jbd2_slab[i] = kmem_cache_create(jbd2_slab_names[i], slab_size,
>  					 slab_size, 0, NULL);
> -	up(&jbd2_slab_create_sem);
> +	mutex_unlock(&jbd2_slab_create_mutex);
>  	if (!jbd2_slab[i]) {
>  		printk(KERN_EMERG "JBD2: no memory for jbd2_slab cache\n");
>  		return -ENOMEM;

gad, whodidthat.

We may as well make it local to jbd2_journal_create_slab() also.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:core/locking] jbd2: Convert jbd2_slab_create_sem to mutex
  2010-10-16 20:34 jbd2: Convert jbd2_slab_create_sem to mutex Thomas Gleixner
  2010-10-16 21:10 ` Andrew Morton
@ 2010-10-30 10:15 ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Thomas Gleixner @ 2010-10-30 10:15 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, akpm, tglx, tytso

Commit-ID:  51dfacdef38b1dd6fc58b03dd1725d517516b115
Gitweb:     http://git.kernel.org/tip/51dfacdef38b1dd6fc58b03dd1725d517516b115
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sat, 16 Oct 2010 22:34:39 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 30 Oct 2010 12:12:50 +0200

jbd2: Convert jbd2_slab_create_sem to mutex

jbd2_slab_create_sem is used as a mutex, so make it one.

[ akpm muttered: We may as well make it local to
jbd2_journal_create_slab() also. ]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ted Ts'o <tytso@mit.edu>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <alpine.LFD.2.00.1010162231480.2496@localhost6.localdomain6>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 fs/jbd2/journal.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 538417c..c590d15 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1838,7 +1838,6 @@ size_t journal_tag_bytes(journal_t *journal)
  */
 #define JBD2_MAX_SLABS 8
 static struct kmem_cache *jbd2_slab[JBD2_MAX_SLABS];
-static DECLARE_MUTEX(jbd2_slab_create_sem);
 
 static const char *jbd2_slab_names[JBD2_MAX_SLABS] = {
 	"jbd2_1k", "jbd2_2k", "jbd2_4k", "jbd2_8k",
@@ -1859,6 +1858,7 @@ static void jbd2_journal_destroy_slabs(void)
 
 static int jbd2_journal_create_slab(size_t size)
 {
+	static DEFINE_MUTEX(jbd2_slab_create_mutex);
 	int i = order_base_2(size) - 10;
 	size_t slab_size;
 
@@ -1870,16 +1870,16 @@ static int jbd2_journal_create_slab(size_t size)
 
 	if (unlikely(i < 0))
 		i = 0;
-	down(&jbd2_slab_create_sem);
+	mutex_lock(&jbd2_slab_create_mutex);
 	if (jbd2_slab[i]) {
-		up(&jbd2_slab_create_sem);
+		mutex_unlock(&jbd2_slab_create_mutex);
 		return 0;	/* Already created */
 	}
 
 	slab_size = 1 << (i+10);
 	jbd2_slab[i] = kmem_cache_create(jbd2_slab_names[i], slab_size,
 					 slab_size, 0, NULL);
-	up(&jbd2_slab_create_sem);
+	mutex_unlock(&jbd2_slab_create_mutex);
 	if (!jbd2_slab[i]) {
 		printk(KERN_EMERG "JBD2: no memory for jbd2_slab cache\n");
 		return -ENOMEM;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-10-30 10:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-16 20:34 jbd2: Convert jbd2_slab_create_sem to mutex Thomas Gleixner
2010-10-16 21:10 ` Andrew Morton
2010-10-30 10:15 ` [tip:core/locking] " tip-bot for Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome