579 case NBD_DISCONNECT:
580 printk(KERN_INFO "%s: NBD_DISCONNECT\n", lo->disk->disk_name);
581 blk_rq_init(NULL, &sreq);
582 sreq.cmd_type = REQ_TYPE_SPECIAL;
583 nbd_cmd(&sreq) = NBD_CMD_DISC;
584
585
586
587
588
589 sreq.sector = 0;
590 sreq.nr_sectors = 0;
591 if (!lo->sock)
592 return -EINVAL;
593 mutex_lock(&lo->tx_lock);
594 nbd_send_req(lo, &sreq);
595 mutex_unlock(&lo->tx_lock);
596 return 0;
597
598 case NBD_CLEAR_SOCK:
599 error = 0;
600 mutex_lock(&lo->tx_lock);
601 lo->sock = NULL;
602 mutex_unlock(&lo->tx_lock);
603 file = lo->file;
604 lo->file = NULL;
605 nbd_clear_que(lo);
606 BUG_ON(!list_empty(&lo->queue_head));
607 if (file)
608 fput(file);
609 return error;
610 case NBD_SET_SOCK:
611 if (lo->file)
612 return -EBUSY;
613 error = -EINVAL;
614 file = fget(arg);
615 if (file) {
616 struct inode *inode = file->f_path.dentry->d_inode;
617 if (S_ISSOCK(inode->i_mode)) {
618 lo->file = file;
619 lo->sock = SOCKET_I(inode);