blob: c6170548831bec4da8b7cea7a1847e60dcdc7e82 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Nathan Scott7b718762005-11-02 14:58:39 +11003 * Copyright (c) 2003-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#ifndef __XFS_IOMAP_H__
7#define __XFS_IOMAP_H__
8
Christoph Hellwig68a9f5e2016-06-21 09:53:44 +10009#include <linux/iomap.h>
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011struct xfs_inode;
12struct xfs_bmbt_irec;
13
Jie Liu0799a3e2013-09-29 18:56:04 +080014int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t,
Christoph Hellwiga206c812010-12-10 08:42:20 +000015 struct xfs_bmbt_irec *, int);
Darrick J. Wong60b49842016-10-03 09:11:34 -070016int xfs_iomap_write_allocate(struct xfs_inode *, int, xfs_off_t,
Christoph Hellwige666aa32018-07-17 16:51:52 -070017 struct xfs_bmbt_irec *, unsigned int *);
Eryu Guanee70daa2017-09-21 11:26:18 -070018int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t, bool);
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Christoph Hellwig3b3dce02016-06-21 09:52:47 +100020void xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *,
21 struct xfs_bmbt_irec *);
Darrick J. Wongf7ca3522016-10-03 09:11:43 -070022xfs_extlen_t xfs_eof_alignment(struct xfs_inode *ip, xfs_extlen_t extsize);
Christoph Hellwig3b3dce02016-06-21 09:52:47 +100023
Christoph Hellwigf13eb202017-02-06 10:42:26 -080024static 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
Dave Chinner0703a8e2018-06-08 09:54:22 -070033 div_u64_rem(offset_fsb, extsz, &align);
Christoph Hellwigf13eb202017-02-06 10:42:26 -080034 if (align)
35 count_fsb += align;
Dave Chinner0703a8e2018-06-08 09:54:22 -070036 div_u64_rem(count_fsb, extsz, &align);
Christoph Hellwigf13eb202017-02-06 10:42:26 -080037 if (align)
38 count_fsb += extsz - align;
39 }
40
41 return count_fsb;
42}
43
Christoph Hellwig8ff6daa2017-01-27 23:20:26 -080044extern const struct iomap_ops xfs_iomap_ops;
45extern const struct iomap_ops xfs_xattr_iomap_ops;
Christoph Hellwig68a9f5e2016-06-21 09:53:44 +100046
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#endif /* __XFS_IOMAP_H__*/