Skip to contentSkip to conversation

ubifs: remove unnecessary check in ubifs_log_start_commit

PATCH Richard Weinberger 1 participant 1 message Aug 21, 2018 1 message not in the archive Memory technology devices (MTD)

lore
Share & tools
lore

Richard Weinberger

author maintainer
#1 lore raw
In reply to a message not in the archive

Am Dienstag, 21. August 2018, 08:57:44 CEST schrieb [email protected]:

Quoted 20 lines

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 }

Quoted 4 lines

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