Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17922498ybl; Thu, 2 Jan 2020 14:52:58 -0800 (PST) X-Google-Smtp-Source: APXvYqzjmAgNUVYXduqGGahUlDdfCZsoOY7YOwLPsmuY5kpowlHmQkGZZrkZl5oXOt9TnMhRN9n4 X-Received: by 2002:a05:6830:22e6:: with SMTP id t6mr99171836otc.244.1578005578589; Thu, 02 Jan 2020 14:52:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578005578; cv=none; d=google.com; s=arc-20160816; b=GiDAGks3vo6+7TsAilKxjgqSYvEFUmFGSWgoTXA+UoI9OMOjj7bqd3JYP5VfEMF7+t HPWadVUBOUwTMQT5UUvd3blQRKzluqGdNbnGGHR6TkUtqxFc0oOaVcmsfIHo0wQXP9ae pcuPTW23MSNzotbap+A2Ib1Jlc3On6VIUUZDpt6bJ8rKenhjdoXkRIL6exmpe3VfV3zD JWvqS13exug1RlmIx5Ymnou2grKKP1tBbQ5XWqMoqXO1QobTDNNktxDQjqc1rGz7BVds MShkZo2yjDwZzGfM4t/JF8hnnSAmkvww223qkDDD2JGTtKsU1RrPJc7tgLvckQCoyZvh ZuUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qrjPxPvvQo6h2bkXwE00Bj4an7+0FPPIabwAvleCJI8=; b=EwFvg9OsBczRJXksQZH2LW2sLJe3T16Q0LYb69+iZKlSZnPOuONcwfHPKW5ojFd5bR rl8SbDXY6515FizEgH3c3r6ntCOySiR7zdljugAd1R4itYq1ufHRRDjJUZhUOrKXEQ7+ dKc1/jpOMX5PBAQRxSixhUD83Xq01iM/DiKMQkzltkzQGG4Ctrn7b/br40QqD2jLlxmZ rzC80UkzZ3EbDeR6Vm3KCZ5jcDn+pY6uiRWegPU1CeHUvywLtT4Om0+WDxg6XzgY1CVK ZKXw9wvLnmFWDtwfDTwSSXIdF/dAGl6yf8zQErCapw3UrfTHjgbfdPMXnyIUOFf42hoz budQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="e/XxyXm1"; 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 f22si27207769otp.178.2020.01.02.14.52.46; Thu, 02 Jan 2020 14:52:58 -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; dkim=pass header.i=@kernel.org header.s=default header.b="e/XxyXm1"; 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 S1729723AbgABWvf (ORCPT + 99 others); Thu, 2 Jan 2020 17:51:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:47266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729201AbgABWX7 (ORCPT ); Thu, 2 Jan 2020 17:23:59 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8597120866; Thu, 2 Jan 2020 22:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003839; bh=YFr8sdVP8d6EmhH91mp17WQOB93TxcA8VDON1OElUv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e/XxyXm1HJeukJv/IzWMg81VqkWCROVmm1mWQPkMLrsST9hfZTTt5PK/GLVD7fHMf cBNOZX419k4JdsgVhwTFShLr1ikXr7OKNj5dpm6iEZrQFMirt/A9naUja03+bc+Bx/ Vs9FWWonRj5edf5/povYfRadYt1Ew/44CYj+DVIk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Eric Biggers , Jaegeuk Kim , Sasha Levin Subject: [PATCH 4.14 20/91] f2fs: fix to update dirs i_pino during cross_rename Date: Thu, 2 Jan 2020 23:07:02 +0100 Message-Id: <20200102220420.759090138@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220356.856162165@linuxfoundation.org> References: <20200102220356.856162165@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu [ Upstream commit 2a60637f06ac94869b2e630eaf837110d39bf291 ] As Eric reported: RENAME_EXCHANGE support was just added to fsstress in xfstests: commit 65dfd40a97b6bbbd2a22538977bab355c5bc0f06 Author: kaixuxia Date: Thu Oct 31 14:41:48 2019 +0800 fsstress: add EXCHANGE renameat2 support This is causing xfstest generic/579 to fail due to fsck.f2fs reporting errors. I'm not sure what the problem is, but it still happens even with all the fs-verity stuff in the test commented out, so that the test just runs fsstress. generic/579 23s ... [10:02:25] [ 7.745370] run fstests generic/579 at 2019-11-04 10:02:25 _check_generic_filesystem: filesystem on /dev/vdc is inconsistent (see /results/f2fs/results-default/generic/579.full for details) [10:02:47] Ran: generic/579 Failures: generic/579 Failed 1 of 1 tests Xunit report: /results/f2fs/results-default/result.xml Here's the contents of 579.full: _check_generic_filesystem: filesystem on /dev/vdc is inconsistent *** fsck.f2fs output *** [ASSERT] (__chk_dots_dentries:1378) --> Bad inode number[0x24] for '..', parent parent ino is [0xd10] The root cause is that we forgot to update directory's i_pino during cross_rename, fix it. Fixes: 32f9bc25cbda0 ("f2fs: support ->rename2()") Signed-off-by: Chao Yu Tested-by: Eric Biggers Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/namei.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index b80e7db3b55b..b13383948fca 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -862,7 +862,8 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, if (!old_dir_entry || whiteout) file_lost_pino(old_inode); else - F2FS_I(old_inode)->i_pino = new_dir->i_ino; + /* adjust dir's i_pino to pass fsck check */ + f2fs_i_pino_write(old_inode, new_dir->i_ino); up_write(&F2FS_I(old_inode)->i_sem); old_inode->i_ctime = current_time(old_inode); @@ -1027,7 +1028,11 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, f2fs_set_link(old_dir, old_entry, old_page, new_inode); down_write(&F2FS_I(old_inode)->i_sem); - file_lost_pino(old_inode); + if (!old_dir_entry) + file_lost_pino(old_inode); + else + /* adjust dir's i_pino to pass fsck check */ + f2fs_i_pino_write(old_inode, new_dir->i_ino); up_write(&F2FS_I(old_inode)->i_sem); old_dir->i_ctime = current_time(old_dir); @@ -1042,7 +1047,11 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, f2fs_set_link(new_dir, new_entry, new_page, old_inode); down_write(&F2FS_I(new_inode)->i_sem); - file_lost_pino(new_inode); + if (!new_dir_entry) + file_lost_pino(new_inode); + else + /* adjust dir's i_pino to pass fsck check */ + f2fs_i_pino_write(new_inode, old_dir->i_ino); up_write(&F2FS_I(new_inode)->i_sem); new_dir->i_ctime = current_time(new_dir); -- 2.20.1