4 * Defines the structures used to track abstract kernel-space io buffers.
8 #ifndef __LINUX_IOBUF_H
9 #define __LINUX_IOBUF_H
12 #include <linux/init.h>
13 #include <linux/wait.h>
14 #include <asm/atomic.h>
17 * The kiobuf structure describes a physical set of pages reserved
18 * locked for IO. The reference counts on each page will have been
19 * incremented, and the flags field will indicate whether or not we have
20 * pre-locked all of the pages for IO.
22 * kiobufs may be passed in arrays to form a kiovec, but we must
23 * preserve the property that no page is present more than once over the
27 #define KIO_MAX_ATOMIC_IO 64 /* in kb */
28 #define KIO_MAX_ATOMIC_BYTES (64 * 1024)
29 #define KIO_STATIC_PAGES (KIO_MAX_ATOMIC_IO / (PAGE_SIZE >> 10) + 1)
30 #define KIO_MAX_SECTORS (KIO_MAX_ATOMIC_IO * 2)
32 /* The main kiobuf struct used for all our IO! */
36 int nr_pages
; /* Pages actually referenced */
37 int array_len
; /* Space in the allocated lists */
38 int offset
; /* Offset to start of valid data */
39 int length
; /* Number of valid bytes of data */
41 /* Keep separate track of the physical addresses and page
42 * structs involved. If we do IO to a memory-mapped device
43 * region, there won't necessarily be page structs defined for
46 struct page
** maplist
;
48 unsigned int locked
: 1; /* If set, pages has been locked */
50 /* Always embed enough struct pages for 64k of IO */
51 struct page
* map_array
[KIO_STATIC_PAGES
];
53 /* Dynamic state for IO completion: */
54 atomic_t io_count
; /* IOs still in progress */
55 int errno
; /* Status of completed IO */
56 void (*end_io
) (struct kiobuf
*); /* Completion callback */
57 wait_queue_head_t wait_queue
;
63 int map_user_kiobuf(int rw
, struct kiobuf
*, unsigned long va
, size_t len
);
64 void unmap_kiobuf(struct kiobuf
*iobuf
);
65 int lock_kiovec(int nr
, struct kiobuf
*iovec
[], int wait
);
66 int unlock_kiovec(int nr
, struct kiobuf
*iovec
[]);
70 void __init
kiobuf_setup(void);
71 void kiobuf_init(struct kiobuf
*);
72 void end_kio_request(struct kiobuf
*, int);
73 void simple_wakeup_kiobuf(struct kiobuf
*);
74 int alloc_kiovec(int nr
, struct kiobuf
**);
75 void free_kiovec(int nr
, struct kiobuf
**);
76 int expand_kiobuf(struct kiobuf
*, int);
77 void kiobuf_wait_for_io(struct kiobuf
*);
81 int brw_kiovec(int rw
, int nr
, struct kiobuf
*iovec
[],
82 kdev_t dev
, unsigned long b
[], int size
);
84 #endif /* __LINUX_IOBUF_H */