"Das U-Boot" Source Tree

ubifs: Fix journal replay wrt. xattr nodes

Backport commit 1cb51a15b576 ("ubifs: Fix journal replay wrt. xattr
nodes") from the Linux Kernel, which has the following Signed-off-by
line:
Signed-off-by: Richard Weinberger <richard@nod.at>

For U-Boot, after comapring with the upstream commit:
Signed-off-by: Tom Rini <trini@konsulko.com>

authored by

Ville Baillie and committed by
Tom Rini
749c6a62 b583348c

+23 -2
+23 -2
fs/ubifs/tnc.c
··· 50 50 NOT_ON_MEDIA = 3, 51 51 }; 52 52 53 + static int try_read_node(const struct ubifs_info *c, void *buf, int type, 54 + int len, int lnum, int offs); 55 + static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key, 56 + struct ubifs_zbranch *zbr, void *node); 57 + 53 58 /** 54 59 * insert_old_idx - record an index node obsoleted since the last commit start. 55 60 * @c: UBIFS file-system description object ··· 402 407 return 0; 403 408 } 404 409 405 - err = ubifs_tnc_read_node(c, zbr, node); 410 + if (c->replaying) { 411 + err = fallible_read_node(c, &zbr->key, zbr, node); 412 + /* 413 + * When the node was not found, return -ENOENT, 0 otherwise. 414 + * Negative return codes stay as-is. 415 + */ 416 + if (err == 0) 417 + err = -ENOENT; 418 + else if (err == 1) 419 + err = 0; 420 + } else { 421 + err = ubifs_tnc_read_node(c, zbr, node); 422 + } 406 423 if (err) 407 424 return err; 408 425 ··· 2770 2787 if (nm->name) { 2771 2788 if (err) { 2772 2789 /* Handle collisions */ 2773 - err = resolve_collision(c, key, &znode, &n, nm); 2790 + if (c->replaying) 2791 + err = fallible_resolve_collision(c, key, &znode, &n, 2792 + nm, 0); 2793 + else 2794 + err = resolve_collision(c, key, &znode, &n, nm); 2774 2795 dbg_tnc("rc returned %d, znode %p, n %d", 2775 2796 err, znode, n); 2776 2797 if (unlikely(err < 0))