diff options
author | Liu Song <liu.song11@zte.com.cn> | 2018-08-24 09:15:45 +0800 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2019-07-08 19:43:51 +0200 |
commit | 8ba0a2ab84b23b541a5d2ef25d759c94880e7457 (patch) | |
tree | 5d33ac133d4a65f1bfd9c019eb040f4f54aa13f3 /fs/ubifs | |
parent | 7d8c811bf9ed513a586b18a28b788dd10fbe1128 (diff) | |
download | linux-8ba0a2ab84b23b541a5d2ef25d759c94880e7457.tar.gz linux-8ba0a2ab84b23b541a5d2ef25d759c94880e7457.tar.bz2 linux-8ba0a2ab84b23b541a5d2ef25d759c94880e7457.zip |
ubifs: remove unnecessary check in ubifs_log_start_commit
In ubifs_log_start_commit, the value of c->lhead_offs is zero or set
to zero by code bellow.
/* Switch to the next log LEB */
if (c->lhead_offs) {
c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum);
ubifs_assert(c->lhead_lnum != c->ltail_lnum);
c->lhead_offs = 0;
}
The value of 'len' can not exceed 'max_len' which assigned value by
code bellow.
max_len = UBIFS_CS_NODE_SZ + c->jhead_cnt * UBIFS_REF_NODE_SZ;
The value of c->lhead_offs changed by code bellow and cannot exceed
'max_len'.
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;
}
Usually, the size of PEB is between 64KB and 256KB. So the value of
c->lhead_offs is far less than c->leb_size. The check
'if (c->lhead_offs == c->leb_size)' could never to be true.
Signed-off-by: Liu Song <liu.song11@zte.com.cn>
Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/ubifs')
-rw-r--r-- | fs/ubifs/log.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c index cd85d7d4c515..b6ac9c4281ef 100644 --- a/fs/ubifs/log.c +++ b/fs/ubifs/log.c @@ -438,10 +438,7 @@ 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; - } + ubifs_assert(c, c->lhead_offs < c->leb_size); remove_buds(c); |