blob: c6170548831bec4da8b7cea7a1847e60dcdc7e82 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001// 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
11struct xfs_inode;
12struct xfs_bmbt_irec;
13
14int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t,
15 struct xfs_bmbt_irec *, int);
16int xfs_iomap_write_allocate(struct xfs_inode *, int, xfs_off_t,
17 struct xfs_bmbt_irec *, unsigned int *);
18int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t, bool);
19
20void xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *,
21 struct xfs_bmbt_irec *);
22xfs_extlen_t xfs_eof_alignment(struct xfs_inode *ip, xfs_extlen_t extsize);
23
24static inline xfs_filblks_t
25xfs_aligned_fsb_count(
26 xfs_fileoff_t offset_fsb,
27 xfs_filblks_t count_fsb,
28 xfs_extlen_t extsz)
29{
30 if (extsz) {
31 xfs_extlen_t align;
32
33 div_u64_rem(offset_fsb, extsz, &align);
34 if (align)
35 count_fsb += align;
36 div_u64_rem(count_fsb, extsz, &align);
37 if (align)
38 count_fsb += extsz - align;
39 }
40
41 return count_fsb;
42}
43
44extern const struct iomap_ops xfs_iomap_ops;
45extern const struct iomap_ops xfs_xattr_iomap_ops;
46
47#endif /* __XFS_IOMAP_H__*/