blk-iopoll.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef BLK_IOPOLL_H
  2. #define BLK_IOPOLL_H
  3. struct blk_iopoll;
  4. typedef int (blk_iopoll_fn)(struct blk_iopoll *, int);
  5. struct blk_iopoll {
  6. struct list_head list;
  7. unsigned long state;
  8. unsigned long data;
  9. int weight;
  10. int max;
  11. blk_iopoll_fn *poll;
  12. };
  13. enum {
  14. IOPOLL_F_SCHED = 0,
  15. IOPOLL_F_DISABLE = 1,
  16. };
  17. /*
  18. * Returns 0 if we successfully set the IOPOLL_F_SCHED bit, indicating
  19. * that we were the first to acquire this iop for scheduling. If this iop
  20. * is currently disabled, return "failure".
  21. */
  22. static inline int blk_iopoll_sched_prep(struct blk_iopoll *iop)
  23. {
  24. if (!test_bit(IOPOLL_F_DISABLE, &iop->state))
  25. return test_and_set_bit(IOPOLL_F_SCHED, &iop->state);
  26. return 1;
  27. }
  28. static inline int blk_iopoll_disable_pending(struct blk_iopoll *iop)
  29. {
  30. return test_bit(IOPOLL_F_DISABLE, &iop->state);
  31. }
  32. extern void blk_iopoll_sched(struct blk_iopoll *);
  33. extern void blk_iopoll_init(struct blk_iopoll *, int, blk_iopoll_fn *);
  34. extern void blk_iopoll_complete(struct blk_iopoll *);
  35. extern void __blk_iopoll_complete(struct blk_iopoll *);
  36. extern void blk_iopoll_enable(struct blk_iopoll *);
  37. extern void blk_iopoll_disable(struct blk_iopoll *);
  38. #endif