All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] ubifs: Fix journal replay wrt. xattr nodes
@ 2022-03-28  9:13 Ville Baillie
  2022-04-11 20:15 ` Tom Rini
  0 siblings, 1 reply; 3+ messages in thread
From: Ville Baillie @ 2022-03-28  9:13 UTC (permalink / raw)
  To: u-boot-patches; +Cc: Ville Baillie, u-boot

backport 1cb51a15b576ee325d527726afff40947218fd5e from Linux
---
 fs/ubifs/tnc.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index e8b8f16838..3303711477 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -50,6 +50,11 @@ enum {
 	NOT_ON_MEDIA = 3,
 };
 
+static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key,
+                              struct ubifs_zbranch *zbr, void *node);
+static int try_read_node(const struct ubifs_info *c, void *buf, int type,
+                         int len, int lnum, int offs);
+
 /**
  * insert_old_idx - record an index node obsoleted since the last commit start.
  * @c: UBIFS file-system description object
@@ -402,7 +407,19 @@ static int tnc_read_node_nm(struct ubifs_info *c, struct ubifs_zbranch *zbr,
 		return 0;
 	}
 
-	err = ubifs_tnc_read_node(c, zbr, node);
+	if (c->replaying) {
+		err = fallible_read_node(c, &zbr->key, zbr, node);
+		/*
+		 * When the node was not found, return -ENOENT, 0 otherwise.
+		 * Negative return codes stay as-is.
+		 */
+		if (err == 0)
+			err = -ENOENT;
+		else if (err == 1)
+			err = 0;
+	} else {
+		err = ubifs_tnc_read_node(c, zbr, node);
+	}
 	if (err)
 		return err;
 
@@ -2770,7 +2787,11 @@ struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c,
 	if (nm->name) {
 		if (err) {
 			/* Handle collisions */
-			err = resolve_collision(c, key, &znode, &n, nm);
+			if (c->replaying)
+				err = fallible_resolve_collision(c, key, &znode, &n,
+							 nm, 0);
+			else
+				err = resolve_collision(c, key, &znode, &n, nm);
 			dbg_tnc("rc returned %d, znode %p, n %d",
 				err, znode, n);
 			if (unlikely(err < 0))
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] ubifs: Fix journal replay wrt. xattr nodes
  2022-03-28  9:13 [PATCH 1/1] ubifs: Fix journal replay wrt. xattr nodes Ville Baillie
@ 2022-04-11 20:15 ` Tom Rini
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Rini @ 2022-04-11 20:15 UTC (permalink / raw)
  To: Ville Baillie; +Cc: u-boot-patches, u-boot

[-- Attachment #1: Type: text/plain, Size: 513 bytes --]

On Mon, Mar 28, 2022 at 09:13:43AM +0000, Ville Baillie wrote:

> 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>
> 

Note that I reworded the commit message to meet our usual style
guidlines and applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] ubifs: Fix journal replay wrt. xattr nodes
@ 2022-03-28  9:16 Ville Baillie
  0 siblings, 0 replies; 3+ messages in thread
From: Ville Baillie @ 2022-03-28  9:16 UTC (permalink / raw)
  To: u-boot; +Cc: Ville Baillie

backport 1cb51a15b576ee325d527726afff40947218fd5e from Linux
---
 fs/ubifs/tnc.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index e8b8f16838..3303711477 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -50,6 +50,11 @@ enum {
 	NOT_ON_MEDIA = 3,
 };
 
+static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key,
+                              struct ubifs_zbranch *zbr, void *node);
+static int try_read_node(const struct ubifs_info *c, void *buf, int type,
+                         int len, int lnum, int offs);
+
 /**
  * insert_old_idx - record an index node obsoleted since the last commit start.
  * @c: UBIFS file-system description object
@@ -402,7 +407,19 @@ static int tnc_read_node_nm(struct ubifs_info *c, struct ubifs_zbranch *zbr,
 		return 0;
 	}
 
-	err = ubifs_tnc_read_node(c, zbr, node);
+	if (c->replaying) {
+		err = fallible_read_node(c, &zbr->key, zbr, node);
+		/*
+		 * When the node was not found, return -ENOENT, 0 otherwise.
+		 * Negative return codes stay as-is.
+		 */
+		if (err == 0)
+			err = -ENOENT;
+		else if (err == 1)
+			err = 0;
+	} else {
+		err = ubifs_tnc_read_node(c, zbr, node);
+	}
 	if (err)
 		return err;
 
@@ -2770,7 +2787,11 @@ struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c,
 	if (nm->name) {
 		if (err) {
 			/* Handle collisions */
-			err = resolve_collision(c, key, &znode, &n, nm);
+			if (c->replaying)
+				err = fallible_resolve_collision(c, key, &znode, &n,
+							 nm, 0);
+			else
+				err = resolve_collision(c, key, &znode, &n, nm);
 			dbg_tnc("rc returned %d, znode %p, n %d",
 				err, znode, n);
 			if (unlikely(err < 0))
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-11 20:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28  9:13 [PATCH 1/1] ubifs: Fix journal replay wrt. xattr nodes Ville Baillie
2022-04-11 20:15 ` Tom Rini
2022-03-28  9:16 Ville Baillie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.