xref: /openbmc/linux/fs/ocfs2/aops.h (revision ecc23d0a422a3118fcf6e4f0a46e17a6c2047b02)
1328970deSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2fa60ce2cSMasahiro Yamada /*
3ccd979bdSMark Fasheh  * Copyright (C) 2002, 2004, 2005 Oracle.  All rights reserved.
4ccd979bdSMark Fasheh  */
5ccd979bdSMark Fasheh 
6ccd979bdSMark Fasheh #ifndef OCFS2_AOPS_H
7ccd979bdSMark Fasheh #define OCFS2_AOPS_H
8ccd979bdSMark Fasheh 
9e2e40f2cSChristoph Hellwig #include <linux/fs.h>
10a27bb332SKent Overstreet 
111fabe148SMark Fasheh handle_t *ocfs2_start_walk_page_trans(struct inode *inode,
12ccd979bdSMark Fasheh 							 struct page *page,
13ccd979bdSMark Fasheh 							 unsigned from,
14ccd979bdSMark Fasheh 							 unsigned to);
15ccd979bdSMark Fasheh 
1660b11392SMark Fasheh int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno,
1760b11392SMark Fasheh 			  struct inode *inode, unsigned int from,
1860b11392SMark Fasheh 			  unsigned int to, int new);
1960b11392SMark Fasheh 
201d410a6eSMark Fasheh void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages);
211d410a6eSMark Fasheh 
2260b11392SMark Fasheh int walk_page_buffers(	handle_t *handle,
2360b11392SMark Fasheh 			struct buffer_head *head,
2460b11392SMark Fasheh 			unsigned from,
2560b11392SMark Fasheh 			unsigned to,
2660b11392SMark Fasheh 			int *partial,
2760b11392SMark Fasheh 			int (*fn)(	handle_t *handle,
2860b11392SMark Fasheh 					struct buffer_head *bh));
2960b11392SMark Fasheh 
307307de80SMark Fasheh int ocfs2_write_end_nolock(struct address_space *mapping,
3107f38d97Spiaojun 			   loff_t pos, unsigned len, unsigned copied, void *fsdata);
327307de80SMark Fasheh 
33c1ad1e3cSRyan Ding typedef enum {
34c1ad1e3cSRyan Ding 	OCFS2_WRITE_BUFFER = 0,
35c1ad1e3cSRyan Ding 	OCFS2_WRITE_DIRECT,
36c1ad1e3cSRyan Ding 	OCFS2_WRITE_MMAP,
37c1ad1e3cSRyan Ding } ocfs2_write_type_t;
38c1ad1e3cSRyan Ding 
39c1ad1e3cSRyan Ding int ocfs2_write_begin_nolock(struct address_space *mapping,
40c1ad1e3cSRyan Ding 			     loff_t pos, unsigned len, ocfs2_write_type_t type,
417307de80SMark Fasheh 			     struct page **pagep, void **fsdata,
427307de80SMark Fasheh 			     struct buffer_head *di_bh, struct page *mmap_page);
437307de80SMark Fasheh 
441afc32b9SMark Fasheh int ocfs2_read_inline_data(struct inode *inode, struct page *page,
451afc32b9SMark Fasheh 			   struct buffer_head *di_bh);
461afc32b9SMark Fasheh int ocfs2_size_fits_inline_data(struct buffer_head *di_bh, u64 new_size);
471afc32b9SMark Fasheh 
486f70fa51STao Ma int ocfs2_get_block(struct inode *inode, sector_t iblock,
496f70fa51STao Ma 		    struct buffer_head *bh_result, int create);
50ccd979bdSMark Fasheh /* all ocfs2_dio_end_io()'s fault */
51ccd979bdSMark Fasheh #define ocfs2_iocb_is_rw_locked(iocb) \
52ccd979bdSMark Fasheh 	test_bit(0, (unsigned long *)&iocb->private)
ocfs2_iocb_set_rw_locked(struct kiocb * iocb,int level)537cdfc3a1SMark Fasheh static inline void ocfs2_iocb_set_rw_locked(struct kiocb *iocb, int level)
547cdfc3a1SMark Fasheh {
557cdfc3a1SMark Fasheh 	set_bit(0, (unsigned long *)&iocb->private);
567cdfc3a1SMark Fasheh 	if (level)
577cdfc3a1SMark Fasheh 		set_bit(1, (unsigned long *)&iocb->private);
587cdfc3a1SMark Fasheh 	else
597cdfc3a1SMark Fasheh 		clear_bit(1, (unsigned long *)&iocb->private);
607cdfc3a1SMark Fasheh }
6139c99f12STristan Ye 
6239c99f12STristan Ye /*
6339c99f12STristan Ye  * Using a named enum representing lock types in terms of #N bit stored in
6425985edcSLucas De Marchi  * iocb->private, which is going to be used for communication between
651202d4baSJia Guo  * ocfs2_dio_end_io() and ocfs2_file_write/read_iter().
6639c99f12STristan Ye  */
6739c99f12STristan Ye enum ocfs2_iocb_lock_bits {
6839c99f12STristan Ye 	OCFS2_IOCB_RW_LOCK = 0,
6939c99f12STristan Ye 	OCFS2_IOCB_RW_LOCK_LEVEL,
7039c99f12STristan Ye 	OCFS2_IOCB_NUM_LOCKS
7139c99f12STristan Ye };
7239c99f12STristan Ye 
73*8e0de82eSDmitry Antipov #define ocfs2_iocb_init_rw_locked(iocb) \
74*8e0de82eSDmitry Antipov 	(iocb->private = NULL)
75ccd979bdSMark Fasheh #define ocfs2_iocb_clear_rw_locked(iocb) \
7639c99f12STristan Ye 	clear_bit(OCFS2_IOCB_RW_LOCK, (unsigned long *)&iocb->private)
777cdfc3a1SMark Fasheh #define ocfs2_iocb_rw_locked_level(iocb) \
7839c99f12STristan Ye 	test_bit(OCFS2_IOCB_RW_LOCK_LEVEL, (unsigned long *)&iocb->private)
79a11f7e63SMark Fasheh 
80ccd979bdSMark Fasheh #endif /* OCFS2_FILE_H */
81