1 #ifndef _DRBD_WRAPPERS_H
2 #define _DRBD_WRAPPERS_H
4 #include <linux/ctype.h>
7 /* see get_sb_bdev and bd_claim */
8 extern char *drbd_sec_holder
;
10 /* sets the number of 512 byte sectors of our virtual device */
11 static inline void drbd_set_my_capacity(struct drbd_conf
*mdev
,
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;
19 #define drbd_bio_uptodate(bio) bio_flagged(bio, BIO_UPTODATE)
21 static inline int drbd_bio_has_active_page(struct bio
*bio
)
26 __bio_for_each_segment(bvec
, bio
, i
, 0) {
27 if (page_count(bvec
->bv_page
) > 1)
34 /* bi_end_io handlers */
35 extern void drbd_md_io_complete(struct bio
*bio
, int error
);
36 extern void drbd_endio_read_sec(struct bio
*bio
, int error
);
37 extern void drbd_endio_write_sec(struct bio
*bio
, int error
);
38 extern void drbd_endio_pri(struct bio
*bio
, int error
);
41 * used to submit our private bio
43 static inline void drbd_generic_make_request(struct drbd_conf
*mdev
,
44 int fault_type
, struct bio
*bio
)
48 printk(KERN_ERR
"drbd%d: drbd_generic_make_request: "
49 "bio->bi_bdev == NULL\n",
52 bio_endio(bio
, -ENODEV
);
56 if (FAULT_ACTIVE(mdev
, fault_type
))
59 generic_make_request(bio
);
62 static inline void drbd_plug_device(struct drbd_conf
*mdev
)
64 struct request_queue
*q
;
65 q
= bdev_get_queue(mdev
->this_bdev
);
67 spin_lock_irq(q
->queue_lock
);
69 /* XXX the check on !blk_queue_plugged is redundant,
70 * implicitly checked in blk_plug_device */
72 if (!blk_queue_plugged(q
)) {
74 del_timer(&q
->unplug_timer
);
75 /* unplugging should not happen automatically... */
77 spin_unlock_irq(q
->queue_lock
);
80 static inline int drbd_crypto_is_hash(struct crypto_tfm
*tfm
)
82 return (crypto_tfm_alg_type(tfm
) & CRYPTO_ALG_TYPE_HASH_MASK
)
83 == CRYPTO_ALG_TYPE_HASH
;
88 # define __cond_lock(x,c) (c)