Received: by 10.223.176.5 with SMTP id f5csp1130522wra; Fri, 2 Feb 2018 11:43:43 -0800 (PST) X-Google-Smtp-Source: AH8x2255HLQMqOxcx/+ul9I0LbNlxILG7BRrZ2XUnuMs9J5IPN7QGTmpVyK2QnkBGLVXvHJXRQer X-Received: by 10.101.73.203 with SMTP id t11mr32941473pgs.48.1517600622995; Fri, 02 Feb 2018 11:43:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517600622; cv=none; d=google.com; s=arc-20160816; b=HIAfTra4YwsoQ6zsEQ8Zs+c2eijOiJG0qAUGGl8V+MlPsvSXVtKR+DJvCGZ+xEjET0 7+niL87/z6OziuSArTYw29n5D5JT+frqPd/iXIl/gfSuwz+s/X3yNSGHc7oODfRDd8hq 1Hggi4XyAP1NMwlnZGnPor8NQuNbD/7P7QpzytuS8PXHnMtXvCiaYWC7bhUIX6s66L7l l/bWJCIfE81ZJgeocEVgapjKrflrkQvGeiXi4d2Qqg9WRbLuHgkp2Ui4exFSCY6Yd4Es fN/3U2kQXek8Cn77oJa1phcY28HGjsw7yzI7wgn0uYvbIJxWE73+AzNNHir4OzyJXCIw 1KIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=bDjprRWQX6VVRnAfHC3gGMMsgPL5H0LhG8+NO5fs7UA=; b=YfIqYPMDyMm2hcj+X9V3kKL0Kkc9rfXsiV8TK1y4r+A4wMUgXl7sHXRrloe+9hbSgF BolhnWhhtQTEbPNFSK4aH8n++4+e5f9BjatEwbEl6MrQvEVe+AGq7SX3AtYFnapDXuuW tnutHzaUtfdS639ltMsJBdMaWzG+7bglFaQP/D0CQyShxRT3Ym9e3vp9TpdKshNHWGq8 VFxXRO7bl5/Bo4xumveMAlIU4Q1tC0mhhnMisTBUNRYwfplM/LsG6k0XUf0/kkEEr+8x QxZGkdJv0TKvcX0NSLaMM6QVXsv5QpqYN5wEqWT9EPQVJ/UnrIWDBgf7742//JoM/nzL 6xzg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b21si2333270pfc.232.2018.02.02.11.43.28; Fri, 02 Feb 2018 11:43:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754015AbeBBSQI (ORCPT + 99 others); Fri, 2 Feb 2018 13:16:08 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36486 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752700AbeBBRF2 (ORCPT ); Fri, 2 Feb 2018 12:05:28 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 729B3E20; Fri, 2 Feb 2018 17:05:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Foster , Carlos Maiolino , "Darrick J. Wong" , Sasha Levin Subject: [PATCH 4.9 62/86] xfs: Properly retry failed dquot items in case of error during buffer writeback Date: Fri, 2 Feb 2018 17:58:22 +0100 Message-Id: <20180202140828.290630135@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140822.679101338@linuxfoundation.org> References: <20180202140822.679101338@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ 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 buffers 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 Signed-off-by: Greg Kroah-Hartman --- fs/xfs/xfs_dquot.c | 14 +++++++++++--- fs/xfs/xfs_dquot_item.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 5 deletions(-) --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -1004,14 +1004,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 == qip->qli_flush_lsn) { + ((lip->li_lsn == qip->qli_flush_lsn) || + (lip->li_flags & XFS_LI_FAILED))) { /* xfs_trans_ail_delete() drops the AIL lock. */ spin_lock(&ailp->xa_lock); - if (lip->li_lsn == qip->qli_flush_lsn) + if (lip->li_lsn == 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); + } } /* --- 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) == 0)); } +/* + * Callback used to mark a buffer with XFS_LI_FAILED when items in the buffer + * 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 before + * 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 = 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 = DQUOT_ITEM(lip)->qli_dquot; - struct xfs_buf *bp = NULL; + struct xfs_buf *bp = lip->li_buf; uint rval = XFS_ITEM_SUCCESS; int error; if (atomic_read(&dqp->q_pincount) > 0) return XFS_ITEM_PINNED; + /* + * 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 = XFS_ITEM_FLUSHING; + + xfs_buf_unlock(bp); + return rval; + } + if (!xfs_dqlock_nowait(dqp)) return XFS_ITEM_LOCKED; @@ -242,7 +277,8 @@ static const struct xfs_item_ops xfs_dqu .iop_unlock = xfs_qm_dquot_logitem_unlock, .iop_committed = xfs_qm_dquot_logitem_committed, .iop_push = xfs_qm_dquot_logitem_push, - .iop_committing = xfs_qm_dquot_logitem_committing + .iop_committing = xfs_qm_dquot_logitem_committing, + .iop_error = xfs_dquot_item_error }; /*