msgpool.h 848 B

123456789101112131415161718192021222324252627
  1. #ifndef _FS_CEPH_MSGPOOL
  2. #define _FS_CEPH_MSGPOOL
  3. #include "messenger.h"
  4. /*
  5. * we use memory pools for preallocating messages we may receive, to
  6. * avoid unexpected OOM conditions.
  7. */
  8. struct ceph_msgpool {
  9. spinlock_t lock;
  10. int front_len; /* preallocated payload size */
  11. struct list_head msgs; /* msgs in the pool; each has 1 ref */
  12. int num, min; /* cur, min # msgs in the pool */
  13. bool blocking;
  14. wait_queue_head_t wait;
  15. };
  16. extern int ceph_msgpool_init(struct ceph_msgpool *pool,
  17. int front_len, int size, bool blocking);
  18. extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);
  19. extern int ceph_msgpool_resv(struct ceph_msgpool *, int delta);
  20. extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *,
  21. int front_len);
  22. extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *);
  23. #endif