Skip to content

Commit 2bc275e

Browse files
Adrian HunterArtem Bityutskiy
authored andcommitted
UBIFS: fix dbg_chk_lpt_sz()
The debugging function dbg_chk_lpt_sz() was not working correctly for small min_io_unit size e.g. NOR flash. Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
1 parent d5b5623 commit 2bc275e

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

‎fs/ubifs/lpt_commit.c‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static int layout_cnodes(struct ubifs_info *c)
229229
while (offs + len > c->leb_size) {
230230
alen = ALIGN(offs, c->min_io_size);
231231
upd_ltab(c, lnum, c->leb_size - alen, alen - offs);
232-
dbg_chk_lpt_sz(c, 2, alen - offs);
232+
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
233233
err = alloc_lpt_leb(c, &lnum);
234234
if (err)
235235
goto no_space;
@@ -272,7 +272,7 @@ static int layout_cnodes(struct ubifs_info *c)
272272
if (offs + c->lsave_sz > c->leb_size) {
273273
alen = ALIGN(offs, c->min_io_size);
274274
upd_ltab(c, lnum, c->leb_size - alen, alen - offs);
275-
dbg_chk_lpt_sz(c, 2, alen - offs);
275+
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
276276
err = alloc_lpt_leb(c, &lnum);
277277
if (err)
278278
goto no_space;
@@ -292,7 +292,7 @@ static int layout_cnodes(struct ubifs_info *c)
292292
if (offs + c->ltab_sz > c->leb_size) {
293293
alen = ALIGN(offs, c->min_io_size);
294294
upd_ltab(c, lnum, c->leb_size - alen, alen - offs);
295-
dbg_chk_lpt_sz(c, 2, alen - offs);
295+
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
296296
err = alloc_lpt_leb(c, &lnum);
297297
if (err)
298298
goto no_space;
@@ -416,9 +416,8 @@ static int write_cnodes(struct ubifs_info *c)
416416
alen, UBI_SHORTTERM);
417417
if (err)
418418
return err;
419-
dbg_chk_lpt_sz(c, 4, alen - wlen);
420419
}
421-
dbg_chk_lpt_sz(c, 2, 0);
420+
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
422421
err = realloc_lpt_leb(c, &lnum);
423422
if (err)
424423
goto no_space;
@@ -477,7 +476,7 @@ static int write_cnodes(struct ubifs_info *c)
477476
UBI_SHORTTERM);
478477
if (err)
479478
return err;
480-
dbg_chk_lpt_sz(c, 2, alen - wlen);
479+
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
481480
err = realloc_lpt_leb(c, &lnum);
482481
if (err)
483482
goto no_space;
@@ -504,7 +503,7 @@ static int write_cnodes(struct ubifs_info *c)
504503
UBI_SHORTTERM);
505504
if (err)
506505
return err;
507-
dbg_chk_lpt_sz(c, 2, alen - wlen);
506+
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
508507
err = realloc_lpt_leb(c, &lnum);
509508
if (err)
510509
goto no_space;
@@ -1756,10 +1755,16 @@ int dbg_chk_lpt_free_spc(struct ubifs_info *c)
17561755
/**
17571756
* dbg_chk_lpt_sz - check LPT does not write more than LPT size.
17581757
* @c: the UBIFS file-system description object
1759-
* @action: action
1758+
* @action: what to do
17601759
* @len: length written
17611760
*
17621761
* This function returns %0 on success and a negative error code on failure.
1762+
* The @action argument may be one of:
1763+
* o %0 - LPT debugging checking starts, initialize debugging variables;
1764+
* o %1 - wrote an LPT node, increase LPT size by @len bytes;
1765+
* o %2 - switched to a different LEB and wasted @len bytes;
1766+
* o %3 - check that we've written the right number of bytes.
1767+
* o %4 - wasted @len bytes;
17631768
*/
17641769
int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
17651770
{

0 commit comments

Comments
 (0)