daemon.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  3. * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
  4. *
  5. * This copyrighted material is made available to anyone wishing to use,
  6. * modify, copy, or redistribute it subject to the terms and conditions
  7. * of the GNU General Public License version 2.
  8. */
  9. #include <linux/sched.h>
  10. #include <linux/slab.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/completion.h>
  13. #include <linux/buffer_head.h>
  14. #include <linux/kthread.h>
  15. #include <linux/delay.h>
  16. #include <linux/gfs2_ondisk.h>
  17. #include <linux/lm_interface.h>
  18. #include <linux/freezer.h>
  19. #include "gfs2.h"
  20. #include "incore.h"
  21. #include "daemon.h"
  22. #include "glock.h"
  23. #include "log.h"
  24. #include "recovery.h"
  25. #include "super.h"
  26. #include "util.h"
  27. /* This uses schedule_timeout() instead of msleep() because it's good for
  28. the daemons to wake up more often than the timeout when unmounting so
  29. the user's unmount doesn't sit there forever.
  30. The kthread functions used to start these daemons block and flush signals. */
  31. /**
  32. * gfs2_glockd - Reclaim unused glock structures
  33. * @sdp: Pointer to GFS2 superblock
  34. *
  35. * One or more of these daemons run, reclaiming glocks on sd_reclaim_list.
  36. * Number of daemons can be set by user, with num_glockd mount option.
  37. */
  38. int gfs2_glockd(void *data)
  39. {
  40. struct gfs2_sbd *sdp = data;
  41. while (!kthread_should_stop()) {
  42. while (atomic_read(&sdp->sd_reclaim_count))
  43. gfs2_reclaim_glock(sdp);
  44. wait_event_interruptible(sdp->sd_reclaim_wq,
  45. (atomic_read(&sdp->sd_reclaim_count) ||
  46. kthread_should_stop()));
  47. if (freezing(current))
  48. refrigerator();
  49. }
  50. return 0;
  51. }