xfs-masters
[Top] [All Lists]

[PATCH] xfs: fix blkdev_issue_flush() failure handling

To: xfs-masters@xxxxxxxxxxx
Subject: [PATCH] xfs: fix blkdev_issue_flush() failure handling
From: Bartlomiej Zolnierkiewicz <bzolnier@xxxxxxxxx>
Date: Sun, 29 Mar 2009 19:31:03 +0200
Cc: linux-kernel@xxxxxxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:cc:mime-version:content-type:content-transfer-encoding :content-disposition:message-id; bh=A2pyKLbi0qylCk/AJc6kmTK7lLdpENo7KBronq0ZKjI=; b=SdYU4rLXYoDUCnuTQvEWPSFGhkveJ2DGs7G7YzMubF2sgOBEjx6R/tJZjHtR+U8gCL hGYiIsPvd4EB0HdEUveoLPXo4IsA6aQrmgLudxczZasm9CtAPkStHyGaPJuAksx+dUkQ y95wCSzmtwnuh7T6gilFLuLOOnjj0oWcT19/g=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:mime-version:content-type :content-transfer-encoding:content-disposition:message-id; b=kbp29FvDX3pdL46pCj07QjlviG7J+CLjDSbZEeLNulmimbm7ajo+KAKHmwWDn4ySqp FA1pXP4wIDhAETHGnJv3nE30IMRug+zevLIroNkEVS+iQ7dYSN5Yjcq1x4Tm0iEgB+sF vzUQgSMumvuKh1iDUOHTwHO+GnY8fd80aV8I8=
User-agent: KMail/1.11.1 (Linux/2.6.29-next-20090327-dirty; KDE/4.2.1; i686; ; )
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;

<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH] xfs: fix blkdev_issue_flush() failure handling, Bartlomiej Zolnierkiewicz <=