blob: ae4981ebd18eaacacafb0cf34b040f67c2c3b729 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * 1999 Copyright (C) Pavel Machek, pavel@ucw.cz. This code is GPL.
3 * 1999/11/04 Copyright (C) 1999 VMware, Inc. (Regis "HPReg" Duchesne)
4 * Made nbd_end_request() use the io_request_lock
5 * 2001 Copyright (C) Steven Whitehouse
6 * New nbd_end_request() for compatibility with new linux block
7 * layer code.
8 * 2003/06/24 Louis D. Langholtz <ldl@aros.net>
9 * Removed unneeded blksize_bits field from nbd_device struct.
10 * Cleanup PARANOIA usage & code.
11 * 2004/02/19 Paul Clements
12 * Removed PARANOIA, plus various cleanup and comments
13 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#ifndef LINUX_NBD_H
15#define LINUX_NBD_H
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Herbert Xu4b2f0262006-01-06 00:09:47 -080018#include <linux/wait.h>
Ingo Molnar82d4dc52006-03-23 03:00:38 -080019#include <linux/mutex.h>
David Howells607ca462012-10-13 10:46:48 +010020#include <uapi/linux/nbd.h>
Herbert Xu4b2f0262006-01-06 00:09:47 -080021
Herbert Xu4b2f0262006-01-06 00:09:47 -080022struct request;
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024struct nbd_device {
25 int flags;
26 int harderror; /* Code of hard error */
27 struct socket * sock;
28 struct file * file; /* If == NULL, device is not ready, yet */
29 int magic;
Herbert Xu4b2f0262006-01-06 00:09:47 -080030
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 spinlock_t queue_lock;
Laurent Vivier48cf6062008-04-29 01:02:46 -070032 struct list_head queue_head; /* Requests waiting result */
Herbert Xu4b2f0262006-01-06 00:09:47 -080033 struct request *active_req;
34 wait_queue_head_t active_wq;
Laurent Vivier48cf6062008-04-29 01:02:46 -070035 struct list_head waiting_queue; /* Requests to be sent */
36 wait_queue_head_t waiting_wq;
Herbert Xu4b2f0262006-01-06 00:09:47 -080037
Ingo Molnar82d4dc52006-03-23 03:00:38 -080038 struct mutex tx_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 struct gendisk *disk;
40 int blksize;
41 u64 bytesize;
Paul Clements6b39bb62006-12-06 20:40:53 -080042 pid_t pid; /* pid of nbd-client, if attached */
Paul Clements7fdfd402007-10-16 23:27:37 -070043 int xmit_timeout;
Paul Clementsc378f702013-07-03 15:09:04 -070044 int disconnect; /* a disconnect has been requested by user */
Linus Torvalds1da177e2005-04-16 15:20:36 -070045};
46
47#endif