Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2289041yba; Fri, 17 May 2019 14:12:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzS8XLgUjWQ4VkebmiYCxvFcWcrLoOMmshAgIPLKxOobAGwCP8GhJN+KDrgjf5VXi8X70ou X-Received: by 2002:a63:a1a:: with SMTP id 26mr57882421pgk.11.1558127552813; Fri, 17 May 2019 14:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558127552; cv=none; d=google.com; s=arc-20160816; b=AkgJa8SVeaiphv/iwFJ/xggAZ7m3ETFzw+JkTlOL5Fnn7T+v3YZPKLMhUY57q0CLJd dWx/Mp28oCszVJAHp6zmjxZsOMDJBbjJixaQY6unOG+VHvRIqHkxCCkj/3YNww565aeX 9eUJJZRdM67G0dTXP4fhLtgzJDa9JZQfBgab+NSeY54uf039u5k4v60pNO7rTdxme0N9 dP81zw4WOPzfja5QmVEb6nkr6jb5kzU3NByhxqhFMgb3ugg9lXqzA221ig8vdjTZUU2M 6bwm+BFusgcmUrpEGC+wQbf+Hl4D2U+fOt9576xbCOr73Jl4z/Elom8U0c+lYLjuKfi1 Avww== 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=7441Lm4+2UZauVZda2oHzHgkIE8IM2Njr6rINfSJRDg=; b=p3nK5b8r0Vqdxozbj7Bmogc2FZIJz9TSSCkjYwAc+5IC/mDkae5yjmU3Yz0v7INrsX TZSpQW5yu4n73Bgtn1UMgHQ/S7dfpf3utcvV3xOiLjeozz1V6jQo2kXJEYsLpAqrTe7/ 9oUTgcUpayE/rEyFV8iTFCebQfdapt4Or2cdaqtspPaB1AfE5JUkWiZ5IOVX8+NoM77D a7fcO96b6Z4W8a5tNDw/6OdcCy5mNI+TN896rls5hc8HOXg90uFoNF3Fjg+EFNmeO6Sl 28R4xMibPFDNhGT/RM8UbvtFA2M7wN5OB/qFVZDU1HS2TbRoBftUEf4NyN2alzlUoMg/ 4LGQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g13si8779833pgj.272.2019.05.17.14.12.05; Fri, 17 May 2019 14:12:32 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727505AbfEQURC (ORCPT + 99 others); Fri, 17 May 2019 16:17:02 -0400 Received: from mga11.intel.com ([192.55.52.93]:39872 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726460AbfEQURC (ORCPT ); Fri, 17 May 2019 16:17:02 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 May 2019 13:17:01 -0700 X-ExtLoop1: 1 Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by fmsmga004.fm.intel.com with ESMTP; 17 May 2019 13:17:01 -0700 Date: Fri, 17 May 2019 13:17:47 -0700 From: Ira Weiny To: Jan Kara Cc: Theodore Ts'o , linux-ext4@vger.kernel.org, Dan Williams Subject: Re: Can ext4_break_layouts() ever fail? Message-ID: <20190517201746.GA14175@iweiny-DESK2.sc.intel.com> References: <20190516205615.GA2926@iweiny-DESK2.sc.intel.com> <20190517090252.GC20550@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190517090252.GC20550@quack2.suse.cz> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, May 17, 2019 at 11:02:52AM +0200, Jan Kara wrote: > On Thu 16-05-19 13:56:15, Ira Weiny wrote: > > > It looks to me like it is possible for ext4_break_layouts() to fail if > > prepare_to_wait_event() sees a pending signal. Therefore I think this is a bug > > in ext4 regardless of how I may implement a truncate failure. > > Yes, it's a bug in ext4. > > > --- a/fs/ext4/inode.c > > +++ b/fs/ext4/inode.c > > @@ -5648,6 +5648,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) > > if (rc) { > > up_write(&EXT4_I(inode)->i_mmap_sem); > > error = rc; > > + if (orphan) > > + ext4_orphan_del(NULL, inode); > > This isn't quite correct. This would silence the warning but leave the > inode in on-disk orphan list. That is OK in case of fs-meltdown types of > failures like IO errors for metadata, aborted journal, or stuff like that. > But failing ext4_break_layouts() needs to be handled gracefully maintaining > fs consistency. So you rather need something like: > > if (orphan && inode->i_nlink > 0) { > handle_t *handle; > > handle = ext4_journal_start(inode, > EXT4_HT_INODE, 3); > if (IS_ERR(handle)) { > ext4_orphan_del(NULL, inode); > goto err_out; > } > ext4_orphan_del(handle, inode); > ext4_journal_stop(handle); > } > Thanks! Unfortunately, even with your suggestion something is still wrong with my code. For some reason this does not seem to be "canceling" the truncate completely. With my test code for FS DAX which fails ext4_break_layout() the file is being truncated and an application which is writing past that truncation is getting a SIGBUS. I don't understand why this is happening because failing here should be skipping the call to truncate_pagecache() which AFAICT does user unmappings... So... I'm still investigating this. But thanks for confirming this is a bug. I will get a generic patch out soon. Thanks, Ira