All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: xfs-masters@oss.sgi.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] xfs: fix blkdev_issue_flush() failure handling
Date: Sun, 29 Mar 2009 19:31:03 +0200	[thread overview]
Message-ID: <200903291931.03775.bzolnier@gmail.com> (raw)

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@gmail.com>
---
 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;

                 reply	other threads:[~2009-03-29 17:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200903291931.03775.bzolnier@gmail.com \
    --to=bzolnier@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xfs-masters@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.