Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7928342ybi; Thu, 6 Jun 2019 03:59:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1MxRla4jpYNqXxcBQcMTBwVO2vx3AZHakCoQ3LO8TZC5s9Y+B6fSxN5AvrexbbVSXBBRf X-Received: by 2002:a17:90a:20c4:: with SMTP id f62mr49963239pjg.16.1559818788945; Thu, 06 Jun 2019 03:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559818788; cv=none; d=google.com; s=arc-20160816; b=Kibdud5QkCgXc0Aza9zTHPz4pX7fLQnxeH5QO/2bjJfdizWSTAh61IOT2zRY9D6VTX 6WC77voMNx9KwAli7INXqInP8KxX+89k8MbGbTTmRTTX8INW10TkJH0TEEypqPJE6Qld NUYmmIZCl//wUzYiHra1rglkrm9ERsThfoEW1Pg2eu+qhuVIxlsKwG9/s7gOPJYsKt+I ajR+qrwFu9HAPJClAEfw22DMK8yaOk/jMN+uSn23Q2MzgBLUOMMlvXXS/kMSy/rNI6Y2 kci2I3Ux/EaHRi6e9WO1U8Shc/CVJS4A4D97En63kDou2PzqHviUmVgK4pjoiJ3OeG3y APHw== 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=fpgy2lN5a/yE57jAoHvcoQ5aUnLsxR1PYtwc2sGpdM4=; b=tuwRDyR+4T95Urr645nD/v4T/TjcFxSxntxZ8gz517375qsSsux5Z26W8lD4bSDKEH t8znjH9MrzKNgrC2s9JdzgXnDtxUOvTSK2LsKp2cDoPznddEdsBQoxJ7/67jGi9Vz8ef zfnNd2/JL/PF9yCY/3qVN/HjcLKkAEEIMi6TXKgri9l9XFEPO0/Ozttwn0XjrslCZCA0 nSvED9J/etr6ymJG3l6wawxttLaRzuGxT2C8mK6hwS62SPZhrcLdrgJJYMdJcPQLo+FE eCVhqz9nRO6xUgL9UmXWG7B4tH5A+xP+Xau++isdb1rOHiR7W7/lmF2GUuNB0S/g6Tmf 7FHA== 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 j1si1531293plt.9.2019.06.06.03.59.31; Thu, 06 Jun 2019 03:59: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 S1727470AbfFFK66 (ORCPT + 99 others); Thu, 6 Jun 2019 06:58:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:32798 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727324AbfFFK66 (ORCPT ); Thu, 6 Jun 2019 06:58:58 -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 7F9F6AF21; Thu, 6 Jun 2019 10:58:56 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id ED0EC1E3F51; Thu, 6 Jun 2019 12:58:55 +0200 (CEST) Date: Thu, 6 Jun 2019 12:58:55 +0200 From: Jan Kara To: ira.weiny@intel.com Cc: Dan Williams , Jan Kara , 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: <20190606105855.GG7433@quack2.suse.cz> References: <20190606014544.8339-1-ira.weiny@intel.com> <20190606014544.8339-8-ira.weiny@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190606014544.8339-8-ira.weiny@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 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? That doesn't look desirable. 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. Honza -- Jan Kara SUSE Labs, CR