aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bitmap.c
diff options
context:
space:
mode:
authorGoldwyn Rodrigues <rgoldwyn@suse.com>2014-06-07 01:36:26 -0400
committerGoldwyn Rodrigues <rgoldwyn@suse.com>2015-02-23 10:59:05 -0500
commit11dd35daaab86d12270d23a10e8d242846a8830a (patch)
tree59e531ed5e28e9768768aa430c9848ef6d843105 /drivers/md/bitmap.c
parentf9209a323547f054c7439a3bf67c45e64a054bdd (diff)
Copy set bits from another slot
bitmap_copy_from_slot reads the bitmap from the slot mentioned. It then copies the set bits to the node local bitmap. This is helper function for the resync operation on node failure. bitmap_set_memory_bits() currently assumes it is only run at startup and that they bitmap is currently empty. So if it finds that a region is already marked as dirty, it won't mark it dirty again. Change bitmap_set_memory_bits() to always set the NEEDED_MASK bit if 'needed' is set. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r--drivers/md/bitmap.c78
1 files changed, 77 insertions, 1 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index f02551f50bb5..dd8c78043eab 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -934,6 +934,28 @@ static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block)
934 } 934 }
935} 935}
936 936
937static int bitmap_file_test_bit(struct bitmap *bitmap, sector_t block)
938{
939 unsigned long bit;
940 struct page *page;
941 void *paddr;
942 unsigned long chunk = block >> bitmap->counts.chunkshift;
943 int set = 0;
944
945 page = filemap_get_page(&bitmap->storage, chunk);
946 if (!page)
947 return -EINVAL;
948 bit = file_page_offset(&bitmap->storage, chunk);
949 paddr = kmap_atomic(page);
950 if (test_bit(BITMAP_HOSTENDIAN, &bitmap->flags))
951 set = test_bit(bit, paddr);
952 else
953 set = test_bit_le(bit, paddr);
954 kunmap_atomic(paddr);
955 return set;
956}
957
958
937/* this gets called when the md device is ready to unplug its underlying 959/* this gets called when the md device is ready to unplug its underlying
938 * (slave) device queues -- before we let any writes go down, we need to 960 * (slave) device queues -- before we let any writes go down, we need to
939 * sync the dirty pages of the bitmap file to disk */ 961 * sync the dirty pages of the bitmap file to disk */
@@ -1581,11 +1603,13 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
1581 return; 1603 return;
1582 } 1604 }
1583 if (!*bmc) { 1605 if (!*bmc) {
1584 *bmc = 2 | (needed ? NEEDED_MASK : 0); 1606 *bmc = 2;
1585 bitmap_count_page(&bitmap->counts, offset, 1); 1607 bitmap_count_page(&bitmap->counts, offset, 1);
1586 bitmap_set_pending(&bitmap->counts, offset); 1608 bitmap_set_pending(&bitmap->counts, offset);
1587 bitmap->allclean = 0; 1609 bitmap->allclean = 0;
1588 } 1610 }
1611 if (needed)
1612 *bmc |= NEEDED_MASK;
1589 spin_unlock_irq(&bitmap->counts.lock); 1613 spin_unlock_irq(&bitmap->counts.lock);
1590} 1614}
1591 1615
@@ -1823,6 +1847,58 @@ out:
1823} 1847}
1824EXPORT_SYMBOL_GPL(bitmap_load); 1848EXPORT_SYMBOL_GPL(bitmap_load);
1825 1849
1850/* Loads the bitmap associated with slot and copies the resync information
1851 * to our bitmap
1852 */
1853int bitmap_copy_from_slot(struct mddev *mddev, int slot,
1854 sector_t *low, sector_t *high)
1855{
1856 int rv = 0, i, j;
1857 sector_t block, lo = 0, hi = 0;
1858 struct bitmap_counts *counts;
1859 struct bitmap *bitmap = bitmap_create(mddev, slot);
1860
1861 if (IS_ERR(bitmap))
1862 return PTR_ERR(bitmap);
1863
1864 rv = bitmap_read_sb(bitmap);
1865 if (rv)
1866 goto err;
1867
1868 rv = bitmap_init_from_disk(bitmap, 0);
1869 if (rv)
1870 goto err;
1871
1872 counts = &bitmap->counts;
1873 for (j = 0; j < counts->chunks; j++) {
1874 block = (sector_t)j << counts->chunkshift;
1875 if (bitmap_file_test_bit(bitmap, block)) {
1876 if (!lo)
1877 lo = block;
1878 hi = block;
1879 bitmap_file_clear_bit(bitmap, block);
1880 bitmap_set_memory_bits(mddev->bitmap, block, 1);
1881 bitmap_file_set_bit(mddev->bitmap, block);
1882 }
1883 }
1884
1885 bitmap_update_sb(bitmap);
1886 /* Setting this for the ev_page should be enough.
1887 * And we do not require both write_all and PAGE_DIRT either
1888 */
1889 for (i = 0; i < bitmap->storage.file_pages; i++)
1890 set_page_attr(bitmap, i, BITMAP_PAGE_DIRTY);
1891 bitmap_write_all(bitmap);
1892 bitmap_unplug(bitmap);
1893 *low = lo;
1894 *high = hi;
1895err:
1896 bitmap_free(bitmap);
1897 return rv;
1898}
1899EXPORT_SYMBOL_GPL(bitmap_copy_from_slot);
1900
1901
1826void bitmap_status(struct seq_file *seq, struct bitmap *bitmap) 1902void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
1827{ 1903{
1828 unsigned long chunk_kb; 1904 unsigned long chunk_kb;