Lines Matching refs:lo
190 void nbd_send_req(struct nbd_device *lo, struct request *req) in nbd_send_req() argument
195 struct socket *sock = lo->sock; in nbd_send_req()
204 down(&lo->tx_lock); in nbd_send_req()
206 if (!sock || !lo->sock) { in nbd_send_req()
224 up(&lo->tx_lock); in nbd_send_req()
228 up(&lo->tx_lock); in nbd_send_req()
232 static struct request *nbd_find_request(struct nbd_device *lo, char *handle) in nbd_find_request() argument
240 spin_lock(&lo->queue_lock); in nbd_find_request()
241 list_for_each(tmp, &lo->queue_head) { in nbd_find_request()
246 spin_unlock(&lo->queue_lock); in nbd_find_request()
249 spin_unlock(&lo->queue_lock); in nbd_find_request()
253 #define HARDFAIL( s ) { printk( KERN_ERR "NBD: " s "(result %d)\n", result ); lo->harderror = resul…
254 struct request *nbd_read_stat(struct nbd_device *lo) in nbd_read_stat() argument
263 result = nbd_xmit(0, lo->sock, (char *) &reply, sizeof(reply), MSG_WAITALL); in nbd_read_stat()
266 req = nbd_find_request(lo, reply.handle); in nbd_read_stat()
279 result = nbd_xmit(0, lo->sock, bh->b_data, bh->b_size, MSG_WAITALL); in nbd_read_stat()
294 void nbd_do_it(struct nbd_device *lo) in nbd_do_it() argument
299 req = nbd_read_stat(lo); in nbd_do_it()
306 if (lo != &nbd_dev[MINOR(req->rq_dev)]) { in nbd_do_it()
310 if (lo->magic != LO_MAGIC) { in nbd_do_it()
323 void nbd_clear_que(struct nbd_device *lo) in nbd_clear_que() argument
328 if (lo->magic != LO_MAGIC) { in nbd_clear_que()
335 spin_lock(&lo->queue_lock); in nbd_clear_que()
336 if (!list_empty(&lo->queue_head)) { in nbd_clear_que()
337 req = list_entry(lo->queue_head.next, struct request, queue); in nbd_clear_que()
340 spin_unlock(&lo->queue_lock); in nbd_clear_que()
363 struct nbd_device *lo; in do_nbd_request() local
376 lo = &nbd_dev[dev]; in do_nbd_request()
377 if (!lo->file) in do_nbd_request()
379 if ((req->cmd == WRITE) && (lo->flags & NBD_READ_ONLY)) in do_nbd_request()
382 if (lo->magic != LO_MAGIC) in do_nbd_request()
390 spin_lock(&lo->queue_lock); in do_nbd_request()
391 if (!lo->file) { in do_nbd_request()
392 spin_unlock(&lo->queue_lock); in do_nbd_request()
400 list_add_tail(&req->queue, &lo->queue_head); in do_nbd_request()
401 spin_unlock(&lo->queue_lock); in do_nbd_request()
403 nbd_send_req(lo, req); in do_nbd_request()
406 spin_lock(&lo->queue_lock); in do_nbd_request()
408 spin_unlock(&lo->queue_lock); in do_nbd_request()
430 struct nbd_device *lo; in nbd_ioctl() local
441 lo = &nbd_dev[dev]; in nbd_ioctl()
460 if (!lo->sock) return -EINVAL; in nbd_ioctl()
461 nbd_send_req(lo, &sreq); in nbd_ioctl()
466 down(&lo->tx_lock); in nbd_ioctl()
467 lo->sock = NULL; in nbd_ioctl()
468 up(&lo->tx_lock); in nbd_ioctl()
469 spin_lock(&lo->queue_lock); in nbd_ioctl()
470 file = lo->file; in nbd_ioctl()
471 lo->file = NULL; in nbd_ioctl()
472 spin_unlock(&lo->queue_lock); in nbd_ioctl()
473 nbd_clear_que(lo); in nbd_ioctl()
474 spin_lock(&lo->queue_lock); in nbd_ioctl()
475 if (!list_empty(&lo->queue_head)) { in nbd_ioctl()
479 spin_unlock(&lo->queue_lock); in nbd_ioctl()
484 if (lo->file) in nbd_ioctl()
491 lo->file = file; in nbd_ioctl()
492 lo->sock = &inode->u.socket_i; in nbd_ioctl()
518 if (!lo->file) in nbd_ioctl()
520 nbd_do_it(lo); in nbd_ioctl()
528 down(&lo->tx_lock); in nbd_ioctl()
529 if (lo->sock) { in nbd_ioctl()
531 lo->sock->ops->shutdown(lo->sock, in nbd_ioctl()
533 lo->sock = NULL; in nbd_ioctl()
535 up(&lo->tx_lock); in nbd_ioctl()
536 spin_lock(&lo->queue_lock); in nbd_ioctl()
537 file = lo->file; in nbd_ioctl()
538 lo->file = NULL; in nbd_ioctl()
539 spin_unlock(&lo->queue_lock); in nbd_ioctl()
540 nbd_clear_que(lo); in nbd_ioctl()
544 return lo->harderror; in nbd_ioctl()
546 down(&lo->tx_lock); in nbd_ioctl()
547 if (lo->sock) { in nbd_ioctl()
548 up(&lo->tx_lock); in nbd_ioctl()
552 up(&lo->tx_lock); in nbd_ioctl()
553 nbd_clear_que(lo); in nbd_ioctl()
558 dev, lo->queue_head.next, lo->queue_head.prev, requests_in, requests_out); in nbd_ioctl()
567 struct nbd_device *lo; in nbd_release() local
575 lo = &nbd_dev[dev]; in nbd_release()
576 if (lo->refcnt <= 0) in nbd_release()
577 printk(KERN_ALERT "nbd_release: refcount(%d) <= 0\n", lo->refcnt); in nbd_release()
578 lo->refcnt--; in nbd_release()