Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1532246ybj; Tue, 5 May 2020 23:50:59 -0700 (PDT) X-Google-Smtp-Source: APiQypIQPDOIxCLbTWyE8Ye+2JfOS7cCp5pM2qU0dxx3DN1ccJ8zJVWVfGa1TIveF9TESxYJyKZA X-Received: by 2002:aa7:d892:: with SMTP id u18mr5681067edq.156.1588747859375; Tue, 05 May 2020 23:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588747859; cv=none; d=google.com; s=arc-20160816; b=LAlJveJmk6FR9dMi4R216BoJv+7fNJte3Y4CUAtFbT9AIQSEbHVGbAXPG21vh+UTgL b9IF1PzBfMlw0ulJopYyvs85631sDwrPSgMdatlBOMH+Kq3/MNdU1DgDc0BjM5aiym5K 4HfIf5iMZr/YtetnOFlbLaBkI7Whs9l+G5PQXtjGpDAyoGNnsnaf01BYN0+vrU12BFqS caQtOfJ4vV40ckUq0fxAC/RC52D1mF20E+LCd0klsoIRknbbwG93ovmEWyMNVmsSiGfa P+lClOh+R7pmhKPG/f5nxOT4+mSK/Qw+7UtQxywLO2XobZYkTxcxanIbsBNqYlHE+ntU i9rw== 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=ke6pWVf22SH/deVrdPBqBuWv0AfvnheuF0POp7g6hiQ=; b=ZYO2IeXfS/ijnIy5gnjlAqkMMIrI298FxxnaDT4IENXC3BRNmJ6kUjSSmU3bKyNcUd Yh8LPFcRZ5ZRbph09FC5xXROcFdY2TS11nQ4HCA+vbHHZo9as1i+NJtEE3TZcVaSf72W 4rozgi0ERReiactrwUrQFa/8ePP+kcMAWuIlrp63Gm02GRvv531manoTSF0VOquzOzFo 29aVGdwDXXmGyHYCcVbQs2XOoapINHnC0jGbZ6FZ+8Ev9zGot584yRUMJvSYwkqD3cBb yg3xVzI0u4d5Z4fGbNUn09uhmevSsbv8ZXTnKqPVbE7aZ7K/TcRf4oixJyqFNJctAVac 2aYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=NQWyk4a2; 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 p12si605742ejo.516.2020.05.05.23.50.36; Tue, 05 May 2020 23:50:59 -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=NQWyk4a2; 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 S1728270AbgEFGro (ORCPT + 99 others); Wed, 6 May 2020 02:47:44 -0400 Received: from mout.gmx.net ([212.227.17.20]:47019 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727812AbgEFGrn (ORCPT ); Wed, 6 May 2020 02:47:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1588747647; bh=hO88QHkEwrRqwifsGMJLO23pyLom4frjxgEUyj9P83s=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=NQWyk4a22wEfqor3GHw6TNgP35oPNmP+FviFHd39bWVDRjgmrTQW4psPkVfgyHL76 kOztWkDVJFm5Y++L31zuV7RQ+CjNzIqbxgALvOw1vGLfE3FQgBzN0hd5w6RDofrhne fN6c6II4XEmkIv2M6mmfYxKYKbY2JaKsGSxsw3rU= 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 (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MZCfJ-1jaqNT0Nnt-00V5nD; Wed, 06 May 2020 08:47:27 +0200 Date: Wed, 6 May 2020 14:47:19 +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: <20200506064709.GA25482@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200506015813.GA9256@hsiangkao-HP-ZHAN-66-Pro-G1> User-Agent: Mutt/1.10.1 (2018-07-13) X-Provags-ID: V03:K1:z6dtdIcZRcSYYph0RGMRdGYvIpDIYF8mz+BYGilcVnLYpEXyg/g mFR8hgBLc0U/As4vQQXjMXzV40093msxEuzJUUh8FIhgivuJI9T50alip1rHMHI6VGfOi0w 5auoIOjOQZbm123Z5TvIA+Lk63KkQ3ai6p+cyDk0MQwedoKnjMp5OTzdMOzO+k9d+YB2Ko0 uU0i4dijVkg60MGHVFpoQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:spzX94Rvc9Y=:Wwm8mk3c5+AdN+K91dNCm9 /dp58Sb+t6/IYOi1wtRT9WN/nKeLuzqqboXLS/vv6yk90m0vaESkL0mweBW4JyzO7G7RA77tG X3Vn4kZ0AOfvheD/63jfo6RzGHHdw6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sp6QUWZHRg1b6NN3GKv2lfckqFEumXl7DRUnfDRDPXKXqHXdrqLSMj14+4kdo/aw nNKZNeOJeTpvtsayc 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 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 knowledg= e? > > > inode itself is locked when fsyncing, so > > > > > > if the fsync inode->i_nlink =3D=3D 1, this inode has only one har= d link > > > (not deleted yet) and should belong to a single directory; and > > > > > > the only one parent directory would not go away (not deleted as w= ell) > > > 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 =3D=3D 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 t= o them. > > Thanks for your inspiration. You are right, thanks. > > Correct my words... I didn't check f2fs code just now, it seems f2fs doe= sn't > take inode_lock as some other fs like __generic_file_fsync or ubifs_fsyn= c. > > And i_sem locks nlink / try_to_fix_pino similarly in some extent. It see= ms > 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 inode= ->i_nlink =3D 1 i_sem d_find_alias d_delete I'm not sure if fsync could still use some wrong alias by chance.. completely untested, maybe just noise... Thanks, Gao Xiang