Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1338934ybj; Tue, 5 May 2020 18:28:41 -0700 (PDT) X-Google-Smtp-Source: APiQypKxkfx609OCOXei9u+uCk46GsCccv6zXXQa1yU/gKtdL2/vVo9n+1G/LpaRXrbAGE8r12yS X-Received: by 2002:a17:906:7f13:: with SMTP id d19mr5293101ejr.57.1588728521494; Tue, 05 May 2020 18:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588728521; cv=none; d=google.com; s=arc-20160816; b=qwV/RQnXhN0D+4G93pj5ADLj6Osy5earkfyCPDCAHc13GANjtqM0x1FroZ6NSWuaaa RL0y1+BkpPDD2PTxVhnRtwT0L3I0GBPiM66zmVRklyMhj/SdHxQfHTlB3/QvPUaTS8Hm DMTh8St+b9lgtQ00HFYuDsq4RGWENJLxKMc+oTgB+cEJCX+r3LxVDB/5bR1YLMp95PVY jsQTh3EYfCca4tM6w4Ch1BsWm9IydGL7FKFGsOLhPW1/2NeYK8NrbwzJUyvNQiC/Az41 5/OzROa6LHGZsp6ARfeQfWHgWUz21IbYBqur/BqY/QGvHmsLSToHOpNcxXQPpV9+B3Oa 9Tww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Dvn17MOoQZJNj052Dfv+VO8ul21v5UP86WVBMo9KyuQ=; b=W5IFzF/ZTcpYfqWAvrsFKB1i2Ti2gdGz6B3PyPxdiFyE3juvXR+Ge2Uvky2Ye4XV+6 t4Do4+H6mQzt+Ymo4pmmouPHxQjG2O622MzC0WaBIGRBtGolJ9nYSebwWgqbgdvHvHzu FgSW2N7YdSBbY66XywwoTS/GahbL7rbHrrAFCvDXvDUkNvt+TFs9iFq1W8QqQoId1K87 /NIdTMl40hnzhxrf9a+W7kY//IGXZeSgpblQy2BG6x0zQDVdcHBV7qFZbu/17KRthzbN aXmIMQdEz4+NOhLVoDZQkMXwwgHepDEzaATvOwqVaSRd9PwNraYLfKRZXjpiUoKvWd8t F7vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tXVf6TQ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx8si182575edb.25.2020.05.05.18.28.16; Tue, 05 May 2020 18:28:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tXVf6TQ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729722AbgEFBYb (ORCPT + 99 others); Tue, 5 May 2020 21:24:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:40380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729457AbgEFBYb (ORCPT ); Tue, 5 May 2020 21:24:31 -0400 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (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 38C3320721; Wed, 6 May 2020 01:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588728270; bh=0MLo2NbZMkoEikI+0ws5DDZ7FousY6/b9nnHo7P+Gjk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tXVf6TQ1Sti0iAG5VHBet6ALroDk6gYzIaC5JV+smROfEfJggD6fgeg19XW+7O8/2 bYWn7fbiDYwRISi5X8fDqEQVdH9Z1kdp2hU8Dh38/TYjeZjSAUC6kkug7gkha0bjeZ VQJDeO6Ztfl/XIAlww3YDrgnB3H7htuULoFp3GfM= Date: Tue, 5 May 2020 18:24:28 -0700 From: Eric Biggers To: Gao Xiang Cc: Jaegeuk Kim , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH] f2fs: get parent inode when recovering pino Message-ID: <20200506012428.GG128280@sol.localdomain> References: <20200505153139.201697-1-jaegeuk@kernel.org> <20200505165847.GA98848@gmail.com> <20200505181323.GA55221@google.com> <20200505181941.GC98848@gmail.com> <20200506001403.GA2101@hsiangkao-HP-ZHAN-66-Pro-G1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200506001403.GA2101@hsiangkao-HP-ZHAN-66-Pro-G1> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 06, 2020 at 08:14:07AM +0800, Gao Xiang wrote: > > > > Actually, I think this is wrong because the fsync can be done via a file > > descriptor that was opened to a now-deleted link to the file. > > I'm still confused about this... > > I don't know what's wrong with this version from my limited knowledge? > inode itself is locked when fsyncing, so > > if the fsync inode->i_nlink == 1, this inode has only one hard link > (not deleted yet) and should belong to a single directory; and > > the only one parent directory would not go away (not deleted as well) > since there are some dirents in it (not empty). > > Could kindly explain more so I would learn more about this scenario? > Thanks a lot! i_nlink == 1 just means that there is one non-deleted link. There can be links that have since been deleted, and file descriptors can still be open to them. > > > > > We need to find the dentry whose parent directory is still exists, i.e. the > > parent directory that is counting towards 'inode->i_nlink == 1'. > > directory counting towards 'inode->i_nlink == 1', what's happening? The non-deleted link is the one counted in i_nlink. > > > > > I think d_find_alias() is what we're looking for. > > It may be simply dentry->d_parent (stable/positive as you said before, and it's > not empty). why need to d_find_alias()? Because we need to get the dentry that hasn't been deleted yet, which isn't necessarily the one associated with the file descriptor being fsync()'ed. > And what is the original problem? I could not get some clue from the original > patch description (I only saw some extra igrab/iput because of some unknown > reasons), it there some backtrace related to the problem? The problem is that i_pino gets set incorrectly. I just noticed this while reviewing the code. It's not hard to reproduce, e.g.: #include #include #include int main() { int fd; mkdir("dir1", 0700); mkdir("dir2", 0700); mknod("dir1/file", S_IFREG|0600, 0); link("dir1/file", "dir2/file"); fd = open("dir2/file", O_WRONLY); unlink("dir2/file"); write(fd, "X", 1); fsync(fd); } Then: sync echo N | dump.f2fs -i $(stat -c %i dir1/file) /dev/vdb | grep 'i_pino' echo "dir1 (correct): $(stat -c %i dir1)" echo "dir2 (wrong): $(stat -c %i dir2)" i_pino will point to dir2 rather than dir1 as expected. - Eric