rgrp.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  4. * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
  5. */
  6. #ifndef __RGRP_DOT_H__
  7. #define __RGRP_DOT_H__
  8. #include <linux/slab.h>
  9. #include <linux/uaccess.h>
  10. /* Since each block in the file system is represented by two bits in the
  11. * bitmap, one 64-bit word in the bitmap will represent 32 blocks.
  12. * By reserving 32 blocks at a time, we can optimize / shortcut how we search
  13. * through the bitmaps by looking a word at a time.
  14. */
  15. #define RGRP_RSRV_MINBLKS 32
  16. #define RGRP_RSRV_ADDBLKS 64
  17. struct gfs2_rgrpd;
  18. struct gfs2_sbd;
  19. struct gfs2_holder;
  20. void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd);
  21. struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk, bool exact);
  22. struct gfs2_rgrpd *gfs2_rgrpd_get_first(struct gfs2_sbd *sdp);
  23. struct gfs2_rgrpd *gfs2_rgrpd_get_next(struct gfs2_rgrpd *rgd);
  24. void gfs2_clear_rgrpd(struct gfs2_sbd *sdp);
  25. int gfs2_rindex_update(struct gfs2_sbd *sdp);
  26. void gfs2_free_clones(struct gfs2_rgrpd *rgd);
  27. int gfs2_rgrp_go_instantiate(struct gfs2_glock *gl);
  28. void gfs2_rgrp_brelse(struct gfs2_rgrpd *rgd);
  29. struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip);
  30. #define GFS2_AF_ORLOV 1
  31. int gfs2_inplace_reserve(struct gfs2_inode *ip,
  32. struct gfs2_alloc_parms *ap);
  33. void gfs2_inplace_release(struct gfs2_inode *ip);
  34. int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n,
  35. bool dinode);
  36. void gfs2_rs_deltree(struct gfs2_blkreserv *rs);
  37. void gfs2_rs_delete(struct gfs2_inode *ip);
  38. void __gfs2_free_blocks(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
  39. u64 bstart, u32 blen, int meta);
  40. void gfs2_free_meta(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
  41. u64 bstart, u32 blen);
  42. void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip);
  43. void gfs2_unlink_di(struct inode *inode);
  44. int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr,
  45. unsigned int type);
  46. struct gfs2_rgrp_list {
  47. unsigned int rl_rgrps;
  48. unsigned int rl_space;
  49. struct gfs2_rgrpd **rl_rgd;
  50. struct gfs2_holder *rl_ghs;
  51. };
  52. void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
  53. u64 block);
  54. void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist,
  55. unsigned int state, u16 flags);
  56. void gfs2_rlist_free(struct gfs2_rgrp_list *rlist);
  57. u64 gfs2_ri_total(struct gfs2_sbd *sdp);
  58. void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_rgrpd *rgd,
  59. const char *fs_id_buf);
  60. int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,
  61. struct buffer_head *bh,
  62. const struct gfs2_bitmap *bi, unsigned minlen,
  63. u64 *ptrimmed);
  64. int gfs2_fitrim(struct file *filp, void __user *argp);
  65. /* This is how to tell if a reservation is in the rgrp tree: */
  66. static inline bool gfs2_rs_active(const struct gfs2_blkreserv *rs)
  67. {
  68. return !RB_EMPTY_NODE(&rs->rs_node);
  69. }
  70. static inline int rgrp_contains_block(struct gfs2_rgrpd *rgd, u64 block)
  71. {
  72. u64 first = rgd->rd_data0;
  73. u64 last = first + rgd->rd_data;
  74. return first <= block && block < last;
  75. }
  76. void check_and_update_goal(struct gfs2_inode *ip);
  77. void rgrp_lock_local(struct gfs2_rgrpd *rgd);
  78. void rgrp_unlock_local(struct gfs2_rgrpd *rgd);
  79. #endif /* __RGRP_DOT_H__ */