From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94015C31E46 for ; Wed, 12 Jun 2019 09:52:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78F1220866 for ; Wed, 12 Jun 2019 09:52:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437714AbfFLJwJ (ORCPT ); Wed, 12 Jun 2019 05:52:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:35500 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2437415AbfFLJwJ (ORCPT ); Wed, 12 Jun 2019 05:52:09 -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 ECAA6AF52; Wed, 12 Jun 2019 09:52:06 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 89C291E4328; Wed, 12 Jun 2019 11:46:34 +0200 (CEST) Date: Wed, 12 Jun 2019 11:46:34 +0200 From: Jan Kara To: Ira Weiny Cc: Jeff Layton , Dan Williams , Jan Kara , Theodore Ts'o , 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 02/10] fs/locks: Export F_LAYOUT lease to user space Message-ID: <20190612094634.GA14578@quack2.suse.cz> References: <20190606014544.8339-1-ira.weiny@intel.com> <20190606014544.8339-3-ira.weiny@intel.com> <4e5eb31a41b91a28fbc83c65195a2c75a59cfa24.camel@kernel.org> <20190611213812.GC14336@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190611213812.GC14336@iweiny-DESK2.sc.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 Tue 11-06-19 14:38:13, Ira Weiny wrote: > On Sun, Jun 09, 2019 at 09:00:24AM -0400, Jeff Layton wrote: > > On Wed, 2019-06-05 at 18:45 -0700, ira.weiny@intel.com wrote: > > > From: Ira Weiny > > > > > > GUP longterm pins of non-pagecache file system pages (eg FS DAX) are > > > currently disallowed because they are unsafe. > > > > > > The danger for pinning these pages comes from the fact that hole punch > > > and/or truncate of those files results in the pages being mapped and > > > pinned by a user space process while DAX has potentially allocated those > > > pages to other processes. > > > > > > Most (All) users who are mapping FS DAX pages for long term pin purposes > > > (such as RDMA) are not going to want to deallocate these pages while > > > those pages are in use. To do so would mean the application would lose > > > data. So the use case for allowing truncate operations of such pages > > > is limited. > > > > > > However, the kernel must protect itself and users from potential > > > mistakes and/or malicious user space code. Rather than disabling long > > > term pins as is done now. Allow for users who know they are going to > > > be pinning this memory to alert the file system of this intention. > > > Furthermore, allow users to be alerted such that they can react if a > > > truncate operation occurs for some reason. > > > > > > Example user space pseudocode for a user using RDMA and wanting to allow > > > a truncate would look like this: > > > > > > lease_break_sigio_handler() { > > > ... > > > if (sigio.fd == rdma_fd) { > > > complete_rdma_operations(...); > > > ibv_dereg_mr(mr); > > > close(rdma_fd); > > > fcntl(rdma_fd, F_SETLEASE, F_UNLCK); > > > } > > > } > > > > > > setup_rdma_to_dax_file() { > > > ... > > > rdma_fd = open(...) > > > fcntl(rdma_fd, F_SETLEASE, F_LAYOUT); > > > > I'm not crazy about this interface. F_LAYOUT doesn't seem to be in the > > same category as F_RDLCK/F_WRLCK/F_UNLCK. > > > > Maybe instead of F_SETLEASE, this should use new > > F_SETLAYOUT/F_GETLAYOUT cmd values? There is nothing that would prevent > > you from setting both a lease and a layout on a file, and indeed knfsd > > can set both. > > > > This interface seems to conflate the two. > > I've been feeling the same way. This is why I was leaning toward a new lease > type. I called it "F_LONGTERM" but the name is not important. > > I think the concept of adding "exclusive" to the layout lease can fix this > because the NFS lease is non-exclusive where the user space one (for the > purpose of GUP pinning) would need to be. > > FWIW I have not worked out exactly what this new "exclusive" code will look > like. Jan said: > > "There actually is support for locks that are not broken after given > timeout so there shouldn't be too many changes need." > > But I'm not seeing that for Lease code. So I'm working on something for the > lease code now. Yeah, sorry for misleading you. Somehow I thought that if lease_break_time == 0, we will wait indefinitely but when checking the code again, that doesn't seem to be the case. Honza -- Jan Kara SUSE Labs, CR