drbd_wrappers.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /* bi_end_io handlers */
  17. extern void drbd_md_io_complete(struct bio *bio, int error);
  18. extern void drbd_endio_sec(struct bio *bio, int error);
  19. extern void drbd_endio_pri(struct bio *bio, int error);
  20. /*
  21. * used to submit our private bio
  22. */
  23. static inline void drbd_generic_make_request(struct drbd_conf *mdev,
  24. int fault_type, struct bio *bio)
  25. {
  26. __release(local);
  27. if (!bio->bi_bdev) {
  28. printk(KERN_ERR "drbd%d: drbd_generic_make_request: "
  29. "bio->bi_bdev == NULL\n",
  30. mdev_to_minor(mdev));
  31. dump_stack();
  32. bio_endio(bio, -ENODEV);
  33. return;
  34. }
  35. if (FAULT_ACTIVE(mdev, fault_type))
  36. bio_endio(bio, -EIO);
  37. else
  38. generic_make_request(bio);
  39. }
  40. static inline void drbd_plug_device(struct drbd_conf *mdev)
  41. {
  42. struct request_queue *q;
  43. q = bdev_get_queue(mdev->this_bdev);
  44. spin_lock_irq(q->queue_lock);
  45. /* XXX the check on !blk_queue_plugged is redundant,
  46. * implicitly checked in blk_plug_device */
  47. if (!blk_queue_plugged(q)) {
  48. blk_plug_device(q);
  49. del_timer(&q->unplug_timer);
  50. /* unplugging should not happen automatically... */
  51. }
  52. spin_unlock_irq(q->queue_lock);
  53. }
  54. static inline int drbd_crypto_is_hash(struct crypto_tfm *tfm)
  55. {
  56. return (crypto_tfm_alg_type(tfm) & CRYPTO_ALG_TYPE_HASH_MASK)
  57. == CRYPTO_ALG_TYPE_HASH;
  58. }
  59. #ifndef __CHECKER__
  60. # undef __cond_lock
  61. # define __cond_lock(x,c) (c)
  62. #endif
  63. #endif