Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp225973ybm; Wed, 22 May 2019 02:01:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7imIZgrHcDuCTf2NEUGJrTD69Lgq7VvaViZO0Xs0DlQ+ZVrRkHZojMVkbZK+lVL+S3Lne X-Received: by 2002:a62:4118:: with SMTP id o24mr63568889pfa.17.1558515708511; Wed, 22 May 2019 02:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558515708; cv=none; d=google.com; s=arc-20160816; b=XnV0NaJY/KiLw7VF8wlQ5/Kr7jl1F40P+tg1Bhp3/weshYm+TSAMN/lNc6Ecb5oTlU i+8iznpUFeSzVfXRPuR7lE/exQ4mbULn5PRRj0dfJPbvK6DEN01OGc+SPVi2V5eJSF19 Oiix4dOzF6sbiCDAPjN9WZUQ2NvIvMAwxcW9D9MRUtOVzVugxPiQvjdXQ5FZCn3gVkT4 SS3CY/0DLP8EGCQQ64dUAnZBSPBbYWx/Q1dj/rPiaWRKiARkn5j6QFT9Fje5cwOT3gCs v+ZEeKOwY//lArCvj34wk0MmerfG3dDBcitxF1ZQ19n/ih6C7wOBXFsNMO2jEfCQrk+I WDNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=jx69NK/flU63gNdnJ9+IQLukStao5dK0wzXPdoSizaA=; b=F5BZZ9OqRfmJxfY0zVGB0nGLViutnJkVaXqqfb7xIAa7z3c8h7tkkonYjPbOkX+fJa N+lZ1Sl7ED4nYjr4ealCNIocHTZw/GIo+1dOMCp5PrtV9T+mejeoSDr3+uzUNMsGIWVt RRz2EBrMM2KWC0QuTvjfT9nFWJhL6oX1a7T+FE+OkGj1mnF4fTdHThIIFDB+Hdx3Wyh2 TzSs/ume2VOjhyygvBAbYAfe7E5IrEsTRvAo9jMzQs4Ebu82IJcx5ReMMaK6D15p9XAC P1q2n8CrWAgPU+gqY2AHqi51gdIgK4CzPKWq4M3nikQLrsdeDNVdbX1cUMEvYz5UURVC 8qYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6si23956387plk.296.2019.05.22.02.01.33; Wed, 22 May 2019 02:01:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728527AbfEVJAx (ORCPT + 99 others); Wed, 22 May 2019 05:00:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:41906 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727946AbfEVJAx (ORCPT ); Wed, 22 May 2019 05:00:53 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 35FBAB03E; Wed, 22 May 2019 09:00:52 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 8F1931E3C69; Wed, 22 May 2019 11:00:52 +0200 (CEST) Date: Wed, 22 May 2019 11:00:52 +0200 From: Jan Kara To: Ira Weiny Cc: Jan Kara , Ted Tso , linux-ext4@vger.kernel.org Subject: Re: [PATCH 2/3] ext4: Do not delete unlinked inode from orphan list on failed truncate Message-ID: <20190522090052.GD17019@quack2.suse.cz> References: <20190521074358.17186-1-jack@suse.cz> <20190521074358.17186-3-jack@suse.cz> <20190521181348.GB31888@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190521181348.GB31888@iweiny-DESK2.sc.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue 21-05-19 11:13:49, Ira Weiny wrote: > On Tue, May 21, 2019 at 09:43:57AM +0200, Jan Kara wrote: > > It is possible that unlinked inode enters ext4_setattr() (e.g. if > > somebody calls ftruncate(2) on unlinked but still open file). In such > > case we should not delete the inode from the orphan list if truncate > > fails. Note that this is mostly a theoretical concern as filesystem is > > corrupted if we reach this path anyway but let's be consistent in our > > orphan handling. > > > > Signed-off-by: Jan Kara > > --- > > fs/ext4/inode.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > > index 9bcb7f2b86dd..c7f77c643008 100644 > > --- a/fs/ext4/inode.c > > +++ b/fs/ext4/inode.c > > @@ -5625,7 +5625,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) > > up_write(&EXT4_I(inode)->i_data_sem); > > ext4_journal_stop(handle); > > if (error) { > > - if (orphan) > > + if (orphan && inode->i_nlink) > > ext4_orphan_del(NULL, inode); > > > NIT: While ext4_orphan_del() can be called even if the inode was not on the > orphan list it kind of tripped me up to see this called even if > ext4_orphan_add() fails... > > But considering how ext4_orphan_del() works: > > Reviewed-by: Ira Weiny Yes, calling ext4_orphan_del() twice is harmless. You're right we just shouldn't set 'orphan = 1' if ext4_orphan_add() fails but that's independent cleanup we could do. Thanks for your review! Honza -- Jan Kara SUSE Labs, CR