drbd_wrappers.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef _DRBD_WRAPPERS_H
  2. #define _DRBD_WRAPPERS_H
  3. #include <linux/ctype.h>
  4. #include <linux/mm.h>
  5. /* see get_sb_bdev and bd_claim */
  6. extern char *drbd_sec_holder;
  7. /* sets the number of 512 byte sectors of our virtual device */
  8. static inline void drbd_set_my_capacity(struct drbd_conf *mdev,
  9. sector_t size)
  10. {
  11. /* set_capacity(mdev->this_bdev->bd_disk, size); */
  12. set_capacity(mdev->vdisk, size);
  13. mdev->this_bdev->bd_inode->i_size = (loff_t)size << 9;
  14. }
  15. #define drbd_bio_uptodate(bio) bio_flagged(bio, BIO_UPTODATE)
  16. static inline int drbd_bio_has_active_page(struct bio *bio)
  17. {
  18. struct bio_vec *bvec;
  19. int i;
  20. __bio_for_each_segment(bvec, bio, i, 0) {
  21. if (page_count(bvec->bv_page) > 1)
  22. return 1;
  23. }
  24. return 0;
  25. }
  26. /* bi_end_io handlers */
  27. extern void drbd_md_io_complete(struct bio *bio, int error);
  28. extern void drbd_endio_read_sec(struct bio *bio, int error);
  29. extern void drbd_endio_write_sec(struct bio *bio, int error);
  30. extern void drbd_endio_pri(struct bio *bio, int error);
  31. /*
  32. * used to submit our private bio
  33. */
  34. static inline void drbd_generic_make_request(struct drbd_conf *mdev,
  35. int fault_type, struct bio *bio)
  36. {
  37. __release(local);
  38. if (!bio->bi_bdev) {
  39. printk(KERN_ERR "drbd%d: drbd_generic_make_request: "
  40. "bio->bi_bdev == NULL\n",
  41. mdev_to_minor(mdev));
  42. dump_stack();
  43. bio_endio(bio, -ENODEV);
  44. return;
  45. }
  46. if (FAULT_ACTIVE(mdev, fault_type))
  47. bio_endio(bio, -EIO);
  48. else
  49. generic_make_request(bio);
  50. }
  51. static inline void drbd_plug_device(struct drbd_conf *mdev)
  52. {
  53. struct request_queue *q;
  54. q = bdev_get_queue(mdev->this_bdev);
  55. spin_lock_irq(q->queue_lock);
  56. /* XXX the check on !blk_queue_plugged is redundant,
  57. * implicitly checked in blk_plug_device */
  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. static inline int drbd_crypto_is_hash(struct crypto_tfm *tfm)
  66. {
  67. return (crypto_tfm_alg_type(tfm) & CRYPTO_ALG_TYPE_HASH_MASK)
  68. == CRYPTO_ALG_TYPE_HASH;
  69. }
  70. #ifndef __CHECKER__
  71. # undef __cond_lock
  72. # define __cond_lock(x,c) (c)
  73. #endif
  74. #endif