From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5FB7C28CBC for ; Wed, 6 May 2020 22:36:54 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 79C8A2078C; Wed, 6 May 2020 22:36:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="eP5r+mgQ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="kGolT0pH"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="DYUT6FUx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79C8A2078C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gmx.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jWSeq-0001sh-R4; Wed, 06 May 2020 22:36:52 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWSeo-0001sU-Fw for linux-f2fs-devel@lists.sourceforge.net; Wed, 06 May 2020 22:36:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8gEwOfUlsMM5h3OpqY7i/EiLvl5WA4yhiNg12Ebub+E=; b=eP5r+mgQXlx2K7RXPGcGdBK5MX JVmhQpeLXGvfuxRKpPB2HoLH9PltfNQX1tXp+qvzkfvpOmEjWiRw4vubhZfSdodS3Y6edmC6YoQAn jSSRS+KBmW66Laab9SuCNDRVavq8m5EUHBrWwyMrRcPXwePvBVz3UKiGdqcvMa6njXww=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=8gEwOfUlsMM5h3OpqY7i/EiLvl5WA4yhiNg12Ebub+E=; b=kGolT0pHmjQxyGdY2gqiAQpw2V YZT3XC3T0S86zXFC0PPXYeuvFddhm+7UF5GTo/mUfqpIj+D3Obvwxae8OH9hlcSUrst6Svxsqjgwb wE29n9FNqWrxcJxrPDBNmFDsm0sVk9ZPagY+/faen/jeY7gpw3x9FWt/zIAr7F7F0ktE=; Received: from mout.gmx.net ([212.227.17.21]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1jWSem-00GqV7-2j for linux-f2fs-devel@lists.sourceforge.net; Wed, 06 May 2020 22:36:50 +0000 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 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-Disposition: inline In-Reply-To: <20200506191613.GB842@sol.localdomain> User-Agent: Mutt/1.10.1 (2018-07-13) X-Provags-ID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R7xYFKK0N4byibFzWN5M/H8MRy7G1zu9uS6o 5GQeu6TT9LOPFQwhtKGLt6Ksf33tRmA/U+51DjUpdt3T+K7wpJENVwq3H6vUJ79QgffLuFTIn omaDP4mZct7qMBUZi8ToC6jDjO9fpOyri8+goGVqO+7p/po9cBLlXRTdO+G/p7I8vVDKOF0Hu VE8+m6hFHDyk0MLagOi9kEyvZSjo9l1JYVv98THoyToNozfc5bXZxAtIgaC03SWRw1GnCiOP1 ov7mTCxlXgCjjo63OISXzstJPBr4dYvUMSKdL3y83pFeLSL/AIwZajb6KuuhUoQNKLPaP0MZf bhKEGoUh8cz5hDG1cU6H2YOawbC0shB/+m/XFP1fPSjBSZDvSHngN1ACQDawZ9pzeaNQaQK6K NEtIZEjSN/yVLHjkKeLZOoJN9tdcS6MwQEazlCn/5JLzgfpe64Y5wsXd6lTBVNf9pPG0tUHSF +EJ/ZlGWO9wRl7rT6 X-Headers-End: 1jWSem-00GqV7-2j Subject: Re: [f2fs-dev] [PATCH] f2fs: get parent inode when recovering pino X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jaegeuk Kim , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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 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. > > > > > > 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 = 1) > > > > (... but this dentry still hashed) i_sem, check inode->i_nlink = 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... > > > > Right, good observation. My patch makes it better, but it's still broken. > > I don't know how to fix it. If we see i_nlink == 1 and multiple hashed > dentries, there doesn't appear to be a way to distingush which one corresponds > 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 hasn'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. That'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, and did it > ever really work? It never actually updates the f2fs_inode::i_name to match 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... such ops instead of in fsync" (maybe it makes better sense of locking)... But actually I'm not a f2fs folk now, just curious about what the original patch resolved with these new extra igrab/iput (as I said before, I could not find some clue previously). Thanks, Gao Xiang > > - Eric _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel