[PATCH] xfs: fix blkdev_issue_flush() failure handling

From: Bartlomiej Zolnierkiewicz
Date: Sun Mar 29 2009 - 13:31:11 EST


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 <bzolnier@xxxxxxxxx>
---
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(-)

Index: b/fs/xfs/linux-2.6/xfs_buf.c
===================================================================
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -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);
Index: b/fs/xfs/linux-2.6/xfs_super.c
===================================================================
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -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
Index: b/fs/xfs/linux-2.6/xfs_super.h
===================================================================
--- a/fs/xfs/linux-2.6/xfs_super.h
+++ b/fs/xfs/linux-2.6/xfs_super.h
@@ -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[];
Index: b/fs/xfs/xfs_vnodeops.c
===================================================================
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/