[lkml]   [2009]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[PATCH] issue storage dev flush from generic file_fsync helper

    Simple and legacy blkdev-based filesystems such HFS, HFS+, ADFS, AFFS,
    FAT, bfs, UFS, NTFS, and qnx4 all use file_fsync as their fsync(2)
    VFS helper implementation.

    Add a storage dev cache flush, to actually provide the guarantees that
    are promised with fsync(2).

    Signed-off-by: Jeff Garzik <>

    Out of 18 other places that call sync_blockdev(), only 3-4 are in
    filesystems that arguably do not need or want a blkdev flush. This
    patch below clearly only addresses 1 out of ~15 callsites that really do
    want metadata, data, and everything in between flushed to disk at the
    sync_blockdev() callsite.

    It should be noted that other calls are NOT used in fsync(2), but
    rather than with guaranteed written data prior to major events such
    as unmount, journal close, MD consistency check, etc.

    diff --git a/fs/sync.c b/fs/sync.c
    index a16d53e..24bb2f4 100644
    --- a/fs/sync.c
    +++ b/fs/sync.c
    @@ -5,6 +5,7 @@
    #include <linux/kernel.h>
    #include <linux/file.h>
    #include <linux/fs.h>
    +#include <linux/blkdev.h>
    #include <linux/module.h>
    #include <linux/sched.h>
    #include <linux/writeback.h>
    @@ -72,6 +73,13 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
    err = sync_blockdev(sb->s_bdev);
    if (!ret)
    ret = err;
    + err = blkdev_issue_flush(sb->s_bdev, NULL);
    + if (err == -EOPNOTSUPP)
    + err = 0;
    + if (!ret)
    + ret = err;
    return ret;

     \ /
      Last update: 2009-03-27 21:53    [W:0.047 / U:3.808 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site