diff mbox series

[2/2] jffs2: Add sync to underlying mtd device when file system is synced

Message ID 1556914418-40288-2-git-send-email-clayton.shotwell@rockwellcollins.com
State Under Review, archived
Delegated to: Richard Weinberger
Headers show
Series [1/2] mtd: gluebi: Add sync logic | expand

Commit Message

Clayton Shotwell May 3, 2019, 8:13 p.m. UTC
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(+)

Comments

Richard Weinberger May 5, 2019, 10:22 p.m. UTC | #1
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.
Richard Weinberger May 16, 2019, 11:04 a.m. UTC | #2
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?
Brandon Maier May 16, 2019, 3:12 p.m. UTC | #3
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
Richard Weinberger May 16, 2019, 3:31 p.m. UTC | #4
----- 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
diff mbox series

Patch

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