Received: by 10.223.176.46 with SMTP id f43csp275120wra; Tue, 23 Jan 2018 20:50:34 -0800 (PST) X-Google-Smtp-Source: AH8x226pPP4quc7Ls/icl+cX1kaQME79S4VQTJnDmqTNXEjj0KX+SwJUS+tPpBXQI5ug9oy5WCai X-Received: by 10.101.81.7 with SMTP id f7mr10006777pgq.431.1516769434758; Tue, 23 Jan 2018 20:50:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516769434; cv=none; d=google.com; s=arc-20160816; b=sm9ORRkQojRMsgJBCYfFnuDLIZkjhCCaLVW2mtPV/CYtHN3hlBtPNgjEt1sqlV67dZ SsSOxquu/S5nWxUFTV6MvLq2WlKb4iujDbLBC9RFzGTAId/bmMPQ4scx/xxVxJ3TnrWv VhQNepix9xI6rgOREBELGYXKDBSD99eSqBx+0vwyl92gDxptTe6d3wITgL0SyWO2gKIR IqQaPM+8g7s+rg8iCoiCYXBujLFqSq9km49WxwmN4IfeYLZ/FTzNAH4urt0EdrUSMp8T zYnNvsN9c6xJIQFN8lnkHK4KGmUsAWcpK+2HDOzvO7jHScCNghQjwi3ccHdGATdRrwf3 l1/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=aAwXXUzHToSZNmnwtGn6lcX+1IxlGaXCNvOb34/0laE=; b=tI6DlrqRVrY9+5mQCC8IEMVI4CyeDgJDx9m1ayzlZfCeI47eQ0oZg0DQhDPybV1814 +n5sE1+H2hxkPl973sdIiFDbrUZgvXRJ9gYlhjnhAcsK9oLhdyZWCrevDhlY6XFpdOXD vqzwR0Jom7dy/OiYbxiGrddMgtnk8R1DIM83k+SonQjJEqnn4Z8S6GX1Ka71nZ4KqJA8 y2mwcM2XjKMmRyPJLEtXNtNKh5tN6tfGPJGX7KZGV1IVbDqH814cW4MhNCqd3FsNwu9Z HiEplyXJqiAi5ejcFgPEUNP9zfngYeOY3L0TQDhxTfatInLkFLJHCJ9OjaX11kDZVvtv Jv8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=mLvkmxwz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6-v6si5554699plp.738.2018.01.23.20.50.21; Tue, 23 Jan 2018 20:50:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=mLvkmxwz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932863AbeAXEsd (ORCPT + 99 others); Tue, 23 Jan 2018 23:48:33 -0500 Received: from mail-sn1nam01on0109.outbound.protection.outlook.com ([104.47.32.109]:14147 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932519AbeAXEQI (ORCPT ); Tue, 23 Jan 2018 23:16:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=aAwXXUzHToSZNmnwtGn6lcX+1IxlGaXCNvOb34/0laE=; b=mLvkmxwz6cJ0ZSIm4lTl74f++1LzaXn6Gccr3oESzd9s8pqtFqx2dy7SfcbqAf8J2ibjkKhRwLIHSdqiRVmGXQdZ2dj7jncmzzbopeWB6z07IfuG3CCNy38/S3FaFJUp5N6gjoBT2bQWGLlceB5jlNO0wUFLClk5rnFFMld1FxY= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0727.namprd21.prod.outlook.com (10.167.110.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.464.1; Wed, 24 Jan 2018 04:16:05 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:16:05 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Carlos Maiolino , "Darrick J . Wong" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 089/100] xfs: Properly retry failed dquot items in case of error during buffer writeback Thread-Topic: [PATCH AUTOSEL for 4.14 089/100] xfs: Properly retry failed dquot items in case of error during buffer writeback Thread-Index: AQHTlMnttZqZz6IfWkqb56Mef57IXA== Date: Wed, 24 Jan 2018 04:15:11 +0000 Message-ID: <20180124041414.32065-89-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0727;7:jiiMq5fB3QyQ5RWkvB8Lprd8/vZ8RHp84N6owlsTbmNjcL2bWoHeHZR/WlQteLVB8iW7dnLiGZLyMgk/tF34j/mnU72SGA7rn7ONTRMTS5cH5TsyzvxWaktq08jzB9r0hmHxaMGrpAggBydKc2z1zR4J9bJkZWiH3I/M1mnEYJ2RJF26A+LZfRDJd3cF0bMb4D/8mxCoF8BG02lvXnEk/H9yDzixiYTBEjn83Cmr+U11venFfJ2V0+NWQNTD4tcl x-ms-office365-filtering-correlation-id: cebcf455-d8e6-4912-e6f2-08d562e13011 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB0727; x-ms-traffictypediagnostic: DM5PR2101MB0727: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(20558992708506)(89211679590171)(146099531331640); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231046)(2400081)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB0727;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0727; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(396003)(366004)(39380400002)(39860400002)(376002)(189003)(199004)(86612001)(6506007)(106356001)(76176011)(59450400001)(6346003)(54906003)(86362001)(2501003)(110136005)(1076002)(7736002)(5250100002)(3660700001)(316002)(26005)(102836004)(2950100002)(6666003)(99286004)(97736004)(22452003)(107886003)(6436002)(53936002)(478600001)(66066001)(14454004)(2900100001)(6512007)(2906002)(5660300001)(8936002)(4326008)(10290500003)(305945005)(10090500001)(68736007)(25786009)(81166006)(72206003)(36756003)(8676002)(81156014)(3846002)(6116002)(3280700002)(105586002)(6486002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0727;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: foQ3bcf3mn3xJTAaz7hyVqugnVjAzCUp4hDp3y7vxLr409QrpM/BpMusuRu7h/9gwcRrOUBEa1IrOt++DZxslA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: cebcf455-d8e6-4912-e6f2-08d562e13011 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:15:11.5892 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0727 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Carlos Maiolino [ Upstream commit 373b0589dc8d58bc09c9a28d03611ae4fb216057 ] Once the inode item writeback errors is already fixed, it's time to fix the= same problem in dquot code. Although there were no reports of users hitting this bug in dquot code (at = least none I've seen), the bug is there and I was already planning to fix it when= the correct approach to fix the inodes part was decided. This patch aims to fix the same problem in dquot code, regarding failed buf= fers being unable to be resubmitted once they are flush locked. Tested with the recently test-case sent to fstests list by Hou Tao. Reviewed-by: Brian Foster Signed-off-by: Carlos Maiolino Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Sasha Levin --- fs/xfs/xfs_dquot.c | 14 +++++++++++--- fs/xfs/xfs_dquot_item.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index cd82429d8df7..5a86495127fd 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -987,14 +987,22 @@ xfs_qm_dqflush_done( * holding the lock before removing the dquot from the AIL. */ if ((lip->li_flags & XFS_LI_IN_AIL) && - lip->li_lsn =3D=3D qip->qli_flush_lsn) { + ((lip->li_lsn =3D=3D qip->qli_flush_lsn) || + (lip->li_flags & XFS_LI_FAILED))) { =20 /* xfs_trans_ail_delete() drops the AIL lock. */ spin_lock(&ailp->xa_lock); - if (lip->li_lsn =3D=3D qip->qli_flush_lsn) + if (lip->li_lsn =3D=3D qip->qli_flush_lsn) { xfs_trans_ail_delete(ailp, lip, SHUTDOWN_CORRUPT_INCORE); - else + } else { + /* + * Clear the failed state since we are about to drop the + * flush lock + */ + if (lip->li_flags & XFS_LI_FAILED) + xfs_clear_li_failed(lip); spin_unlock(&ailp->xa_lock); + } } =20 /* diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c index 2c7a1629e064..664dea105e76 100644 --- a/fs/xfs/xfs_dquot_item.c +++ b/fs/xfs/xfs_dquot_item.c @@ -137,6 +137,26 @@ xfs_qm_dqunpin_wait( wait_event(dqp->q_pinwait, (atomic_read(&dqp->q_pincount) =3D=3D 0)); } =20 +/* + * Callback used to mark a buffer with XFS_LI_FAILED when items in the buf= fer + * have been failed during writeback + * + * this informs the AIL that the dquot is already flush locked on the next= push, + * and acquires a hold on the buffer to ensure that it isn't reclaimed bef= ore + * dirty data makes it to disk. + */ +STATIC void +xfs_dquot_item_error( + struct xfs_log_item *lip, + struct xfs_buf *bp) +{ + struct xfs_dquot *dqp; + + dqp =3D DQUOT_ITEM(lip)->qli_dquot; + ASSERT(!completion_done(&dqp->q_flush)); + xfs_set_li_failed(lip, bp); +} + STATIC uint xfs_qm_dquot_logitem_push( struct xfs_log_item *lip, @@ -144,13 +164,28 @@ xfs_qm_dquot_logitem_push( __acquires(&lip->li_ailp->xa_lock) { struct xfs_dquot *dqp =3D DQUOT_ITEM(lip)->qli_dquot; - struct xfs_buf *bp =3D NULL; + struct xfs_buf *bp =3D lip->li_buf; uint rval =3D XFS_ITEM_SUCCESS; int error; =20 if (atomic_read(&dqp->q_pincount) > 0) return XFS_ITEM_PINNED; =20 + /* + * The buffer containing this item failed to be written back + * previously. Resubmit the buffer for IO + */ + if (lip->li_flags & XFS_LI_FAILED) { + if (!xfs_buf_trylock(bp)) + return XFS_ITEM_LOCKED; + + if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list)) + rval =3D XFS_ITEM_FLUSHING; + + xfs_buf_unlock(bp); + return rval; + } + if (!xfs_dqlock_nowait(dqp)) return XFS_ITEM_LOCKED; =20 @@ -242,7 +277,8 @@ static const struct xfs_item_ops xfs_dquot_item_ops =3D= { .iop_unlock =3D xfs_qm_dquot_logitem_unlock, .iop_committed =3D xfs_qm_dquot_logitem_committed, .iop_push =3D xfs_qm_dquot_logitem_push, - .iop_committing =3D xfs_qm_dquot_logitem_committing + .iop_committing =3D xfs_qm_dquot_logitem_committing, + .iop_error =3D xfs_dquot_item_error }; =20 /* --=20 2.11.0