1328970deSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2*fa60ce2cSMasahiro Yamada /*
3ccd979bdSMark Fasheh * ocfs2_buffer_head.h
4ccd979bdSMark Fasheh *
5ccd979bdSMark Fasheh * Buffer cache handling functions defined
6ccd979bdSMark Fasheh *
7ccd979bdSMark Fasheh * Copyright (C) 2002, 2004 Oracle. All rights reserved.
8ccd979bdSMark Fasheh */
9ccd979bdSMark Fasheh
10ccd979bdSMark Fasheh #ifndef OCFS2_BUFFER_HEAD_IO_H
11ccd979bdSMark Fasheh #define OCFS2_BUFFER_HEAD_IO_H
12ccd979bdSMark Fasheh
13ccd979bdSMark Fasheh #include <linux/buffer_head.h>
14ccd979bdSMark Fasheh
15ccd979bdSMark Fasheh int ocfs2_write_block(struct ocfs2_super *osb,
16ccd979bdSMark Fasheh struct buffer_head *bh,
178cb471e8SJoel Becker struct ocfs2_caching_info *ci);
18da1e9098SJoel Becker int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
19da1e9098SJoel Becker unsigned int nr, struct buffer_head *bhs[]);
20ccd979bdSMark Fasheh
21970e4936SJoel Becker /*
22970e4936SJoel Becker * If not NULL, validate() will be called on a buffer that is freshly
23970e4936SJoel Becker * read from disk. It will not be called if the buffer was in cache.
24970e4936SJoel Becker * Note that if validate() is being used for this buffer, it needs to
25970e4936SJoel Becker * be set even for a READAHEAD call, as it marks the buffer for later
26970e4936SJoel Becker * validation.
27970e4936SJoel Becker */
288cb471e8SJoel Becker int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
29970e4936SJoel Becker struct buffer_head *bhs[], int flags,
30970e4936SJoel Becker int (*validate)(struct super_block *sb,
31970e4936SJoel Becker struct buffer_head *bh));
32970e4936SJoel Becker
33d659072fSTao Ma int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
34d659072fSTao Ma struct buffer_head *bh);
35ccd979bdSMark Fasheh
36d4a8c93cSJoel Becker #define OCFS2_BH_IGNORE_CACHE 1
37aa958874SMark Fasheh #define OCFS2_BH_READAHEAD 8
38ccd979bdSMark Fasheh
ocfs2_read_block(struct ocfs2_caching_info * ci,u64 off,struct buffer_head ** bh,int (* validate)(struct super_block * sb,struct buffer_head * bh))398cb471e8SJoel Becker static inline int ocfs2_read_block(struct ocfs2_caching_info *ci, u64 off,
40970e4936SJoel Becker struct buffer_head **bh,
41970e4936SJoel Becker int (*validate)(struct super_block *sb,
42970e4936SJoel Becker struct buffer_head *bh))
43ccd979bdSMark Fasheh {
44ccd979bdSMark Fasheh int status = 0;
45ccd979bdSMark Fasheh
46ccd979bdSMark Fasheh if (bh == NULL) {
47ccd979bdSMark Fasheh printk("ocfs2: bh == NULL\n");
48ccd979bdSMark Fasheh status = -EINVAL;
49ccd979bdSMark Fasheh goto bail;
50ccd979bdSMark Fasheh }
51ccd979bdSMark Fasheh
528cb471e8SJoel Becker status = ocfs2_read_blocks(ci, off, 1, bh, 0, validate);
53ccd979bdSMark Fasheh
54ccd979bdSMark Fasheh bail:
55ccd979bdSMark Fasheh return status;
56ccd979bdSMark Fasheh }
57ccd979bdSMark Fasheh
58ccd979bdSMark Fasheh #endif /* OCFS2_BUFFER_HEAD_IO_H */
59