From patchwork Fri Oct 6 22:36:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9990669 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 05D2060244 for ; Fri, 6 Oct 2017 22:42:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB2C628E14 for ; Fri, 6 Oct 2017 22:42:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFCF928E48; Fri, 6 Oct 2017 22:42:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7954228E14 for ; Fri, 6 Oct 2017 22:42:32 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 252BE21FC7498; Fri, 6 Oct 2017 15:39:08 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ECCAC21FC7476 for ; Fri, 6 Oct 2017 15:39:06 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Oct 2017 15:42:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,486,1500966000"; d="scan'208";a="157749211" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by orsmga005.jf.intel.com with ESMTP; 06 Oct 2017 15:42:30 -0700 Subject: [PATCH v7 09/12] xfs: wire up ->lease_direct() From: Dan Williams To: linux-nvdimm@lists.01.org Date: Fri, 06 Oct 2017 15:36:06 -0700 Message-ID: <150732936625.22363.7638037715540836828.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <150732931273.22363.8436792888326501071.stgit@dwillia2-desk3.amr.corp.intel.com> References: <150732931273.22363.8436792888326501071.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "J. Bruce Fields" , Jan Kara , "Darrick J. Wong" , linux-rdma@vger.kernel.org, linux-api@vger.kernel.org, Dave Chinner , linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Jeff Layton , Christoph Hellwig Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP A 'lease_direct' lease requires that the vma have a valid MAP_DIRECT mapping established. For xfs we establish a new lease and then check if the MAP_DIRECT mapping has been broken. We want to be sure that the process will receive notification that the MAP_DIRECT mapping is being torn down so it knows why other code paths are throwing failures. For example in the RDMA/ibverbs case we want ibv_reg_mr() to fail if the MAP_DIRECT mapping is invalid or in the process of being invalidated. Cc: Jan Kara Cc: Jeff Moyer Cc: Christoph Hellwig Cc: Dave Chinner Cc: "Darrick J. Wong" Cc: Ross Zwisler Cc: Jeff Layton Cc: "J. Bruce Fields" Signed-off-by: Dan Williams --- fs/xfs/xfs_file.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index e35518600e28..823b65f17429 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1166,6 +1166,33 @@ xfs_filemap_direct_close( put_map_direct_vma(vma->vm_private_data); } +static struct lease_direct * +xfs_filemap_direct_lease( + struct vm_area_struct *vma, + void (*break_fn)(void *), + void *owner) +{ + struct lease_direct *ld; + + ld = map_direct_lease(vma, break_fn, owner); + + if (IS_ERR(ld)) + return ld; + + /* + * We now have an established lease while the base MAP_DIRECT + * lease was not broken. So, we know that the "lease holder" will + * receive a SIGIO notification when the lease is broken and + * take any necessary cleanup actions. + */ + if (!is_map_direct_broken(vma->vm_private_data)) + return ld; + + map_direct_lease_destroy(ld); + + return ERR_PTR(-ENXIO); +} + static const struct vm_operations_struct xfs_file_vm_direct_ops = { .fault = xfs_filemap_fault, .huge_fault = xfs_filemap_huge_fault, @@ -1175,6 +1202,7 @@ static const struct vm_operations_struct xfs_file_vm_direct_ops = { .open = xfs_filemap_direct_open, .close = xfs_filemap_direct_close, + .lease_direct = xfs_filemap_direct_lease, }; static const struct vm_operations_struct xfs_file_vm_ops = {