lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Thu, 30 May 2019 15:53:25 +0800 From: xiubli@...hat.com To: josef@...icpanda.com, axboe@...nel.dk, nbd@...er.debian.org Cc: mchristi@...hat.com, linux-block@...r.kernel.org, linux-kernel@...r.kernel.org, atumball@...hat.com, Xiubo Li <xiubli@...hat.com> Subject: [PATCH] nbd: no need to check all the connections one by one if all are dead From: Xiubo Li <xiubli@...hat.com> If all connections are dead the live_connections should be already set to 0. And set the nsock->fallback to -1 again if all connections are dead. Signed-off-by: Xiubo Li <xiubli@...hat.com> --- drivers/block/nbd.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 98be6ca..6da42aa 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -783,13 +783,16 @@ static int find_fallback(struct nbd_device *nbd, int index) return new_index; } + if (atomic_read(&config->live_connections) <= 0) { + dev_err_ratelimited(disk_to_dev(nbd->disk), + "Dead connection, failed to find a fallback\n"); + goto out; + } + if (fallback >= 0 && fallback < config->num_connections && - !config->socks[fallback]->dead) + !config->socks[fallback]->dead) { return fallback; - - if (nsock->fallback_index < 0 || - nsock->fallback_index >= config->num_connections || - config->socks[nsock->fallback_index]->dead) { + } else { int i; for (i = 0; i < config->num_connections; i++) { if (i == index) @@ -799,14 +802,10 @@ static int find_fallback(struct nbd_device *nbd, int index) break; } } - nsock->fallback_index = new_index; - if (new_index < 0) { - dev_err_ratelimited(disk_to_dev(nbd->disk), - "Dead connection, failed to find a fallback\n"); - return new_index; - } } - new_index = nsock->fallback_index; + +out: + nsock->fallback_index = new_index; return new_index; } -- 1.8.3.1
Powered by blists - more mailing lists