]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: use wait queue instead of completion on mount
authorSage Weil <sage@newdream.net>
Fri, 11 Apr 2008 18:55:34 +0000 (11:55 -0700)
committerSage Weil <sage@newdream.net>
Fri, 11 Apr 2008 21:12:54 +0000 (14:12 -0700)
src/kernel/client.c
src/kernel/messenger.c
src/kernel/super.h

index 45d53573c1c04f15dba6a2385ae3d662995fc43b..06a6945113b663adf995dc372238a4aad0ba1935 100644 (file)
@@ -103,11 +103,16 @@ int ceph_mount(struct ceph_client *client, struct ceph_mount_args *args, struct
                
                /* wait */
                dout(10, "mount sent mount request, waiting for maps\n");
-               err = wait_for_completion_timeout(&client->mount_completion, 
-                                                 6*HZ);
+               //err = wait_for_completion_timeout(&client->mount_completion, 
+               //6*HZ);
+               err = wait_event_interruptible_timeout(
+                       client->mount_wq,
+                       ceph_have_all_maps(client),
+                       6*HZ);
+               dout(10, "mount wait got %d\n", err);
                if (err == -EINTR)
                        return err; 
-               if (client->mounting == 7) 
+               if (ceph_have_all_maps(client))
                        break;  /* success */
                dout(10, "mount still waiting for mount, attempts=%d\n", 
                     attempts);
@@ -160,11 +165,11 @@ static void handle_monmap(struct ceph_client *client, struct ceph_msg *msg)
 void got_first_map(struct ceph_client *client, int num)
 {
        set_bit(num, &client->mounting);
-       dout(10, "got_first_map num %d mounting now %lu bits %d\n", 
-            num, client->mounting, (int)find_first_zero_bit(&client->mounting, 4));
-       if (find_first_zero_bit(&client->mounting, 4) == 3) {
+       dout(10, "got_first_map num %d mounting now %lu  done=%d\n", 
+            num, client->mounting, ceph_have_all_maps(client));
+       if (ceph_have_all_maps(client)) {
                dout(10, "got_first_map kicking mount\n");
-               complete(&client->mount_completion);
+               wake_up(&client->mount_wq);
        }
 }
 
@@ -183,7 +188,7 @@ struct ceph_client *ceph_create_client(struct ceph_mount_args *args, struct supe
        if (cl == NULL)
                return ERR_PTR(-ENOMEM);
 
-       init_completion(&cl->mount_completion);
+       init_waitqueue_head(&cl->mount_wq);
        spin_lock_init(&cl->sb_lock);
        get_client_counter();
 
index 8c5b98aef806881d4bc936ea16851eae78b0aff9..bf1b0c77a810767d71243d3c4d6eb9c6497204dd 100644 (file)
@@ -1192,9 +1192,8 @@ struct ceph_messenger *ceph_messenger_create(struct ceph_entity_addr *myaddr)
        if (myaddr)
                msgr->inst.addr.ipaddr.sin_addr = myaddr->ipaddr.sin_addr;
 
-       dout(1, "create %p listening on %x:%d\n", msgr,
-            ntohl(msgr->inst.addr.ipaddr.sin_addr.s_addr),
-            ntohs(msgr->inst.addr.ipaddr.sin_port));
+       dout(1, "create %p listening on %u.%u.%u.%u:%u\n", msgr,
+            IPQUADPORT(msgr->inst.addr.ipaddr));
        return msgr;
 }
 
index d8cbaad372c5687417ed83b64cb2c9cff305082c..74e93a4814a7fe0a83cba150c6dd1669bf4357d1 100644 (file)
@@ -45,11 +45,11 @@ extern int ceph_debug_addr;
 #define CEPH_BLOCK  (1 << CEPH_BLOCK_SHIFT)
 
 #define IPQUADPORT(n)                                                  \
-       (unsigned int)((n.sin_addr.s_addr)) & 0xFF,                     \
-               (unsigned int)((n.sin_addr.s_addr)>>8) & 0xFF,          \
-               (unsigned int)((n.sin_addr.s_addr)>>16) & 0xFF,         \
-               (unsigned int)((n.sin_addr.s_addr)>>24) & 0xFF,         \
-               (unsigned int)(ntohs(n.sin_port))
+       (unsigned int)(((n).sin_addr.s_addr)) & 0xFF,                   \
+               (unsigned int)(((n).sin_addr.s_addr)>>8) & 0xFF,        \
+               (unsigned int)(((n).sin_addr.s_addr)>>16) & 0xFF,       \
+               (unsigned int)(((n).sin_addr.s_addr)>>24) & 0xFF,       \
+               (unsigned int)(ntohs((n).sin_port))
 
 /*
  * mount options
@@ -84,8 +84,8 @@ struct ceph_client {
        struct super_block *sb;
 
        unsigned long mounting;   /* map bitset; 4=mon, 2=mds, 1=osd map */
-       struct completion mount_completion;
-
+       wait_queue_head_t mount_wq;
+       
        struct ceph_messenger *msgr;   /* messenger instance */
        struct ceph_mon_client monc;
        struct ceph_mds_client mdsc;
@@ -100,6 +100,11 @@ struct ceph_client {
        struct list_head sb_list;
 };
 
+static inline int ceph_have_all_maps(struct ceph_client *client)
+{
+       return find_first_zero_bit(&client->mounting, 4) == 3;
+}
+
 /*
  * CEPH per-mount superblock info
  */