From patchwork Thu Mar 14 21:03:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10853587 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 538A16C2 for ; Thu, 14 Mar 2019 21:03:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BEF72A710 for ; Thu, 14 Mar 2019 21:03:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A35C2A7A7; Thu, 14 Mar 2019 21:03:57 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 96FBB2A7A9 for ; Thu, 14 Mar 2019 21:03:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727625AbfCNVD4 (ORCPT ); Thu, 14 Mar 2019 17:03:56 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:49784 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727412AbfCNVD4 (ORCPT ); Thu, 14 Mar 2019 17:03:56 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2EKwqgN095361; Thu, 14 Mar 2019 21:03:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=jQ4x/kmEGo8n/vc83NDm3EAKpuiA4+Bs9ApeLePX2VQ=; b=GYk9hInWwX0TpOR/eaVpb2JibTYQ0V66yB6gGY5PaPk0WskGK0QK85PUJtMC5Q3rW8dO mZaQJbRmwCB6bPkd4UzKu8JFfgA4pPMx1tD1e6AWfXB1RShs69WDC0FV/rXmgBCkIM2W k41Vq4qbx1z63kevLGn5CeL53Nd3jbmV1HYdDVjfM/TYCWWR3F8BW1pKpoe04H8JKjdP sJwgtfniK21QBGpqWf6KX0DGCiBY/ph5O9Bq9et0BslAr5qeGeO5tnq5H1eNlWv1RbfH y4mjB4+XBc7tayLRL39uUmvyF2P37ECRECqGL8f8P3W7Xnrq2YO8kNMkq5G6PyHSWjm0 ow== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2r44wukfcf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Mar 2019 21:03:51 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2EL3pBG025470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Mar 2019 21:03:51 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x2EL3nwB019113; Thu, 14 Mar 2019 21:03:50 GMT Received: from localhost (/10.145.178.102) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 14 Mar 2019 21:03:49 +0000 Subject: [PATCH 01/36] libxfs: fix repair deadlock due to failed inode flushes. From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, Arkadiusz Miskiewicz , Dave Chinner Date: Thu, 14 Mar 2019 14:03:49 -0700 Message-ID: <155259742930.31886.16675099707553706623.stgit@magnolia> In-Reply-To: <155259742281.31886.17157720770696604377.stgit@magnolia> References: <155259742281.31886.17157720770696604377.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9195 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903140143 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 From: Dave Chinner If inode_item_done() fails to flush an inode after we've grabbed a reference to the underlying buffer during a transaction commit, we fail to put the buffer and hence leak it. We then deadlock on the next lookup ofthe inode buffer as it is still locked and no-one owns it. To fix it, put the buffer on error so that it gets unlocked and can be recovered appropriately in a later phase of repair. Reported-by: Arkadiusz Miskiewicz Fixes: d15188a1ec14 ("xfs: rework the inline directory verifiers") Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson --- libxfs/trans.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libxfs/trans.c b/libxfs/trans.c index 46ff8b4a..10a35dd4 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -824,8 +824,10 @@ _("Transaction block reservation exceeded! %u > %u\n"), /* * Transaction commital code follows (i.e. write to disk in libxfs) + * + * XXX (dgc): should failure to flush the inode (e.g. due to uncorrected + * corruption) result in transaction commit failure w/ EFSCORRUPTED? */ - static void inode_item_done( xfs_inode_log_item_t *iip) @@ -856,17 +858,24 @@ inode_item_done( return; } + /* + * Flush the inode and disassociate it from the transaction regardless + * of whether the flush succeed or not. If we fail the flush, make sure + * we still release the buffer reference we currently hold. + */ bp->b_log_item = iip; error = libxfs_iflush_int(ip, bp); + ip->i_transp = NULL; /* disassociate from transaction */ + bp->b_log_item = NULL; /* remove log item */ + bp->b_transp = NULL; /* remove xact ptr */ + if (error) { fprintf(stderr, _("%s: warning - iflush_int failed (%d)\n"), progname, error); + libxfs_putbuf(bp); return; } - ip->i_transp = NULL; /* disassociate from transaction */ - bp->b_log_item = NULL; /* remove log item */ - bp->b_transp = NULL; /* remove xact ptr */ libxfs_writebuf(bp, 0); #ifdef XACT_DEBUG fprintf(stderr, "flushing dirty inode %llu, buffer %p\n",