Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 1 | #ifndef _DRBD_WRAPPERS_H |
| 2 | #define _DRBD_WRAPPERS_H |
| 3 | |
| 4 | #include <linux/ctype.h> |
| 5 | #include <linux/mm.h> |
| 6 | |
| 7 | /* see get_sb_bdev and bd_claim */ |
| 8 | extern char *drbd_sec_holder; |
| 9 | |
| 10 | /* sets the number of 512 byte sectors of our virtual device */ |
| 11 | static inline void drbd_set_my_capacity(struct drbd_conf *mdev, |
| 12 | sector_t size) |
| 13 | { |
| 14 | /* set_capacity(mdev->this_bdev->bd_disk, size); */ |
| 15 | set_capacity(mdev->vdisk, size); |
| 16 | mdev->this_bdev->bd_inode->i_size = (loff_t)size << 9; |
| 17 | } |
| 18 | |
| 19 | #define drbd_bio_uptodate(bio) bio_flagged(bio, BIO_UPTODATE) |
| 20 | |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 21 | /* bi_end_io handlers */ |
| 22 | extern void drbd_md_io_complete(struct bio *bio, int error); |
Lars Ellenberg | 45bb912 | 2010-05-14 17:10:48 +0200 | [diff] [blame^] | 23 | extern void drbd_endio_sec(struct bio *bio, int error); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 24 | extern void drbd_endio_pri(struct bio *bio, int error); |
| 25 | |
| 26 | /* |
| 27 | * used to submit our private bio |
| 28 | */ |
| 29 | static inline void drbd_generic_make_request(struct drbd_conf *mdev, |
| 30 | int fault_type, struct bio *bio) |
| 31 | { |
| 32 | __release(local); |
| 33 | if (!bio->bi_bdev) { |
| 34 | printk(KERN_ERR "drbd%d: drbd_generic_make_request: " |
| 35 | "bio->bi_bdev == NULL\n", |
| 36 | mdev_to_minor(mdev)); |
| 37 | dump_stack(); |
| 38 | bio_endio(bio, -ENODEV); |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | if (FAULT_ACTIVE(mdev, fault_type)) |
| 43 | bio_endio(bio, -EIO); |
| 44 | else |
| 45 | generic_make_request(bio); |
| 46 | } |
| 47 | |
| 48 | static inline void drbd_plug_device(struct drbd_conf *mdev) |
| 49 | { |
| 50 | struct request_queue *q; |
| 51 | q = bdev_get_queue(mdev->this_bdev); |
| 52 | |
| 53 | spin_lock_irq(q->queue_lock); |
| 54 | |
| 55 | /* XXX the check on !blk_queue_plugged is redundant, |
| 56 | * implicitly checked in blk_plug_device */ |
| 57 | |
| 58 | if (!blk_queue_plugged(q)) { |
| 59 | blk_plug_device(q); |
| 60 | del_timer(&q->unplug_timer); |
| 61 | /* unplugging should not happen automatically... */ |
| 62 | } |
| 63 | spin_unlock_irq(q->queue_lock); |
| 64 | } |
| 65 | |
| 66 | static inline int drbd_crypto_is_hash(struct crypto_tfm *tfm) |
| 67 | { |
| 68 | return (crypto_tfm_alg_type(tfm) & CRYPTO_ALG_TYPE_HASH_MASK) |
| 69 | == CRYPTO_ALG_TYPE_HASH; |
| 70 | } |
| 71 | |
| 72 | #ifndef __CHECKER__ |
| 73 | # undef __cond_lock |
| 74 | # define __cond_lock(x,c) (c) |
| 75 | #endif |
| 76 | |
| 77 | #endif |