All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhaohongjiang <zhaohongjiang@huawei.com>
To: david@fromorbit.com, hch@infradead.org
Cc: xfs@oss.sgi.com
Subject: [PATCH] cancel the setfilesize transation when io error happen
Date: Thu, 10 Sep 2015 09:40:10 +0800	[thread overview]
Message-ID: <55F0DF7A.7050404@huawei.com> (raw)

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

Signed-off-by: Zhao Hongjiang <zhaohongjiang@huawei.com>
---
 fs/xfs/xfs_aops.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 50ab287..fab55da 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -212,8 +212,21 @@ xfs_end_io(
 		ioend->io_error = -EIO;
 		goto done;
 	}
-	if (ioend->io_error)
+	if (ioend->io_error) {
+		/*
+		 * We should cancel the setfilesize transation when io error
+		 * happen.
+		 */
+		if (ioend->io_append_trans) {
+			current_set_flags_nested(&ioend->io_append_trans->t_pflags,
+								PF_FSTRANS);
+			rwsem_acquire_read(&VFS_I(XFS_I(ioend->io_inode))->i_sb
+				->s_writers.lock_map[SB_FREEZE_FS-1], 0, 1, _THIS_IP_);
+			xfs_trans_cancel(ioend->io_append_trans);			
+		}
+
 		goto done;
+	}

 	/*
 	 * For unwritten extents we need to issue transactions to convert a
-- 
1.8.3.1
-- 
version="9"
logging="no"

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

             reply	other threads:[~2015-09-10  1:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-10  1:40 Zhaohongjiang [this message]
2015-09-15 11:42 ` [PATCH] cancel the setfilesize transation when io error happen Brian Foster
2015-10-12  4:28   ` Dave Chinner

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=55F0DF7A.7050404@huawei.com \
    --to=zhaohongjiang@huawei.com \
    --cc=david@fromorbit.com \
    --cc=hch@infradead.org \
    --cc=xfs@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.