Skip to content

Commit

Permalink
UBIFS: fix dbg_chk_lpt_sz()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Adrian Hunter authored and Artem Bityutskiy committed Feb 9, 2009
1 parent d5b5623 commit 2bc275e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions fs/ubifs/lpt_commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static int layout_cnodes(struct ubifs_info *c)
while (offs + len > c->leb_size) {
alen = ALIGN(offs, c->min_io_size);
upd_ltab(c, lnum, c->leb_size - alen, alen - offs);
dbg_chk_lpt_sz(c, 2, alen - offs);
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
err = alloc_lpt_leb(c, &lnum);
if (err)
goto no_space;
Expand Down Expand Up @@ -272,7 +272,7 @@ static int layout_cnodes(struct ubifs_info *c)
if (offs + c->lsave_sz > c->leb_size) {
alen = ALIGN(offs, c->min_io_size);
upd_ltab(c, lnum, c->leb_size - alen, alen - offs);
dbg_chk_lpt_sz(c, 2, alen - offs);
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
err = alloc_lpt_leb(c, &lnum);
if (err)
goto no_space;
Expand All @@ -292,7 +292,7 @@ static int layout_cnodes(struct ubifs_info *c)
if (offs + c->ltab_sz > c->leb_size) {
alen = ALIGN(offs, c->min_io_size);
upd_ltab(c, lnum, c->leb_size - alen, alen - offs);
dbg_chk_lpt_sz(c, 2, alen - offs);
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
err = alloc_lpt_leb(c, &lnum);
if (err)
goto no_space;
Expand Down Expand Up @@ -416,9 +416,8 @@ static int write_cnodes(struct ubifs_info *c)
alen, UBI_SHORTTERM);
if (err)
return err;
dbg_chk_lpt_sz(c, 4, alen - wlen);
}
dbg_chk_lpt_sz(c, 2, 0);
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
err = realloc_lpt_leb(c, &lnum);
if (err)
goto no_space;
Expand Down Expand Up @@ -477,7 +476,7 @@ static int write_cnodes(struct ubifs_info *c)
UBI_SHORTTERM);
if (err)
return err;
dbg_chk_lpt_sz(c, 2, alen - wlen);
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
err = realloc_lpt_leb(c, &lnum);
if (err)
goto no_space;
Expand All @@ -504,7 +503,7 @@ static int write_cnodes(struct ubifs_info *c)
UBI_SHORTTERM);
if (err)
return err;
dbg_chk_lpt_sz(c, 2, alen - wlen);
dbg_chk_lpt_sz(c, 2, c->leb_size - offs);
err = realloc_lpt_leb(c, &lnum);
if (err)
goto no_space;
Expand Down Expand Up @@ -1756,10 +1755,16 @@ int dbg_chk_lpt_free_spc(struct ubifs_info *c)
/**
* dbg_chk_lpt_sz - check LPT does not write more than LPT size.
* @c: the UBIFS file-system description object
* @action: action
* @action: what to do
* @len: length written
*
* This function returns %0 on success and a negative error code on failure.
* The @action argument may be one of:
* o %0 - LPT debugging checking starts, initialize debugging variables;
* o %1 - wrote an LPT node, increase LPT size by @len bytes;
* o %2 - switched to a different LEB and wasted @len bytes;
* o %3 - check that we've written the right number of bytes.
* o %4 - wasted @len bytes;
*/
int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
{
Expand Down

0 comments on commit 2bc275e

Please sign in to comment.