mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fix panic in jbd by adding locks
@ 2007-08-14 15:22 Josef Bacik
  2007-08-15 11:37 ` Jan Kara
  0 siblings, 1 reply; 10+ messages in thread
From: Josef Bacik @ 2007-08-14 15:22 UTC (permalink / raw)
  To: linux-ext4; +Cc: linux-kernel

Hello,

It is possible to panic the box by a race condition that exists in the
journalling code where we do not take the j_revoke_lock when traversing the
journal's revoked record list.  This patch has been tested and we haven't seen
the issue yet, its a rather straightforward and correct (at least I think so :)
fix.  Thank you,

Signed-off-by: Josef Bacik <jbacik@redhat.com>


diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c
index 62e13c8..317f598 100644
--- a/fs/jbd/revoke.c
+++ b/fs/jbd/revoke.c
@@ -518,6 +518,7 @@ void journal_write_revoke_records(journal_t *journal,
 	for (i = 0; i < revoke->hash_size; i++) {
 		hash_list = &revoke->hash_table[i];
 
+		spin_lock(&journal->j_revoke_lock);
 		while (!list_empty(hash_list)) {
 			record = (struct jbd_revoke_record_s *)
 				hash_list->next;
@@ -528,6 +529,7 @@ void journal_write_revoke_records(journal_t *journal,
 			list_del(&record->hash);
 			kmem_cache_free(revoke_record_cache, record);
 		}
+		spin_unlock(&journal->j_revoke_lock);
 	}
 	if (descriptor)
 		flush_descriptor(journal, descriptor, offset);
@@ -694,10 +696,12 @@ void journal_clear_revoke(journal_t *journal)
 
 	for (i = 0; i < revoke->hash_size; i++) {
 		hash_list = &revoke->hash_table[i];
+		spin_lock(&journal->j_revoke_lock);
 		while (!list_empty(hash_list)) {
 			record = (struct jbd_revoke_record_s*) hash_list->next;
 			list_del(&record->hash);
 			kmem_cache_free(revoke_record_cache, record);
 		}
+		spin_unlock(&journal->j_revoke_lock);
 	}
 }

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

end of thread, other threads:[~2007-08-23 18:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-14 15:22 [PATCH] fix panic in jbd by adding locks Josef Bacik
2007-08-15 11:37 ` Jan Kara
2007-08-15 12:17   ` Josef Bacik
2007-08-16 16:08     ` Jan Kara
2007-08-16 16:37       ` Josef Bacik
2007-08-20 15:20         ` Jan Kara
2007-08-21 15:43           ` Josef Bacik
2007-08-21 16:48             ` Jan Kara
2007-08-21 17:45               ` Josef Bacik
2007-08-23 18:41                 ` Josef Bacik

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

all inboxes | Powered by JetHome®