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
10 #define NBD_SET_SOCK _IO( 0xab, 0 )
11 #define NBD_SET_BLKSIZE _IO( 0xab, 1 )
12 #define NBD_SET_SIZE _IO( 0xab, 2 )
13 #define NBD_DO_IT _IO( 0xab, 3 )
14 #define NBD_CLEAR_SOCK _IO( 0xab, 4 )
15 #define NBD_CLEAR_QUE _IO( 0xab, 5 )
16 #define NBD_PRINT_DEBUG _IO( 0xab, 6 )
17 #define NBD_SET_SIZE_BLOCKS _IO( 0xab, 7 )
18 #define NBD_DISCONNECT _IO( 0xab, 8 )
22 #include <linux/locks.h>
23 #include <asm/semaphore.h>
25 #define LOCAL_END_REQUEST
27 #include <linux/blk.h>
30 extern int requests_in
;
31 extern int requests_out
;
35 nbd_end_request(struct request
*req
)
44 * This is a very dirty hack that we have to do to handle
45 * merged requests because end_request stuff is a bit
46 * broken. The fact we have to do this only if there
47 * aren't errors looks even more silly.
50 req
->sector
+= req
->current_nr_sectors
;
51 req
->nr_sectors
-= req
->current_nr_sectors
;
54 spin_lock_irqsave(&io_request_lock
, flags
);
55 if (end_that_request_first( req
, !req
->errors
, "nbd" ))
58 end_that_request_last( req
);
61 spin_unlock_irqrestore(&io_request_lock
, flags
);
70 int harderror
; /* Code of hard error */
71 #define NBD_READ_ONLY 0x0001
72 #define NBD_WRITE_NOCHK 0x0002
74 struct file
* file
; /* If == NULL, device is not ready, yet */
75 int magic
; /* FIXME: not if debugging is off */
76 struct list_head queue_head
; /* Requests are added here... */
77 struct semaphore queue_lock
;
81 /* This now IS in some kind of include file... */
83 /* These are send over network in request/reply magic field */
85 #define NBD_REQUEST_MAGIC 0x25609513
86 #define NBD_REPLY_MAGIC 0x67446698
87 /* Do *not* use magics: 0x12560953 0x96744668. */
90 * This is packet used for communication between client and
91 * server. All data are in network byte order.
95 u32 type
; /* == READ || == WRITE */
101 __attribute__ ((packed
))
107 u32 error
; /* 0 = ok, else error */
108 char handle
[8]; /* handle you got from request */