Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * ocfs2_buffer_head.h
0004  *
0005  * Buffer cache handling functions defined
0006  *
0007  * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
0008  */
0009 
0010 #ifndef OCFS2_BUFFER_HEAD_IO_H
0011 #define OCFS2_BUFFER_HEAD_IO_H
0012 
0013 #include <linux/buffer_head.h>
0014 
0015 int ocfs2_write_block(struct ocfs2_super          *osb,
0016               struct buffer_head  *bh,
0017               struct ocfs2_caching_info   *ci);
0018 int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
0019                unsigned int nr, struct buffer_head *bhs[]);
0020 
0021 /*
0022  * If not NULL, validate() will be called on a buffer that is freshly
0023  * read from disk.  It will not be called if the buffer was in cache.
0024  * Note that if validate() is being used for this buffer, it needs to
0025  * be set even for a READAHEAD call, as it marks the buffer for later
0026  * validation.
0027  */
0028 int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
0029               struct buffer_head *bhs[], int flags,
0030               int (*validate)(struct super_block *sb,
0031                       struct buffer_head *bh));
0032 
0033 int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
0034                 struct buffer_head *bh);
0035 
0036 #define OCFS2_BH_IGNORE_CACHE      1
0037 #define OCFS2_BH_READAHEAD         8
0038 
0039 static inline int ocfs2_read_block(struct ocfs2_caching_info *ci, u64 off,
0040                    struct buffer_head **bh,
0041                    int (*validate)(struct super_block *sb,
0042                            struct buffer_head *bh))
0043 {
0044     int status = 0;
0045 
0046     if (bh == NULL) {
0047         printk("ocfs2: bh == NULL\n");
0048         status = -EINVAL;
0049         goto bail;
0050     }
0051 
0052     status = ocfs2_read_blocks(ci, off, 1, bh, 0, validate);
0053 
0054 bail:
0055     return status;
0056 }
0057 
0058 #endif /* OCFS2_BUFFER_HEAD_IO_H */