Skip to content

Commit

Permalink
fat: device-level-flush-after-sync
Browse files Browse the repository at this point in the history
    This patch forces a device-level flush after the generic Linux
    code for sync has run.

    The kernel depends upon filesystem-specific code to flush when
    the filesystem itself thinks it is necessary, and otherwise
    does nothing.  Someone expecting sync to behave as expected
    might be in for a rude surprise.

    The usual caveats apply:  Devices that do not implement flush
    or whose implementation is buggy will not behave well.  IO
    that occurs after the sync will not be flushed.

Signed-off-by: Ken Kofman <gianfranco.dutka@arista.com>
  • Loading branch information
gdutka authored and intel-lab-lkp committed Sep 14, 2022
1 parent 3245cb6 commit b1130c7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,14 @@ static int fat_remount(struct super_block *sb, int *flags, char *data)
return 0;
}

static int fat_sync_fs(struct super_block *sb, int wait)
{
if (wait)
return blkdev_issue_flush(sb->s_bdev, GFP_KERNEL, NULL);
else
return 0;
}

static int fat_statfs(struct dentry *dentry, struct kstatfs *buf)
{
struct super_block *sb = dentry->d_sb;
Expand Down Expand Up @@ -937,6 +945,7 @@ static const struct super_operations fat_sops = {
.put_super = fat_put_super,
.statfs = fat_statfs,
.remount_fs = fat_remount,
.sync_fs = fat_sync_fs,

.show_options = fat_show_options,
};
Expand Down

0 comments on commit b1130c7

Please sign in to comment.