Commit 79ed9bd0 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Philipp Reisner

drbd: _drbd_send_bitmap(): Use the pre-allocated send buffer

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 5a87d920
...@@ -790,9 +790,6 @@ int drbd_send_sync_param(struct drbd_conf *mdev) ...@@ -790,9 +790,6 @@ int drbd_send_sync_param(struct drbd_conf *mdev)
: apv <= 94 ? sizeof(struct p_rs_param_89) : apv <= 94 ? sizeof(struct p_rs_param_89)
: /* apv >= 95 */ sizeof(struct p_rs_param_95); : /* apv >= 95 */ sizeof(struct p_rs_param_95);
/* used from admin command context and receiver/worker context.
* to avoid kmalloc, grab the socket right here,
* then use the pre-allocated sbuf there */
mutex_lock(&mdev->tconn->data.mutex); mutex_lock(&mdev->tconn->data.mutex);
sock = mdev->tconn->data.socket; sock = mdev->tconn->data.socket;
...@@ -1147,10 +1144,9 @@ int fill_bitmap_rle_bits(struct drbd_conf *mdev, ...@@ -1147,10 +1144,9 @@ int fill_bitmap_rle_bits(struct drbd_conf *mdev,
* code upon failure. * code upon failure.
*/ */
static int static int
send_bitmap_rle_or_plain(struct drbd_conf *mdev, send_bitmap_rle_or_plain(struct drbd_conf *mdev, struct bm_xfer_ctx *c)
struct p_header *h, struct bm_xfer_ctx *c)
{ {
struct p_compressed_bm *p = (void*)h; struct p_compressed_bm *p = mdev->tconn->data.sbuf;
unsigned long num_words; unsigned long num_words;
int len, err; int len, err;
...@@ -1162,7 +1158,7 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, ...@@ -1162,7 +1158,7 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev,
if (len) { if (len) {
dcbp_set_code(p, RLE_VLI_Bits); dcbp_set_code(p, RLE_VLI_Bits);
err = _drbd_send_cmd(mdev, mdev->tconn->data.socket, err = _drbd_send_cmd(mdev, mdev->tconn->data.socket,
P_COMPRESSED_BITMAP, h, P_COMPRESSED_BITMAP, &p->head,
sizeof(*p) + len, 0); sizeof(*p) + len, 0);
c->packets[0]++; c->packets[0]++;
...@@ -1173,10 +1169,12 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, ...@@ -1173,10 +1169,12 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev,
} else { } else {
/* was not compressible. /* was not compressible.
* send a buffer full of plain text bits instead. */ * send a buffer full of plain text bits instead. */
struct p_header *h = mdev->tconn->data.sbuf;
num_words = min_t(size_t, BM_PACKET_WORDS, c->bm_words - c->word_offset); num_words = min_t(size_t, BM_PACKET_WORDS, c->bm_words - c->word_offset);
len = num_words * sizeof(long); len = num_words * sizeof(long);
if (len) if (len)
drbd_bm_get_lel(mdev, c->word_offset, num_words, (unsigned long*)h->payload); drbd_bm_get_lel(mdev, c->word_offset, num_words,
(unsigned long *)h->payload);
err = _drbd_send_cmd(mdev, mdev->tconn->data.socket, P_BITMAP, err = _drbd_send_cmd(mdev, mdev->tconn->data.socket, P_BITMAP,
h, sizeof(struct p_header80) + len, 0); h, sizeof(struct p_header80) + len, 0);
c->word_offset += num_words; c->word_offset += num_words;
...@@ -1202,20 +1200,11 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, ...@@ -1202,20 +1200,11 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev,
static int _drbd_send_bitmap(struct drbd_conf *mdev) static int _drbd_send_bitmap(struct drbd_conf *mdev)
{ {
struct bm_xfer_ctx c; struct bm_xfer_ctx c;
struct p_header *p;
int err; int err;
if (!expect(mdev->bitmap)) if (!expect(mdev->bitmap))
return false; return false;
/* maybe we should use some per thread scratch page,
* and allocate that during initial device creation? */
p = (struct p_header *) __get_free_page(GFP_NOIO);
if (!p) {
dev_err(DEV, "failed to allocate one page buffer in %s\n", __func__);
return false;
}
if (get_ldev(mdev)) { if (get_ldev(mdev)) {
if (drbd_md_test_flag(mdev->ldev, MDF_FULL_SYNC)) { if (drbd_md_test_flag(mdev->ldev, MDF_FULL_SYNC)) {
dev_info(DEV, "Writing the whole bitmap, MDF_FullSync was set.\n"); dev_info(DEV, "Writing the whole bitmap, MDF_FullSync was set.\n");
...@@ -1239,10 +1228,9 @@ static int _drbd_send_bitmap(struct drbd_conf *mdev) ...@@ -1239,10 +1228,9 @@ static int _drbd_send_bitmap(struct drbd_conf *mdev)
}; };
do { do {
err = send_bitmap_rle_or_plain(mdev, p, &c); err = send_bitmap_rle_or_plain(mdev, &c);
} while (err > 0); } while (err > 0);
free_page((unsigned long) p);
return err == 0; return err == 0;
} }
......
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