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