dm cache: share cache-metadata object across inactive and active DM tables
[firefly-linux-kernel-4.4.55.git] / drivers / md / bitmap.c
index 4fd9d6aeff6aba9f532e8513701045aaa9f94f42..a79cbd6038f6ec5d79d5dc32b64f0933425f90f2 100644 (file)
@@ -846,7 +846,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
        if (test_bit(BITMAP_HOSTENDIAN, &bitmap->flags))
                set_bit(bit, kaddr);
        else
-               test_and_set_bit_le(bit, kaddr);
+               set_bit_le(bit, kaddr);
        kunmap_atomic(kaddr);
        pr_debug("set file bit %lu page %lu\n", bit, page->index);
        /* record page number so it gets flushed to disk when unplug occurs */
@@ -868,7 +868,7 @@ static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block)
        if (test_bit(BITMAP_HOSTENDIAN, &bitmap->flags))
                clear_bit(bit, paddr);
        else
-               test_and_clear_bit_le(bit, paddr);
+               clear_bit_le(bit, paddr);
        kunmap_atomic(paddr);
        if (!test_page_attr(bitmap, page->index, BITMAP_PAGE_NEEDWRITE)) {
                set_page_attr(bitmap, page->index, BITMAP_PAGE_PENDING);
@@ -883,7 +883,6 @@ void bitmap_unplug(struct bitmap *bitmap)
 {
        unsigned long i;
        int dirty, need_write;
-       int wait = 0;
 
        if (!bitmap || !bitmap->storage.filemap ||
            test_bit(BITMAP_STALE, &bitmap->flags))
@@ -901,16 +900,13 @@ void bitmap_unplug(struct bitmap *bitmap)
                        clear_page_attr(bitmap, i, BITMAP_PAGE_PENDING);
                        write_page(bitmap, bitmap->storage.filemap[i], 0);
                }
-               if (dirty)
-                       wait = 1;
-       }
-       if (wait) { /* if any writes were performed, we need to wait on them */
-               if (bitmap->storage.file)
-                       wait_event(bitmap->write_wait,
-                                  atomic_read(&bitmap->pending_writes)==0);
-               else
-                       md_super_wait(bitmap->mddev);
        }
+       if (bitmap->storage.file)
+               wait_event(bitmap->write_wait,
+                          atomic_read(&bitmap->pending_writes)==0);
+       else
+               md_super_wait(bitmap->mddev);
+
        if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags))
                bitmap_file_kick(bitmap);
 }