]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: pass in flag indicating whether dir i_mutex is held
authorSage Weil <sage@newdream.net>
Tue, 24 Jun 2008 23:02:27 +0000 (16:02 -0700)
committerSage Weil <sage@newdream.net>
Tue, 24 Jun 2008 23:02:27 +0000 (16:02 -0700)
src/kernel/dir.c
src/kernel/file.c
src/kernel/inode.c
src/kernel/mds_client.h
src/kernel/super.h

index b5a158672112d540f5a2a0cf7c521ca7e9d7a108..30af6571386f4b54634a89c7d879e4ae9557501d 100644 (file)
@@ -286,7 +286,7 @@ struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
  * built from @dentry.
  */
 struct dentry *ceph_do_lookup(struct super_block *sb, struct dentry *dentry, 
-                             int mask, int on_inode)
+                             int mask, int on_inode, int locked_dir)
 {
        struct ceph_client *client = ceph_sb_to_client(sb);
        struct ceph_mds_client *mdsc = &client->mdsc;
@@ -323,6 +323,7 @@ struct dentry *ceph_do_lookup(struct super_block *sb, struct dentry *dentry,
        rhead->args.stat.mask = cpu_to_le32(mask);
        dget(dentry);                /* to match put_request below */
        req->r_last_dentry = dentry; /* use this dentry in fill_trace */
+       req->r_locked_dir = dentry->d_parent->d_inode;
        err = ceph_mdsc_do_request(mdsc, req);
        dentry = ceph_finish_lookup(req, dentry, err);
        ceph_mdsc_put_request(req);  /* will dput(dentry) */
@@ -342,10 +343,10 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
            (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);
+               return ceph_lookup_open(dir, dentry, nd, mode, 1);
        }
 
-       return ceph_do_lookup(dir->i_sb, dentry, CEPH_STAT_MASK_INODE_ALL, 0);
+       return ceph_do_lookup(dir->i_sb, dentry, CEPH_STAT_MASK_INODE_ALL, 0,1);
 }
 
 static int ceph_mknod(struct inode *dir, struct dentry *dentry,
@@ -383,7 +384,7 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,
                /* no trace.  do lookup, in case we are called from create. */
                struct dentry *d;
                d = ceph_do_lookup(dir->i_sb, dentry, CEPH_STAT_MASK_INODE_ALL,
-                                  0);
+                                  0, 0);
                if (d) {
                        /* ick.  this is untested... */
                        dput(d);
@@ -406,7 +407,7 @@ static int ceph_create(struct inode *dir, struct dentry *dentry, int mode,
             dir, dentry, dentry->d_name.len, dentry->d_name.name);
        if (nd) {
                BUG_ON((nd->flags & LOOKUP_OPEN) == 0);
-               dentry = ceph_lookup_open(dir, dentry, nd, mode);
+               dentry = ceph_lookup_open(dir, dentry, nd, mode, 0);
                /* hrm, what should i do here if we get aliased? */
                if (IS_ERR(dentry))
                        return PTR_ERR(dentry);
index a4de93827936a9b053b19bed061ee9da7e8650bd..8d8246cd4864291096c389b8c6cbd5214795dad5 100644 (file)
@@ -137,7 +137,8 @@ out:
  *  path_lookup_create -> LOOKUP_OPEN|LOOKUP_CREATE
  */
 struct dentry *ceph_lookup_open(struct inode *dir, struct dentry *dentry,
-                               struct nameidata *nd, int mode)
+                               struct nameidata *nd, int mode,
+                               int locked_dir)
 {
        struct ceph_client *client = ceph_sb_to_client(dir->i_sb);
        struct ceph_mds_client *mdsc = &client->mdsc;
@@ -157,6 +158,7 @@ struct dentry *ceph_lookup_open(struct inode *dir, struct dentry *dentry,
                ceph_mdsc_lease_release(mdsc, dir, 0, CEPH_LOCK_ICONTENT);
        dget(dentry);                /* to match put_request below */
        req->r_last_dentry = dentry; /* use this dentry in fill_trace */
+       req->r_locked_dir = dir;     /* caller holds dir->i_mutex */
        err = ceph_mdsc_do_request(mdsc, req);
        dentry = ceph_finish_lookup(req, dentry, err);
        if (err == 0)
index 430086343713063316b9238e455a1b2fa38d1de3..ac5cfde3381b0674bcd9c091b0c399a14a6da155 100644 (file)
@@ -2005,7 +2005,7 @@ static int do_getattr(struct dentry *dentry, int mask)
                             dentry->d_name.len, dentry->d_name.name);
        }
        ret = ceph_do_lookup(dentry->d_inode->i_sb, dentry, mask,
-                            want_inode);
+                            want_inode, 0);
        if (IS_ERR(ret))
                return PTR_ERR(ret);
        if (ret)
index 75a8d2d23a304f11bce003d21859f3ad52093e76..f2daac9d16f12d8ffbe385802d5ece51f2633307 100644 (file)
@@ -100,6 +100,7 @@ struct ceph_mds_request {
        unsigned long           r_from_time;
        struct ceph_mds_session *r_session;
        struct ceph_mds_session *r_fwd_session;  /* forwarded from */
+       struct inode     *r_locked_dir;
 
        int               r_attempts;   /* resend attempts */
        int               r_num_fwd;    /* number of forward attempts */
index 63a90a5e936aadcfc2459c9cebc954e76e3a9516..caee8f092e8ddc1e7e91d6ed79fea7178a30c435 100644 (file)
@@ -500,7 +500,8 @@ extern const struct file_operations ceph_file_fops;
 extern const struct address_space_operations ceph_aops;
 extern int ceph_open(struct inode *inode, struct file *file);
 extern struct dentry *ceph_lookup_open(struct inode *dir, struct dentry *dentry,
-                                      struct nameidata *nd, int mode);
+                                      struct nameidata *nd, int mode,
+                                      int locked_dir);
 extern int ceph_release(struct inode *inode, struct file *filp);
 
 
@@ -513,7 +514,7 @@ extern char *ceph_build_dentry_path(struct dentry *dn, int *len, __u64 *base,
                                    int min);
 extern struct dentry *ceph_do_lookup(struct super_block *sb, 
                                     struct dentry *dentry, 
-                                    int mask, int on_inode);
+                                    int mask, int on_inode, int locked_dir);
 extern struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
                                         struct dentry *dentry, int err);