md-cluster: use %pU to print UUIDs
[pandora-kernel.git] / drivers / md / md-cluster.c
index fcfc4b9..85ef5c5 100644 (file)
@@ -44,6 +44,7 @@ struct resync_info {
 
 /* md_cluster_info flags */
 #define                MD_CLUSTER_WAITING_FOR_NEWDISK          1
+#define                MD_CLUSTER_SUSPEND_READ_BALANCING       2
 
 
 struct md_cluster_info {
@@ -176,18 +177,6 @@ static void lockres_free(struct dlm_lock_resource *res)
        kfree(res);
 }
 
-static char *pretty_uuid(char *dest, char *src)
-{
-       int i, len = 0;
-
-       for (i = 0; i < 16; i++) {
-               if (i == 4 || i == 6 || i == 8 || i == 10)
-                       len += sprintf(dest + len, "-");
-               len += sprintf(dest + len, "%02x", (__u8)src[i]);
-       }
-       return dest;
-}
-
 static void add_resync_info(struct mddev *mddev, struct dlm_lock_resource *lockres,
                sector_t lo, sector_t hi)
 {
@@ -275,6 +264,9 @@ clear_bit:
 
 static void recover_prep(void *arg)
 {
+       struct mddev *mddev = arg;
+       struct md_cluster_info *cinfo = mddev->cluster_info;
+       set_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state);
 }
 
 static void recover_slot(void *arg, struct dlm_slot *slot)
@@ -307,6 +299,7 @@ static void recover_done(void *arg, struct dlm_slot *slots,
 
        cinfo->slot_number = our_slot;
        complete(&cinfo->completion);
+       clear_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state);
 }
 
 static const struct dlm_lockspace_ops md_ls_ops = {
@@ -383,7 +376,7 @@ static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
        int len;
 
        len = snprintf(disk_uuid, 64, "DEVICE_UUID=");
-       pretty_uuid(disk_uuid + len, cmsg->uuid);
+       sprintf(disk_uuid + len, "%pU", cmsg->uuid);
        snprintf(raid_slot, 16, "RAID_DISK=%d", cmsg->raid_slot);
        pr_info("%s:%d Sending kobject change with %s and %s\n", __func__, __LINE__, disk_uuid, raid_slot);
        init_completion(&cinfo->newdisk_completion);
@@ -641,7 +634,7 @@ static int join(struct mddev *mddev, int nodes)
        mddev->cluster_info = cinfo;
 
        memset(str, 0, 64);
-       pretty_uuid(str, mddev->uuid);
+       sprintf(str, "%pU", mddev->uuid);
        ret = dlm_new_lockspace(str, mddev->bitmap_info.cluster_name,
                                DLM_LSFL_FS, LVB_SIZE,
                                &md_ls_ops, mddev, &ops_rv, &cinfo->lockspace);
@@ -816,12 +809,17 @@ static void resync_finish(struct mddev *mddev)
        resync_send(mddev, RESYNCING, 0, 0);
 }
 
-static int area_resyncing(struct mddev *mddev, sector_t lo, sector_t hi)
+static int area_resyncing(struct mddev *mddev, int direction,
+               sector_t lo, sector_t hi)
 {
        struct md_cluster_info *cinfo = mddev->cluster_info;
        int ret = 0;
        struct suspend_info *s;
 
+       if ((direction == READ) &&
+               test_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state))
+               return 1;
+
        spin_lock_irq(&cinfo->suspend_lock);
        if (list_empty(&cinfo->suspend_list))
                goto out;