Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1263523ybm; Tue, 21 May 2019 11:08:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxirUUUXVDofzO0GI3tFl5cdHrvdre898MYTqC6A3ifKD7vMpHhz1s8B54P0otfeX6XivrT X-Received: by 2002:a63:5b5c:: with SMTP id l28mr39929557pgm.158.1558462086610; Tue, 21 May 2019 11:08:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558462086; cv=none; d=google.com; s=arc-20160816; b=mQ3dtG43pJDxFfMQmU/a6nISfde5GIX86Lr+06oMw39DW2Fde+Y4JERcYsZYUjt5UZ kTYkxj4HryMlHUDjJp2NiDm4DpPMA0X+j8jEAP0YOJr13Ps4gDYELGDwJxjsZmMlevbM JhlUmf4Im5o4EGCdguqcd5Mpep6oIDHfM9J8DFXnjXTIsH2u/XoCyeEjoUQSqXyKyGIn T7nfCRS/dtw9kmaFQ7WFlJePSQPP0zplud6FSqH0fYV65KrUcAckIzkdHnFTV+vAM7aT 7RH+I8wx+muC2r8T6E4m0Gio2w24Ofnx1HOfrjqy31oCS7Whd1K10g2gmZnUhf+f32Hd Kyeg== 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=/w7HLwWBFeWoJsLyPHUEgBT+BxIB4VJQKrvliTsahDM=; b=PMjRLg3SlXucSnX2A6oulOqi/yyYfjkQwPdOrAaZ+XKUWsK5lHAVHAnnLLmbFNw4bM GTwjKpLmOXrsA2vzdfBCVcyJy7q6um3C6ihW+dOuZ5LA1bV5JZig2spcQEsTgGY1BbE0 xIhjAEDm7QngTa6Mj6CMdp84Iv6OVKnPnUVbouWumbRP92L2gdlqj+C1Xat+ihs7eBnN Pj3f1WtAbTfnsYj4g3CGrtUfbQxl4pJxFXF2giFEG59Hohz571JthhBRYODoLkdv3BPi FD4MEslIRTdIqR/+/AmtN45maKSTElKZ52JgzNHEcv7iN9cz/6L7TLsUmbncfC4Kqcwg VzqA== 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 b66si23818527plb.426.2019.05.21.11.07.48; Tue, 21 May 2019 11:08:06 -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 S1728768AbfEUSGs (ORCPT + 99 others); Tue, 21 May 2019 14:06:48 -0400 Received: from mga11.intel.com ([192.55.52.93]:19875 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727898AbfEUSGs (ORCPT ); Tue, 21 May 2019 14:06:48 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2019 11:06:48 -0700 X-ExtLoop1: 1 Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by orsmga005.jf.intel.com with ESMTP; 21 May 2019 11:06:47 -0700 Date: Tue, 21 May 2019 11:07:38 -0700 From: Ira Weiny To: Jan Kara Cc: Ted Tso , linux-ext4@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 1/3] ext4: Wait for outstanding dio during truncate in nojournal mode Message-ID: <20190521180737.GA31888@iweiny-DESK2.sc.intel.com> References: <20190521074358.17186-1-jack@suse.cz> <20190521074358.17186-2-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190521074358.17186-2-jack@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 Tue, May 21, 2019 at 09:43:56AM +0200, Jan Kara wrote: > We didn't wait for outstanding direct IO during truncate in nojournal > mode (as we skip orphan handling in that case). This can lead to fs > corruption or stale data exposure if truncate ends up freeing blocks > and these get reallocated before direct IO finishes. Fix the condition > determining whether the wait is necessary. > > CC: stable@vger.kernel.org > Fixes: 1c9114f9c0f1 ("ext4: serialize unlocked dio reads with truncate") > Signed-off-by: Jan Kara Reviewed-by: Ira Weiny > --- > fs/ext4/inode.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 82298c63ea6d..9bcb7f2b86dd 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -5630,20 +5630,17 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) > goto err_out; > } > } > - if (!shrink) > + if (!shrink) { > pagecache_isize_extended(inode, oldsize, inode->i_size); > - > - /* > - * Blocks are going to be removed from the inode. Wait > - * for dio in flight. Temporarily disable > - * dioread_nolock to prevent livelock. > - */ > - if (orphan) { > - if (!ext4_should_journal_data(inode)) { > - inode_dio_wait(inode); > - } else > - ext4_wait_for_tail_page_commit(inode); > + } else { > + /* > + * Blocks are going to be removed from the inode. Wait > + * for dio in flight. > + */ > + inode_dio_wait(inode); > } > + if (orphan && ext4_should_journal_data(inode)) > + ext4_wait_for_tail_page_commit(inode); > down_write(&EXT4_I(inode)->i_mmap_sem); > > rc = ext4_break_layouts(inode); > -- > 2.16.4 >