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=-0.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 47D0BC28CBC for ; Wed, 6 May 2020 19:16:32 +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 15BE720A8B; Wed, 6 May 2020 19:16:31 +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="OAS8oCy5"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="QBotdU7Z"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="bjYUPi2p" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15BE720A8B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jWPWx-0007wn-Fp; Wed, 06 May 2020 19:16:31 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWPWu-0007wR-Ls for linux-f2fs-devel@lists.sourceforge.net; Wed, 06 May 2020 19:16:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: 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=ulSUYx7ZjegD+oTS6cBVUEO4A/wK+Jxxywwgfcb628Y=; b=OAS8oCy5VAH7yuWZ95n38+oPVv piCpPPJDnfCx14FZLuY8BPNsubZg04Hj1WrevE8h/wNsaL4FdEX0kUbadivbYOAwifPT1FZf70dkm Jc+6ITXB+saja6AChyqb8zP5g+fu/xgI3j5P5Ox4UVw0w3rtlphIiAg8mO2JN9shCRTw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding: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=ulSUYx7ZjegD+oTS6cBVUEO4A/wK+Jxxywwgfcb628Y=; b=QBotdU7ZkDH+PPNEoxOTvl6jHZ ahlmdqYdcv0oRunUYbnd3L525gpxRgqWgnz5pmxpu3GNsYQmLfhxMVMYd557OOFndaEmeTmnpsOSR OvhPF/KAaN9Ly1ya6bgsd2dx9H0lWiCAY7eVRsL9ldRlYxMgslJbVKjwg/e5m7wSOpL8=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jWPWt-00Gd4z-GU for linux-f2fs-devel@lists.sourceforge.net; Wed, 06 May 2020 19:16:28 +0000 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 49C9E2075A; Wed, 6 May 2020 19:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588792575; bh=THl2Lpu9sfzGxpEl85CqvltCNIh7W5yIuzClFt9bv4U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bjYUPi2pTno6Scq4ERj8iiHIh0GEoMacr7jaA2J4s/5IsEU1LWt5+o/FCoeLtkmFK DxxtXGvfDR1GG96aaJqEqyebWNFBkIFPkxTQQzxoqE1ij9FvnN6vpdfeXvcarR2rp6 V5nPvdyZqzQ0PF6fqZkn4/A5yvF/qrA1pH9uGbDY= Date: Wed, 6 May 2020 12:16:13 -0700 From: Eric Biggers To: Gao Xiang Message-ID: <20200506191613.GB842@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> <20200506012428.GG128280@sol.localdomain> <20200506015813.GA9256@hsiangkao-HP-ZHAN-66-Pro-G1> <20200506064709.GA25482@hsiangkao-HP-ZHAN-66-Pro-G1> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200506064709.GA25482@hsiangkao-HP-ZHAN-66-Pro-G1> X-Headers-End: 1jWPWt-00Gd4z-GU 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 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. - Eric _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel