diff options
Diffstat (limited to 'fs/ubifs/lpt_commit.c')
-rw-r--r-- | fs/ubifs/lpt_commit.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index 3216a1f277f8..8cbfb8248025 100644 --- a/fs/ubifs/lpt_commit.c +++ b/fs/ubifs/lpt_commit.c | |||
@@ -229,7 +229,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
229 | while (offs + len > c->leb_size) { | 229 | while (offs + len > c->leb_size) { |
230 | alen = ALIGN(offs, c->min_io_size); | 230 | alen = ALIGN(offs, c->min_io_size); |
231 | upd_ltab(c, lnum, c->leb_size - alen, alen - offs); | 231 | 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); |
233 | err = alloc_lpt_leb(c, &lnum); | 233 | err = alloc_lpt_leb(c, &lnum); |
234 | if (err) | 234 | if (err) |
235 | goto no_space; | 235 | goto no_space; |
@@ -272,7 +272,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
272 | if (offs + c->lsave_sz > c->leb_size) { | 272 | if (offs + c->lsave_sz > c->leb_size) { |
273 | alen = ALIGN(offs, c->min_io_size); | 273 | alen = ALIGN(offs, c->min_io_size); |
274 | upd_ltab(c, lnum, c->leb_size - alen, alen - offs); | 274 | 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); |
276 | err = alloc_lpt_leb(c, &lnum); | 276 | err = alloc_lpt_leb(c, &lnum); |
277 | if (err) | 277 | if (err) |
278 | goto no_space; | 278 | goto no_space; |
@@ -292,7 +292,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
292 | if (offs + c->ltab_sz > c->leb_size) { | 292 | if (offs + c->ltab_sz > c->leb_size) { |
293 | alen = ALIGN(offs, c->min_io_size); | 293 | alen = ALIGN(offs, c->min_io_size); |
294 | upd_ltab(c, lnum, c->leb_size - alen, alen - offs); | 294 | 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); |
296 | err = alloc_lpt_leb(c, &lnum); | 296 | err = alloc_lpt_leb(c, &lnum); |
297 | if (err) | 297 | if (err) |
298 | goto no_space; | 298 | goto no_space; |
@@ -416,14 +416,12 @@ static int write_cnodes(struct ubifs_info *c) | |||
416 | alen, UBI_SHORTTERM); | 416 | alen, UBI_SHORTTERM); |
417 | if (err) | 417 | if (err) |
418 | return err; | 418 | return err; |
419 | dbg_chk_lpt_sz(c, 4, alen - wlen); | ||
420 | } | 419 | } |
421 | dbg_chk_lpt_sz(c, 2, 0); | 420 | dbg_chk_lpt_sz(c, 2, c->leb_size - offs); |
422 | err = realloc_lpt_leb(c, &lnum); | 421 | err = realloc_lpt_leb(c, &lnum); |
423 | if (err) | 422 | if (err) |
424 | goto no_space; | 423 | goto no_space; |
425 | offs = 0; | 424 | offs = from = 0; |
426 | from = 0; | ||
427 | ubifs_assert(lnum >= c->lpt_first && | 425 | ubifs_assert(lnum >= c->lpt_first && |
428 | lnum <= c->lpt_last); | 426 | lnum <= c->lpt_last); |
429 | err = ubifs_leb_unmap(c, lnum); | 427 | err = ubifs_leb_unmap(c, lnum); |
@@ -477,11 +475,11 @@ static int write_cnodes(struct ubifs_info *c) | |||
477 | UBI_SHORTTERM); | 475 | UBI_SHORTTERM); |
478 | if (err) | 476 | if (err) |
479 | return err; | 477 | return err; |
480 | dbg_chk_lpt_sz(c, 2, alen - wlen); | 478 | dbg_chk_lpt_sz(c, 2, c->leb_size - offs); |
481 | err = realloc_lpt_leb(c, &lnum); | 479 | err = realloc_lpt_leb(c, &lnum); |
482 | if (err) | 480 | if (err) |
483 | goto no_space; | 481 | goto no_space; |
484 | offs = 0; | 482 | offs = from = 0; |
485 | ubifs_assert(lnum >= c->lpt_first && | 483 | ubifs_assert(lnum >= c->lpt_first && |
486 | lnum <= c->lpt_last); | 484 | lnum <= c->lpt_last); |
487 | err = ubifs_leb_unmap(c, lnum); | 485 | err = ubifs_leb_unmap(c, lnum); |
@@ -504,11 +502,11 @@ static int write_cnodes(struct ubifs_info *c) | |||
504 | UBI_SHORTTERM); | 502 | UBI_SHORTTERM); |
505 | if (err) | 503 | if (err) |
506 | return err; | 504 | return err; |
507 | dbg_chk_lpt_sz(c, 2, alen - wlen); | 505 | dbg_chk_lpt_sz(c, 2, c->leb_size - offs); |
508 | err = realloc_lpt_leb(c, &lnum); | 506 | err = realloc_lpt_leb(c, &lnum); |
509 | if (err) | 507 | if (err) |
510 | goto no_space; | 508 | goto no_space; |
511 | offs = 0; | 509 | offs = from = 0; |
512 | ubifs_assert(lnum >= c->lpt_first && | 510 | ubifs_assert(lnum >= c->lpt_first && |
513 | lnum <= c->lpt_last); | 511 | lnum <= c->lpt_last); |
514 | err = ubifs_leb_unmap(c, lnum); | 512 | err = ubifs_leb_unmap(c, lnum); |
@@ -1756,10 +1754,16 @@ int dbg_chk_lpt_free_spc(struct ubifs_info *c) | |||
1756 | /** | 1754 | /** |
1757 | * dbg_chk_lpt_sz - check LPT does not write more than LPT size. | 1755 | * dbg_chk_lpt_sz - check LPT does not write more than LPT size. |
1758 | * @c: the UBIFS file-system description object | 1756 | * @c: the UBIFS file-system description object |
1759 | * @action: action | 1757 | * @action: what to do |
1760 | * @len: length written | 1758 | * @len: length written |
1761 | * | 1759 | * |
1762 | * This function returns %0 on success and a negative error code on failure. | 1760 | * This function returns %0 on success and a negative error code on failure. |
1761 | * The @action argument may be one of: | ||
1762 | * o %0 - LPT debugging checking starts, initialize debugging variables; | ||
1763 | * o %1 - wrote an LPT node, increase LPT size by @len bytes; | ||
1764 | * o %2 - switched to a different LEB and wasted @len bytes; | ||
1765 | * o %3 - check that we've written the right number of bytes. | ||
1766 | * o %4 - wasted @len bytes; | ||
1763 | */ | 1767 | */ |
1764 | int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) | 1768 | int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) |
1765 | { | 1769 | { |
@@ -1917,12 +1921,12 @@ static void dump_lpt_leb(const struct ubifs_info *c, int lnum) | |||
1917 | lnum, offs); | 1921 | lnum, offs); |
1918 | err = ubifs_unpack_nnode(c, buf, &nnode); | 1922 | err = ubifs_unpack_nnode(c, buf, &nnode); |
1919 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { | 1923 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { |
1920 | printk("%d:%d", nnode.nbranch[i].lnum, | 1924 | printk(KERN_CONT "%d:%d", nnode.nbranch[i].lnum, |
1921 | nnode.nbranch[i].offs); | 1925 | nnode.nbranch[i].offs); |
1922 | if (i != UBIFS_LPT_FANOUT - 1) | 1926 | if (i != UBIFS_LPT_FANOUT - 1) |
1923 | printk(", "); | 1927 | printk(KERN_CONT ", "); |
1924 | } | 1928 | } |
1925 | printk("\n"); | 1929 | printk(KERN_CONT "\n"); |
1926 | break; | 1930 | break; |
1927 | } | 1931 | } |
1928 | case UBIFS_LPT_LTAB: | 1932 | case UBIFS_LPT_LTAB: |