xref: /openbmc/linux/fs/xfs/xfs_iomap.h (revision 20e8ef5c)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2003-2005 Silicon Graphics, Inc.
4  * All Rights Reserved.
5  */
6 #ifndef __XFS_IOMAP_H__
7 #define __XFS_IOMAP_H__
8 
9 #include <linux/iomap.h>
10 
11 struct xfs_inode;
12 struct xfs_bmbt_irec;
13 
14 int xfs_iomap_write_direct(struct xfs_inode *ip, xfs_fileoff_t offset_fsb,
15 		xfs_fileoff_t count_fsb, unsigned int flags,
16 		struct xfs_bmbt_irec *imap);
17 int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t, bool);
18 xfs_fileoff_t xfs_iomap_eof_align_last_fsb(struct xfs_inode *ip,
19 		xfs_fileoff_t end_fsb);
20 
21 int xfs_bmbt_to_iomap(struct xfs_inode *ip, struct iomap *iomap,
22 		struct xfs_bmbt_irec *imap, unsigned int mapping_flags,
23 		u16 iomap_flags);
24 
25 int xfs_zero_range(struct xfs_inode *ip, loff_t pos, loff_t len,
26 		bool *did_zero);
27 int xfs_truncate_page(struct xfs_inode *ip, loff_t pos, bool *did_zero);
28 
29 static inline xfs_filblks_t
30 xfs_aligned_fsb_count(
31 	xfs_fileoff_t		offset_fsb,
32 	xfs_filblks_t		count_fsb,
33 	xfs_extlen_t		extsz)
34 {
35 	if (extsz) {
36 		xfs_extlen_t	align;
37 
38 		div_u64_rem(offset_fsb, extsz, &align);
39 		if (align)
40 			count_fsb += align;
41 		div_u64_rem(count_fsb, extsz, &align);
42 		if (align)
43 			count_fsb += extsz - align;
44 	}
45 
46 	return count_fsb;
47 }
48 
49 extern const struct iomap_ops xfs_buffered_write_iomap_ops;
50 extern const struct iomap_ops xfs_direct_write_iomap_ops;
51 extern const struct iomap_ops xfs_read_iomap_ops;
52 extern const struct iomap_ops xfs_seek_iomap_ops;
53 extern const struct iomap_ops xfs_xattr_iomap_ops;
54 
55 #endif /* __XFS_IOMAP_H__*/
56