From patchwork Sat Mar 10 18:18:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273951 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 CCFCA601A0 for ; Sat, 10 Mar 2018 18:21:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB5B328BAE for ; Sat, 10 Mar 2018 18:21:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B04C8296E5; Sat, 10 Mar 2018 18:21:39 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no 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 7AD0329106 for ; Sat, 10 Mar 2018 18:21:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 515D7226462FA; Sat, 10 Mar 2018 10:15:13 -0800 (PST) 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=2607:f8b0:400e:c00::243; helo=mail-pf0-x243.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5E39A226462E2 for ; Sat, 10 Mar 2018 10:15:11 -0800 (PST) Received: by mail-pf0-x243.google.com with SMTP id d26so2620394pfn.5 for ; Sat, 10 Mar 2018 10:21:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eng.ucsd.edu; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G9ZBcBjFAWczdZyrpAg1M/J+xWQNIR+loegDsVKUyzg=; b=iVC3rPJKLS+mh/Yf+EQlYi9RlB6eX1VPHk6Wgvcay1dAFtGoQ8y5yN0/TvKOwv1QNi 2X6dfAUQFrJOCXISBx3ZxyIjyU1XLD1S2GX9LSF0dALBRGx4f2awDPy1QnLfwFBHNrcQ 5+Xl81FjG21tf6xu/hU+c2wodWb9QD6JefXAk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G9ZBcBjFAWczdZyrpAg1M/J+xWQNIR+loegDsVKUyzg=; b=PLGfB8C3/NU8cM0g8Gcu2KmWyutX8MDvcPH8ODbOhScUa8hYHOXcYJ6NCnYpC9QBgA FN3t9URK4cr4tG9OlUwbEUv6Ql6M9ewJLnsTeONOKPnc0XxTcAmjS3C02+S6i/CWwFz6 bIX0FBYpIPyoEagyclvVL+5ekrrDE4qO9BDycZF0SXcKLDQp5+2dzPv3yu6SfY6KwGnc uM8BICLjkooT+xcZtUS7dA0lBlbIInC2Th6gaK4sIx9D1gdvxh+BVJEszd5rWVbKqWR0 WJHCsIEaBl8b6HLBvxYJg20e8z6DGt8LcuGGnIl4L5eE57t+O0Ocum5biHVG8bTF1+qj ceFw== X-Gm-Message-State: AElRT7Fm8anqXw45Gy3t0oerzTSbmuswJFmneGx7kRKPLyrL2lW1piOs wM/WYvE3JxcE44ntHud4ZK2yBw== X-Google-Smtp-Source: AG47ELtwkMKN3MjkCwqH0yskJRR+NyRC1uUlgMZgPQFBIIfgR+/gw3Q6FbrE5Fgs+70JJ68m0ScLlg== X-Received: by 10.99.109.72 with SMTP id i69mr1605068pgc.417.1520706089801; Sat, 10 Mar 2018 10:21:29 -0800 (PST) Received: from brienza-desktop.8.8.4.4 (andxu.ucsd.edu. [132.239.17.134]) by smtp.gmail.com with ESMTPSA id h80sm9210167pfj.181.2018.03.10.10.21.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:21:29 -0800 (PST) From: Andiry Xu To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [RFC v2 61/83] Super: Add nova_export_ops. Date: Sat, 10 Mar 2018 10:18:42 -0800 Message-Id: <1520705944-6723-62-git-send-email-jix024@eng.ucsd.edu> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520705944-6723-1-git-send-email-jix024@eng.ucsd.edu> References: <1520705944-6723-1-git-send-email-jix024@eng.ucsd.edu> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: coughlan@redhat.com, miklos@szeredi.hu, Andiry Xu , david@fromorbit.com, jack@suse.com, swanson@cs.ucsd.edu, swhiteho@redhat.com, andiry.xu@gmail.com MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Andiry Xu Signed-off-by: Andiry Xu --- fs/nova/super.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/fs/nova/super.c b/fs/nova/super.c index daf3270..0847e57 100644 --- a/fs/nova/super.c +++ b/fs/nova/super.c @@ -51,6 +51,7 @@ module_param(nova_dbgmask, int, 0444); MODULE_PARM_DESC(nova_dbgmask, "Control debugging output"); static struct super_operations nova_sops; +static const struct export_operations nova_export_ops; static struct kmem_cache *nova_inode_cachep; static struct kmem_cache *nova_range_node_cachep; @@ -631,6 +632,7 @@ static int nova_fill_super(struct super_block *sb, void *data, int silent) sb->s_op = &nova_sops; sb->s_maxbytes = nova_max_size(sb->s_blocksize_bits); sb->s_time_gran = 1000000000; // 1 second. + sb->s_export_op = &nova_export_ops; sb->s_xattr = NULL; sb->s_flags |= MS_NOSEC; @@ -904,6 +906,52 @@ static struct file_system_type nova_fs_type = { .kill_sb = kill_block_super, }; +static struct inode *nova_nfs_get_inode(struct super_block *sb, + u64 ino, u32 generation) +{ + struct inode *inode; + + if (ino < NOVA_ROOT_INO) + return ERR_PTR(-ESTALE); + + if (ino > LONG_MAX) + return ERR_PTR(-ESTALE); + + inode = nova_iget(sb, ino); + if (IS_ERR(inode)) + return ERR_CAST(inode); + + if (generation && inode->i_generation != generation) { + /* we didn't find the right inode.. */ + iput(inode); + return ERR_PTR(-ESTALE); + } + + return inode; +} + +static struct dentry *nova_fh_to_dentry(struct super_block *sb, + struct fid *fid, int fh_len, + int fh_type) +{ + return generic_fh_to_dentry(sb, fid, fh_len, fh_type, + nova_nfs_get_inode); +} + +static struct dentry *nova_fh_to_parent(struct super_block *sb, + struct fid *fid, int fh_len, + int fh_type) +{ + return generic_fh_to_parent(sb, fid, fh_len, fh_type, + nova_nfs_get_inode); +} + +static const struct export_operations nova_export_ops = { + .fh_to_dentry = nova_fh_to_dentry, + .fh_to_parent = nova_fh_to_parent, + .get_parent = nova_get_parent, +}; + static int __init init_nova_fs(void) { int rc = 0;