bmap.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  4. * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
  5. */
  6. #ifndef __BMAP_DOT_H__
  7. #define __BMAP_DOT_H__
  8. #include <linux/iomap.h>
  9. #include "inode.h"
  10. struct inode;
  11. struct gfs2_inode;
  12. struct page;
  13. /**
  14. * gfs2_write_calc_reserv - calculate number of blocks needed to write to a file
  15. * @ip: the file
  16. * @len: the number of bytes to be written to the file
  17. * @data_blocks: returns the number of data blocks required
  18. * @ind_blocks: returns the number of indirect blocks required
  19. *
  20. */
  21. static inline void gfs2_write_calc_reserv(const struct gfs2_inode *ip,
  22. unsigned int len,
  23. unsigned int *data_blocks,
  24. unsigned int *ind_blocks)
  25. {
  26. const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
  27. unsigned int tmp;
  28. BUG_ON(gfs2_is_dir(ip));
  29. *data_blocks = (len >> sdp->sd_sb.sb_bsize_shift) + 3;
  30. *ind_blocks = 3 * (sdp->sd_max_height - 1);
  31. for (tmp = *data_blocks; tmp > sdp->sd_diptrs;) {
  32. tmp = DIV_ROUND_UP(tmp, sdp->sd_inptrs);
  33. *ind_blocks += tmp;
  34. }
  35. }
  36. extern const struct iomap_ops gfs2_iomap_ops;
  37. extern const struct iomap_writeback_ops gfs2_writeback_ops;
  38. extern int gfs2_unstuff_dinode(struct gfs2_inode *ip);
  39. extern int gfs2_block_map(struct inode *inode, sector_t lblock,
  40. struct buffer_head *bh, int create);
  41. extern int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
  42. struct iomap *iomap);
  43. extern int gfs2_iomap_alloc(struct inode *inode, loff_t pos, loff_t length,
  44. struct iomap *iomap);
  45. extern int gfs2_get_extent(struct inode *inode, u64 lblock, u64 *dblock,
  46. unsigned int *extlen);
  47. extern int gfs2_alloc_extent(struct inode *inode, u64 lblock, u64 *dblock,
  48. unsigned *extlen, bool *new);
  49. extern int gfs2_setattr_size(struct inode *inode, u64 size);
  50. extern void gfs2_trim_blocks(struct inode *inode);
  51. extern int gfs2_truncatei_resume(struct gfs2_inode *ip);
  52. extern int gfs2_file_dealloc(struct gfs2_inode *ip);
  53. extern int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
  54. unsigned int len);
  55. extern int gfs2_map_journal_extents(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd);
  56. extern void gfs2_free_journal_extents(struct gfs2_jdesc *jd);
  57. extern int __gfs2_punch_hole(struct file *file, loff_t offset, loff_t length);
  58. #endif /* __BMAP_DOT_H__ */