linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] jbd: Cleanup __process_buffer()
@ 2010-10-16  8:30 Namhyung Kim
  2010-10-18 10:57 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Namhyung Kim @ 2010-10-16  8:30 UTC (permalink / raw)
  To: Andrew Morton, Jan Kara; +Cc: linux-ext4, linux-kernel

Change initial value of 'ret' to 1 and set to 0 only if nothing
happens actually.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 fs/jbd/checkpoint.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c
index e4b87bc..0a687a6 100644
--- a/fs/jbd/checkpoint.c
+++ b/fs/jbd/checkpoint.c
@@ -280,7 +280,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
 			struct buffer_head **bhs, int *batch_count)
 {
 	struct buffer_head *bh = jh2bh(jh);
-	int ret = 0;
+	int ret = 1;
 
 	if (buffer_locked(bh)) {
 		get_bh(bh);
@@ -290,7 +290,6 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
 		/* the journal_head may have gone by now */
 		BUFFER_TRACE(bh, "brelse");
 		__brelse(bh);
-		ret = 1;
 	} else if (jh->b_transaction != NULL) {
 		transaction_t *t = jh->b_transaction;
 		tid_t tid = t->t_tid;
@@ -299,9 +298,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
 		jbd_unlock_bh_state(bh);
 		log_start_commit(journal, tid);
 		log_wait_commit(journal, tid);
-		ret = 1;
 	} else if (!buffer_dirty(bh)) {
-		ret = 1;
 		if (unlikely(buffer_write_io_error(bh)))
 			ret = -EIO;
 		J_ASSERT_JH(jh, !buffer_jbddirty(bh));
@@ -330,8 +327,8 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
 		if (*batch_count == NR_BATCH) {
 			spin_unlock(&journal->j_list_lock);
 			__flush_batch(journal, bhs, batch_count);
-			ret = 1;
-		}
+		} else
+			ret = 0;
 	}
 	return ret;
 }
-- 
1.7.0.4


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

* Re: [PATCH] jbd: Cleanup __process_buffer()
  2010-10-16  8:30 [PATCH] jbd: Cleanup __process_buffer() Namhyung Kim
@ 2010-10-18 10:57 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2010-10-18 10:57 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: Andrew Morton, Jan Kara, linux-ext4, linux-kernel

On Sat 16-10-10 17:30:14, Namhyung Kim wrote:
> Change initial value of 'ret' to 1 and set to 0 only if nothing
> happens actually.
  The result is 3 removed lines and I find the code readability the same
before and after the patch. So it's IMHO an unnecessary code churn. So I'm
sorry but I'm not taking the patch.

								Honza
> 
> Signed-off-by: Namhyung Kim <namhyung@gmail.com>
> ---
>  fs/jbd/checkpoint.c |    9 +++------
>  1 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c
> index e4b87bc..0a687a6 100644
> --- a/fs/jbd/checkpoint.c
> +++ b/fs/jbd/checkpoint.c
> @@ -280,7 +280,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
>  			struct buffer_head **bhs, int *batch_count)
>  {
>  	struct buffer_head *bh = jh2bh(jh);
> -	int ret = 0;
> +	int ret = 1;
>  
>  	if (buffer_locked(bh)) {
>  		get_bh(bh);
> @@ -290,7 +290,6 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
>  		/* the journal_head may have gone by now */
>  		BUFFER_TRACE(bh, "brelse");
>  		__brelse(bh);
> -		ret = 1;
>  	} else if (jh->b_transaction != NULL) {
>  		transaction_t *t = jh->b_transaction;
>  		tid_t tid = t->t_tid;
> @@ -299,9 +298,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
>  		jbd_unlock_bh_state(bh);
>  		log_start_commit(journal, tid);
>  		log_wait_commit(journal, tid);
> -		ret = 1;
>  	} else if (!buffer_dirty(bh)) {
> -		ret = 1;
>  		if (unlikely(buffer_write_io_error(bh)))
>  			ret = -EIO;
>  		J_ASSERT_JH(jh, !buffer_jbddirty(bh));
> @@ -330,8 +327,8 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
>  		if (*batch_count == NR_BATCH) {
>  			spin_unlock(&journal->j_list_lock);
>  			__flush_batch(journal, bhs, batch_count);
> -			ret = 1;
> -		}
> +		} else
> +			ret = 0;
>  	}
>  	return ret;
>  }
> -- 
> 1.7.0.4
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-16  8:30 [PATCH] jbd: Cleanup __process_buffer() Namhyung Kim
2010-10-18 10:57 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).