From patchwork Thu Mar 14 21:06:57 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: 10853645 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 E478A1515 for ; Thu, 14 Mar 2019 21:07:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC3BA2A1E1 for ; Thu, 14 Mar 2019 21:07:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAC582A23B; Thu, 14 Mar 2019 21:07:08 +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 6A3A42A296 for ; Thu, 14 Mar 2019 21:07:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727760AbfCNVHI (ORCPT ); Thu, 14 Mar 2019 17:07:08 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:53594 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727204AbfCNVHH (ORCPT ); Thu, 14 Mar 2019 17:07:07 -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 x2EKwfks095309; Thu, 14 Mar 2019 21:07:04 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=U9x2grLXIwFAZk9VosXftNJ02YbP7UP9ZHhDmdGIKkg=; b=EGJvS9DTEmozpejufKmkspV9/h5j82dVrD7C3XhstN3cIFoKrvjlhS7cZYO1C31fQm15 4r05OioUd2NkR6K6B+8SQYO7fHdlCH1D6KtchY3FJ41vqSGGh7LEj5tJIGLnbTECQyGa Gk6VO010/EzN8okcHN6NyBaRH/j5NCCad9bRaJ6TIwX7NGLGTF3ie9XdE8nJWwe/U6gx 5J1Y0Q+lpKKPw9TfKLgxMTK1yswca8SFhumNft1SNfLn5Da5Hemq3MR6CMb/AfqcAz86 5K7UKpuLZ1yEuSo3+esIwM6tGu0Uk6KOgKgi9gK7Ev0WmUqie02O5hcIdv1mTJ9WAqSy wg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2r44wukftq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Mar 2019 21:07:04 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x2EL6we8008321 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Mar 2019 21:06:58 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x2EL6wN5020649; Thu, 14 Mar 2019 21:06:58 GMT Received: from localhost (/10.145.178.102) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 14 Mar 2019 21:06:57 +0000 Subject: [PATCH 30/36] libxfs: retain ifork_ops when flushing inode From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, Arkadiusz Miskiewicz Date: Thu, 14 Mar 2019 14:06:57 -0700 Message-ID: <155259761740.31886.12775146464846669280.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=1015 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: Darrick J. Wong Retain the ifork ops used to validate the inode so that we can use the same one to iflush it. xfs_repair phase 6 can use multiple transactions to fix various inode problems, which means that the inode might not be fully fixed when each transaction commits. This can be a particular problem if there's a shortform directory with both invalid directory entries and incorrect i8count. Phase 3 will set the parent inode to "0" to signal to phase 6 that it needs to reset the parent and i8count, but phase 6 starts a transaction to junk the bad entries which fail to commit because the parent is invalid: fixing i8count in inode 69022994673 Invalid inode number 0x0 xfs_dir_ino_validate: XFS_ERROR_REPORT Metadata corruption detected at 0x464eb0, inode 0x10121750f1 data fork xfs_repair: warning - iflush_int failed (-117) And thus the inode fixes never get written out. Reported-by: Arkadiusz Miskiewicz Signed-off-by: Darrick J. Wong --- include/xfs_inode.h | 1 + libxfs/rdwr.c | 1 + libxfs/util.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/xfs_inode.h b/include/xfs_inode.h index 79ec3a2d..e1e8b430 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -51,6 +51,7 @@ typedef struct xfs_inode { xfs_fsize_t i_size; /* in-memory size */ const struct xfs_dir_ops *d_ops; /* directory ops vector */ + struct xfs_ifork_ops *i_fork_ops; /* fork verifiers */ struct inode i_vnode; } xfs_inode_t; diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index a00360e7..69d5abb2 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -1391,6 +1391,7 @@ libxfs_iget( return error; } + ip->i_fork_ops = ifork_ops; if (!libxfs_inode_verify_forks(ip, ifork_ops)) { libxfs_irele(ip); return -EFSCORRUPTED; diff --git a/libxfs/util.c b/libxfs/util.c index bd414043..0799f965 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -420,7 +420,7 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp) VFS_I(ip)->i_version++; /* Check the inline fork data before we write out. */ - if (!libxfs_inode_verify_forks(ip, &xfs_default_ifork_ops)) + if (!libxfs_inode_verify_forks(ip, ip->i_fork_ops)) return -EFSCORRUPTED; /*