]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: merge and simplify ceph_lookup, ceph_do_lookup
authorSage Weil <sage@newdream.net>
Tue, 17 Mar 2009 21:45:33 +0000 (14:45 -0700)
committerSage Weil <sage@newdream.net>
Tue, 17 Mar 2009 21:45:33 +0000 (14:45 -0700)
Ceph_lookup was the only remaining caller.

src/kernel/dir.c
src/kernel/super.h

index b0cae3212382f377e09ed1cbebf57c92ab25d2de..132c217389a2b53b65ccd0181e721734cd169f9e 100644 (file)
@@ -266,34 +266,42 @@ struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
 }
 
 /*
- * Do a lookup / lstat (same thing, modulo the metadata @mask).
- * @on_inode indicates that we should stat the ino directly, and not a
- * path built from @dentry.
+ * Try to do a lookup+open, if possible.
  */
-struct dentry *ceph_do_lookup(struct super_block *sb, struct dentry *dentry,
-                             int mask, int on_inode, int locked_dir)
+static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
+                                 struct nameidata *nd)
 {
-       struct ceph_client *client = ceph_sb_to_client(sb);
+       struct ceph_client *client = ceph_sb_to_client(dir->i_sb);
        struct ceph_mds_client *mdsc = &client->mdsc;
        struct ceph_mds_request *req;
-       struct inode *dir = dentry->d_parent->d_inode;
        int err;
 
+       dout(5, "lookup %p dentry %p '%.*s'\n",
+            dir, dentry, dentry->d_name.len, dentry->d_name.name);
+
        if (dentry->d_name.len > NAME_MAX)
                return ERR_PTR(-ENAMETOOLONG);
 
+       /* open (but not create!) intent? */
+       if (nd &&
+           (nd->flags & LOOKUP_OPEN) &&
+           (nd->flags & LOOKUP_CONTINUE) == 0 && /* only open last component */
+           !(nd->intent.open.flags & O_CREAT)) {
+               int mode = nd->intent.open.create_mode & ~current->fs->umask;
+               return ceph_lookup_open(dir, dentry, nd, mode, 1);
+       }
+
        /* can we conclude ENOENT locally? */
        if (dentry->d_inode == NULL) {
                struct ceph_inode_info *ci = ceph_inode(dir);
 
                spin_lock(&dir->i_lock);
-               dout(10, "%p flags are %d\n", dir, ci->i_ceph_flags);
+               dout(40, " dir %p flags are %d\n", dir, ci->i_ceph_flags);
                if (ceph_ino(dir) != CEPH_INO_ROOT &&
                    (ci->i_ceph_flags & CEPH_I_COMPLETE) &&
                    (__ceph_caps_issued(ci, NULL) & CEPH_CAP_FILE_RDCACHE)) {
                        spin_unlock(&dir->i_lock);
-                       dout(10, "do_lookup %p dir %p complete, -ENOENT\n",
-                            dentry, dir);
+                       dout(10, " dir %p complete, -ENOENT\n", dir);
                        ceph_init_dentry(dentry);
                        d_add(dentry, NULL);
                        dentry->d_time = ci->i_version;
@@ -302,42 +310,21 @@ struct dentry *ceph_do_lookup(struct super_block *sb, struct dentry *dentry,
                spin_unlock(&dir->i_lock);
        }
 
-       dout(10, "do_lookup %p mask %d\n", dentry, mask);
        req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LSTAT,
                                       dentry, NULL, NULL, NULL,
-                                      on_inode ? USE_CAP_MDS:USE_ANY_MDS);
+                                      USE_ANY_MDS);
        if (IS_ERR(req))
                return ERR_PTR(PTR_ERR(req));
-       req->r_args.stat.mask = cpu_to_le32(mask);
+       /* we only need inode linkage */
+       req->r_args.stat.mask = cpu_to_le32(CEPH_STAT_CAP_INODE);
        req->r_locked_dir = dentry->d_parent->d_inode;  /* by the VFS */
        err = ceph_mdsc_do_request(mdsc, NULL, req);
        dentry = ceph_finish_lookup(req, dentry, err);
        ceph_mdsc_put_request(req);  /* will dput(dentry) */
-       dout(20, "do_lookup result=%p\n", dentry);
+       dout(20, "lookup result=%p\n", dentry);
        return dentry;
 }
 
-/*
- * Try to do a lookup+open, if possible.
- */
-static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
-                                 struct nameidata *nd)
-{
-       dout(5, "lookup in dir %p dentry %p '%.*s'\n",
-            dir, dentry, dentry->d_name.len, dentry->d_name.name);
-
-       /* open (but not create!) intent?  (not on special files, tho)  */
-       if (nd &&
-           (nd->flags & LOOKUP_OPEN) &&
-           (nd->flags & LOOKUP_CONTINUE) == 0 && /* only open last component */
-           !(nd->intent.open.flags & O_CREAT)) {
-               int mode = nd->intent.open.create_mode & ~current->fs->umask;
-               return ceph_lookup_open(dir, dentry, nd, mode, 1);
-       }
-
-       return ceph_do_lookup(dir->i_sb, dentry, CEPH_STAT_CAP_INODE, 0, 1);
-}
-
 static int ceph_mknod(struct inode *dir, struct dentry *dentry,
                          int mode, dev_t rdev)
 {
index 6f5afc8efd0b833f02956599c75038d0f80f4247..e6baf6cfb11054a0ff90f7bdb87a685107e37f1f 100644 (file)
@@ -769,9 +769,6 @@ extern const struct inode_operations ceph_dir_iops;
 extern struct dentry_operations ceph_dentry_ops, ceph_snap_dentry_ops,
        ceph_snapdir_dentry_ops;
 
-extern struct dentry *ceph_do_lookup(struct super_block *sb,
-                                    struct dentry *dentry,
-                                    int mask, int on_inode, int locked_dir);
 extern struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
                                         struct dentry *dentry, int err);