Patchwork [1/2] MTD: add fsync capability

login
register
mail settings
Submitter Corentin Chary
Date Feb. 5, 2009, 9:25 p.m.
Message ID <1233869152-23992-1-git-send-email-corentincj@iksaif.net>
Download mbox | patch
Permalink /patch/22214/
State New
Headers show

Comments

Corentin Chary - Feb. 5, 2009, 9:25 p.m.
Now, we can call fsync() on an mtd device.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
 drivers/mtd/mtdchar.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
Mike Frysinger - Feb. 5, 2009, 10 p.m.
On Thu, Feb 5, 2009 at 16:25, Corentin Chary wrote:
> +static int mtd_fsync(struct file *file, struct dentry *dentry, int datasync)
> +{
> +       struct mtd_file_info *mfi = file->private_data;
> +       struct mtd_info *mtd = mfi->mtd;
> +
> +       DEBUG(MTD_DEBUG_LEVEL0, "MTD_fsync\n");
> +
> +       /* Only sync if opened RW */
> +       if ((file->f_mode & FMODE_WRITE) && mtd->sync)
> +               mtd->sync(mtd);
> +
> +       return 0;
> +} /* mtd_fsync */

adding a comment to mark the end of a function isnt common ... i'd
drop that.  otherwise, the patch looks pretty straightforward to me,
but i'm not a big VFS guru ;).
-mike
Artem Bityutskiy - Feb. 6, 2009, 7:34 a.m.
On Thu, 2009-02-05 at 17:00 -0500, Mike Frysinger wrote:
> On Thu, Feb 5, 2009 at 16:25, Corentin Chary wrote:
> > +static int mtd_fsync(struct file *file, struct dentry *dentry, int datasync)
> > +{
> > +       struct mtd_file_info *mfi = file->private_data;
> > +       struct mtd_info *mtd = mfi->mtd;
> > +
> > +       DEBUG(MTD_DEBUG_LEVEL0, "MTD_fsync\n");
> > +
> > +       /* Only sync if opened RW */
> > +       if ((file->f_mode & FMODE_WRITE) && mtd->sync)
> > +               mtd->sync(mtd);
> > +
> > +       return 0;
> > +} /* mtd_fsync */
> 
> adding a comment to mark the end of a function isnt common ... i'd
> drop that.  otherwise, the patch looks pretty straightforward to me,
> but i'm not a big VFS guru ;).
> -mike

The patch looks fine for me, except of the weird end comment, and
the ancient ugly "DEBUG(MTD_DEBUG_LEVEL0, "MTD_fsync\n");" ...
Corentin Chary - Feb. 6, 2009, 8:06 a.m.
I just copied the mtd_close()/mtd_open() function thinking that is was
mtd's codestyle.
So, maybe it's time to clean the while file. I can try to do that next
week if I find the time.

Have the receveid "fsync() for UBI" patch ? it's seems the mail is
waiting for approval on the mailing list.


On 2/6/09, Artem Bityutskiy <dedekind@infradead.org> wrote:
> On Thu, 2009-02-05 at 17:00 -0500, Mike Frysinger wrote:
>> On Thu, Feb 5, 2009 at 16:25, Corentin Chary wrote:
>> > +static int mtd_fsync(struct file *file, struct dentry *dentry, int
>> > datasync)
>> > +{
>> > +       struct mtd_file_info *mfi = file->private_data;
>> > +       struct mtd_info *mtd = mfi->mtd;
>> > +
>> > +       DEBUG(MTD_DEBUG_LEVEL0, "MTD_fsync\n");
>> > +
>> > +       /* Only sync if opened RW */
>> > +       if ((file->f_mode & FMODE_WRITE) && mtd->sync)
>> > +               mtd->sync(mtd);
>> > +
>> > +       return 0;
>> > +} /* mtd_fsync */
>>
>> adding a comment to mark the end of a function isnt common ... i'd
>> drop that.  otherwise, the patch looks pretty straightforward to me,
>> but i'm not a big VFS guru ;).
>> -mike
>
> The patch looks fine for me, except of the weird end comment, and
> the ancient ugly "DEBUG(MTD_DEBUG_LEVEL0, "MTD_fsync\n");" ...
>
> --
> Best regards,
> Artem Bityutskiy (Битюцкий Артём)
>
>
Artem Bityutskiy - Feb. 6, 2009, 8:10 a.m.
On Fri, 2009-02-06 at 09:06 +0100, Corentin Chary wrote:
> I just copied the mtd_close()/mtd_open() function thinking that is was
> mtd's codestyle.
> So, maybe it's time to clean the while file. I can try to do that next
> week if I find the time.
> 
> Have the receveid "fsync() for UBI" patch ? it's seems the mail is
> waiting for approval on the mailing list.

I've pushed the UBI patch. The MTD part is David's, I do not maintain
the mtd-2.6.git tree.

Patch

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index e9ec59e..5f095bb 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -154,6 +154,20 @@  static int mtd_close(struct inode *inode, struct file *file)
 	return 0;
 } /* mtd_close */
 
+static int mtd_fsync(struct file *file, struct dentry *dentry, int datasync)
+{
+	struct mtd_file_info *mfi = file->private_data;
+	struct mtd_info *mtd = mfi->mtd;
+
+	DEBUG(MTD_DEBUG_LEVEL0, "MTD_fsync\n");
+
+	/* Only sync if opened RW */
+	if ((file->f_mode & FMODE_WRITE) && mtd->sync)
+		mtd->sync(mtd);
+
+	return 0;
+} /* mtd_fsync */
+
 /* FIXME: This _really_ needs to die. In 2.5, we should lock the
    userspace buffer down and use it directly with readv/writev.
 */
@@ -787,6 +801,7 @@  static const struct file_operations mtd_fops = {
 	.read		= mtd_read,
 	.write		= mtd_write,
 	.ioctl		= mtd_ioctl,
+	.fsync		= mtd_fsync,
 	.open		= mtd_open,
 	.release	= mtd_close,
 };