diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/nbd.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 386d40e3cf48..d724da52153b 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -590,8 +590,11 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, nbd_cmd(&sreq) = NBD_CMD_DISC; if (!nbd->sock) return -EINVAL; + + nbd->disconnect = 1; + nbd_send_req(nbd, &sreq); - return 0; + return 0; } case NBD_CLEAR_SOCK: { @@ -620,6 +623,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, nbd->sock = SOCKET_I(inode); if (max_part > 0) bdev->bd_invalidated = 1; + nbd->disconnect = 0; /* we're connected now */ return 0; } else { fput(file); @@ -691,6 +695,8 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, set_capacity(nbd->disk, 0); if (max_part > 0) ioctl_by_bdev(bdev, BLKRRPART, 0); + if (nbd->disconnect) /* user requested, ignore socket errors */ + return 0; return nbd->harderror; } |