Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
nbd/server: avoid per-NBDRequest nbd_client_get/put()
nbd_trip() processes a single NBD request from start to finish and holds
an NBDClient reference throughout. NBDRequest does not outlive the scope
of nbd_trip(). Therefore it is unnecessary to ref/unref NBDClient for
each NBDRequest.

Removing these nbd_client_get()/nbd_client_put() calls will make
thread-safety easier in the commits that follow.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20231221192452.1785567-5-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
Stefan Hajnoczi authored and Kevin Wolf committed Dec 21, 2023
1 parent 191710c commit efade66
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions nbd/server.c
Expand Up @@ -1557,7 +1557,6 @@ static NBDRequestData *nbd_request_get(NBDClient *client)
client->nb_requests++;

req = g_new0(NBDRequestData, 1);
nbd_client_get(client);
req->client = client;
return req;
}
Expand All @@ -1578,8 +1577,6 @@ static void nbd_request_put(NBDRequestData *req)
}

nbd_client_receive_next_request(client);

nbd_client_put(client);
}

static void blk_aio_attached(AioContext *ctx, void *opaque)
Expand Down

0 comments on commit efade66

Please sign in to comment.