- Kai Germaschewski: ISDN update (including Makefiles)
[davej-history.git] / include / linux / iobuf.h
blob3de43c924039b731a281799ea912fa2bc3dd2fe3
1 /*
2 * iobuf.h
4 * Defines the structures used to track abstract kernel-space io buffers.
6 */
8 #ifndef __LINUX_IOBUF_H
9 #define __LINUX_IOBUF_H
11 #include <linux/mm.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
24 * entire iovec.
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! */
34 struct kiobuf
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
44 * every address. */
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;
61 /* mm/memory.c */
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[]);
68 /* fs/iobuf.c */
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 *);
79 /* fs/buffer.c */
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 */