Linux-mtd Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ubifs: Correctly initialize c->min_log_bytes
@ 2019-07-25 20:56 Richard Weinberger
  2019-07-25 21:03 ` Richard Weinberger
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Richard Weinberger @ 2019-07-25 20:56 UTC (permalink / raw)
  To: linux-mtd; +Cc: Richard Weinberger, u.kleine-koenig

Currently on a freshly mounted UBIFS, c->min_log_bytes is 0.
This can lead to a log overrun and make commits fail.

Recent kernels will report the following assert:
UBIFS assert failed: c->lhead_lnum != c->ltail_lnum, in fs/ubifs/log.c:412

c->min_log_bytes can have two states, 0 and c->leb_size.
It controls how much bytes of the log area are reserved for non-bud
nodes such as commit nodes.

After a commit it has to be set to c->leb_size such that we have always
enought space for a commit. While a commit runs it can be 0 to make the
remaining bytes of the log available to writers.

Having it set to 0 right after mount is wrong since no space for commits
is reserved.

Reported-and-tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/ubifs/super.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 2c0803b0ac3a..8c1d571334bc 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -609,6 +609,10 @@ static int init_constants_early(struct ubifs_info *c)
 	c->max_bu_buf_len = UBIFS_MAX_BULK_READ * UBIFS_MAX_DATA_NODE_SZ;
 	if (c->max_bu_buf_len > c->leb_size)
 		c->max_bu_buf_len = c->leb_size;
+
+	/* Log is ready, preserve one LEB for commits. */
+	c->min_log_bytes = c->leb_size;
+
 	return 0;
 }
 
-- 
2.16.4


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] ubifs: Correctly initialize c->min_log_bytes
  2019-07-25 20:56 [PATCH] ubifs: Correctly initialize c->min_log_bytes Richard Weinberger
@ 2019-07-25 21:03 ` Richard Weinberger
  2019-07-25 21:04 ` Uwe Kleine-König
  2019-07-31  7:42 ` Uwe Kleine-König
  2 siblings, 0 replies; 6+ messages in thread
From: Richard Weinberger @ 2019-07-25 21:03 UTC (permalink / raw)
  To: linux-mtd; +Cc: Uwe Kleine-König

----- Ursprüngliche Mail -----
> Von: "richard" <richard@nod.at>
> An: "linux-mtd" <linux-mtd@lists.infradead.org>
> CC: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>, "richard" <richard@nod.at>
> Gesendet: Donnerstag, 25. Juli 2019 22:56:27
> Betreff: [PATCH] ubifs: Correctly initialize c->min_log_bytes

> Currently on a freshly mounted UBIFS, c->min_log_bytes is 0.
> This can lead to a log overrun and make commits fail.
> 
> Recent kernels will report the following assert:
> UBIFS assert failed: c->lhead_lnum != c->ltail_lnum, in fs/ubifs/log.c:412
> 
> c->min_log_bytes can have two states, 0 and c->leb_size.
> It controls how much bytes of the log area are reserved for non-bud
> nodes such as commit nodes.
> 
> After a commit it has to be set to c->leb_size such that we have always
> enought space for a commit. While a commit runs it can be 0 to make the
> remaining bytes of the log available to writers.
> 
> Having it set to 0 right after mount is wrong since no space for commits
> is reserved.
> 
> Reported-and-tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Richard Weinberger <richard@nod.at>

Fixes: 1e51764a3c2ac ("UBIFS: add new flash file system")

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] ubifs: Correctly initialize c->min_log_bytes
  2019-07-25 20:56 [PATCH] ubifs: Correctly initialize c->min_log_bytes Richard Weinberger
  2019-07-25 21:03 ` Richard Weinberger
@ 2019-07-25 21:04 ` Uwe Kleine-König
  2019-07-31  7:42 ` Uwe Kleine-König
  2 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2019-07-25 21:04 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-mtd, kernel

Hello Richard,

On Thu, Jul 25, 2019 at 10:56:27PM +0200, Richard Weinberger wrote:
> Currently on a freshly mounted UBIFS, c->min_log_bytes is 0.
> This can lead to a log overrun and make commits fail.
> 
> Recent kernels will report the following assert:
> UBIFS assert failed: c->lhead_lnum != c->ltail_lnum, in fs/ubifs/log.c:412
> 
> c->min_log_bytes can have two states, 0 and c->leb_size.
> It controls how much bytes of the log area are reserved for non-bud
> nodes such as commit nodes.
> 
> After a commit it has to be set to c->leb_size such that we have always
> enought space for a commit. While a commit runs it can be 0 to make the

s/enought/enough/

> remaining bytes of the log available to writers.
> 
> Having it set to 0 right after mount is wrong since no space for commits
> is reserved.
> 
> Reported-and-tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Richard Weinberger <richard@nod.at>

Thanks for your support
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] ubifs: Correctly initialize c->min_log_bytes
  2019-07-25 20:56 [PATCH] ubifs: Correctly initialize c->min_log_bytes Richard Weinberger
  2019-07-25 21:03 ` Richard Weinberger
  2019-07-25 21:04 ` Uwe Kleine-König
@ 2019-07-31  7:42 ` Uwe Kleine-König
  2019-07-31  8:07   ` Richard Weinberger
  2 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2019-07-31  7:42 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-mtd

Hello Richard,

On Thu, Jul 25, 2019 at 10:56:27PM +0200, Richard Weinberger wrote:
> Currently on a freshly mounted UBIFS, c->min_log_bytes is 0.
> This can lead to a log overrun and make commits fail.
> 
> Recent kernels will report the following assert:
> UBIFS assert failed: c->lhead_lnum != c->ltail_lnum, in fs/ubifs/log.c:412
> 
> c->min_log_bytes can have two states, 0 and c->leb_size.
> It controls how much bytes of the log area are reserved for non-bud
> nodes such as commit nodes.
> 
> After a commit it has to be set to c->leb_size such that we have always
> enought space for a commit. While a commit runs it can be 0 to make the
> remaining bytes of the log available to writers.
> 
> Having it set to 0 right after mount is wrong since no space for commits
> is reserved.
> 
> Reported-and-tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Richard Weinberger <richard@nod.at>

I assume you care for applying this to mainline? I wonder it isn't in
next yet?!

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] ubifs: Correctly initialize c->min_log_bytes
  2019-07-31  7:42 ` Uwe Kleine-König
@ 2019-07-31  8:07   ` Richard Weinberger
  2019-07-31  8:22     ` Uwe Kleine-König
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Weinberger @ 2019-07-31  8:07 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: linux-mtd

----- Ursprüngliche Mail -----
> Von: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> An: "richard" <richard@nod.at>
> CC: "linux-mtd" <linux-mtd@lists.infradead.org>
> Gesendet: Mittwoch, 31. Juli 2019 09:42:44
> Betreff: Re: [PATCH] ubifs: Correctly initialize c->min_log_bytes

> Hello Richard,
> 
> On Thu, Jul 25, 2019 at 10:56:27PM +0200, Richard Weinberger wrote:
>> Currently on a freshly mounted UBIFS, c->min_log_bytes is 0.
>> This can lead to a log overrun and make commits fail.
>> 
>> Recent kernels will report the following assert:
>> UBIFS assert failed: c->lhead_lnum != c->ltail_lnum, in fs/ubifs/log.c:412
>> 
>> c->min_log_bytes can have two states, 0 and c->leb_size.
>> It controls how much bytes of the log area are reserved for non-bud
>> nodes such as commit nodes.
>> 
>> After a commit it has to be set to c->leb_size such that we have always
>> enought space for a commit. While a commit runs it can be 0 to make the
>> remaining bytes of the log available to writers.
>> 
>> Having it set to 0 right after mount is wrong since no space for commits
>> is reserved.
>> 
>> Reported-and-tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>> Signed-off-by: Richard Weinberger <richard@nod.at>
> 
> I assume you care for applying this to mainline? I wonder it isn't in
> next yet?!

Don't stress me. The issue is present in UBIFS since day 0, there is absolutely
no reason to hurry.
It will get merged when I'm back from traveling and my time permits it.

Thanks,
//richard

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] ubifs: Correctly initialize c->min_log_bytes
  2019-07-31  8:07   ` Richard Weinberger
@ 2019-07-31  8:22     ` Uwe Kleine-König
  0 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2019-07-31  8:22 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-mtd

Hello Richard,

On Wed, Jul 31, 2019 at 10:07:06AM +0200, Richard Weinberger wrote:
> > On Thu, Jul 25, 2019 at 10:56:27PM +0200, Richard Weinberger wrote:
> >> Currently on a freshly mounted UBIFS, c->min_log_bytes is 0.
> >> This can lead to a log overrun and make commits fail.
> >> 
> >> Recent kernels will report the following assert:
> >> UBIFS assert failed: c->lhead_lnum != c->ltail_lnum, in fs/ubifs/log.c:412
> >> 
> >> c->min_log_bytes can have two states, 0 and c->leb_size.
> >> It controls how much bytes of the log area are reserved for non-bud
> >> nodes such as commit nodes.
> >> 
> >> After a commit it has to be set to c->leb_size such that we have always
> >> enought space for a commit. While a commit runs it can be 0 to make the
> >> remaining bytes of the log available to writers.
> >> 
> >> Having it set to 0 right after mount is wrong since no space for commits
> >> is reserved.
> >> 
> >> Reported-and-tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> >> Signed-off-by: Richard Weinberger <richard@nod.at>
> > 
> > I assume you care for applying this to mainline? I wonder it isn't in
> > next yet?!
> 
> Don't stress me. The issue is present in UBIFS since day 0, there is absolutely
> no reason to hurry.
> It will get merged when I'm back from traveling and my time permits it.

My intention was not to stess you, just to ensure this is eventually
taken care of and to check if there is a blocker that I can help to
remove.

Thanks
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-25 20:56 [PATCH] ubifs: Correctly initialize c->min_log_bytes Richard Weinberger
2019-07-25 21:03 ` Richard Weinberger
2019-07-25 21:04 ` Uwe Kleine-König
2019-07-31  7:42 ` Uwe Kleine-König
2019-07-31  8:07   ` Richard Weinberger
2019-07-31  8:22     ` Uwe Kleine-König

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org linux-mtd@archiver.kernel.org
	public-inbox-index linux-mtd


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/ public-inbox