Skip to contentSkip to conversation

jbd: Use printk_ratelimit() in journal_alloc_journal_head()

PATCH In review Namhyung Kim 2 participants 6 messages Oct 4, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jbd: Use printk_ratelimit() in journal_alloc_journal_head()

Use printk_ratelimit() instead of doing it manually.

---
 fs/jbd/journal.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
fs/jbd/journal.c +2 -4
index 6f20a75..d66dd36 100644
@@ -1718,7 +1718,6 @@ static void journal_destroy_journal_head_cache(void)
 static struct journal_head *journal_alloc_journal_head(void)
 {
 	struct journal_head *ret;
-	static unsigned long last_warning;
 
 #ifdef CONFIG_JBD_DEBUG
 	atomic_inc(&nr_journal_heads);
@@ -1726,11 +1725,10 @@ static struct journal_head *journal_alloc_journal_head(void)
 	ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
 	if (ret == NULL) {
 		jbd_debug(1, "out of memory for journal_head\n");
-		if (time_after(jiffies, last_warning + 5*HZ)) {
+		if (printk_ratelimit())
 			printk(KERN_NOTICE "ENOMEM in %s, retrying.\n",
 			       __func__);
-			last_warning = jiffies;
-		}
+
 		while (ret == NULL) {
 			yield();
 			ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
Signature · 1 line
1.7.0.4
#1 lore raw

fs/jbd/journal.c static struct journal_head *journal_alloc_journal_head(void) · line 1731

Quoted 13 lines · Namhyung Kim

#ifdef CONFIG_JBD_DEBUG

fs/jbd/journal.c +2 -3
 	atomic_inc(&nr_journal_heads);
@@ -1726,11 +1725,10 @@ static struct journal_head *journal_alloc_journal_head(void)
 	ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
 	if (ret == NULL) {
 		jbd_debug(1, "out of memory for journal_head\n");
-		if (time_after(jiffies, last_warning + 5*HZ)) {
+		if (printk_ratelimit())
 			printk(KERN_NOTICE "ENOMEM in %s, retrying.\n",
 			       __func__);
-			last_warning = jiffies;
-		}
+

OK, but can we convert this directly to printk_ratelimited please?
Thanks.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#2 lore raw

PATCH 1/1 jbd: Use printk_ratelimited() in journal_alloc_journal_head()

Use printk_ratelimited() instead of doing it manually.

---
 fs/jbd/journal.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
fs/jbd/journal.c +3 -6
index 6f20a75..f79767d 100644
@@ -1718,7 +1718,6 @@ static void journal_destroy_journal_head_cache(void)
 static struct journal_head *journal_alloc_journal_head(void)
 {
 	struct journal_head *ret;
-	static unsigned long last_warning;
 
 #ifdef CONFIG_JBD_DEBUG
 	atomic_inc(&nr_journal_heads);
@@ -1726,11 +1725,9 @@ static struct journal_head *journal_alloc_journal_head(void)
 	ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
 	if (ret == NULL) {
 		jbd_debug(1, "out of memory for journal_head\n");
-		if (time_after(jiffies, last_warning + 5*HZ)) {
-			printk(KERN_NOTICE "ENOMEM in %s, retrying.\n",
-			       __func__);
-			last_warning = jiffies;
-		}
+		printk_ratelimited(KERN_NOTICE "ENOMEM in %s, retrying.\n",
+				   __func__);
+
 		while (ret == NULL) {
 			yield();
 			ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
Signature · 1 line
1.7.0.4
#3 lore raw

Re: [PATCH UPDATED] jbd: Use printk_ratelimited() in journal_alloc_journal_head()

Quoted 1 line · Namhyung Kim

Use printk_ratelimited() instead of doing it manually.

Thanks. I've merged the patch into my tree.

Honza

Quoted 36 lines
---
 fs/jbd/journal.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
fs/jbd/journal.c +3 -6
index 6f20a75..f79767d 100644
@@ -1718,7 +1718,6 @@ static void journal_destroy_journal_head_cache(void)
 static struct journal_head *journal_alloc_journal_head(void)
 {
 	struct journal_head *ret;
-	static unsigned long last_warning;
 
 #ifdef CONFIG_JBD_DEBUG
 	atomic_inc(&nr_journal_heads);
@@ -1726,11 +1725,9 @@ static struct journal_head *journal_alloc_journal_head(void)
 	ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
 	if (ret == NULL) {
 		jbd_debug(1, "out of memory for journal_head\n");
-		if (time_after(jiffies, last_warning + 5*HZ)) {
-			printk(KERN_NOTICE "ENOMEM in %s, retrying.\n",
-			       __func__);
-			last_warning = jiffies;
-		}
+		printk_ratelimited(KERN_NOTICE "ENOMEM in %s, retrying.\n",
+				   __func__);
+
 		while (ret == NULL) {
 			yield();
 			ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
Signature · 1 line
1.7.0.4
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#4 lore raw

Re: [PATCH UPDATED] jbd: Use printk_ratelimited() in journal_alloc_journal_head()

Quoted 3 lines · Jan Kara
Quoted 1 line · Namhyung Kim

Use printk_ratelimited() instead of doing it manually.

Thanks. I've merged the patch into my tree.

Grumble, you apparently didn't try to compile the thing... The patch
was missing #include <linux/ratelimit.h>. I've fixed that up now. Please be more careful next time. Thanks.

Honza

Quoted 40 lines
Quoted 37 lines
---
 fs/jbd/journal.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
fs/jbd/journal.c +3 -6
index 6f20a75..f79767d 100644
@@ -1718,7 +1718,6 @@ static void journal_destroy_journal_head_cache(void)
 static struct journal_head *journal_alloc_journal_head(void)
 {
 	struct journal_head *ret;
-	static unsigned long last_warning;
 
 #ifdef CONFIG_JBD_DEBUG
 	atomic_inc(&nr_journal_heads);
@@ -1726,11 +1725,9 @@ static struct journal_head *journal_alloc_journal_head(void)
 	ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
 	if (ret == NULL) {
 		jbd_debug(1, "out of memory for journal_head\n");
-		if (time_after(jiffies, last_warning + 5*HZ)) {
-			printk(KERN_NOTICE "ENOMEM in %s, retrying.\n",
-			       __func__);
-			last_warning = jiffies;
-		}
+		printk_ratelimited(KERN_NOTICE "ENOMEM in %s, retrying.\n",
+				   __func__);
+
 		while (ret == NULL) {
 			yield();
 			ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
Signature · 1 line
1.7.0.4
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#5 lore raw

Re: [PATCH UPDATED] jbd: Use printk_ratelimited() in journal_alloc_journal_head()

2010-10-04 (월), 13:37 +0200, Jan Kara:

Quoted 5 lines

Grumble, you apparently didn't try to compile the thing... The patch
was missing #include <linux/ratelimit.h>. I've fixed that up now. Please be more careful next time. Thanks.

Honza

Egads, I did compile-test but I forgot I did make allnoconfig before. (And then I added ext3 support manually.) I'll double check a patch before sending it in the future. Sorry for the inconvenience.

Thanks.

Signature · 8 lines
Regards,
Namhyung Kim


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