Commit c72a18bc authored by Josef Bacik's avatar Josef Bacik Committed by Ben Hutchings

nbd: only set MSG_MORE when we have more to send

commit d61b7f97 upstream.

A user noticed that write performance was horrible over loopback and we
traced it to an inversion of when we need to set MSG_MORE.  It should be
set when we have more bvec's to send, not when we are on the last bvec.
This patch made the test go from 20 iops to 78k iops.
Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
Fixes: 429a787b ("nbd: fix use-after-free of rq/bio in the xmit path")
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent cd38b7d5
...@@ -239,7 +239,7 @@ static inline int sock_send_bvec(struct nbd_device *nbd, struct bio_vec *bvec, ...@@ -239,7 +239,7 @@ static inline int sock_send_bvec(struct nbd_device *nbd, struct bio_vec *bvec,
/* always call with the tx_lock held */ /* always call with the tx_lock held */
static int nbd_send_req(struct nbd_device *nbd, struct request *req) static int nbd_send_req(struct nbd_device *nbd, struct request *req)
{ {
int result, flags; int result;
struct nbd_request request; struct nbd_request request;
unsigned long size = blk_rq_bytes(req); unsigned long size = blk_rq_bytes(req);
struct bio *bio; struct bio *bio;
...@@ -270,7 +270,6 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req) ...@@ -270,7 +270,6 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req)
if (nbd_cmd(req) != NBD_CMD_WRITE) if (nbd_cmd(req) != NBD_CMD_WRITE)
return 0; return 0;
flags = 0;
bio = req->bio; bio = req->bio;
while (bio) { while (bio) {
struct bio *next = bio->bi_next; struct bio *next = bio->bi_next;
...@@ -279,9 +278,8 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req) ...@@ -279,9 +278,8 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req)
bio_for_each_segment(bvec, bio, iter) { bio_for_each_segment(bvec, bio, iter) {
bool is_last = !next && bio_iter_last(bvec, iter); bool is_last = !next && bio_iter_last(bvec, iter);
int flags = is_last ? 0 : MSG_MORE;
if (is_last)
flags = MSG_MORE;
dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n", dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n",
nbd->disk->disk_name, req, bvec.bv_len); nbd->disk->disk_name, req, bvec.bv_len);
result = sock_send_bvec(nbd, &bvec, flags); result = sock_send_bvec(nbd, &bvec, flags);
......
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