Home | History | Annotate | Download | only in linux
      1 /****************************************************************************
      2  ****************************************************************************
      3  ***
      4  ***   This header was automatically generated from a Linux kernel header
      5  ***   of the same name, to make information necessary for userspace to
      6  ***   call into the kernel available to libc.  It contains only constants,
      7  ***   structures, and macros generated from the original header, and thus,
      8  ***   contains no copyrightable information.
      9  ***
     10  ****************************************************************************
     11  ****************************************************************************/
     12 #ifndef __LINUX_BIO_H
     13 #define __LINUX_BIO_H
     14 
     15 #include <linux/highmem.h>
     16 #include <linux/mempool.h>
     17 #include <linux/ioprio.h>
     18 
     19 #include <asm/io.h>
     20 
     21 #if defined(BIO_VMERGE_MAX_SIZE) && defined(BIO_VMERGE_BOUNDARY)
     22 #define BIOVEC_VIRT_START_SIZE(x) (bvec_to_phys(x) & (BIO_VMERGE_BOUNDARY - 1))
     23 #define BIOVEC_VIRT_OVERSIZE(x) ((x) > BIO_VMERGE_MAX_SIZE)
     24 #else
     25 #define BIOVEC_VIRT_START_SIZE(x) 0
     26 #define BIOVEC_VIRT_OVERSIZE(x) 0
     27 #endif
     28 
     29 #ifndef BIO_VMERGE_BOUNDARY
     30 #define BIO_VMERGE_BOUNDARY 0
     31 #endif
     32 
     33 #define BIO_DEBUG
     34 
     35 #ifdef BIO_DEBUG
     36 #define BIO_BUG_ON BUG_ON
     37 #else
     38 #define BIO_BUG_ON
     39 #endif
     40 
     41 #define BIO_MAX_PAGES 256
     42 #define BIO_MAX_SIZE (BIO_MAX_PAGES << PAGE_CACHE_SHIFT)
     43 #define BIO_MAX_SECTORS (BIO_MAX_SIZE >> 9)
     44 
     45 struct bio_vec {
     46  struct page *bv_page;
     47  unsigned int bv_len;
     48  unsigned int bv_offset;
     49 };
     50 
     51 struct bio_set;
     52 struct bio;
     53 typedef int (bio_end_io_t) (struct bio *, unsigned int, int);
     54 typedef void (bio_destructor_t) (struct bio *);
     55 
     56 struct bio {
     57  sector_t bi_sector;
     58  struct bio *bi_next;
     59  struct block_device *bi_bdev;
     60  unsigned long bi_flags;
     61  unsigned long bi_rw;
     62 
     63  unsigned short bi_vcnt;
     64  unsigned short bi_idx;
     65 
     66  unsigned short bi_phys_segments;
     67 
     68  unsigned short bi_hw_segments;
     69 
     70  unsigned int bi_size;
     71 
     72  unsigned int bi_hw_front_size;
     73  unsigned int bi_hw_back_size;
     74 
     75  unsigned int bi_max_vecs;
     76 
     77  struct bio_vec *bi_io_vec;
     78 
     79  bio_end_io_t *bi_end_io;
     80  atomic_t bi_cnt;
     81 
     82  void *bi_private;
     83 
     84  bio_destructor_t *bi_destructor;
     85 };
     86 
     87 #define BIO_UPTODATE 0
     88 #define BIO_RW_BLOCK 1
     89 #define BIO_EOF 2
     90 #define BIO_SEG_VALID 3
     91 #define BIO_CLONED 4
     92 #define BIO_BOUNCED 5
     93 #define BIO_USER_MAPPED 6
     94 #define BIO_EOPNOTSUPP 7
     95 #define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag)))
     96 
     97 #define BIO_POOL_BITS (4)
     98 #define BIO_POOL_OFFSET (BITS_PER_LONG - BIO_POOL_BITS)
     99 #define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET)
    100 #define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET)
    101 
    102 #define BIO_RW 0
    103 #define BIO_RW_AHEAD 1
    104 #define BIO_RW_BARRIER 2
    105 #define BIO_RW_FAILFAST 3
    106 #define BIO_RW_SYNC 4
    107 
    108 #define BIO_PRIO_SHIFT (8 * sizeof(unsigned long) - IOPRIO_BITS)
    109 #define bio_prio(bio) ((bio)->bi_rw >> BIO_PRIO_SHIFT)
    110 #define bio_prio_valid(bio) ioprio_valid(bio_prio(bio))
    111 
    112 #define bio_set_prio(bio, prio) do {   WARN_ON(prio >= (1 << IOPRIO_BITS));   (bio)->bi_rw &= ((1UL << BIO_PRIO_SHIFT) - 1);   (bio)->bi_rw |= ((unsigned long) (prio) << BIO_PRIO_SHIFT);  } while (0)
    113 
    114 #define bio_iovec_idx(bio, idx) (&((bio)->bi_io_vec[(idx)]))
    115 #define bio_iovec(bio) bio_iovec_idx((bio), (bio)->bi_idx)
    116 #define bio_page(bio) bio_iovec((bio))->bv_page
    117 #define bio_offset(bio) bio_iovec((bio))->bv_offset
    118 #define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx)
    119 #define bio_sectors(bio) ((bio)->bi_size >> 9)
    120 #define bio_cur_sectors(bio) (bio_iovec(bio)->bv_len >> 9)
    121 #define bio_data(bio) (page_address(bio_page((bio))) + bio_offset((bio)))
    122 #define bio_barrier(bio) ((bio)->bi_rw & (1 << BIO_RW_BARRIER))
    123 #define bio_sync(bio) ((bio)->bi_rw & (1 << BIO_RW_SYNC))
    124 #define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST))
    125 #define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD))
    126 
    127 #define bio_to_phys(bio) (page_to_phys(bio_page((bio))) + (unsigned long) bio_offset((bio)))
    128 #define bvec_to_phys(bv) (page_to_phys((bv)->bv_page) + (unsigned long) (bv)->bv_offset)
    129 
    130 #define __bio_kmap_atomic(bio, idx, kmtype)   (kmap_atomic(bio_iovec_idx((bio), (idx))->bv_page, kmtype) +   bio_iovec_idx((bio), (idx))->bv_offset)
    131 
    132 #define __bio_kunmap_atomic(addr, kmtype) kunmap_atomic(addr, kmtype)
    133 
    134 #define __BVEC_END(bio) bio_iovec_idx((bio), (bio)->bi_vcnt - 1)
    135 #define __BVEC_START(bio) bio_iovec_idx((bio), (bio)->bi_idx)
    136 
    137 #ifndef BIOVEC_PHYS_MERGEABLE
    138 #define BIOVEC_PHYS_MERGEABLE(vec1, vec2)   ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))
    139 #endif
    140 
    141 #define BIOVEC_VIRT_MERGEABLE(vec1, vec2)   ((((bvec_to_phys((vec1)) + (vec1)->bv_len) | bvec_to_phys((vec2))) & (BIO_VMERGE_BOUNDARY - 1)) == 0)
    142 #define __BIO_SEG_BOUNDARY(addr1, addr2, mask)   (((addr1) | (mask)) == (((addr2) - 1) | (mask)))
    143 #define BIOVEC_SEG_BOUNDARY(q, b1, b2)   __BIO_SEG_BOUNDARY(bvec_to_phys((b1)), bvec_to_phys((b2)) + (b2)->bv_len, (q)->seg_boundary_mask)
    144 #define BIO_SEG_BOUNDARY(q, b1, b2)   BIOVEC_SEG_BOUNDARY((q), __BVEC_END((b1)), __BVEC_START((b2)))
    145 
    146 #define bio_io_error(bio, bytes) bio_endio((bio), (bytes), -EIO)
    147 
    148 #define __bio_for_each_segment(bvl, bio, i, start_idx)   for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx);   i < (bio)->bi_vcnt;   bvl++, i++)
    149 
    150 #define bio_for_each_segment(bvl, bio, i)   __bio_for_each_segment(bvl, bio, i, (bio)->bi_idx)
    151 
    152 #define bio_get(bio) atomic_inc(&(bio)->bi_cnt)
    153 
    154 struct bio_pair {
    155  struct bio bio1, bio2;
    156  struct bio_vec bv1, bv2;
    157  atomic_t cnt;
    158  int error;
    159 };
    160 
    161 struct request_queue;
    162 
    163 struct sg_iovec;
    164 
    165 #define bvec_kmap_irq(bvec, flags) (page_address((bvec)->bv_page) + (bvec)->bv_offset)
    166 #define bvec_kunmap_irq(buf, flags) do { *(flags) = 0; } while (0)
    167 
    168 #define __bio_kunmap_irq(buf, flags) bvec_kunmap_irq(buf, flags)
    169 #define bio_kmap_irq(bio, flags)   __bio_kmap_irq((bio), (bio)->bi_idx, (flags))
    170 #define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags)
    171 #endif
    172