All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yan, Zheng" <zheng.z.yan@intel.com>
To: ceph-devel@vger.kernel.org
Cc: "Yan, Zheng" <zheng.z.yan@intel.com>
Subject: [PATCH v2 3/5] ceph: fix ceph_fh_to_parent()
Date: Fri,  7 Mar 2014 17:04:35 +0800	[thread overview]
Message-ID: <1394183077-399-4-git-send-email-zheng.z.yan@intel.com> (raw)
In-Reply-To: <1394183077-399-1-git-send-email-zheng.z.yan@intel.com>

ceph_fh_to_parent() returns dentry that corresponds to the 'ino' field
of struct ceph_nfs_confh. This is wrong, it should return dentry that
corresponds to the 'parent_ino' field.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
---
 fs/ceph/export.c | 42 +++++++++---------------------------------
 1 file changed, 9 insertions(+), 33 deletions(-)

diff --git a/fs/ceph/export.c b/fs/ceph/export.c
index 3794255..6e611e7 100644
--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -174,48 +174,24 @@ struct dentry *ceph_get_parent(struct dentry *child)
 }
 
 /*
- * get parent, if possible.
- *
- * FIXME: we could do better by querying the mds to discover the
- * parent.
+ * convert regular fh to parent
  */
 static struct dentry *ceph_fh_to_parent(struct super_block *sb,
-					 struct fid *fid,
+					struct fid *fid,
 					int fh_len, int fh_type)
 {
 	struct ceph_nfs_confh *cfh = (void *)fid->raw;
-	struct ceph_vino vino;
-	struct inode *inode;
 	struct dentry *dentry;
-	int err;
 
-	if (fh_type == 1)
-		return ERR_PTR(-ESTALE);
+	if (fh_type != FILEID_INO32_GEN_PARENT)
+		return NULL;
 	if (fh_len < sizeof(*cfh) / 4)
-		return ERR_PTR(-ESTALE);
-
-	pr_debug("fh_to_parent %llx/%d\n", cfh->parent_ino,
-		 cfh->parent_name_hash);
-
-	vino.ino = cfh->ino;
-	vino.snap = CEPH_NOSNAP;
-	inode = ceph_find_inode(sb, vino);
-	if (!inode)
-		return ERR_PTR(-ESTALE);
+		return NULL;
 
-	dentry = d_obtain_alias(inode);
-	if (IS_ERR(dentry)) {
-		pr_err("fh_to_parent %llx -- inode %p but ENOMEM\n",
-		       cfh->ino, inode);
-		iput(inode);
-		return dentry;
-	}
-	err = ceph_init_dentry(dentry);
-	if (err < 0) {
-		iput(inode);
-		return ERR_PTR(err);
-	}
-	dout("fh_to_parent %llx %p dentry %p\n", cfh->ino, inode, dentry);
+	dout("fh_to_parent %llx\n", cfh->parent_ino);
+	dentry = __get_parent(sb, cfh->ino);
+	if (IS_ERR(dentry) && PTR_ERR(dentry) == -ENOENT)
+		dentry = __fh_to_dentry(sb, cfh->parent_ino);
 	return dentry;
 }
 
-- 
1.8.5.3


  parent reply	other threads:[~2014-03-07  9:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07  9:04 [PATCH v2 0/5] ceph: fixes for nfs export Yan, Zheng
2014-03-07  9:04 ` [PATCH v2 1/5] ceph: simplify ceph_fh_to_dentry() Yan, Zheng
2014-03-07  9:04 ` [PATCH v2 2/5] ceph: add get_parent() NFS export callback Yan, Zheng
2014-03-07  9:04 ` Yan, Zheng [this message]
2014-03-07  9:04 ` [PATCH v2 4/5] ceph: add get_name() " Yan, Zheng
2014-03-07  9:04 ` [PATCH v2 5/5] ceph: print inode number for LOOKUPINO request Yan, Zheng
2014-03-07 15:03 ` [PATCH v2 0/5] ceph: fixes for nfs export Sage Weil
2014-03-08  0:01   ` Yan, Zheng
2014-03-10  1:43     ` Sage Weil
2014-03-10  3:18       ` Yan, Zheng
2014-03-10  1:49     ` Sage Weil
2014-03-10  3:23       ` Yan, Zheng
2014-03-10  4:12         ` Sage Weil
2014-03-10  4:19           ` Yan, Zheng
2014-03-10  4:25             ` Sage Weil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394183077-399-4-git-send-email-zheng.z.yan@intel.com \
    --to=zheng.z.yan@intel.com \
    --cc=ceph-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.