Commit 1dfa17f4ab8543d82caf4d36636b93916a18f456

Authored by Jens Axboe
1 parent 213d9417fe

block: add bio_rw_flagged() for testing bio->bi_rw

The existing functions for checking bio->bi_rw are badly named. So lets
mirror what we do for bio->bi_flags testing, use a properly named
function so that it's immediately obvious what is being tested.

Maintain compatability names for the old macros, eventually we'll get
rid of these.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

Showing 1 changed file with 18 additions and 10 deletions Side-by-side Diff

... ... @@ -173,7 +173,25 @@
173 173  
174 174 #define BIO_RW_SYNC (BIO_RW_SYNCIO | BIO_RW_UNPLUG)
175 175  
  176 +#define bio_rw_flagged(bio, flag) ((bio)->bi_rw & (1 << (flag)))
  177 +
176 178 /*
  179 + * Old defines, these should eventually be replaced by direct usage of
  180 + * bio_rw_flagged()
  181 + */
  182 +#define bio_barrier(bio) bio_rw_flagged(bio, BIO_RW_BARRIER)
  183 +#define bio_sync(bio) bio_rw_flagged(bio, BIO_RW_SYNCIO)
  184 +#define bio_unplug(bio) bio_rw_flagged(bio, BIO_RW_UNPLUG)
  185 +#define bio_failfast_dev(bio) bio_rw_flagged(bio, BIO_RW_FAILFAST_DEV)
  186 +#define bio_failfast_transport(bio) \
  187 + bio_rw_flagged(bio, BIO_RW_FAILFAST_TRANSPORT)
  188 +#define bio_failfast_driver(bio) \
  189 + bio_rw_flagged(bio, BIO_RW_FAILFAST_DRIVER)
  190 +#define bio_rw_ahead(bio) bio_rw_flagged(bio, BIO_RW_AHEAD)
  191 +#define bio_rw_meta(bio) bio_rw_flagged(bio, BIO_RW_META)
  192 +#define bio_discard(bio) bio_rw_flagged(bio, BIO_RW_DISCARD)
  193 +
  194 +/*
177 195 * upper 16 bits of bi_rw define the io priority of this bio
178 196 */
179 197 #define BIO_PRIO_SHIFT (8 * sizeof(unsigned long) - IOPRIO_BITS)
... ... @@ -196,16 +214,6 @@
196 214 #define bio_offset(bio) bio_iovec((bio))->bv_offset
197 215 #define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx)
198 216 #define bio_sectors(bio) ((bio)->bi_size >> 9)
199   -#define bio_barrier(bio) ((bio)->bi_rw & (1 << BIO_RW_BARRIER))
200   -#define bio_sync(bio) ((bio)->bi_rw & (1 << BIO_RW_SYNCIO))
201   -#define bio_unplug(bio) ((bio)->bi_rw & (1 << BIO_RW_UNPLUG))
202   -#define bio_failfast_dev(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST_DEV))
203   -#define bio_failfast_transport(bio) \
204   - ((bio)->bi_rw & (1 << BIO_RW_FAILFAST_TRANSPORT))
205   -#define bio_failfast_driver(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST_DRIVER))
206   -#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD))
207   -#define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META))
208   -#define bio_discard(bio) ((bio)->bi_rw & (1 << BIO_RW_DISCARD))
209 217 #define bio_empty_barrier(bio) (bio_barrier(bio) && !bio_has_data(bio) && !bio_discard(bio))
210 218  
211 219 static inline unsigned int bio_cur_sectors(struct bio *bio)