Commit 02d9a94b authored by Philipp Reisner's avatar Philipp Reisner

drbd: Implemented the set_new_bits parameter for drbd_bm_resize()

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent d845030f
...@@ -441,7 +441,7 @@ static void bm_memset(struct drbd_bitmap *b, size_t offset, int c, size_t len) ...@@ -441,7 +441,7 @@ static void bm_memset(struct drbd_bitmap *b, size_t offset, int c, size_t len)
* In case this is actually a resize, we copy the old bitmap into the new one. * In case this is actually a resize, we copy the old bitmap into the new one.
* Otherwise, the bitmap is initialized to all bits set. * Otherwise, the bitmap is initialized to all bits set.
*/ */
int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity) int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity, int set_new_bits)
{ {
struct drbd_bitmap *b = mdev->bitmap; struct drbd_bitmap *b = mdev->bitmap;
unsigned long bits, words, owords, obits, *p_addr, *bm; unsigned long bits, words, owords, obits, *p_addr, *bm;
...@@ -526,8 +526,12 @@ int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity) ...@@ -526,8 +526,12 @@ int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity)
b->bm_dev_capacity = capacity; b->bm_dev_capacity = capacity;
if (growing) { if (growing) {
if (set_new_bits) {
bm_memset(b, owords, 0xff, words-owords); bm_memset(b, owords, 0xff, words-owords);
b->bm_set += bits - obits; b->bm_set += bits - obits;
} else
bm_memset(b, owords, 0x00, words-owords);
} }
if (want < have) { if (want < have) {
......
...@@ -1311,7 +1311,7 @@ struct bm_extent { ...@@ -1311,7 +1311,7 @@ struct bm_extent {
#define APP_R_HSIZE 15 #define APP_R_HSIZE 15
extern int drbd_bm_init(struct drbd_conf *mdev); extern int drbd_bm_init(struct drbd_conf *mdev);
extern int drbd_bm_resize(struct drbd_conf *mdev, sector_t sectors); extern int drbd_bm_resize(struct drbd_conf *mdev, sector_t sectors, int set_new_bits);
extern void drbd_bm_cleanup(struct drbd_conf *mdev); extern void drbd_bm_cleanup(struct drbd_conf *mdev);
extern void drbd_bm_set_all(struct drbd_conf *mdev); extern void drbd_bm_set_all(struct drbd_conf *mdev);
extern void drbd_bm_clear_all(struct drbd_conf *mdev); extern void drbd_bm_clear_all(struct drbd_conf *mdev);
......
...@@ -2688,7 +2688,7 @@ void drbd_mdev_cleanup(struct drbd_conf *mdev) ...@@ -2688,7 +2688,7 @@ void drbd_mdev_cleanup(struct drbd_conf *mdev)
drbd_set_my_capacity(mdev, 0); drbd_set_my_capacity(mdev, 0);
if (mdev->bitmap) { if (mdev->bitmap) {
/* maybe never allocated. */ /* maybe never allocated. */
drbd_bm_resize(mdev, 0); drbd_bm_resize(mdev, 0, 1);
drbd_bm_cleanup(mdev); drbd_bm_cleanup(mdev);
} }
......
...@@ -546,7 +546,7 @@ enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *mdev, enum dds_ ...@@ -546,7 +546,7 @@ enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *mdev, enum dds_
if (drbd_get_capacity(mdev->this_bdev) != size || if (drbd_get_capacity(mdev->this_bdev) != size ||
drbd_bm_capacity(mdev) != size) { drbd_bm_capacity(mdev) != size) {
int err; int err;
err = drbd_bm_resize(mdev, size); err = drbd_bm_resize(mdev, size, !(flags & DDSF_NO_RESYNC));
if (unlikely(err)) { if (unlikely(err)) {
/* currently there is only one error: ENOMEM! */ /* currently there is only one error: ENOMEM! */
size = drbd_bm_capacity(mdev)>>1; size = drbd_bm_capacity(mdev)>>1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment