From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-901460-1516769343-2-7513145835920573210 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.25, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='US', FromHeader='com', MailFrom='org', XOriginatingCountry='US' X-Spam-charsets: plain='iso-8859-1' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1516769342; b=fRqbWCf+9/j3OyH11fip2nGt/FT29C/vpDf3jM+aNPOAQmb 5HfCa1hDBY2c78AJRtdNOZynifEbao486At/IBHK6FLG1fewC3kvkxQSC5Tjq8xm b4Aa0yTlNJvQPuca/9KK3v//EacTZ0k083LG4V2diFycZWga71ePBWkXmQXnI8+z /ZntBX20SQxWM+1n/z5RU7v4dyExStE5m2zBBiE+DCkVP828nB2PsJA39wTDaGGv jek0FCX7nq0Mk7FfR7kov/qD9cbH8wA4J2zeIR/hRdjPUNxXv51nk7Dwxo98PfZ6 ZGtfykp1yFZT7LIterzkVbX2iI7IWvkHZXZwGow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=from:to:cc:subject:date:message-id :references:in-reply-to:content-type:content-transfer-encoding :mime-version:sender:list-id; s=arctest; t=1516769342; bh=aAwXXU zHToSZNmnwtGn6lcX+1IxlGaXCNvOb34/0laE=; b=WsoFoS5S0HChSPhWT5+jWK A0bugr9opCpZYahBfxjrdNvWe9SckM/sUP+px1bBmcwvefpEp5aZARJCH/3k5mua eXeKmg2XhIgVZ0GBHXX2pzoIaWIhVXeEglUXX+YojWzzzyf4Nk5MoAs/IE8+nwci atMgSp4+xrEOkqe+BKuybBNDm572q8IymVkk9gLX3gP5JPwO3BHMAiWMJ9zNjd9O UnJODjmza3ECkE0/4wEeB5iNvH8NHTeS4vKsIkuxyST1/Jj1TVtuqPFWcTm7ohHI gpI4qobPCyHgvuDGsSSPGmW9MiMafcY7F18ZQevULTQbxWpP1oh7B3gqX4FGv1+w == ARC-Authentication-Results: i=1; mx3.messagingengine.com; arc=none (no signatures found); dkim=pass (1024-bit rsa key sha256) header.d=microsoft.com header.i=@microsoft.com header.b=mLvkmxwz x-bits=1024 x-keytype=rsa x-algorithm=sha256 x-selector=selector1; dmarc=pass (p=reject,has-list-id=yes,d=none) header.from=microsoft.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=microsoft.com header.result=pass header_is_org_domain=yes Authentication-Results: mx3.messagingengine.com; arc=none (no signatures found); dkim=pass (1024-bit rsa key sha256) header.d=microsoft.com header.i=@microsoft.com header.b=mLvkmxwz x-bits=1024 x-keytype=rsa x-algorithm=sha256 x-selector=selector1; dmarc=pass (p=reject,has-list-id=yes,d=none) header.from=microsoft.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=microsoft.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932520AbeAXEsb (ORCPT ); Tue, 23 Jan 2018 23:48:31 -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 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; 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: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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