From patchwork Wed Aug 2 05:35:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lu Fengqi X-Patchwork-Id: 9875957 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BEECB6037D for ; Wed, 2 Aug 2017 05:47:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B15A228759 for ; Wed, 2 Aug 2017 05:47:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A62F12876B; Wed, 2 Aug 2017 05:47:27 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 1A43F28759 for ; Wed, 2 Aug 2017 05:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751156AbdHBFrY (ORCPT ); Wed, 2 Aug 2017 01:47:24 -0400 Received: from [183.91.158.132] ([183.91.158.132]:52148 "EHLO heian.cn.fujitsu.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751063AbdHBFrX (ORCPT ); Wed, 2 Aug 2017 01:47:23 -0400 X-Greylist: delayed 711 seconds by postgrey-1.27 at vger.kernel.org; Wed, 02 Aug 2017 01:47:23 EDT X-IronPort-AV: E=Sophos;i="5.41,309,1498492800"; d="scan'208";a="22093555" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Aug 2017 13:35:28 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 9B48546B5FDE for ; Wed, 2 Aug 2017 13:35:29 +0800 (CST) Received: from localhost.localdomain (10.167.226.155) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 2 Aug 2017 13:35:27 +0800 From: Lu Fengqi To: CC: Su Yue Subject: [PATCH] btrfs: verify_dir_item fails in replay_xattr_deletes Date: Wed, 2 Aug 2017 13:35:21 +0800 Message-ID: <20170802053521.22053-1-lufq.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.13.3 MIME-Version: 1.0 X-Originating-IP: [10.167.226.155] X-yoursite-MailScanner-ID: 9B48546B5FDE.AB785 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lufq.fnst@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Su Yue In replay_xattr_deletes(), the argument @slot of verify_dir_item() should be variable @i instead of path->slots[0]. The bug causes failure of generic/066 and shared/002 in xfstest. dmesg: [12507.810781] BTRFS critical (device dm-0): invalid dir item name len: 10 [12507.811185] BTRFS: error (device dm-0) in btrfs_replay_log:2475: errno=-5 IO failure (Failed to recover log tree) [12507.811928] BTRFS error (device dm-0): cleaner transaction attach returned -30 [12507.821020] BTRFS error (device dm-0): open_ctree failed [12508.131526] BTRFS info (device dm-0): disk space caching is enabled [12508.132145] BTRFS info (device dm-0): has skinny extents [12508.136265] BTRFS critical (device dm-0): invalid dir item name len: 10 [12508.136678] BTRFS: error (device dm-0) in btrfs_replay_log:2475: errno=-5 IO failure (Failed to recover log tree) [12508.137501] BTRFS error (device dm-0): cleaner transaction attach returned -30 [12508.147982] BTRFS error (device dm-0): open_ctree failed Signed-off-by: Su Yue --- fs/btrfs/tree-log.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index f20ef211a73d..3a11ae63676e 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2153,8 +2153,7 @@ static int replay_xattr_deletes(struct btrfs_trans_handle *trans, u32 this_len = sizeof(*di) + name_len + data_len; char *name; - ret = verify_dir_item(fs_info, path->nodes[0], - path->slots[0], di); + ret = verify_dir_item(fs_info, path->nodes[0], i, di); if (ret) { ret = -EIO; goto out;