Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 359399
b: refs/heads/master
c: 3a2d63f
h: refs/heads/master
i:
  359397: 7fe7b3a
  359395: 867412c
  359391: 0bfa4a8
v: v3
  • Loading branch information
Paolo Bonzini authored and Linus Torvalds committed Feb 28, 2013
1 parent 92d3a32 commit 9e0be15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 75f187aba5e7a3eea259041f85099029774a4c5b
refs/heads/master: 3a2d63f87989e01437ba994df5f297528c353d7d
10 changes: 10 additions & 0 deletions trunk/drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,12 +608,20 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
struct request sreq;

dev_info(disk_to_dev(nbd->disk), "NBD_DISCONNECT\n");
if (!nbd->sock)
return -EINVAL;

mutex_unlock(&nbd->tx_lock);
fsync_bdev(bdev);
mutex_lock(&nbd->tx_lock);
blk_rq_init(NULL, &sreq);
sreq.cmd_type = REQ_TYPE_SPECIAL;
nbd_cmd(&sreq) = NBD_CMD_DISC;

/* Check again after getting mutex back. */
if (!nbd->sock)
return -EINVAL;

nbd_send_req(nbd, &sreq);
return 0;
}
Expand All @@ -627,6 +635,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
nbd_clear_que(nbd);
BUG_ON(!list_empty(&nbd->queue_head));
BUG_ON(!list_empty(&nbd->waiting_queue));
kill_bdev(bdev);
if (file)
fput(file);
return 0;
Expand Down Expand Up @@ -719,6 +728,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
nbd->file = NULL;
nbd_clear_que(nbd);
dev_warn(disk_to_dev(nbd->disk), "queue cleared\n");
kill_bdev(bdev);
queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, nbd->disk->queue);
if (file)
fput(file);
Expand Down

0 comments on commit 9e0be15

Please sign in to comment.