From patchwork Tue Nov 17 11:52:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 7636321 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 80FFDC05CA for ; Tue, 17 Nov 2015 11:54:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD05D204E2 for ; Tue, 17 Nov 2015 11:54:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C660F204EA for ; Tue, 17 Nov 2015 11:54:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752922AbbKQLyQ (ORCPT ); Tue, 17 Nov 2015 06:54:16 -0500 Received: from mail-qk0-f173.google.com ([209.85.220.173]:35881 "EHLO mail-qk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753582AbbKQLxv (ORCPT ); Tue, 17 Nov 2015 06:53:51 -0500 Received: by qkda6 with SMTP id a6so1677525qkd.3 for ; Tue, 17 Nov 2015 03:53:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poochiereds_net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0bBxI3gaaJTmVUIvu/K5LW9VAPv5BHJ6agvVyz858cs=; b=Wvtc8AIC5YvBw48XgEsADHO1bMnWH8YZ10N7ooc29hNojBPgeO1pxrzrjm/c+eXb0W Gx9Ty8z21NuPet3VM4tB/Htu0B5sMBI5+eg2ZJPDRSn5XoEAcjDOEnUultjKYpNynhj5 ULYOtxB/5myHjrEXKQLP/afYSB1z/ACJDm26AXZzhvGPCmbZWIVEeN4lJ4Mn8Zrr6ztN Ho2HNNo5ZHX3gEQqZVnm7mxhC0o3XlfvVmV6+JQCj93tlVA4K9nEb4MjYQzojp3u+mGT hzx4ME16iTBHkcPxlLdF0+8Lg22T8I2tFNK80TaL810b8apu11Kw9OkNISGf0R4VIvd+ NO4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0bBxI3gaaJTmVUIvu/K5LW9VAPv5BHJ6agvVyz858cs=; b=HxzYd5MxOHkbNSPx4Ggn6AlpiWQYs0Uq0XWRfZgFsi9Ed09tTSPmhTc3sT6ZMDL/c/ HoNd6ceTAO6HqSCAMXB02HLNTMf0YelAXlJRIzpFdUhj4uBKG1pTj7GI7TWxEmENEblk SWfhqsWa8eA72ljKz8UzBuxQBIlwBZyVFBZbKR7ag7LIQsN9NJilzUZ4dnjV/yltU3Xl hhvTO2cC2dQIb/6pp2EzObBETbDqURhjrB3tj5CUGJ2nEgh3EGwo700psuktXVRNzoqa G2G/Kvf6NROSnWnRPEFGHlyblsVuBzYx5ZzotD223CiQNS8xjxKMNLoin8eomZ1q5vKU bjTg== X-Gm-Message-State: ALoCoQlnapdkGSCyppdIG92LqEJejnUAEDWgXw2+yb528U68umQlj8pZT+MUpI7+wwqVMm9zuipx X-Received: by 10.55.71.146 with SMTP id u140mr40535057qka.17.1447761230406; Tue, 17 Nov 2015 03:53:50 -0800 (PST) Received: from tlielax.poochiereds.net ([2606:a000:1125:4075::d5a]) by smtp.googlemail.com with ESMTPSA id w10sm1583910qhc.16.2015.11.17.03.53.49 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Nov 2015 03:53:49 -0800 (PST) From: Jeff Layton X-Google-Original-From: Jeff Layton To: bfields@fieldses.org, trond.myklebust@primarydata.com Cc: linux-nfs@vger.kernel.org, Eric Paris , Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH v1 32/38] nfs: add encode_fh export op Date: Tue, 17 Nov 2015 06:52:54 -0500 Message-Id: <1447761180-4250-33-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1447761180-4250-1-git-send-email-jeff.layton@primarydata.com> References: <1447761180-4250-1-git-send-email-jeff.layton@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peng Tao A very first step of re-exporting nfs via knfsd. For now, it's just copying the underlying server's filehandle. Later patches will add the piece that embeds it in a new FH instead. [jlayton: add export ops flags field] Signed-off-by: Peng Tao Signed-off-by: Jeff Layton --- fs/nfs/Makefile | 1 + fs/nfs/export.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 fs/nfs/export.c diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile index 8664417955a2..f1443f14be79 100644 --- a/fs/nfs/Makefile +++ b/fs/nfs/Makefile @@ -11,6 +11,7 @@ nfs-y := client.o dir.o file.o getroot.o inode.o super.o \ nfs-$(CONFIG_ROOT_NFS) += nfsroot.o nfs-$(CONFIG_SYSCTL) += sysctl.o nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o +nfs-$(CONFIG_NFS_REEXPORT) += export.o obj-$(CONFIG_NFS_V2) += nfsv2.o nfsv2-y := nfs2super.o proc.o nfs2xdr.o diff --git a/fs/nfs/export.c b/fs/nfs/export.c new file mode 100644 index 000000000000..d446f77b26b3 --- /dev/null +++ b/fs/nfs/export.c @@ -0,0 +1,46 @@ +/* + * Module for pnfs flexfile layout driver. + * + * Copyright (c) 2015, Primary Data, Inc. All rights reserved. + * + * Tao Peng + */ + +#include +#include +#include + +#include "nfstrace.h" + +#define NFSDBG_FACILITY NFSDBG_VFS + +/* + * Let's break subtree checking for now... otherwise we'll have to embed parent fh + * but there might not be enough space. + */ +static int +nfs_encode_fh(struct inode *inode, __u32 *p, int *max_len, struct inode *parent) +{ + struct nfs_fh *server_fh = NFS_FH(inode); + struct nfs_fh *clnt_fh = (struct nfs_fh *)p; + int disconnected_fh_len = server_fh->size / 4 + 1; + + dprintk("%s: max fh len %d inode %p parent %p", + __func__, *max_len, inode, parent); + + if (*max_len < disconnected_fh_len) { + *max_len = disconnected_fh_len; + return FILEID_INVALID; + } + + nfs_copy_fh(clnt_fh, server_fh); + *max_len = disconnected_fh_len; + + dprintk("%s: result fh size %d\n", __func__, *max_len); + return *max_len; +} + +const struct export_operations nfs_export_ops = { + .encode_fh = nfs_encode_fh, + .flags = EXPORT_OP_NOWCC|EXPORT_OP_NOSUBTREECHK|EXPORT_OP_CLOSE_BEFORE_UNLINK, +};