162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2002, 2004, 2005 Oracle.  All rights reserved.
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef OCFS2_AOPS_H
762306a36Sopenharmony_ci#define OCFS2_AOPS_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/fs.h>
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_cihandle_t *ocfs2_start_walk_page_trans(struct inode *inode,
1262306a36Sopenharmony_ci							 struct page *page,
1362306a36Sopenharmony_ci							 unsigned from,
1462306a36Sopenharmony_ci							 unsigned to);
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciint ocfs2_map_page_blocks(struct page *page, u64 *p_blkno,
1762306a36Sopenharmony_ci			  struct inode *inode, unsigned int from,
1862306a36Sopenharmony_ci			  unsigned int to, int new);
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_civoid ocfs2_unlock_and_free_pages(struct page **pages, int num_pages);
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciint walk_page_buffers(	handle_t *handle,
2362306a36Sopenharmony_ci			struct buffer_head *head,
2462306a36Sopenharmony_ci			unsigned from,
2562306a36Sopenharmony_ci			unsigned to,
2662306a36Sopenharmony_ci			int *partial,
2762306a36Sopenharmony_ci			int (*fn)(	handle_t *handle,
2862306a36Sopenharmony_ci					struct buffer_head *bh));
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ciint ocfs2_write_end_nolock(struct address_space *mapping,
3162306a36Sopenharmony_ci			   loff_t pos, unsigned len, unsigned copied, void *fsdata);
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_citypedef enum {
3462306a36Sopenharmony_ci	OCFS2_WRITE_BUFFER = 0,
3562306a36Sopenharmony_ci	OCFS2_WRITE_DIRECT,
3662306a36Sopenharmony_ci	OCFS2_WRITE_MMAP,
3762306a36Sopenharmony_ci} ocfs2_write_type_t;
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciint ocfs2_write_begin_nolock(struct address_space *mapping,
4062306a36Sopenharmony_ci			     loff_t pos, unsigned len, ocfs2_write_type_t type,
4162306a36Sopenharmony_ci			     struct page **pagep, void **fsdata,
4262306a36Sopenharmony_ci			     struct buffer_head *di_bh, struct page *mmap_page);
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ciint ocfs2_read_inline_data(struct inode *inode, struct page *page,
4562306a36Sopenharmony_ci			   struct buffer_head *di_bh);
4662306a36Sopenharmony_ciint ocfs2_size_fits_inline_data(struct buffer_head *di_bh, u64 new_size);
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ciint ocfs2_get_block(struct inode *inode, sector_t iblock,
4962306a36Sopenharmony_ci		    struct buffer_head *bh_result, int create);
5062306a36Sopenharmony_ci/* all ocfs2_dio_end_io()'s fault */
5162306a36Sopenharmony_ci#define ocfs2_iocb_is_rw_locked(iocb) \
5262306a36Sopenharmony_ci	test_bit(0, (unsigned long *)&iocb->private)
5362306a36Sopenharmony_cistatic inline void ocfs2_iocb_set_rw_locked(struct kiocb *iocb, int level)
5462306a36Sopenharmony_ci{
5562306a36Sopenharmony_ci	set_bit(0, (unsigned long *)&iocb->private);
5662306a36Sopenharmony_ci	if (level)
5762306a36Sopenharmony_ci		set_bit(1, (unsigned long *)&iocb->private);
5862306a36Sopenharmony_ci	else
5962306a36Sopenharmony_ci		clear_bit(1, (unsigned long *)&iocb->private);
6062306a36Sopenharmony_ci}
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci/*
6362306a36Sopenharmony_ci * Using a named enum representing lock types in terms of #N bit stored in
6462306a36Sopenharmony_ci * iocb->private, which is going to be used for communication between
6562306a36Sopenharmony_ci * ocfs2_dio_end_io() and ocfs2_file_write/read_iter().
6662306a36Sopenharmony_ci */
6762306a36Sopenharmony_cienum ocfs2_iocb_lock_bits {
6862306a36Sopenharmony_ci	OCFS2_IOCB_RW_LOCK = 0,
6962306a36Sopenharmony_ci	OCFS2_IOCB_RW_LOCK_LEVEL,
7062306a36Sopenharmony_ci	OCFS2_IOCB_NUM_LOCKS
7162306a36Sopenharmony_ci};
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci#define ocfs2_iocb_clear_rw_locked(iocb) \
7462306a36Sopenharmony_ci	clear_bit(OCFS2_IOCB_RW_LOCK, (unsigned long *)&iocb->private)
7562306a36Sopenharmony_ci#define ocfs2_iocb_rw_locked_level(iocb) \
7662306a36Sopenharmony_ci	test_bit(OCFS2_IOCB_RW_LOCK_LEVEL, (unsigned long *)&iocb->private)
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#endif /* OCFS2_FILE_H */
79