Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8265728ybi; Thu, 6 Jun 2019 09:16:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6gUmnI/h4TPRi/5Au7tVDQNbvUWCdNBRf4kZjwjx5yRQ33h60yxZau78kD7goN0DQDc8q X-Received: by 2002:a17:902:2b8a:: with SMTP id l10mr12611099plb.283.1559837812569; Thu, 06 Jun 2019 09:16:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559837812; cv=none; d=google.com; s=arc-20160816; b=DpLu3e89AMIIxoFdqw/D/wM2CzThPOuFS9yNTjyro27sQq0nB7+Cxh+B1Zocq8z2ck xJnzHzAdHNh4mlT6t6P58fvdAdHOeZsQAZdsP6LEyeLm5E4Tba/luE2sQSEyXzvPPAA0 sEMXnC0NhXvgbbwU/floxV8E6mCqZTplmwhDORXRjdQjdbgES36AcwBp7+vwo8ljgwST BVwPUekkNQJkcQMiInZ4LJmrwFu032g3v4aL0my0LN3NHbl82u3REBVaMRylIy+dLtju Z3JnwX81+s6PejLatAfydK8of6ts2U2Zn3T9t+NLVA8SD0OneMxlQIDReMJsOa2S1IS1 RMZQ== 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=xEoOsJCl9B7w4jWFHWKPrUHI08IrYTJNXsZHGapYT7w=; b=KV/kpBm6S5+d8cLOlMxqRktMui6NvwTxoXyz/h/FT23lZgtYsm1Rb8Ugn4c0mApMw5 DBlD37/HVEVdOBWqOdKoYmskqnrgvDks+WNG0T364DFfkJgruq+7c2eRKocIdLEAmEOG Br47y/MIitOrvMfPCe5cgtIBBFVbug+TK1vIvfIo1Wp5J4a7IGRO8IBQnfU5v86n+Qdr Wji8BBrf5W2GRRG9B0ysC5mAWNIuap78GZBV+FNGjkOmybcCyzZdmixjZrcF7+Nq8izZ En8rweJ5a+WEpt+SOn7A9CjUP1VQdtv88wCuqiJksqPs5sjd0r9tdkEI6WP3u8J/vGWK Hnxg== 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 p21si1988344plq.328.2019.06.06.09.16.38; Thu, 06 Jun 2019 09:16:52 -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 S1729657AbfFFQPv (ORCPT + 99 others); Thu, 6 Jun 2019 12:15:51 -0400 Received: from mga02.intel.com ([134.134.136.20]:55622 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729165AbfFFQPv (ORCPT ); Thu, 6 Jun 2019 12:15:51 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 09:15:50 -0700 X-ExtLoop1: 1 Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by fmsmga006.fm.intel.com with ESMTP; 06 Jun 2019 09:15:50 -0700 Date: Thu, 6 Jun 2019 09:17:02 -0700 From: Ira Weiny To: Jan Kara Cc: Dan Williams , Theodore Ts'o , Jeff Layton , Dave Chinner , Matthew Wilcox , linux-xfs@vger.kernel.org, Andrew Morton , John Hubbard , =?iso-8859-1?B?Suly9G1l?= Glisse , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH RFC 07/10] fs/ext4: Fail truncate if pages are GUP pinned Message-ID: <20190606161702.GA11374@iweiny-DESK2.sc.intel.com> References: <20190606014544.8339-1-ira.weiny@intel.com> <20190606014544.8339-8-ira.weiny@intel.com> <20190606105855.GG7433@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190606105855.GG7433@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 Thu, Jun 06, 2019 at 12:58:55PM +0200, Jan Kara wrote: > On Wed 05-06-19 18:45:40, ira.weiny@intel.com wrote: > > From: Ira Weiny > > > > If pages are actively gup pinned fail the truncate operation. > > > > Signed-off-by: Ira Weiny > > --- > > fs/ext4/inode.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > > index 75f543f384e4..1ded83ec08c0 100644 > > --- a/fs/ext4/inode.c > > +++ b/fs/ext4/inode.c > > @@ -4250,6 +4250,9 @@ int ext4_break_layouts(struct inode *inode, loff_t offset, loff_t len) > > if (!page) > > return 0; > > > > + if (page_gup_pinned(page)) > > + return -ETXTBSY; > > + > > error = ___wait_var_event(&page->_refcount, > > atomic_read(&page->_refcount) == 1, > > TASK_INTERRUPTIBLE, 0, 0, > > This caught my eye. Does this mean that now truncate for a file which has > temporary gup users (such buffers for DIO) can fail with ETXTBUSY? I thought about that before and I _thought_ I had accounted for it. But I think you are right... > > That > doesn't look desirable. No not desirable at all... Ah it just dawned on my why I thought it was ok... I was wrong. :-/ > If we would mandate layout lease while pages are > pinned as I suggested, this could be dealt with by checking for leases with > pins (breaking such lease would return error and not break it) and if > breaking leases succeeds (i.e., there are no long-term pinned pages), we'd > just wait for the remaining references as we do now. Agreed. But I'm going to respond with some of the challenges of this (and ideas I had) when replying to your other email. Ira > > Honza > -- > Jan Kara > SUSE Labs, CR