Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17925192ybl; Thu, 2 Jan 2020 14:56:33 -0800 (PST) X-Google-Smtp-Source: APXvYqzxXw33GZgBOaXo2sT6v5mzjFyaHqNU6RjpwQvX7p7SA43qRHZkJ7rsZk2DD+XmVpSk2Tva X-Received: by 2002:a05:6808:ab1:: with SMTP id r17mr2964511oij.141.1578005793088; Thu, 02 Jan 2020 14:56:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578005793; cv=none; d=google.com; s=arc-20160816; b=gH4eHMA03lif4ITORzXHkSgSy+COSnhfcF7C80DqfNWgaN4T19fbuQDI0aSLwr8TjU zX5876d8s5f6jEVvExOAJTPUGLDicMYqd6+Z8uYbfxQh+3dCqETGEG9X/wqYDWNnXET7 0sEepS0DUfPLTzdWR8zMe+kqmIHKm2zTD79vXt4Gp6nUwd2Pbz5tFv+eC3nHpK52eqof K7v42JVRM22WYqdjUBcHuQVONj5Ali3mvriL+6yKiZo807hPNDu+5xxwIQgRyfkgxXFD t358zkgwoOFOgddEbgITMNfDRg8c2Tc6NRQF4bjhLGn4tvzICHcO+DZcqBY4GFb3hBnQ Sz2g== 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=N3A0xQDhOe+4f+7c7C+ou0F59B8j97sN3685/b064as=; b=dGSIw7WbTXvlb2BrqbQC9Ok9DHATNSzsoQQXRiW4uVd/8R8ODA2tJaYk0MeRWye7aw qrQB5h9DT7Hfvu+SVDI3HHx7e1Jj/PwrT9YTQVEKXdBgSjwvxve1BbK4ZP+tukXSWgoR y7NuJM0B3obPuhf++4PcD78OzEvdO+J7lOXtUSt2U1J9TAqnYboKhxxzsIzscdq5c83e Mngk2rk+oUfRryRju5NTzdmsonJsY87fRXA57QBejTeL219iD3yJIlepTmgLidnIocyz PLLx5Ch0NMOpWFN5vYUzi7efIqgRq59liC67Ohhda1OBSMwccsmPKXgXV0BZgXr96PHV b6AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rUXiZwrR; 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 17si12557235oix.22.2020.01.02.14.56.21; Thu, 02 Jan 2020 14:56:33 -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=rUXiZwrR; 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 S1728180AbgABWTn (ORCPT + 99 others); Thu, 2 Jan 2020 17:19:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:36004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728144AbgABWTh (ORCPT ); Thu, 2 Jan 2020 17:19:37 -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 8D04321582; Thu, 2 Jan 2020 22:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003577; bh=FjeBkZ61tze9AralcRZgis9AfdDnqF0kdtbdJ+5ayR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rUXiZwrRhgELIl7ssHHCLNrmoqa5+iHd5/Oq/nrb9TARP9iaZhv/grDbxAnTa6l0a IsH463GVpm/QGe2WfQAnfvpTBZxK/OReKj9ix1/+l8k14BArieoNJotG7tPL0pxb53 UL//7KI8F+2bVo+OrAzU7LuQOkmFeLVTCVHBpw7U= 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.19 027/114] f2fs: fix to update dirs i_pino during cross_rename Date: Thu, 2 Jan 2020 23:06:39 +0100 Message-Id: <20200102220031.850609799@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@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 6b23dcbf52f4..0ace2c2e3de9 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -948,7 +948,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); @@ -1103,7 +1104,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); @@ -1118,7 +1123,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