Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp216988ybj; Wed, 6 May 2020 15:40:07 -0700 (PDT) X-Google-Smtp-Source: APiQypKcnWhiArrgvBWQrBrogxpwuNPAeScjyWJasEAcC4cfaEKJ3MD/TWrbJTJkM/6mNEXA/MQE X-Received: by 2002:a05:6402:1a2f:: with SMTP id be15mr9437214edb.385.1588804807457; Wed, 06 May 2020 15:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588804807; cv=none; d=google.com; s=arc-20160816; b=uWbZuWRsJaQiZ78UIn/VWAaLGCTEJCUMqyscac82/G3yR5jLGR10l5wdvB6zvNdkbd J/RO0uQ2bOgYlzL9f3X01i1ycLBfVUD/PRq4ocdN0swBR274gY3bZWdzgIO0gXD3BilL qJunF49KdD93F+iriCkc/h65jA8i+4NGCt44zndVH+hzhv9h02zIB5ofSVat7o1pb7ht HUY1DWvmthtqnY41d//5Cp3fK8AWZ/fCWib9kfZjsZtKDdPkhJJYnQbcFqPEzatQkSNt Ji9l70U8y9YFnrXWB9isbb4RQV4/+/z64ifDbHio5MxtV6HNK3Yu39j1SPgcIadS7zzn ZSRg== 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:user-agent :in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:dkim-signature; bh=8gEwOfUlsMM5h3OpqY7i/EiLvl5WA4yhiNg12Ebub+E=; b=r/HDPkfNXz+ePH1i7rc9d/oNTyQT10JUOdW8SfBfzoFMnvXd+fLb/V+TCj0ELDhdUa Yi/yNRzF8/QYq+jgHyeWTnZpdiXgDpJP/+ObeIP3aR5MuAE36SWHOVqb65d7DwSoARz+ UaMUTReTtZY5Q7toIpPqqPIZBBbu2P6aUxiV7JMC7PUr7Gtcqn5P93hhfxBHG4YReF7a 3b0ZN2nKQHHT3TWyroNwC9EEeiHTDolNrpMQISM9+BxAORhcYqT5gxYR8ZCXgibPYeCO XYC+1JG3T4JLdtoV6NdqQPQCYWnDz001SFTZqE69KC5z1KLwyF9n7cSwGmQ7FU9r0Pm5 8hjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=DYUT6FUx; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l5si1916995ejg.164.2020.05.06.15.39.44; Wed, 06 May 2020 15:40:07 -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=@gmx.net header.s=badeba3b8450 header.b=DYUT6FUx; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730326AbgEFWg4 (ORCPT + 99 others); Wed, 6 May 2020 18:36:56 -0400 Received: from mout.gmx.net ([212.227.17.21]:37845 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730313AbgEFWgy (ORCPT ); Wed, 6 May 2020 18:36:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1588804597; bh=jMqTPLplV3feDysjlHGaAHOsRH2Ey6JsMC0NKjgtrfM=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=DYUT6FUxuw9qQ1wAYbAe6qjKFNWYfbXkGhDXd5/F0XVIVHXHHApscpdoOe78IE2iF 9rytMwth/vTVtfzxZN7onK1bpx4TGDVRkrKTQAl50/h0O5HYQ24Ezh3F+XwcSpANv9 fp+gp7YVL1FfrYqHhmE+XZ9gMDeGskEUPvZLJ1b8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from hsiangkao-HP-ZHAN-66-Pro-G1 ([120.242.76.42]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1N7iCg-1j1GTO2bYo-014kRU; Thu, 07 May 2020 00:36:37 +0200 Date: Thu, 7 May 2020 06:36:26 +0800 From: Gao Xiang To: Eric Biggers 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: <20200506223623.GA27760@hsiangkao-HP-ZHAN-66-Pro-G1> 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> <20200506012428.GG128280@sol.localdomain> <20200506015813.GA9256@hsiangkao-HP-ZHAN-66-Pro-G1> <20200506064709.GA25482@hsiangkao-HP-ZHAN-66-Pro-G1> <20200506191613.GB842@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200506191613.GB842@sol.localdomain> User-Agent: Mutt/1.10.1 (2018-07-13) X-Provags-ID: V03:K1:ri2UJfRqCi9CrS2zGaKMZ6aJn281d6XAnbJ9XZIUIviP96/s9Eu IYngQM4ftXQDiHgqRWZCkQeQyAh1AqJM8f3K8+21t5Y0FFFfNO9OX+ZmMTu0KAtYJtFKzPk xrnQ98ASz/SJsokxdl++9IL6cNU4Uuj+GWqrkeYGfsk82Uw9C9/g2KRr9MxfiEAPiYrQQPy O1CLYUyrWGH8CikI5M6mw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:B+lt3r38RYQ=:D2ZUtIJvYc/qkhW/+EPb34 0mUY5T0xNv7hjQfW990tRbucCEcrq2+FSe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EGoUh8cz5hDG1cU6H2YOawbC0shB/+m/XFP1fPSjBSZDvSHngN1ACQDawZ9pzeaNQaQK6K NEtIZEjSN/yVLHjkKeLZOoJN9tdcS6MwQEazlCn/5JLzgfpe64Y5wsXd6lTBVNf9pPG0tUHSF +EJ/ZlGWO9wRl7rT6 Content-Transfer-Encoding: quoted-printable 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 12:16:13PM -0700, Eric Biggers wrote: > On Wed, May 06, 2020 at 02:47:19PM +0800, Gao Xiang wrote: > > On Wed, May 06, 2020 at 09:58:22AM +0800, Gao Xiang wrote: > > > On Tue, May 05, 2020 at 06:24:28PM -0700, Eric Biggers wrote: > > > > 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 know= ledge? > > > > > inode itself is locked when fsyncing, so > > > > > > > > > > if the fsync inode->i_nlink =3D=3D 1, this inode has only one= hard link > > > > > (not deleted yet) and should belong to a single directory; an= d > > > > > > > > > > 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 scena= rio? > > > > > Thanks a lot! > > > > > > > > i_nlink =3D=3D 1 just means that there is one non-deleted link. T= here can be links > > > > that have since been deleted, and file descriptors can still be op= en to them. > > > > > > Thanks for your inspiration. You are right, thanks. > > > > > > Correct my words... I didn't check f2fs code just now, it seems f2fs= doesn't > > > take inode_lock as some other fs like __generic_file_fsync or ubifs_= fsync. > > > > > > And i_sem locks nlink / try_to_fix_pino similarly in some extent. It= seems > > > no race by using d_find_alias here. Thanks again. > > > > > > > (think more little bit just now...) > > > > Thread 1: Thread 2 (fsync): > > vfs_unlink try_to_fix_pino > > f2fs_unlink > > f2fs_delete_entry > > f2fs_drop_nlink (i_sem, inode->i_nlink =3D 1) > > > > (... but this dentry still hashed) i_sem, check i= node->i_nlink =3D 1 > > i_sem d_find_a= lias > > > > d_delete > > > > I'm not sure if fsync could still use some wrong alias by chance.. > > completely untested, maybe just noise... > > > > Right, good observation. My patch makes it better, but it's still broke= n. > > I don't know how to fix it. If we see i_nlink =3D=3D 1 and multiple has= hed > dentries, there doesn't appear to be a way to distingush which one corre= sponds > to the remaining link on-disk (if any; it may not even be in the dcache)= , and > which correspond to links that vfs_unlink() has deleted from disk but ha= sn't yet > done d_delete() on. > > One idea would be choose one, then take inode_lock_shared(dir) and do > __f2fs_find_entry() to check if the dentry is really still on-disk. Tha= t's > heavyweight and error-prone though, and the locking could cause problems= . > > I'm wondering though, does f2fs really need try_to_fix_pino() at all, an= d did it > ever really work? It never actually updates the f2fs_inode::i_name to m= atch the > new directory. So independently of this bug with deleted links, I don't= see how > it can possibly work as intended. Part of my humble opinion would be "update pino in rename/unlink/link... s= uch ops instead of in fsync" (maybe it makes better sense of locking)... But actua= lly I'm not a f2fs folk now, just curious about what the original patch resolved w= ith these new extra igrab/iput (as I said before, I could not find some clue p= reviously). Thanks, Gao Xiang > > - Eric