Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp645955ybm; Tue, 21 May 2019 00:45:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjX0R3XGOpKHcjv1/cPNgOw10CVcJwdaGEyKxkpUOn2rcCxyUCjrPvs0PZEW0PZtpB7RrV X-Received: by 2002:aa7:9e51:: with SMTP id z17mr85126984pfq.212.1558424729922; Tue, 21 May 2019 00:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558424729; cv=none; d=google.com; s=arc-20160816; b=YBzqKJ3qk5TjGI4UyshemIZdLRzPdtNLUlErQQElvOuyzh9thGuMV/8e59IB2ImoDr rtxUVdsWmE4jE66QfpjrV/GcIaNgjRhYJJ4VdIzILdEv7iVA9/F71+y9j2JydbMNkWnT pDSx9RuqiFzd6u+GuHz3DtYTZkKBt1WhEh/mp/DMvDcvSHadeX2GgCcIv2IRX3P10mtZ hWJroh37RgcqUc3x311fgqe8OQH8+JBdwdTX8+qQahxAQ7dLxh26BtwmIYHTs8AHw6KW gs+Rd39k/jTIKLUtJI2cUj858sHgvnZNVPXitt9IUpc0r8gO/E2DDv+rn6BCQt72PXhK yXYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=C4CMfmrjCe5tPJYPu9XI42/mZ7Vv/zux7aBHoICg0T8=; b=lWl8gpc7j4oZf4mnmw21L9WNAP719mY0AWES0Xt6zCetYAQ9t3EKB4u7yvM4xkjpVd E/vWKgqc4Ibuyx+iZNuNR5IZ+31dY7rpuFqLzmAML0MvImgVqOZp9QTZ6fD7+rISpJDa MYl0lONecSWhIQdtebMkl5x5PxABkcu/PFmb3ADTcNacqkh5bkCiePU40TdLYKKqb2AS 7HRgZCMI7UWOoXsjJ96rS68iK42xCON5I4M2yqWqAwR5vIrUGV2EQiK/H+DyhDrnztwY 0kIvenavzf6KPygidm5d4xv5atSHQuTIAGa2VyEX5SX8asmCVHobcSvcNrj5CRj8ZLnL JEKA== 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 b7si2161328pgk.553.2019.05.21.00.45.14; Tue, 21 May 2019 00:45:29 -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 S1726242AbfEUHoH (ORCPT + 99 others); Tue, 21 May 2019 03:44:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:37326 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726028AbfEUHoH (ORCPT ); Tue, 21 May 2019 03:44:07 -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 E026DAD62; Tue, 21 May 2019 07:44:05 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id CF4221E3C5F; Tue, 21 May 2019 09:44:04 +0200 (CEST) From: Jan Kara To: Ted Tso Cc: , "Weiny, Ira" , Jan Kara Subject: [PATCH 2/3] ext4: Do not delete unlinked inode from orphan list on failed truncate Date: Tue, 21 May 2019 09:43:57 +0200 Message-Id: <20190521074358.17186-3-jack@suse.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190521074358.17186-1-jack@suse.cz> References: <20190521074358.17186-1-jack@suse.cz> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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); goto err_out; } -- 2.16.4