Re: [patch 2/3] [PATCH] reiserfs: convert j_flush_sem to mutex

Previous thread: [patch 3/3] [PATCH] reiserfs: convert j_commit_lock to mutex by Jeff Mahoney on Wednesday, May 7, 2008 - 11:36 pm. (1 message)

Next thread: [PATCH 1/2 2.6.26] cxgb3 - fix port up/down error path by Divy Le Ray on Tuesday, May 6, 2008 - 7:25 pm. (1 message)
From: Jeff Mahoney
Date: Wednesday, May 7, 2008 - 11:35 pm

j_flush_sem is a semaphore but uses it as if it were a mutex. This
 patch converts it to a mutex.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 fs/reiserfs/journal.c           |   14 +++++++-------
 include/linux/reiserfs_fs_sb.h  |    2 +-
 include/linux/reiserfs_fs_sb.h~ |    2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -1411,8 +1411,8 @@ static int flush_journal_list(struct sup
 
 	/* if flushall == 0, the lock is already held */
 	if (flushall) {
-		down(&journal->j_flush_sem);
-	} else if (!down_trylock(&journal->j_flush_sem)) {
+		mutex_lock(&journal->j_flush_mutex);
+	} else if (!mutex_trylock(&journal->j_flush_mutex)) {
 		BUG();
 	}
 
@@ -1642,7 +1642,7 @@ static int flush_journal_list(struct sup
 	jl->j_state = 0;
 	put_journal_list(s, jl);
 	if (flushall)
-		up(&journal->j_flush_sem);
+		mutex_unlock(&journal->j_flush_mutex);
 	put_fs_excl();
 	return err;
 }
@@ -1772,12 +1772,12 @@ static int kupdate_transactions(struct s
 	struct reiserfs_journal *journal = SB_JOURNAL(s);
 	chunk.nr = 0;
 
-	down(&journal->j_flush_sem);
+	mutex_lock(&journal->j_flush_mutex);
 	if (!journal_list_still_alive(s, orig_trans_id)) {
 		goto done;
 	}
 
-	/* we've got j_flush_sem held, nobody is going to delete any
+	/* we've got j_flush_mutex held, nobody is going to delete any
 	 * of these lists out from underneath us
 	 */
 	while ((num_trans && transactions_flushed < num_trans) ||
@@ -1812,7 +1812,7 @@ static int kupdate_transactions(struct s
 	}
 
       done:
-	up(&journal->j_flush_sem);
+	mutex_unlock(&journal->j_flush_mutex);
 	return ret;
 }
 
@@ -2842,7 +2842,7 @@ int journal_init(struct super_block *p_s
 	journal->j_first = NULL;
 	init_waitqueue_head(&(journal->j_join_wait));
 	mutex_init(&journal->j_mutex);
-	sema_init(&journal->j_flush_sem, 1);
+	mutex_init(&journal->j_flush_mutex);
 
 	journal->j_trans_id = 10;
 	journal->j_mount_id = 10;
--- ...
From: Jeff Mahoney
Date: Wednesday, May 14, 2008 - 7:41 am

Oops. This chunk didn't get refreshed, here's the right one.

-Jeff

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 fs/reiserfs/journal.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -1410,7 +1410,7 @@ static int flush_journal_list(struct sup
 	/* if flushall == 0, the lock is already held */
 	if (flushall) {
 		mutex_lock(&journal->j_flush_mutex);
-	} else if (!mutex_trylock(&journal->j_flush_mutex)) {
+	} else if (mutex_trylock(&journal->j_flush_mutex)) {
 		BUG();
 	}
 


-- 
Jeff Mahoney
SUSE Labs
--

From: Kamalesh Babulal
Date: Wednesday, May 14, 2008 - 11:22 am

Thanks, the patch resolves the kernel bug.



-- 
Thanks & Regards,
Kamalesh Babulal,
Linux Technology Center,
IBM, ISTL.
--

Previous thread: [patch 3/3] [PATCH] reiserfs: convert j_commit_lock to mutex by Jeff Mahoney on Wednesday, May 7, 2008 - 11:36 pm. (1 message)

Next thread: [PATCH 1/2 2.6.26] cxgb3 - fix port up/down error path by Divy Le Ray on Tuesday, May 6, 2008 - 7:25 pm. (1 message)