buffer_head_io.h 1.6 KB

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