rgrp.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. extern void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd);
  21. extern struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk, bool exact);
  22. extern struct gfs2_rgrpd *gfs2_rgrpd_get_first(struct gfs2_sbd *sdp);
  23. extern struct gfs2_rgrpd *gfs2_rgrpd_get_next(struct gfs2_rgrpd *rgd);
  24. extern void gfs2_clear_rgrpd(struct gfs2_sbd *sdp);
  25. extern int gfs2_rindex_update(struct gfs2_sbd *sdp);
  26. extern void gfs2_free_clones(struct gfs2_rgrpd *rgd);
  27. extern int gfs2_rgrp_go_instantiate(struct gfs2_glock *gl);
  28. extern void gfs2_rgrp_brelse(struct gfs2_rgrpd *rgd);
  29. extern struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip);
  30. #define GFS2_AF_ORLOV 1
  31. extern int gfs2_inplace_reserve(struct gfs2_inode *ip,
  32. struct gfs2_alloc_parms *ap);
  33. extern void gfs2_inplace_release(struct gfs2_inode *ip);
  34. extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n,
  35. bool dinode, u64 *generation);
  36. extern void gfs2_rs_deltree(struct gfs2_blkreserv *rs);
  37. extern void gfs2_rs_delete(struct gfs2_inode *ip);
  38. extern void __gfs2_free_blocks(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
  39. u64 bstart, u32 blen, int meta);
  40. extern void gfs2_free_meta(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
  41. u64 bstart, u32 blen);
  42. extern void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip);
  43. extern void gfs2_unlink_di(struct inode *inode);
  44. extern 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. extern void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
  53. u64 block);
  54. extern void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist,
  55. unsigned int state, u16 flags);
  56. extern void gfs2_rlist_free(struct gfs2_rgrp_list *rlist);
  57. extern u64 gfs2_ri_total(struct gfs2_sbd *sdp);
  58. extern void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_rgrpd *rgd,
  59. const char *fs_id_buf);
  60. extern int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,
  61. struct buffer_head *bh,
  62. const struct gfs2_bitmap *bi, unsigned minlen, u64 *ptrimmed);
  63. extern int gfs2_fitrim(struct file *filp, void __user *argp);
  64. /* This is how to tell if a reservation is in the rgrp tree: */
  65. static inline bool gfs2_rs_active(const struct gfs2_blkreserv *rs)
  66. {
  67. return !RB_EMPTY_NODE(&rs->rs_node);
  68. }
  69. static inline int rgrp_contains_block(struct gfs2_rgrpd *rgd, u64 block)
  70. {
  71. u64 first = rgd->rd_data0;
  72. u64 last = first + rgd->rd_data;
  73. return first <= block && block < last;
  74. }
  75. extern void check_and_update_goal(struct gfs2_inode *ip);
  76. extern void rgrp_lock_local(struct gfs2_rgrpd *rgd);
  77. extern void rgrp_unlock_local(struct gfs2_rgrpd *rgd);
  78. #endif /* __RGRP_DOT_H__ */