From patchwork Sat Mar 1 15:23:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 3747391 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EAED19F381 for ; Sat, 1 Mar 2014 15:24:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1351520374 for ; Sat, 1 Mar 2014 15:24:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3721B20364 for ; Sat, 1 Mar 2014 15:24:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752972AbaCAPYG (ORCPT ); Sat, 1 Mar 2014 10:24:06 -0500 Received: from mga03.intel.com ([143.182.124.21]:8582 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752964AbaCAPYF (ORCPT ); Sat, 1 Mar 2014 10:24:05 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by azsmga101.ch.intel.com with ESMTP; 01 Mar 2014 07:24:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,568,1389772800"; d="scan'208";a="484155331" Received: from unknown (HELO zyan5-mobl.ccr.corp.intel.com) ([10.255.21.204]) by fmsmga001.fm.intel.com with ESMTP; 01 Mar 2014 07:23:37 -0800 From: "Yan, Zheng" To: ceph-devel@vger.kernel.org Cc: "Yan, Zheng" Subject: [PATCH 3/4] ceph: add get_parent() callback for export_operations Date: Sat, 1 Mar 2014 23:23:30 +0800 Message-Id: <1393687411-2457-3-git-send-email-zheng.z.yan@intel.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1393687411-2457-1-git-send-email-zheng.z.yan@intel.com> References: <1393687411-2457-1-git-send-email-zheng.z.yan@intel.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 The callback uses LOOKUPPARENT MDS request to find parent. Signed-off-by: Yan, Zheng --- fs/ceph/export.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/fs/ceph/export.c b/fs/ceph/export.c index 017af26..817d370 100644 --- a/fs/ceph/export.c +++ b/fs/ceph/export.c @@ -139,8 +139,52 @@ static struct dentry *ceph_fh_to_parent(struct super_block *sb, return __fh_to_dentry(sb, cfh->parent_ino); } +static struct dentry *ceph_get_parent(struct dentry *child) +{ + struct ceph_mds_client *mdsc; + struct ceph_mds_request *req; + struct inode *inode; + struct dentry *dentry; + int err; + + /* don't re-export snaps */ + if (ceph_snap(child->d_inode) != CEPH_NOSNAP) + return ERR_PTR(-EINVAL); + + mdsc = ceph_inode_to_client(child->d_inode)->mdsc; + req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LOOKUPPARENT, + USE_ANY_MDS); + if (IS_ERR(req)) + return ERR_CAST(req); + + req->r_ino1 = ceph_vino(child->d_inode); + req->r_num_caps = 1; + err = ceph_mdsc_do_request(mdsc, NULL, req); + inode = req->r_target_inode; + if (inode) + ihold(inode); + ceph_mdsc_put_request(req); + if (!inode) + return ERR_PTR(-ESTALE); + + dentry = d_obtain_alias(inode); + if (IS_ERR(dentry)) { + iput(inode); + return dentry; + } + err = ceph_init_dentry(dentry); + if (err < 0) { + dput(dentry); + return ERR_PTR(err); + } + dout("get_parent child %p parent %llx %p\n", + child, ceph_ino(inode), dentry); + return dentry; +} + const struct export_operations ceph_export_ops = { .encode_fh = ceph_encode_fh, .fh_to_dentry = ceph_fh_to_dentry, .fh_to_parent = ceph_fh_to_parent, + .get_parent = ceph_get_parent, };