linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mtd: gluebi: Add sync logic
@ 2019-05-03 20:13 Clayton Shotwell
  2019-05-03 20:13 ` [PATCH 2/2] jffs2: Add sync to underlying mtd device when file system is synced Clayton Shotwell
  0 siblings, 1 reply; 6+ messages in thread
From: Clayton Shotwell @ 2019-05-03 20:13 UTC (permalink / raw)
  To: linux-mtd
  Cc: bbrezillon, richard, brandon.maier, marek.vasut,
	computersforpeace, dwmw2, Clayton Shotwell

Adding sync function to sync the underlying ubi device when a mtd sync
is called. This is being used to ensure a JFFS2 file system running on
top of the UBI volume is able to sync the underlying device.

Signed-off-by: Clayton Shotwell <clayton.shotwell@rockwellcollins.com>
---
 drivers/mtd/ubi/gluebi.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index 6b655a5..b7d1d7c 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -280,6 +280,19 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
 }
 
 /**
+ * gluebi_sync - sync operation of emulated MTD devices.
+ * @mtd: the MTD device description object
+ *
+ * This function syncs the underlying UBI device when the MTD device is synced.
+ */
+static void gluebi_sync(struct mtd_info *mtd)
+{
+	struct gluebi_device *gluebi;
+	gluebi = container_of(mtd, struct gluebi_device, mtd);
+	ubi_sync(gluebi->ubi_num);
+}
+
+/**
  * gluebi_create - create a gluebi device for an UBI volume.
  * @di: UBI device description object
  * @vi: UBI volume description object
@@ -318,6 +331,7 @@ static int gluebi_create(struct ubi_device_info *di,
 	mtd->_erase      = gluebi_erase;
 	mtd->_get_device = gluebi_get_device;
 	mtd->_put_device = gluebi_put_device;
+	mtd->_sync       = gluebi_sync;
 
 	/*
 	 * In case of dynamic a volume, MTD device size is just volume size. In
-- 
1.9.1


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

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

* [PATCH 2/2] jffs2: Add sync to underlying mtd device when file system is synced
  2019-05-03 20:13 [PATCH 1/2] mtd: gluebi: Add sync logic Clayton Shotwell
@ 2019-05-03 20:13 ` Clayton Shotwell
  2019-05-05 22:22   ` Richard Weinberger
  0 siblings, 1 reply; 6+ messages in thread
From: Clayton Shotwell @ 2019-05-03 20:13 UTC (permalink / raw)
  To: linux-mtd
  Cc: bbrezillon, richard, brandon.maier, marek.vasut,
	computersforpeace, dwmw2, Clayton Shotwell

Need to ensure the underlying flash does not cache anything even though
the file system thinks it's synced back.

Signed-off-by: Clayton Shotwell <clayton.shotwell@rockwellcollins.com>
---
 fs/jffs2/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 05d892c..4341565 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -111,6 +111,7 @@ static int jffs2_sync_fs(struct super_block *sb, int wait)
 	mutex_lock(&c->alloc_sem);
 	jffs2_flush_wbuf_pad(c);
 	mutex_unlock(&c->alloc_sem);
+	mtd_sync(c->mtd);
 	return 0;
 }
 
-- 
1.9.1


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

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

* Re: [PATCH 2/2] jffs2: Add sync to underlying mtd device when file system is synced
  2019-05-03 20:13 ` [PATCH 2/2] jffs2: Add sync to underlying mtd device when file system is synced Clayton Shotwell
@ 2019-05-05 22:22   ` Richard Weinberger
  2019-05-16 11:04     ` Richard Weinberger
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Weinberger @ 2019-05-05 22:22 UTC (permalink / raw)
  To: Clayton Shotwell
  Cc: bbrezillon, Richard Weinberger, Brandon Maier, Marek Vasut,
	linux-mtd, Brian Norris, David Woodhouse

On Fri, May 3, 2019 at 10:14 PM Clayton Shotwell
<clayton.shotwell@rockwellcollins.com> wrote:
>
> Need to ensure the underlying flash does not cache anything even though
> the file system thinks it's synced back.
>
> Signed-off-by: Clayton Shotwell <clayton.shotwell@rockwellcollins.com>
> ---
>  fs/jffs2/super.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
> index 05d892c..4341565 100644
> --- a/fs/jffs2/super.c
> +++ b/fs/jffs2/super.c
> @@ -111,6 +111,7 @@ static int jffs2_sync_fs(struct super_block *sb, int wait)
>         mutex_lock(&c->alloc_sem);
>         jffs2_flush_wbuf_pad(c);
>         mutex_unlock(&c->alloc_sem);
> +       mtd_sync(c->mtd);

This needs a more detailed explanation.
mtd_sync() is not cheap, so you make syncfs() more expensive.

Please explain what failure you are facing without mtd_sync().
jffs2 is supposed to recover from a power failure at any time, just like ubifs.

-- 
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 2/2] jffs2: Add sync to underlying mtd device when file system is synced
  2019-05-05 22:22   ` Richard Weinberger
@ 2019-05-16 11:04     ` Richard Weinberger
  2019-05-16 15:12       ` Brandon Maier
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Weinberger @ 2019-05-16 11:04 UTC (permalink / raw)
  To: Clayton Shotwell
  Cc: Boris Brezillon, Richard Weinberger, Brandon Maier, Marek Vasut,
	linux-mtd, Brian Norris, David Woodhouse

On Mon, May 6, 2019 at 12:22 AM Richard Weinberger
<richard.weinberger@gmail.com> wrote:
>
> On Fri, May 3, 2019 at 10:14 PM Clayton Shotwell
> <clayton.shotwell@rockwellcollins.com> wrote:
> >
> > Need to ensure the underlying flash does not cache anything even though
> > the file system thinks it's synced back.
> >
> > Signed-off-by: Clayton Shotwell <clayton.shotwell@rockwellcollins.com>
> > ---
> >  fs/jffs2/super.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
> > index 05d892c..4341565 100644
> > --- a/fs/jffs2/super.c
> > +++ b/fs/jffs2/super.c
> > @@ -111,6 +111,7 @@ static int jffs2_sync_fs(struct super_block *sb, int wait)
> >         mutex_lock(&c->alloc_sem);
> >         jffs2_flush_wbuf_pad(c);
> >         mutex_unlock(&c->alloc_sem);
> > +       mtd_sync(c->mtd);
>
> This needs a more detailed explanation.
> mtd_sync() is not cheap, so you make syncfs() more expensive.
>
> Please explain what failure you are facing without mtd_sync().
> jffs2 is supposed to recover from a power failure at any time, just like ubifs.

Ping?

-- 
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 2/2] jffs2: Add sync to underlying mtd device when file system is synced
  2019-05-16 11:04     ` Richard Weinberger
@ 2019-05-16 15:12       ` Brandon Maier
  2019-05-16 15:31         ` Richard Weinberger
  0 siblings, 1 reply; 6+ messages in thread
From: Brandon Maier @ 2019-05-16 15:12 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Boris Brezillon, Richard Weinberger, Marek Vasut, linux-mtd,
	Brian Norris, David Woodhouse, Clayton Shotwell

Clayton is out currently, but I can comment on what he had told me.

On Thu, May 16, 2019 at 6:05 AM Richard Weinberger
<richard.weinberger@gmail.com> wrote:
>
> On Mon, May 6, 2019 at 12:22 AM Richard Weinberger
> <richard.weinberger@gmail.com> wrote:
> >
> > On Fri, May 3, 2019 at 10:14 PM Clayton Shotwell
> > <clayton.shotwell@rockwellcollins.com> wrote:
> > >
> > > Need to ensure the underlying flash does not cache anything even though
> > > the file system thinks it's synced back.
> > >
> > > Signed-off-by: Clayton Shotwell <clayton.shotwell@rockwellcollins.com>
> > > ---
> > >  fs/jffs2/super.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
> > > index 05d892c..4341565 100644
> > > --- a/fs/jffs2/super.c
> > > +++ b/fs/jffs2/super.c
> > > @@ -111,6 +111,7 @@ static int jffs2_sync_fs(struct super_block *sb, int wait)
> > >         mutex_lock(&c->alloc_sem);
> > >         jffs2_flush_wbuf_pad(c);
> > >         mutex_unlock(&c->alloc_sem);
> > > +       mtd_sync(c->mtd);
> >
> > This needs a more detailed explanation.
> > mtd_sync() is not cheap, so you make syncfs() more expensive.
> >
> > Please explain what failure you are facing without mtd_sync().
> > jffs2 is supposed to recover from a power failure at any time, just like ubifs.

The system exhibiting problems runs jffs2 on a gluebi device. Our
software sync()'s the jffs2 at certain points so that it's safe if
power is cut. The jffs2 always recovers the filesystem after power
cut, but sometimes data written before the sync() call gets lost.

These patches attempt to solve this problem by 1) calling _sync() on
the underlying mtd device after writing to flush any buffers in the
mtd, and 2) adding a _sync() callback to gluebi so that if something
syncs the mtd device, we sync any blocks associated with it.

>
> Ping?
>
> --
> 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 2/2] jffs2: Add sync to underlying mtd device when file system is synced
  2019-05-16 15:12       ` Brandon Maier
@ 2019-05-16 15:31         ` Richard Weinberger
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Weinberger @ 2019-05-16 15:31 UTC (permalink / raw)
  To: Brandon Maier
  Cc: Boris Brezillon, Marek Vasut, linux-mtd, Brian Norris,
	David Woodhouse, Clayton Shotwell

----- Ursprüngliche Mail -----
> Von: "Brandon Maier" <brandon.maier@collins.com>
> An: "Richard Weinberger" <richard.weinberger@gmail.com>
> CC: "Clayton Shotwell" <clayton.shotwell@rockwellcollins.com>, "linux-mtd" <linux-mtd@lists.infradead.org>, "Boris
> Brezillon" <bbrezillon@kernel.org>, "richard" <richard@nod.at>, "Marek Vasut" <marek.vasut@gmail.com>, "Brian Norris"
> <computersforpeace@gmail.com>, "David Woodhouse" <dwmw2@infradead.org>
> Gesendet: Donnerstag, 16. Mai 2019 17:12:45
> Betreff: Re: [PATCH 2/2] jffs2: Add sync to underlying mtd device when file system is synced

> Clayton is out currently, but I can comment on what he had told me.

Thanks!
 
> On Thu, May 16, 2019 at 6:05 AM Richard Weinberger
>> > Please explain what failure you are facing without mtd_sync().
>> > jffs2 is supposed to recover from a power failure at any time, just like ubifs.
> 
> The system exhibiting problems runs jffs2 on a gluebi device. Our
> software sync()'s the jffs2 at certain points so that it's safe if
> power is cut. The jffs2 always recovers the filesystem after power
> cut, but sometimes data written before the sync() call gets lost.
> 
> These patches attempt to solve this problem by 1) calling _sync() on
> the underlying mtd device after writing to flush any buffers in the
> mtd, and 2) adding a _sync() callback to gluebi so that if something
> syncs the mtd device, we sync any blocks associated with it.

The interesting question is, do you loose data which was already
written and synced using fsync() or fdatasync()?

Both JFFS2 and UBIFS try to avoid writes and are rather strict when it
comes to fsync().

Thanks,
//richard

______________________________________________________
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, other threads:[~2019-05-16 15:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 20:13 [PATCH 1/2] mtd: gluebi: Add sync logic Clayton Shotwell
2019-05-03 20:13 ` [PATCH 2/2] jffs2: Add sync to underlying mtd device when file system is synced Clayton Shotwell
2019-05-05 22:22   ` Richard Weinberger
2019-05-16 11:04     ` Richard Weinberger
2019-05-16 15:12       ` Brandon Maier
2019-05-16 15:31         ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).