blob: 7d3703556d0e082271ccfd6b06b915fe11c34425 [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
Christoph Hellwige6966632019-10-30 12:24:59 -070014int xfs_iomap_write_direct(struct xfs_inode *ip, xfs_fileoff_t offset_fsb,
15 xfs_fileoff_t count_fsb, struct xfs_bmbt_irec *imap);
Eryu Guanee70daa2017-09-21 11:26:18 -070016int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t, bool);
Christoph Hellwige6966632019-10-30 12:24:59 -070017xfs_fileoff_t xfs_iomap_eof_align_last_fsb(struct xfs_inode *ip,
18 xfs_fileoff_t end_fsb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Christoph Hellwig16be1432019-02-18 09:38:46 -080020int xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *,
Christoph Hellwig2492a602019-10-17 13:12:02 -070021 struct xfs_bmbt_irec *, u16);
Christoph Hellwig3b3dce02016-06-21 09:52:47 +100022
Christoph Hellwigf13eb202017-02-06 10:42:26 -080023static inline xfs_filblks_t
24xfs_aligned_fsb_count(
25 xfs_fileoff_t offset_fsb,
26 xfs_filblks_t count_fsb,
27 xfs_extlen_t extsz)
28{
29 if (extsz) {
30 xfs_extlen_t align;
31
Dave Chinner0703a8e2018-06-08 09:54:22 -070032 div_u64_rem(offset_fsb, extsz, &align);
Christoph Hellwigf13eb202017-02-06 10:42:26 -080033 if (align)
34 count_fsb += align;
Dave Chinner0703a8e2018-06-08 09:54:22 -070035 div_u64_rem(count_fsb, extsz, &align);
Christoph Hellwigf13eb202017-02-06 10:42:26 -080036 if (align)
37 count_fsb += extsz - align;
38 }
39
40 return count_fsb;
41}
42
Christoph Hellwigf150b422019-10-19 09:09:46 -070043extern const struct iomap_ops xfs_buffered_write_iomap_ops;
44extern const struct iomap_ops xfs_direct_write_iomap_ops;
Christoph Hellwig690c2a32019-10-19 09:09:45 -070045extern const struct iomap_ops xfs_read_iomap_ops;
Christoph Hellwig60271ab72019-02-18 09:38:46 -080046extern const struct iomap_ops xfs_seek_iomap_ops;
Christoph Hellwig8ff6daa2017-01-27 23:20:26 -080047extern const struct iomap_ops xfs_xattr_iomap_ops;
Christoph Hellwig68a9f5e2016-06-21 09:53:44 +100048
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#endif /* __XFS_IOMAP_H__*/