home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / Include / Linux / iobuf.h < prev    next >
C/C++ Source or Header  |  2002-04-26  |  3KB  |  89 lines

  1. /* $Id: iobuf.h,v 1.2 2002/04/26 23:09:06 smilcke Exp $ */
  2.  
  3. /*
  4.  * iobuf.h
  5.  *
  6.  * Defines the structures used to track abstract kernel-space io buffers.
  7.  *
  8.  */
  9.  
  10. #ifndef __LINUX_IOBUF_H
  11. #define __LINUX_IOBUF_H
  12.  
  13. #include <linux/mm.h>
  14. #include <linux/init.h>
  15. #include <linux/wait.h>
  16. #include <asm/atomic.h>
  17.  
  18. /*
  19.  * The kiobuf structure describes a physical set of pages reserved
  20.  * locked for IO.  The reference counts on each page will have been
  21.  * incremented, and the flags field will indicate whether or not we have
  22.  * pre-locked all of the pages for IO.
  23.  *
  24.  * kiobufs may be passed in arrays to form a kiovec, but we must
  25.  * preserve the property that no page is present more than once over the
  26.  * entire iovec.
  27.  */
  28.  
  29. #define KIO_MAX_ATOMIC_IO    512 /* in kb */
  30. #define KIO_STATIC_PAGES    (KIO_MAX_ATOMIC_IO / (PAGE_SIZE >> 10) + 1)
  31. #define KIO_MAX_SECTORS        (KIO_MAX_ATOMIC_IO * 2)
  32.  
  33. /* The main kiobuf struct used for all our IO! */
  34.  
  35. struct kiobuf 
  36. {
  37.     int        nr_pages;    /* Pages actually referenced */
  38.     int        array_len;    /* Space in the allocated lists */
  39.     int        offset;        /* Offset to start of valid data */
  40.     int        length;        /* Number of valid bytes of data */
  41.  
  42.     /* Keep separate track of the physical addresses and page
  43.      * structs involved.  If we do IO to a memory-mapped device
  44.      * region, there won't necessarily be page structs defined for
  45.      * every address. */
  46.  
  47.     struct page **    maplist;
  48.  
  49.     unsigned int    locked : 1;    /* If set, pages has been locked */
  50.     
  51.     /* Always embed enough struct pages for atomic IO */
  52.     struct page *    map_array[KIO_STATIC_PAGES];
  53.     struct buffer_head * bh[KIO_MAX_SECTORS];
  54.     unsigned long blocks[KIO_MAX_SECTORS];
  55.  
  56.     /* Dynamic state for IO completion: */
  57.     atomic_t    io_count;    /* IOs still in progress */
  58.     int        errno;        /* Status of completed IO */
  59.     void        (*end_io) (struct kiobuf *); /* Completion callback */
  60.     wait_queue_head_t wait_queue;
  61. };
  62.  
  63.  
  64. /* mm/memory.c */
  65.  
  66. int    map_user_kiobuf(int rw, struct kiobuf *, unsigned long va, size_t len);
  67. void    unmap_kiobuf(struct kiobuf *iobuf);
  68. int    lock_kiovec(int nr, struct kiobuf *iovec[], int wait);
  69. int    unlock_kiovec(int nr, struct kiobuf *iovec[]);
  70. void    mark_dirty_kiobuf(struct kiobuf *iobuf, int bytes);
  71.  
  72. /* fs/iobuf.c */
  73.  
  74. void    end_kio_request(struct kiobuf *, int);
  75. void    simple_wakeup_kiobuf(struct kiobuf *);
  76. int    alloc_kiovec(int nr, struct kiobuf **);
  77. void    free_kiovec(int nr, struct kiobuf **);
  78. int    expand_kiobuf(struct kiobuf *, int);
  79. void    kiobuf_wait_for_io(struct kiobuf *);
  80. extern int alloc_kiobuf_bhs(struct kiobuf *);
  81. extern void free_kiobuf_bhs(struct kiobuf *);
  82.  
  83. /* fs/buffer.c */
  84.  
  85. int    brw_kiovec(int rw, int nr, struct kiobuf *iovec[], 
  86.            kdev_t dev, unsigned long b[], int size);
  87.  
  88. #endif /* __LINUX_IOBUF_H */
  89.