From patchwork Thu Mar 23 15:19:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 9641469 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4B15B602CA for ; Thu, 23 Mar 2017 15:20:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 378EC26E91 for ; Thu, 23 Mar 2017 15:20:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A3032766D; Thu, 23 Mar 2017 15:20:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA12026E91 for ; Thu, 23 Mar 2017 15:20:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935244AbdCWPUI (ORCPT ); Thu, 23 Mar 2017 11:20:08 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:34554 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932449AbdCWPUG (ORCPT ); Thu, 23 Mar 2017 11:20:06 -0400 Received: by mail-wr0-f194.google.com with SMTP id y90so7858141wrb.1; Thu, 23 Mar 2017 08:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version; bh=Hv5OX3/7ZmLFGNYKAzfQwNLgiVUtMQLTAC15pN7e8oo=; b=OgQFSZBjDsK4U5Xw8v3kIIRPANp9fLf5Ur/4FGfROpT6rE19JTdls3pXWYFhlY4lmE iDTmyZsP23MuRJTQ6e2UExVD2EP5ngdQtK8XCX52oJ1vKOtO4BLE2jOUa6CZCGaWY3a6 DRVJHILY2XV5nwki+9di0MJiSk/llS77rCI+x+SPVpGMcKaqcv9Lb9xa7EPoo/13t8g0 7jO8eq8SQfAoQ6u4dbFN8VYBuzHbfA51ctLa3/7hop4OdEJQ7mmizKY9i3dnjxb28fmu qMiAdas6Esim+sitkrfVN5hdWBHpEcpD7NElzNXIFYqKfx0GYSpYr9F8tYihuT6HAoIC ZKig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version; bh=Hv5OX3/7ZmLFGNYKAzfQwNLgiVUtMQLTAC15pN7e8oo=; b=bdfIDUtNZM1qxxcfeuGfOoWft4zfn06LSV0Qimw+dADuWmKXShIFnFVuhKRC8gJpTA GDWRZFt79n78cH7iWJY7zvo1QQqO1ade0CFTRLgnsyBWueMXaxr1SuvhZKwmR5pUwJ6B N35sXXRps1EIVZOEx0hXvMb9wqEr8sGZTaMRdFYl/0lxQEYjqIdBJkd669iaRcEdg20+ EvfZOatnyLVsY6zyrQvomhq/8USUwiyBg86onNsek5MluWMdMMpHESa8YoFWn1ylAH7C 2tY1vSATcIQ4HGF+6u0GDDKe4QtODPEr1+nqVjYC7SdmWKo8+Ra++lUQaWerrSkLWhC0 gt+g== X-Gm-Message-State: AFeK/H0qWUNDAAD7qpMA75DRcz7QJnRMHiDIoGAVF9jTNMuDWvQ3DcGMs7GlZhxcGRw2hw== X-Received: by 10.223.142.23 with SMTP id n23mr2295822wrb.145.1490282399243; Thu, 23 Mar 2017 08:19:59 -0700 (PDT) Received: from [10.20.1.207] (ivokamhome.ddns.nbis.net. [87.120.136.31]) by smtp.gmail.com with ESMTPSA id 127sm4718194wmt.20.2017.03.23.08.19.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Mar 2017 08:19:58 -0700 (PDT) To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org, darrick.wong@oracle.com, bfoster@redhat.com, david@fromorbit.com From: Nikolay Borisov Subject: Request 5c6863019e45 ("cancel the setfilesize transation when io error happen") for 3.12 stable inclusion Message-ID: <48c85015-5520-bd42-dca7-cfb9634dcc39@gmail.com> Date: Thu, 23 Mar 2017 17:19:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello, I'd like to request the above patch be included into the 3.12 stable tree. I've attached a backport and have run xfstest and no regressions were observed. This fixes hang in generic/361 test. Regards, Nikolay Reviewed-by: Christoph Hellwig From 5c6863019e453bee3ac6dbdf1fbf0d9125942c3b Mon Sep 17 00:00:00 2001 From: Zhaohongjiang Date: Mon, 12 Oct 2015 15:28:39 +1100 Subject: [PATCH] cancel the setfilesize transation when io error happen 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. ] [ nborisov: Adjusted context for 3.12 ] Signed-off-by: Zhao Hongjiang Signed-off-by: Dave Chinner Signed-off-by: Nikolay Borisov --- fs/xfs/xfs_aops.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index ab28ad576b16..6394e3f51553 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -150,6 +150,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) { @@ -205,14 +211,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)) { -- 2.7.4