Re: [PATCH] fat: issue flush after the writeback of FAT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 09, 2019 at 11:01:58AM +0800, Hou Tao wrote:
> fsync() needs to make sure the data & meta-data of file are persistent
> after the return of fsync(), even when a power-failure occurs later.
> In the case of fat-fs, the FAT belongs to the meta-data of file,
> so we need to issue a flush after the writeback of FAT instead before.
> 
> Also bail out early when any stage of fsync fails.
> 
> Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx>
> ---
>  fs/fat/file.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/fat/file.c b/fs/fat/file.c
> index b3bed32946b1..0e3ed79fcc3f 100644
> --- a/fs/fat/file.c
> +++ b/fs/fat/file.c
> @@ -193,12 +193,17 @@ static int fat_file_release(struct inode *inode, struct file *filp)
>  int fat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
>  {
>  	struct inode *inode = filp->f_mapping->host;
> -	int res, err;
> +	int err;
> +
> +	err = __generic_file_fsync(filp, start, end, datasync);
> +	if (err)
> +		return err;
>  
> -	res = generic_file_fsync(filp, start, end, datasync);
>  	err = sync_mapping_buffers(MSDOS_SB(inode->i_sb)->fat_inode->i_mapping);

Huh.  I would've thought that flushing the FAT would also be required
at the end of a WB_SYNC_ALL (aka data integrity) writepages call?

The patch itself seems good, though.

--D

> +	if (err)
> +		return err;
>  
> -	return res ? res : err;
> +	return blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
>  }
>  
>  
> -- 
> 2.16.2.dirty
> 



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux