async-thread.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (C) 2007 Oracle. All rights reserved.
  3. * Copyright (C) 2014 Fujitsu. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public
  7. * License v2 as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public
  15. * License along with this program; if not, write to the
  16. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17. * Boston, MA 021110-1307, USA.
  18. */
  19. #ifndef __BTRFS_ASYNC_THREAD_
  20. #define __BTRFS_ASYNC_THREAD_
  21. struct btrfs_workqueue;
  22. /* Internal use only */
  23. struct __btrfs_workqueue;
  24. struct btrfs_work;
  25. typedef void (*btrfs_func_t)(struct btrfs_work *arg);
  26. struct btrfs_work {
  27. btrfs_func_t func;
  28. btrfs_func_t ordered_func;
  29. btrfs_func_t ordered_free;
  30. /* Don't touch things below */
  31. struct work_struct normal_work;
  32. struct list_head ordered_list;
  33. struct __btrfs_workqueue *wq;
  34. unsigned long flags;
  35. };
  36. struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
  37. int flags,
  38. int max_active,
  39. int thresh);
  40. void btrfs_init_work(struct btrfs_work *work,
  41. btrfs_func_t func,
  42. btrfs_func_t ordered_func,
  43. btrfs_func_t ordered_free);
  44. void btrfs_queue_work(struct btrfs_workqueue *wq,
  45. struct btrfs_work *work);
  46. void btrfs_destroy_workqueue(struct btrfs_workqueue *wq);
  47. void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max);
  48. void btrfs_set_work_high_priority(struct btrfs_work *work);
  49. #endif