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: 7636301 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0F83D9F1D3 for ; Tue, 17 Nov 2015 11:54:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E0A5204EA for ; Tue, 17 Nov 2015 11:54:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3877A204E2 for ; Tue, 17 Nov 2015 11:54:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753673AbbKQLyQ (ORCPT ); Tue, 17 Nov 2015 06:54:16 -0500 Received: from mail-qk0-f171.google.com ([209.85.220.171]:34295 "EHLO mail-qk0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753586AbbKQLxv (ORCPT ); Tue, 17 Nov 2015 06:53:51 -0500 Received: by qkfo3 with SMTP id o3so1687401qkf.1 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=E7mo2x6zjZ5qHdtdWWdDvsQh+GrKKDToVgoduAuOvrIWrBuBX1qdkxXuInEsdUr5SI plW15wOvh0iUqAKi2GPjvPVtnFBlBRwMCXwy5JjDqVwQ3eBKSUQ0fqWfpvzGfJvWuPqJ MG0TLf7qOfj6B6v+Iv8rlDqlJecw47HUm4zHIuoR/LC+SfP0A0f7mN435CvUq+W33hQn nKaof1R4QL2qMBufEJsS/s2CEYVW3hEW3nx+r+dmuZwir0sJDMq7kJm6jowCz761NzWx VL7xnv1UmUS0Gxw4DBxfSccDy9PpN+zMP1vfUKTLzuZxJwjVGX8CcUKq/CsCaxsdXGyE I2rw== X-Gm-Message-State: ALoCoQl2Z1opChGxOUanHEqbeIf+cla74BiiAMoe4Z77s+O8cmsCzATfib+dH2A/c0tqn+NgOp7e 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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=ham 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, +};