]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.18
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Mar 2017 15:12:23 +0000 (16:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Mar 2017 15:12:23 +0000 (16:12 +0100)
queue-3.18/cancel-the-setfilesize-transation-when-io-error-happen.patch [new file with mode: 0644]
queue-3.18/series

diff --git a/queue-3.18/cancel-the-setfilesize-transation-when-io-error-happen.patch b/queue-3.18/cancel-the-setfilesize-transation-when-io-error-happen.patch
new file mode 100644 (file)
index 0000000..937f9e5
--- /dev/null
@@ -0,0 +1,71 @@
+From 5cb13dcd0fac071b45c4bebe1801a08ff0d89cad Mon Sep 17 00:00:00 2001
+From: Zhaohongjiang <zhaohongjiang@huawei.com>
+Date: Mon, 12 Oct 2015 15:28:39 +1100
+Subject: cancel the setfilesize transation when io error happen
+
+From: Zhaohongjiang <zhaohongjiang@huawei.com>
+
+commit 5cb13dcd0fac071b45c4bebe1801a08ff0d89cad upstream.
+
+When I ran xfstest/073 case, the remount process was blocked to wait
+transactions to be zero. I found there was a io error happened, and
+the setfilesize transaction was not released properly. We should add
+the changes to cancel the io error in this case.
+
+Reproduction steps:
+1. dd if=/dev/zero of=xfs1.img bs=1M count=2048
+2. mkfs.xfs xfs1.img
+3. losetup -f ./xfs1.img /dev/loop0
+4. mount -t xfs /dev/loop0 /home/test_dir/
+5. mkdir /home/test_dir/test
+6. mkfs.xfs -dfile,name=image,size=2g
+7. mount -t xfs -o loop image /home/test_dir/test
+8. cp a file bigger than 2g to /home/test_dir/test
+9. mount -t xfs -o remount,ro /home/test_dir/test
+
+[ dchinner: moved io error detection to xfs_setfilesize_ioend() after
+  transaction context restoration. ]
+
+Signed-off-by: Zhao Hongjiang <zhaohongjiang@huawei.com>
+Signed-off-by: Dave Chinner <david@fromorbit.com>
+Signed-off-by: Nikolay Borisov <nborisov@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/xfs/xfs_aops.c |   13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+--- a/fs/xfs/xfs_aops.c
++++ b/fs/xfs/xfs_aops.c
+@@ -153,6 +153,12 @@ xfs_setfilesize(
+       rwsem_acquire_read(&VFS_I(ip)->i_sb->s_writers.lock_map[SB_FREEZE_FS-1],
+                          0, 1, _THIS_IP_);
++      /* we abort the update if there was an IO error */
++      if (ioend->io_error) {
++              xfs_trans_cancel(tp, 0);
++              return ioend->io_error;
++      }
++
+       xfs_ilock(ip, XFS_ILOCK_EXCL);
+       isize = xfs_new_eof(ip, ioend->io_offset + ioend->io_size);
+       if (!isize) {
+@@ -208,14 +214,17 @@ xfs_end_io(
+               ioend->io_error = -EIO;
+               goto done;
+       }
+-      if (ioend->io_error)
+-              goto done;
+       /*
+        * For unwritten extents we need to issue transactions to convert a
+        * range to normal written extens after the data I/O has finished.
++       * Detecting and handling completion IO errors is done individually
++       * for each case as different cleanup operations need to be performed
++       * on error.
+        */
+       if (ioend->io_type == XFS_IO_UNWRITTEN) {
++              if (ioend->io_error)
++                      goto done;
+               error = xfs_iomap_write_unwritten(ip, ioend->io_offset,
+                                                 ioend->io_size);
+       } else if (ioend->io_isdirect && xfs_ioend_is_append(ioend)) {
index cc3bb708bc38586ad501096d95999cf2fdd6df12..95b84b800a5f92437384531b8187d27b1fc645f4 100644 (file)
@@ -60,3 +60,4 @@ net-socket-fix-recvmmsg-not-returning-error-from-sock_error.patch
 lib-vsprintf.c-improve-sanity-check-in-vsnprintf.patch
 tty-n_hdlc-fix-lockdep-false-positive.patch
 tty-n_hdlc-get-rid-of-racy-n_hdlc.tbuf.patch
+cancel-the-setfilesize-transation-when-io-error-happen.patch