Commit fc56815c authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Philipp Reisner

drbd: receive_bitmap(): Use the pre-allocated receive buffer

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent e6ef8a5c
...@@ -3574,8 +3574,9 @@ static int receive_sync_uuid(struct drbd_conf *mdev, enum drbd_packet cmd, ...@@ -3574,8 +3574,9 @@ static int receive_sync_uuid(struct drbd_conf *mdev, enum drbd_packet cmd,
*/ */
static int static int
receive_bitmap_plain(struct drbd_conf *mdev, unsigned int data_size, receive_bitmap_plain(struct drbd_conf *mdev, unsigned int data_size,
unsigned long *buffer, struct bm_xfer_ctx *c) struct p_header *h, struct bm_xfer_ctx *c)
{ {
unsigned long *buffer = (unsigned long *)h->payload;
unsigned num_words = min_t(size_t, BM_PACKET_WORDS, c->bm_words - c->word_offset); unsigned num_words = min_t(size_t, BM_PACKET_WORDS, c->bm_words - c->word_offset);
unsigned want = num_words * sizeof(long); unsigned want = num_words * sizeof(long);
int err; int err;
...@@ -3750,7 +3751,6 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd, ...@@ -3750,7 +3751,6 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd,
unsigned int data_size) unsigned int data_size)
{ {
struct bm_xfer_ctx c; struct bm_xfer_ctx c;
void *buffer;
int err; int err;
struct p_header *h = mdev->tconn->data.rbuf; struct p_header *h = mdev->tconn->data.rbuf;
struct packet_info pi; struct packet_info pi;
...@@ -3759,15 +3759,6 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd, ...@@ -3759,15 +3759,6 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd,
/* you are supposed to send additional out-of-sync information /* you are supposed to send additional out-of-sync information
* if you actually set bits during this phase */ * if you actually set bits during this phase */
/* maybe we should use some per thread scratch page,
* and allocate that during initial device creation? */
buffer = (unsigned long *) __get_free_page(GFP_NOIO);
if (!buffer) {
dev_err(DEV, "failed to allocate one page buffer in %s\n", __func__);
err = -ENOMEM;
goto out;
}
c = (struct bm_xfer_ctx) { c = (struct bm_xfer_ctx) {
.bm_bits = drbd_bm_bits(mdev), .bm_bits = drbd_bm_bits(mdev),
.bm_words = drbd_bm_words(mdev), .bm_words = drbd_bm_words(mdev),
...@@ -3775,7 +3766,7 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd, ...@@ -3775,7 +3766,7 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd,
for(;;) { for(;;) {
if (cmd == P_BITMAP) { if (cmd == P_BITMAP) {
err = receive_bitmap_plain(mdev, data_size, buffer, &c); err = receive_bitmap_plain(mdev, data_size, h, &c);
} else if (cmd == P_COMPRESSED_BITMAP) { } else if (cmd == P_COMPRESSED_BITMAP) {
/* MAYBE: sanity check that we speak proto >= 90, /* MAYBE: sanity check that we speak proto >= 90,
* and the feature is enabled! */ * and the feature is enabled! */
...@@ -3786,9 +3777,8 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd, ...@@ -3786,9 +3777,8 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd,
err = -EIO; err = -EIO;
goto out; goto out;
} }
/* use the page buff */
p = buffer; p = mdev->tconn->data.rbuf;
memcpy(p, h, sizeof(*h));
err = drbd_recv_all(mdev->tconn, p->head.payload, data_size); err = drbd_recv_all(mdev->tconn, p->head.payload, data_size);
if (err) if (err)
goto out; goto out;
...@@ -3842,7 +3832,6 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd, ...@@ -3842,7 +3832,6 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd,
drbd_bm_unlock(mdev); drbd_bm_unlock(mdev);
if (!err && mdev->state.conn == C_WF_BITMAP_S) if (!err && mdev->state.conn == C_WF_BITMAP_S)
drbd_start_resync(mdev, C_SYNC_SOURCE); drbd_start_resync(mdev, C_SYNC_SOURCE);
free_page((unsigned long) buffer);
return err; return err;
} }
......
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