aops.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2002, 2004, 2005 Oracle. All rights reserved.
  4. */
  5. #ifndef OCFS2_AOPS_H
  6. #define OCFS2_AOPS_H
  7. #include <linux/fs.h>
  8. handle_t *ocfs2_start_walk_page_trans(struct inode *inode,
  9. struct page *page,
  10. unsigned from,
  11. unsigned to);
  12. int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno,
  13. struct inode *inode, unsigned int from,
  14. unsigned int to, int new);
  15. void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages);
  16. int walk_page_buffers( handle_t *handle,
  17. struct buffer_head *head,
  18. unsigned from,
  19. unsigned to,
  20. int *partial,
  21. int (*fn)( handle_t *handle,
  22. struct buffer_head *bh));
  23. int ocfs2_write_end_nolock(struct address_space *mapping,
  24. loff_t pos, unsigned len, unsigned copied, void *fsdata);
  25. typedef enum {
  26. OCFS2_WRITE_BUFFER = 0,
  27. OCFS2_WRITE_DIRECT,
  28. OCFS2_WRITE_MMAP,
  29. } ocfs2_write_type_t;
  30. int ocfs2_write_begin_nolock(struct address_space *mapping,
  31. loff_t pos, unsigned len, ocfs2_write_type_t type,
  32. struct folio **foliop, void **fsdata,
  33. struct buffer_head *di_bh, struct page *mmap_page);
  34. int ocfs2_read_inline_data(struct inode *inode, struct page *page,
  35. struct buffer_head *di_bh);
  36. int ocfs2_size_fits_inline_data(struct buffer_head *di_bh, u64 new_size);
  37. int ocfs2_get_block(struct inode *inode, sector_t iblock,
  38. struct buffer_head *bh_result, int create);
  39. /* all ocfs2_dio_end_io()'s fault */
  40. #define ocfs2_iocb_is_rw_locked(iocb) \
  41. test_bit(0, (unsigned long *)&iocb->private)
  42. static inline void ocfs2_iocb_set_rw_locked(struct kiocb *iocb, int level)
  43. {
  44. set_bit(0, (unsigned long *)&iocb->private);
  45. if (level)
  46. set_bit(1, (unsigned long *)&iocb->private);
  47. else
  48. clear_bit(1, (unsigned long *)&iocb->private);
  49. }
  50. /*
  51. * Using a named enum representing lock types in terms of #N bit stored in
  52. * iocb->private, which is going to be used for communication between
  53. * ocfs2_dio_end_io() and ocfs2_file_write/read_iter().
  54. */
  55. enum ocfs2_iocb_lock_bits {
  56. OCFS2_IOCB_RW_LOCK = 0,
  57. OCFS2_IOCB_RW_LOCK_LEVEL,
  58. OCFS2_IOCB_NUM_LOCKS
  59. };
  60. #define ocfs2_iocb_init_rw_locked(iocb) \
  61. (iocb->private = NULL)
  62. #define ocfs2_iocb_clear_rw_locked(iocb) \
  63. clear_bit(OCFS2_IOCB_RW_LOCK, (unsigned long *)&iocb->private)
  64. #define ocfs2_iocb_rw_locked_level(iocb) \
  65. test_bit(OCFS2_IOCB_RW_LOCK_LEVEL, (unsigned long *)&iocb->private)
  66. #endif /* OCFS2_FILE_H */