All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ubifs: remove unnecessary check in ubifs_log_start_commit
@ 2018-08-21  3:17 Liu Song
  2018-08-21  6:25 ` Richard Weinberger
  0 siblings, 1 reply; 3+ messages in thread
From: Liu Song @ 2018-08-21  3:17 UTC (permalink / raw)
  To: richard, dedekind1, adrian.hunter
  Cc: linux-mtd, linux-kernel, liu.song11, jiang.biao2, zhong.weidong

The value of c->lhead_offs cannot exceed max_len which much
smaller than c->leb_size. So the check will never be true.
Just remove it.

Signed-off-by: Liu Song <liu.song11@zte.com.cn>
Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
---
 fs/ubifs/log.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c
index 7cffa120a750..5a338737223b 100644
--- a/fs/ubifs/log.c
+++ b/fs/ubifs/log.c
@@ -427,10 +427,6 @@ int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum)
 	*ltail_lnum = c->lhead_lnum;
 
 	c->lhead_offs += len;
-	if (c->lhead_offs == c->leb_size) {
-		c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum);
-		c->lhead_offs = 0;
-	}
 
 	remove_buds(c);
 
-- 
2.17.1


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

* Re: [PATCH] ubifs: remove unnecessary check in ubifs_log_start_commit
  2018-08-21  3:17 [PATCH] ubifs: remove unnecessary check in ubifs_log_start_commit Liu Song
@ 2018-08-21  6:25 ` Richard Weinberger
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Weinberger @ 2018-08-21  6:25 UTC (permalink / raw)
  To: Liu Song
  Cc: dedekind1, adrian.hunter, linux-mtd, linux-kernel, jiang.biao2,
	zhong.weidong

Liu Song,

Am Dienstag, 21. August 2018, 05:17:22 CEST schrieb Liu Song:
> The value of c->lhead_offs cannot exceed max_len which much
> smaller than c->leb_size. So the check will never be true.
> Just remove it.

Please explain in more detail why this case is never ever possible.
Removing such code needs a good justification. 

In general I don't much like such changes for two reasons:
1. They don't fix a problem
2. They are likely to introduce very hard to debug new issues if they are wrong

Thanks,
//richard



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

* Re: [PATCH] ubifs: remove unnecessary check in ubifs_log_start_commit
       [not found] <201808211457448170622@zte.com.cn>
@ 2018-08-21  7:41 ` Richard Weinberger
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Weinberger @ 2018-08-21  7:41 UTC (permalink / raw)
  To: liu.song11
  Cc: dedekind1, adrian.hunter, linux-mtd, linux-kernel, jiang.biao2,
	zhong.weidong

Am Dienstag, 21. August 2018, 08:57:44 CEST schrieb liu.song11@zte.com.cn:
> Hi Richard,
> 
> In ubifs_log_start_commit, the value of c->lhead_offs is zero or set to zero by code bellow
> 409         /* Switch to the next log LEB */
> 410         if (c->lhead_offs) {
> 411                 c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum);
> 412                 ubifs_assert(c->lhead_lnum != c->ltail_lnum);
> 413                 c->lhead_offs = 0;
> 414         }
> 
> The value of 'len' can not exceed 'max_len' which assigned value by code bellow
> 370         max_len = UBIFS_CS_NODE_SZ + c->jhead_cnt * UBIFS_REF_NODE_SZ;
> 
> So, the value of c->lhead_offs cannot exceed 'max_len' 
> 429         c->lhead_offs += len;
> 430         if (c->lhead_offs == c->leb_size) {
> 431                 c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum);
> 432                 c->lhead_offs = 0;
> 433         }
> 
> Usually, the size of PEB is between 64KB and 256KB, and in UBIFS, the value of
> c->lhead_offs far less than UBIFS_BLOCK_SIZE which equal to 4096. So I think
> the value of c->lhead_offs far less than c->leb_size, the check in line 430 seem 
> never to be true.

Okay, now it makes sense.
But what has this do to with UBIFS_BLOCK_SIZE?

Anyway, your patch description needs to be more detailed.
What you explained to me right now needs to go in the commit message.
Then people can understand why the check is not needed.
For the sake of paranoia and debug-ability, please also add a
ubifs_assert(c->lhead_offs < c->leb_size);.

Thanks,
//richard



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

end of thread, other threads:[~2018-08-21  7:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-21  3:17 [PATCH] ubifs: remove unnecessary check in ubifs_log_start_commit Liu Song
2018-08-21  6:25 ` Richard Weinberger
     [not found] <201808211457448170622@zte.com.cn>
2018-08-21  7:41 ` Richard Weinberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.