buffer_head_io.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * ocfs2_buffer_head.h
  4. *
  5. * Buffer cache handling functions defined
  6. *
  7. * Copyright (C) 2002, 2004 Oracle. All rights reserved.
  8. */
  9. #ifndef OCFS2_BUFFER_HEAD_IO_H
  10. #define OCFS2_BUFFER_HEAD_IO_H
  11. #include <linux/buffer_head.h>
  12. int ocfs2_write_block(struct ocfs2_super *osb,
  13. struct buffer_head *bh,
  14. struct ocfs2_caching_info *ci);
  15. int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
  16. unsigned int nr, struct buffer_head *bhs[]);
  17. /*
  18. * If not NULL, validate() will be called on a buffer that is freshly
  19. * read from disk. It will not be called if the buffer was in cache.
  20. * Note that if validate() is being used for this buffer, it needs to
  21. * be set even for a READAHEAD call, as it marks the buffer for later
  22. * validation.
  23. */
  24. int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
  25. struct buffer_head *bhs[], int flags,
  26. int (*validate)(struct super_block *sb,
  27. struct buffer_head *bh));
  28. int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
  29. struct buffer_head *bh);
  30. #define OCFS2_BH_IGNORE_CACHE 1
  31. #define OCFS2_BH_READAHEAD 8
  32. static inline int ocfs2_read_block(struct ocfs2_caching_info *ci, u64 off,
  33. struct buffer_head **bh,
  34. int (*validate)(struct super_block *sb,
  35. struct buffer_head *bh))
  36. {
  37. int status = 0;
  38. if (bh == NULL) {
  39. printk("ocfs2: bh == NULL\n");
  40. status = -EINVAL;
  41. goto bail;
  42. }
  43. status = ocfs2_read_blocks(ci, off, 1, bh, 0, validate);
  44. bail:
  45. return status;
  46. }
  47. #endif /* OCFS2_BUFFER_HEAD_IO_H */