18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* -*- mode: c; c-basic-offset: 8; -*- 38c2ecf20Sopenharmony_ci * vim: noexpandtab sw=8 ts=8 sts=0: 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * ocfs2_buffer_head.h 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Buffer cache handling functions defined 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Copyright (C) 2002, 2004 Oracle. All rights reserved. 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef OCFS2_BUFFER_HEAD_IO_H 138c2ecf20Sopenharmony_ci#define OCFS2_BUFFER_HEAD_IO_H 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <linux/buffer_head.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciint ocfs2_write_block(struct ocfs2_super *osb, 188c2ecf20Sopenharmony_ci struct buffer_head *bh, 198c2ecf20Sopenharmony_ci struct ocfs2_caching_info *ci); 208c2ecf20Sopenharmony_ciint ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block, 218c2ecf20Sopenharmony_ci unsigned int nr, struct buffer_head *bhs[]); 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* 248c2ecf20Sopenharmony_ci * If not NULL, validate() will be called on a buffer that is freshly 258c2ecf20Sopenharmony_ci * read from disk. It will not be called if the buffer was in cache. 268c2ecf20Sopenharmony_ci * Note that if validate() is being used for this buffer, it needs to 278c2ecf20Sopenharmony_ci * be set even for a READAHEAD call, as it marks the buffer for later 288c2ecf20Sopenharmony_ci * validation. 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ciint ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr, 318c2ecf20Sopenharmony_ci struct buffer_head *bhs[], int flags, 328c2ecf20Sopenharmony_ci int (*validate)(struct super_block *sb, 338c2ecf20Sopenharmony_ci struct buffer_head *bh)); 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciint ocfs2_write_super_or_backup(struct ocfs2_super *osb, 368c2ecf20Sopenharmony_ci struct buffer_head *bh); 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define OCFS2_BH_IGNORE_CACHE 1 398c2ecf20Sopenharmony_ci#define OCFS2_BH_READAHEAD 8 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistatic inline int ocfs2_read_block(struct ocfs2_caching_info *ci, u64 off, 428c2ecf20Sopenharmony_ci struct buffer_head **bh, 438c2ecf20Sopenharmony_ci int (*validate)(struct super_block *sb, 448c2ecf20Sopenharmony_ci struct buffer_head *bh)) 458c2ecf20Sopenharmony_ci{ 468c2ecf20Sopenharmony_ci int status = 0; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci if (bh == NULL) { 498c2ecf20Sopenharmony_ci printk("ocfs2: bh == NULL\n"); 508c2ecf20Sopenharmony_ci status = -EINVAL; 518c2ecf20Sopenharmony_ci goto bail; 528c2ecf20Sopenharmony_ci } 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci status = ocfs2_read_blocks(ci, off, 1, bh, 0, validate); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cibail: 578c2ecf20Sopenharmony_ci return status; 588c2ecf20Sopenharmony_ci} 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#endif /* OCFS2_BUFFER_HEAD_IO_H */ 61