blob: 71d0ae460c44021a791537800331f3b4751ec166 [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);
Eryu Guanee70daa2017-09-21 11:26:18 -070016int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t, bool);
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Christoph Hellwig16be1432019-02-18 09:38:46 -080018int xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *,
Christoph Hellwig2492a602019-10-17 13:12:02 -070019 struct xfs_bmbt_irec *, u16);
Darrick J. Wongf7ca3522016-10-03 09:11:43 -070020xfs_extlen_t xfs_eof_alignment(struct xfs_inode *ip, xfs_extlen_t extsize);
Christoph Hellwig3b3dce02016-06-21 09:52:47 +100021
Christoph Hellwigf13eb202017-02-06 10:42:26 -080022static inline xfs_filblks_t
23xfs_aligned_fsb_count(
24 xfs_fileoff_t offset_fsb,
25 xfs_filblks_t count_fsb,
26 xfs_extlen_t extsz)
27{
28 if (extsz) {
29 xfs_extlen_t align;
30
Dave Chinner0703a8e2018-06-08 09:54:22 -070031 div_u64_rem(offset_fsb, extsz, &align);
Christoph Hellwigf13eb202017-02-06 10:42:26 -080032 if (align)
33 count_fsb += align;
Dave Chinner0703a8e2018-06-08 09:54:22 -070034 div_u64_rem(count_fsb, extsz, &align);
Christoph Hellwigf13eb202017-02-06 10:42:26 -080035 if (align)
36 count_fsb += extsz - align;
37 }
38
39 return count_fsb;
40}
41
Christoph Hellwig8ff6daa2017-01-27 23:20:26 -080042extern const struct iomap_ops xfs_iomap_ops;
Christoph Hellwig60271ab72019-02-18 09:38:46 -080043extern const struct iomap_ops xfs_seek_iomap_ops;
Christoph Hellwig8ff6daa2017-01-27 23:20:26 -080044extern const struct iomap_ops xfs_xattr_iomap_ops;
Christoph Hellwig68a9f5e2016-06-21 09:53:44 +100045
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#endif /* __XFS_IOMAP_H__*/