xref: /openbmc/linux/fs/xfs/xfs_iomap.h (revision 304a68b9)
10b61f8a4SDave Chinner // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
37b718769SNathan Scott  * Copyright (c) 2003-2005 Silicon Graphics, Inc.
47b718769SNathan Scott  * All Rights Reserved.
51da177e4SLinus Torvalds  */
61da177e4SLinus Torvalds #ifndef __XFS_IOMAP_H__
71da177e4SLinus Torvalds #define __XFS_IOMAP_H__
81da177e4SLinus Torvalds 
968a9f5e7SChristoph Hellwig #include <linux/iomap.h>
1068a9f5e7SChristoph Hellwig 
111da177e4SLinus Torvalds struct xfs_inode;
121da177e4SLinus Torvalds struct xfs_bmbt_irec;
131da177e4SLinus Torvalds 
14e696663aSChristoph Hellwig int xfs_iomap_write_direct(struct xfs_inode *ip, xfs_fileoff_t offset_fsb,
15952da063SChristoph Hellwig 		xfs_fileoff_t count_fsb, unsigned int flags,
16*304a68b9SDave Chinner 		struct xfs_bmbt_irec *imap, u64 *sequence);
17ee70daabSEryu Guan int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t, bool);
18e696663aSChristoph Hellwig xfs_fileoff_t xfs_iomap_eof_align_last_fsb(struct xfs_inode *ip,
19e696663aSChristoph Hellwig 		xfs_fileoff_t end_fsb);
201da177e4SLinus Torvalds 
21*304a68b9SDave Chinner u64 xfs_iomap_inode_sequence(struct xfs_inode *ip, u16 iomap_flags);
22740fd671SChristoph Hellwig int xfs_bmbt_to_iomap(struct xfs_inode *ip, struct iomap *iomap,
23740fd671SChristoph Hellwig 		struct xfs_bmbt_irec *imap, unsigned int mapping_flags,
24*304a68b9SDave Chinner 		u16 iomap_flags, u64 sequence_cookie);
253b3dce05SChristoph Hellwig 
26f1ba5fafSShiyang Ruan int xfs_zero_range(struct xfs_inode *ip, loff_t pos, loff_t len,
27f1ba5fafSShiyang Ruan 		bool *did_zero);
28f1ba5fafSShiyang Ruan int xfs_truncate_page(struct xfs_inode *ip, loff_t pos, bool *did_zero);
29f1ba5fafSShiyang Ruan 
30f13eb205SChristoph Hellwig static inline xfs_filblks_t
xfs_aligned_fsb_count(xfs_fileoff_t offset_fsb,xfs_filblks_t count_fsb,xfs_extlen_t extsz)31f13eb205SChristoph Hellwig xfs_aligned_fsb_count(
32f13eb205SChristoph Hellwig 	xfs_fileoff_t		offset_fsb,
33f13eb205SChristoph Hellwig 	xfs_filblks_t		count_fsb,
34f13eb205SChristoph Hellwig 	xfs_extlen_t		extsz)
35f13eb205SChristoph Hellwig {
36f13eb205SChristoph Hellwig 	if (extsz) {
37f13eb205SChristoph Hellwig 		xfs_extlen_t	align;
38f13eb205SChristoph Hellwig 
390703a8e1SDave Chinner 		div_u64_rem(offset_fsb, extsz, &align);
40f13eb205SChristoph Hellwig 		if (align)
41f13eb205SChristoph Hellwig 			count_fsb += align;
420703a8e1SDave Chinner 		div_u64_rem(count_fsb, extsz, &align);
43f13eb205SChristoph Hellwig 		if (align)
44f13eb205SChristoph Hellwig 			count_fsb += extsz - align;
45f13eb205SChristoph Hellwig 	}
46f13eb205SChristoph Hellwig 
47f13eb205SChristoph Hellwig 	return count_fsb;
48f13eb205SChristoph Hellwig }
49f13eb205SChristoph Hellwig 
50f150b423SChristoph Hellwig extern const struct iomap_ops xfs_buffered_write_iomap_ops;
51118e021bSDave Chinner extern const struct iomap_ops xfs_page_mkwrite_iomap_ops;
52f150b423SChristoph Hellwig extern const struct iomap_ops xfs_direct_write_iomap_ops;
53690c2a38SChristoph Hellwig extern const struct iomap_ops xfs_read_iomap_ops;
5460271ab7SChristoph Hellwig extern const struct iomap_ops xfs_seek_iomap_ops;
558ff6daa1SChristoph Hellwig extern const struct iomap_ops xfs_xattr_iomap_ops;
56ea6c49b7SShiyang Ruan extern const struct iomap_ops xfs_dax_write_iomap_ops;
5768a9f5e7SChristoph Hellwig 
581da177e4SLinus Torvalds #endif /* __XFS_IOMAP_H__*/
59