These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / md / bitmap.c
index c90118e..4f22e91 100644 (file)
@@ -559,6 +559,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
        unsigned long sectors_reserved = 0;
        int err = -EINVAL;
        struct page *sb_page;
+       loff_t offset = bitmap->mddev->bitmap_info.offset;
 
        if (!bitmap->storage.file && !bitmap->mddev->bitmap_info.offset) {
                chunksize = 128 * 1024 * 1024;
@@ -585,9 +586,9 @@ re_read:
                bm_blocks = ((bm_blocks+7) >> 3) + sizeof(bitmap_super_t);
                /* to 4k blocks */
                bm_blocks = DIV_ROUND_UP_SECTOR_T(bm_blocks, 4096);
-               bitmap->mddev->bitmap_info.offset += bitmap->cluster_slot * (bm_blocks << 3);
+               offset = bitmap->mddev->bitmap_info.offset + (bitmap->cluster_slot * (bm_blocks << 3));
                pr_info("%s:%d bm slot: %d offset: %llu\n", __func__, __LINE__,
-                       bitmap->cluster_slot, (unsigned long long)bitmap->mddev->bitmap_info.offset);
+                       bitmap->cluster_slot, offset);
        }
 
        if (bitmap->storage.file) {
@@ -598,7 +599,7 @@ re_read:
                                bitmap, bytes, sb_page);
        } else {
                err = read_sb_page(bitmap->mddev,
-                                  bitmap->mddev->bitmap_info.offset,
+                                  offset,
                                   sb_page,
                                   0, sizeof(bitmap_super_t));
        }
@@ -612,12 +613,10 @@ re_read:
        daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ;
        write_behind = le32_to_cpu(sb->write_behind);
        sectors_reserved = le32_to_cpu(sb->sectors_reserved);
-       /* XXX: This is a hack to ensure that we don't use clustering
-        *  in case:
-        *      - dm-raid is in use and
-        *      - the nodes written in bitmap_sb is erroneous.
+       /* Setup nodes/clustername only if bitmap version is
+        * cluster-compatible
         */
-       if (!bitmap->mddev->sync_super) {
+       if (sb->version == cpu_to_le32(BITMAP_MAJOR_CLUSTERED)) {
                nodes = le32_to_cpu(sb->nodes);
                strlcpy(bitmap->mddev->bitmap_info.cluster_name,
                                sb->cluster_name, 64);
@@ -627,7 +626,7 @@ re_read:
        if (sb->magic != cpu_to_le32(BITMAP_MAGIC))
                reason = "bad magic";
        else if (le32_to_cpu(sb->version) < BITMAP_MAJOR_LO ||
-                le32_to_cpu(sb->version) > BITMAP_MAJOR_HI)
+                le32_to_cpu(sb->version) > BITMAP_MAJOR_CLUSTERED)
                reason = "unrecognized superblock version";
        else if (chunksize < 512)
                reason = "bitmap chunksize too small";
@@ -680,7 +679,7 @@ out:
        kunmap_atomic(sb);
        /* Assiging chunksize is required for "re_read" */
        bitmap->mddev->bitmap_info.chunksize = chunksize;
-       if (nodes && (bitmap->cluster_slot < 0)) {
+       if (err == 0 && nodes && (bitmap->cluster_slot < 0)) {
                err = md_setup_cluster(bitmap->mddev, nodes);
                if (err) {
                        pr_err("%s: Could not setup cluster service (%d)\n",
@@ -848,7 +847,7 @@ static void bitmap_file_kick(struct bitmap *bitmap)
                if (bitmap->storage.file) {
                        path = kmalloc(PAGE_SIZE, GFP_KERNEL);
                        if (path)
-                               ptr = d_path(&bitmap->storage.file->f_path,
+                               ptr = file_path(bitmap->storage.file,
                                             path, PAGE_SIZE);
 
                        printk(KERN_ALERT
@@ -1571,7 +1570,7 @@ void bitmap_close_sync(struct bitmap *bitmap)
 }
 EXPORT_SYMBOL(bitmap_close_sync);
 
-void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector)
+void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force)
 {
        sector_t s = 0;
        sector_t blocks;
@@ -1582,7 +1581,7 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector)
                bitmap->last_end_sync = jiffies;
                return;
        }
-       if (time_before(jiffies, (bitmap->last_end_sync
+       if (!force && time_before(jiffies, (bitmap->last_end_sync
                                  + bitmap->mddev->bitmap_info.daemon_sleep)))
                return;
        wait_event(bitmap->mddev->recovery_wait,
@@ -1875,10 +1874,6 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
        if (IS_ERR(bitmap))
                return PTR_ERR(bitmap);
 
-       rv = bitmap_read_sb(bitmap);
-       if (rv)
-               goto err;
-
        rv = bitmap_init_from_disk(bitmap, 0);
        if (rv)
                goto err;
@@ -1936,7 +1931,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
                   chunk_kb ? "KB" : "B");
        if (bitmap->storage.file) {
                seq_printf(seq, ", file: ");
-               seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
+               seq_file_path(seq, bitmap->storage.file, " \t\n");
        }
 
        seq_printf(seq, "\n");
@@ -2000,7 +1995,8 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
        if (bitmap->mddev->bitmap_info.offset || bitmap->mddev->bitmap_info.file)
                ret = bitmap_storage_alloc(&store, chunks,
                                           !bitmap->mddev->bitmap_info.external,
-                                          bitmap->cluster_slot);
+                                          mddev_is_clustered(bitmap->mddev)
+                                          ? bitmap->cluster_slot : 0);
        if (ret)
                goto err;