* [PATCH] fat: issue flush after the writeback of FAT
@ 2019-04-09 3:01 Hou Tao
2019-04-09 3:41 ` Darrick J. Wong
2019-04-09 5:16 ` OGAWA Hirofumi
0 siblings, 2 replies; 4+ messages in thread
From: Hou Tao @ 2019-04-09 3:01 UTC (permalink / raw)
To: hirofumi; +Cc: linux-fsdevel, viro, jack, linux-kernel
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@huawei.com>
---
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);
+ if (err)
+ return err;
- return res ? res : err;
+ return blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
}
--
2.16.2.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] fat: issue flush after the writeback of FAT
2019-04-09 3:01 [PATCH] fat: issue flush after the writeback of FAT Hou Tao
@ 2019-04-09 3:41 ` Darrick J. Wong
2019-04-09 5:22 ` OGAWA Hirofumi
2019-04-09 5:16 ` OGAWA Hirofumi
1 sibling, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2019-04-09 3:41 UTC (permalink / raw)
To: Hou Tao; +Cc: hirofumi, linux-fsdevel, viro, jack, linux-kernel
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@huawei.com>
> ---
> 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fat: issue flush after the writeback of FAT
2019-04-09 3:01 [PATCH] fat: issue flush after the writeback of FAT Hou Tao
2019-04-09 3:41 ` Darrick J. Wong
@ 2019-04-09 5:16 ` OGAWA Hirofumi
1 sibling, 0 replies; 4+ messages in thread
From: OGAWA Hirofumi @ 2019-04-09 5:16 UTC (permalink / raw)
To: Hou Tao; +Cc: linux-fsdevel, viro, jack, linux-kernel, Andrew Morton
Hou Tao <houtao1@huawei.com> writes:
> 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@huawei.com>
Looks good.
Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
> ---
> 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);
> + if (err)
> + return err;
>
> - return res ? res : err;
> + return blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
> }
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fat: issue flush after the writeback of FAT
2019-04-09 3:41 ` Darrick J. Wong
@ 2019-04-09 5:22 ` OGAWA Hirofumi
0 siblings, 0 replies; 4+ messages in thread
From: OGAWA Hirofumi @ 2019-04-09 5:22 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Hou Tao, linux-fsdevel, viro, jack, linux-kernel
"Darrick J. Wong" <darrick.wong@oracle.com> writes:
>> + 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?
In fatfs implement, FAT area is flushed by sync_mapping_buffers(fat_inode).
(FAT buffer is dirtied only by using bh->b_assoc_map to fat_inode)
Thanks.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-09 5:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-09 3:01 [PATCH] fat: issue flush after the writeback of FAT Hou Tao
2019-04-09 3:41 ` Darrick J. Wong
2019-04-09 5:22 ` OGAWA Hirofumi
2019-04-09 5:16 ` OGAWA Hirofumi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).