Commit efcfde54 authored by Artem Bityutskiy's avatar Artem Bityutskiy

UBIFS: amend ubifs_recover_leb interface

Instead of passing "grouped" parameter to 'ubifs_recover_leb()' which tells
whether the nodes are grouped in the LEB to recover, pass the journal head
number and let 'ubifs_recover_leb()' look at the journal head's 'grouped' flag.

This patch is a preparation to a further fix where we'll need to know the
journal head number for other purposes.
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent 1a0b0699
...@@ -674,7 +674,7 @@ static int kill_orphans(struct ubifs_info *c) ...@@ -674,7 +674,7 @@ static int kill_orphans(struct ubifs_info *c)
if (IS_ERR(sleb)) { if (IS_ERR(sleb)) {
if (PTR_ERR(sleb) == -EUCLEAN) if (PTR_ERR(sleb) == -EUCLEAN)
sleb = ubifs_recover_leb(c, lnum, 0, sleb = ubifs_recover_leb(c, lnum, 0,
c->sbuf, 0); c->sbuf, -1);
if (IS_ERR(sleb)) { if (IS_ERR(sleb)) {
err = PTR_ERR(sleb); err = PTR_ERR(sleb);
break; break;
......
...@@ -604,7 +604,8 @@ static int drop_last_node(struct ubifs_scan_leb *sleb, int *offs, int grouped) ...@@ -604,7 +604,8 @@ static int drop_last_node(struct ubifs_scan_leb *sleb, int *offs, int grouped)
* @lnum: LEB number * @lnum: LEB number
* @offs: offset * @offs: offset
* @sbuf: LEB-sized buffer to use * @sbuf: LEB-sized buffer to use
* @grouped: nodes may be grouped for recovery * @jhead: journal head number this LEB belongs to (%-1 if the LEB does not
* belong to any journal head)
* *
* This function does a scan of a LEB, but caters for errors that might have * This function does a scan of a LEB, but caters for errors that might have
* been caused by the unclean unmount from which we are attempting to recover. * been caused by the unclean unmount from which we are attempting to recover.
...@@ -612,13 +613,14 @@ static int drop_last_node(struct ubifs_scan_leb *sleb, int *offs, int grouped) ...@@ -612,13 +613,14 @@ static int drop_last_node(struct ubifs_scan_leb *sleb, int *offs, int grouped)
* found, and a negative error code in case of failure. * found, and a negative error code in case of failure.
*/ */
struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,
int offs, void *sbuf, int grouped) int offs, void *sbuf, int jhead)
{ {
int ret = 0, err, len = c->leb_size - offs, start = offs, min_io_unit; int ret = 0, err, len = c->leb_size - offs, start = offs, min_io_unit;
int grouped = jhead == -1 ? 0 : c->jheads[jhead].grouped;
struct ubifs_scan_leb *sleb; struct ubifs_scan_leb *sleb;
void *buf = sbuf + offs; void *buf = sbuf + offs;
dbg_rcvry("%d:%d", lnum, offs); dbg_rcvry("%d:%d, jhead %d, grouped %d", lnum, offs, jhead, grouped);
sleb = ubifs_start_scan(c, lnum, offs, sbuf); sleb = ubifs_start_scan(c, lnum, offs, sbuf);
if (IS_ERR(sleb)) if (IS_ERR(sleb))
...@@ -881,7 +883,7 @@ struct ubifs_scan_leb *ubifs_recover_log_leb(struct ubifs_info *c, int lnum, ...@@ -881,7 +883,7 @@ struct ubifs_scan_leb *ubifs_recover_log_leb(struct ubifs_info *c, int lnum,
} }
ubifs_scan_destroy(sleb); ubifs_scan_destroy(sleb);
} }
return ubifs_recover_leb(c, lnum, offs, sbuf, 0); return ubifs_recover_leb(c, lnum, offs, sbuf, -1);
} }
/** /**
......
...@@ -557,8 +557,7 @@ static int replay_bud(struct ubifs_info *c, struct bud_entry *b) ...@@ -557,8 +557,7 @@ static int replay_bud(struct ubifs_info *c, struct bud_entry *b)
* these LEBs could possibly be written to at the power cut * these LEBs could possibly be written to at the power cut
* time. * time.
*/ */
sleb = ubifs_recover_leb(c, lnum, offs, c->sbuf, sleb = ubifs_recover_leb(c, lnum, offs, c->sbuf, b->bud->jhead);
b->bud->jhead != GCHD);
else else
sleb = ubifs_scan(c, lnum, offs, c->sbuf, 0); sleb = ubifs_scan(c, lnum, offs, c->sbuf, 0);
if (IS_ERR(sleb)) if (IS_ERR(sleb))
......
...@@ -1744,7 +1744,7 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum); ...@@ -1744,7 +1744,7 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum);
int ubifs_recover_master_node(struct ubifs_info *c); int ubifs_recover_master_node(struct ubifs_info *c);
int ubifs_write_rcvrd_mst_node(struct ubifs_info *c); int ubifs_write_rcvrd_mst_node(struct ubifs_info *c);
struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,
int offs, void *sbuf, int grouped); int offs, void *sbuf, int jhead);
struct ubifs_scan_leb *ubifs_recover_log_leb(struct ubifs_info *c, int lnum, struct ubifs_scan_leb *ubifs_recover_log_leb(struct ubifs_info *c, int lnum,
int offs, void *sbuf); int offs, void *sbuf);
int ubifs_recover_inl_heads(const struct ubifs_info *c, void *sbuf); int ubifs_recover_inl_heads(const struct ubifs_info *c, void *sbuf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment