Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1050280ybj; Tue, 5 May 2020 12:06:10 -0700 (PDT) X-Google-Smtp-Source: APiQypKxB7Kc0lXjE9bTUVxIS/Bwrr/n0E1H4ucqmSZPenw2wDRFv8Vuyt1h5xW3vrx/ElqhKnuC X-Received: by 2002:a17:906:11c7:: with SMTP id o7mr4301368eja.108.1588705570309; Tue, 05 May 2020 12:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588705570; cv=none; d=google.com; s=arc-20160816; b=NXqBLgPyUyUkZxjl3ZctYIREybEtJRS881i8u4i7qwR2tgwnBVb7zFKZIkBmGPxoCF 1CCT5+FmpkAKT3b6WAKeu6b+Lgf7+SFmUXPrijB2t7qXeo/eKjuP2zLX1RNZgNEK/yDB z0PhXzB59g7k4FNGpxdlzXd1NPJSVVaQzryEHwELSbO4A/r8IxLwIAG2dT+AEiWRIoJv 3C+/Rr95m7+dnZ0ISEhf36uuDbetMJAOEvnyz37Cvo8HeAEjja9E6B36Z9GpyFkOML3+ rHF0FE7PDnLSLnjYEqwBIcxR80pAD2xZXGNvqkUintWg/tzE5j7HPbaSd3HJ/Gg3CrhG ZjrA== 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=5mJnkmCotb0tVp778KZsffXdscMhySCoKbefLJW0xpA=; b=eo59Y7sfNMjNuak7//wS37unAgbLjo630aELsThlIjGScf+8sV5Fdh6NxAvIwtir0V 0Oof1YT7RVuxaUBmnAhggfl0lCyI8N8j4+/K3q6igXupRkxC51uo+3Rmz2XK5OLqtqXz yyLWmmgarFFG0DkzwMtebBHcbYXV0IW4ZGLyPyTvchMpRnAkJ04CwWYyE1cjv5zP15/A 2Vo9I0gn2fotQ6CP1F4r0hr07lMYgO8xyRvf4YJfQ63btkTapW79j+w3+VM5o7Q8JDJt g1i9+AxHaTkfVtL5hjnUjq6XbyiIF1p7EkPmbo82+8UVb+3wUj3eGzBAg1Ulq7hQwNvX 7LZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q9Is3IRW; 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 e7si1571520ejq.15.2020.05.05.12.05.45; Tue, 05 May 2020 12:06:10 -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=Q9Is3IRW; 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 S1729158AbgEETBK (ORCPT + 99 others); Tue, 5 May 2020 15:01:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:39758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727857AbgEETBK (ORCPT ); Tue, 5 May 2020 15:01:10 -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 C27A120721; Tue, 5 May 2020 19:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588705269; bh=BZtLJRZM1ELXagARN2dB3BtMJyx+5UOFE8fa/QlEPmw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Q9Is3IRW3exH7Z8EgzlDpPYb8lw7lPWzkhqFt64feVmD1T0gryKxdnb4sUTcYauev oI6qJaX40yGxFm38jqffbdJPRTW7N5th6tQr/U44bWkE9Jcn7HPc181S3rAmh5LqVy kmAyid8yccRLaJv/89RXG07gRwDdftt5YoJMAEYQ= Date: Tue, 5 May 2020 12:01:08 -0700 From: Eric Biggers To: Jaegeuk Kim Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Subject: Re: [f2fs-dev] [PATCH] f2fs: get parent inode when recovering pino Message-ID: <20200505190108.GB128280@sol.localdomain> References: <20200505153139.201697-1-jaegeuk@kernel.org> <20200505165847.GA98848@gmail.com> <20200505181323.GA55221@google.com> <20200505181941.GC98848@gmail.com> <20200505184932.GC55221@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200505184932.GC55221@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 05, 2020 at 11:49:32AM -0700, Jaegeuk Kim wrote: > How about this? > > From 2a6b0e53e592854306062a2dc35db2d8f79062f2 Mon Sep 17 00:00:00 2001 > From: Jaegeuk Kim > Date: Tue, 5 May 2020 11:33:29 -0700 > Subject: [PATCH] f2fs: find a living dentry when finding parent ino > > We need to check any dentry still alive to get parent inode number. > > Suggested-by: Eric Biggers > Signed-off-by: Jaegeuk Kim > --- > fs/f2fs/file.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index a0a4413d6083b..95139cb85faca 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -169,9 +169,8 @@ static int get_parent_ino(struct inode *inode, nid_t *pino) > { > struct dentry *dentry; > > - inode = igrab(inode); > - dentry = d_find_any_alias(inode); > - iput(inode); > + /* Need to check if valid dentry still exists. */ > + dentry = d_find_alias(inode); > if (!dentry) > return 0; > It's fine, but it could use some more explanation. (What's a "valid dentry"?) How about the following? From f8fe7d57eead1423e8548ac7a5ec881d701466a5 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Tue, 5 May 2020 11:41:11 -0700 Subject: [PATCH] f2fs: correctly fix the parent inode number during fsync() fsync() may be called on a deleted file that's still open. So when fsync() tries to set the parent inode number when the inode has LOST_PINO and i_nlink == 1 (to avoid later checkpoints), it needs to make sure to get the parent directory via a non-deleted alias. Also remove the unnecessary igrab() and iput(), as the caller already holds a reference to the inode. Signed-off-by: Eric Biggers --- fs/f2fs/file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 6ab8f621a3c5a2..b3069188fd3478 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -165,9 +165,11 @@ static int get_parent_ino(struct inode *inode, nid_t *pino) { struct dentry *dentry; - inode = igrab(inode); - dentry = d_find_any_alias(inode); - iput(inode); + /* + * Make sure to get the non-deleted alias. The alias associated with + * the open file descriptor being fsync()'ed may be deleted already. + */ + dentry = d_find_alias(inode); if (!dentry) return 0; -- 2.26.2