xfs: fix blkdev_issue_flush() failure handling
PATCH 1/1 xfs: fix blkdev_issue_flush() failure handling
blkdev_issue_flush() may fail (i.e. due to media error on FLUSH CACHE command execution) so its users should check for the return value.
Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>
--- fs/xfs/linux-2.6/xfs_buf.c | 1 + fs/xfs/linux-2.6/xfs_super.c | 4 ++-- fs/xfs/linux-2.6/xfs_super.h | 2 +- fs/xfs/xfs_vnodeops.c | 19 +++++++++++++++---- 4 files changed, 19 insertions(+), 7 deletions(-)
fs/xfs/linux-2.6/xfs_buf.c +1 -0
@@ -1446,6 +1446,7 @@ xfs_free_buftarg( {xfs_flush_buftarg (btp,1 );if (mp->m_flags &XFS_MOUNT_BARRIER ) +/* FIXME: check return value */ xfs_blkdev_issue_flush (btp);xfs_free_bufhash (btp);iput (btp->bt_mapping->host);
fs/xfs/linux-2.6/xfs_super.c +2 -2
@@ -721,11 +721,11 @@ xfs_mountfs_check_barriers(xfs_mount_t * } } -void +int xfs_blkdev_issue_flush (xfs_buftarg_t *buftarg) { -blkdev_issue_flush (buftarg->bt_bdev,NULL ); +return blkdev_issue_flush (buftarg->bt_bdev,NULL ); }STATIC void
fs/xfs/linux-2.6/xfs_super.h +1 -1
@@ -89,7 +89,7 @@ struct block_device;extern __uint64_t xfs_max_file_offset (unsigned int ); -extern void xfs_blkdev_issue_flush (struct xfs_buftarg *); +extern int xfs_blkdev_issue_flush (struct xfs_buftarg *);extern const struct export_operations xfs_export_operations;extern struct xattr_handler *xfs_xattr_handlers[];
fs/xfs/xfs_vnodeops.c +15 -4
@@ -597,6 +597,7 @@ xfs_fsync(xfs_trans_t *tp;int error;int log_flushed =0 , changed =1 ; +int tmp_ret;xfs_itrace_entry (ip);
@@ -679,19 +680,29 @@ xfs_fsync( }if ((ip->i_mount->m_flags &XFS_MOUNT_BARRIER ) && changed) { +xfs_buftarg_t *btp; +/* * If the log write didn't issue an ordered tag we need * to flush the disk cache for the data device now. */ -if (!log_flushed) -xfs_blkdev_issue_flush (ip->i_mount->m_ddev_targp); +if (!log_flushed) { + btp = ip->i_mount->m_ddev_targp; + tmp_ret =xfs_blkdev_issue_flush (btp); +if (error ==0 && tmp_ret <0 && tmp_ret != -EOPNOTSUPP ) + error = tmp_ret; + }/* * If this inode is on the RT dev we need to flush that * cache as well. */ -if (XFS_IS_REALTIME_INODE (ip)) -xfs_blkdev_issue_flush (ip->i_mount->m_rtdev_targp); +if (XFS_IS_REALTIME_INODE (ip)) { + btp = ip->i_mount->m_rtdev_targp; + tmp_ret =xfs_blkdev_issue_flush (btp); +if (error ==0 && tmp_ret <0 && tmp_ret != -EOPNOTSUPP ) + error = tmp_ret; + } }return error;