Skip to content

Commit

Permalink
fs: convert a pile of fsync routines to errseq_t based reporting
Browse files Browse the repository at this point in the history
This patch converts most of the in-kernel filesystems that do writeback
out of the pagecache to report errors using the errseq_t-based
infrastructure that was recently added. This allows them to report
errors once for each open file description.

Most filesystems have a fairly straightforward fsync operation. They
call filemap_write_and_wait_range to write back all of the data and
wait on it, and then (sometimes) sync out the metadata.

For those filesystems this is a straightforward conversion from calling
filemap_write_and_wait_range in their fsync operation to calling
file_write_and_wait_range.

Acked-by: Jan Kara <[email protected]>
Acked-by: Dave Kleikamp <[email protected]>
Signed-off-by: Jeff Layton <[email protected]>
  • Loading branch information
jtlayton committed Aug 1, 2017
1 parent d07a6ac commit 3b49c9a
Show file tree
Hide file tree
Showing 22 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@ static int spufs_mfc_flush(struct file *file, fl_owner_t id)
static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int datasync)
{
struct inode *inode = file_inode(file);
int err = filemap_write_and_wait_range(inode->i_mapping, start, end);
int err = file_write_and_wait_range(file, start, end);
if (!err) {
inode_lock(inode);
err = spufs_mfc_flush(file, NULL);
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/lustre/lustre/llite/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2364,7 +2364,7 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
PFID(ll_inode2fid(inode)), inode);
ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_FSYNC, 1);

rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
rc = file_write_and_wait_range(file, start, end);
inode_lock(inode);

/* catch async errors that were recorded back when async writeback
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/core/fb_defio.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int fb_deferred_io_fsync(struct file *file, loff_t start, loff_t end, int datasy
{
struct fb_info *info = file->private_data;
struct inode *inode = file_inode(file);
int err = filemap_write_and_wait_range(inode->i_mapping, start, end);
int err = file_write_and_wait_range(file, start, end);
if (err)
return err;

Expand Down
4 changes: 2 additions & 2 deletions fs/9p/vfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ static int v9fs_file_fsync(struct file *filp, loff_t start, loff_t end,
struct p9_wstat wstat;
int retval;

retval = filemap_write_and_wait_range(inode->i_mapping, start, end);
retval = file_write_and_wait_range(filp, start, end);
if (retval)
return retval;

Expand All @@ -468,7 +468,7 @@ int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
struct inode *inode = filp->f_mapping->host;
int retval;

retval = filemap_write_and_wait_range(inode->i_mapping, start, end);
retval = file_write_and_wait_range(filp, start, end);
if (retval)
return retval;

Expand Down
2 changes: 1 addition & 1 deletion fs/affs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ int affs_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
struct inode *inode = filp->f_mapping->host;
int ret, err;

err = filemap_write_and_wait_range(inode->i_mapping, start, end);
err = file_write_and_wait_range(filp, start, end);
if (err)
return err;

Expand Down
2 changes: 1 addition & 1 deletion fs/afs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ int afs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
vnode->fid.vid, vnode->fid.vnode, file,
datasync);

ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
ret = file_write_and_wait_range(file, start, end);
if (ret)
return ret;
inode_lock(inode);
Expand Down
4 changes: 2 additions & 2 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2329,7 +2329,7 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
struct inode *inode = file_inode(file);
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);

rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
rc = file_write_and_wait_range(file, start, end);
if (rc)
return rc;
inode_lock(inode);
Expand Down Expand Up @@ -2371,7 +2371,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
struct inode *inode = file->f_mapping->host;

rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
rc = file_write_and_wait_range(file, start, end);
if (rc)
return rc;
inode_lock(inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/exofs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static int exofs_file_fsync(struct file *filp, loff_t start, loff_t end,
struct inode *inode = filp->f_mapping->host;
int ret;

ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
ret = file_write_and_wait_range(filp, start, end);
if (ret)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion fs/f2fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
/* if fdatasync is triggered, let's do in-place-update */
if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)
set_inode_flag(inode, FI_NEED_IPU);
ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
ret = file_write_and_wait_range(file, start, end);
clear_inode_flag(inode, FI_NEED_IPU);

if (ret) {
Expand Down
2 changes: 1 addition & 1 deletion fs/hfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ static int hfs_file_fsync(struct file *filp, loff_t start, loff_t end,
struct super_block * sb;
int ret, err;

ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
ret = file_write_and_wait_range(filp, start, end);
if (ret)
return ret;
inode_lock(inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/hfsplus/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
int error = 0, error2;

error = filemap_write_and_wait_range(inode->i_mapping, start, end);
error = file_write_and_wait_range(file, start, end);
if (error)
return error;
inode_lock(inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/hostfs/hostfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ static int hostfs_fsync(struct file *file, loff_t start, loff_t end,
struct inode *inode = file->f_mapping->host;
int ret;

ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
ret = file_write_and_wait_range(file, start, end);
if (ret)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion fs/hpfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int hpfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
struct inode *inode = file->f_mapping->host;
int ret;

ret = filemap_write_and_wait_range(file->f_mapping, start, end);
ret = file_write_and_wait_range(file, start, end);
if (ret)
return ret;
return sync_blockdev(inode->i_sb->s_bdev);
Expand Down
2 changes: 1 addition & 1 deletion fs/jffs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
int ret;

ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
ret = file_write_and_wait_range(filp, start, end);
if (ret)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int jfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
struct inode *inode = file->f_mapping->host;
int rc = 0;

rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
rc = file_write_and_wait_range(file, start, end);
if (rc)
return rc;

Expand Down
2 changes: 1 addition & 1 deletion fs/ncpfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

static int ncp_fsync(struct file *file, loff_t start, loff_t end, int datasync)
{
return filemap_write_and_wait_range(file->f_mapping, start, end);
return file_write_and_wait_range(file, start, end);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion fs/ntfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ static int ntfs_dir_fsync(struct file *filp, loff_t start, loff_t end,

ntfs_debug("Entering for inode 0x%lx.", vi->i_ino);

err = filemap_write_and_wait_range(vi->i_mapping, start, end);
err = file_write_and_wait_range(filp, start, end);
if (err)
return err;
inode_lock(vi);
Expand Down
2 changes: 1 addition & 1 deletion fs/ntfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1989,7 +1989,7 @@ static int ntfs_file_fsync(struct file *filp, loff_t start, loff_t end,

ntfs_debug("Entering for inode 0x%lx.", vi->i_ino);

err = filemap_write_and_wait_range(vi->i_mapping, start, end);
err = file_write_and_wait_range(filp, start, end);
if (err)
return err;
inode_lock(vi);
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static int ocfs2_sync_file(struct file *file, loff_t start, loff_t end,
if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
return -EROFS;

err = filemap_write_and_wait_range(inode->i_mapping, start, end);
err = file_write_and_wait_range(file, start, end);
if (err)
return err;

Expand Down
2 changes: 1 addition & 1 deletion fs/reiserfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
struct inode *inode = filp->f_mapping->host;
int err;

err = filemap_write_and_wait_range(inode->i_mapping, start, end);
err = file_write_and_wait_range(filp, start, end);
if (err)
return err;

Expand Down
2 changes: 1 addition & 1 deletion fs/reiserfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static int reiserfs_sync_file(struct file *filp, loff_t start, loff_t end,
int err;
int barrier_done;

err = filemap_write_and_wait_range(inode->i_mapping, start, end);
err = file_write_and_wait_range(filp, start, end);
if (err)
return err;

Expand Down
2 changes: 1 addition & 1 deletion fs/ubifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
*/
return 0;

err = filemap_write_and_wait_range(inode->i_mapping, start, end);
err = file_write_and_wait_range(file, start, end);
if (err)
return err;
inode_lock(inode);
Expand Down

0 comments on commit 3b49c9a

Please sign in to comment.