Skip to content

Commit 6db3885

Browse files
Christoph Hellwigbrauner
authored andcommitted
iomap: turn iomap_want_unshare_iter into an inline function
iomap_want_unshare_iter currently sits in fs/iomap/buffered-io.c, which depends on CONFIG_BLOCK. It is also in used in fs/dax.c whіch has no such dependency. Given that it is a trivial check turn it into an inline in include/linux/iomap.h to fix the DAX && !BLOCK build. Fixes: 6ef6a0e ("iomap: share iomap_unshare_iter predicate code with fsdax") Reported-by: kernel test robot <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Brian Foster <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent dad1b6c commit 6db3885

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

fs/iomap/buffered-io.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,23 +1309,6 @@ void iomap_file_buffered_write_punch_delalloc(struct inode *inode,
13091309
}
13101310
EXPORT_SYMBOL_GPL(iomap_file_buffered_write_punch_delalloc);
13111311

1312-
bool iomap_want_unshare_iter(const struct iomap_iter *iter)
1313-
{
1314-
/*
1315-
* Don't bother with blocks that are not shared to start with; or
1316-
* mappings that cannot be shared, such as inline data, delalloc
1317-
* reservations, holes or unwritten extents.
1318-
*
1319-
* Note that we use srcmap directly instead of iomap_iter_srcmap as
1320-
* unsharing requires providing a separate source map, and the presence
1321-
* of one is a good indicator that unsharing is needed, unlike
1322-
* IOMAP_F_SHARED which can be set for any data that goes into the COW
1323-
* fork for XFS.
1324-
*/
1325-
return (iter->iomap.flags & IOMAP_F_SHARED) &&
1326-
iter->srcmap.type == IOMAP_MAPPED;
1327-
}
1328-
13291312
static loff_t iomap_unshare_iter(struct iomap_iter *iter)
13301313
{
13311314
struct iomap *iomap = &iter->iomap;

include/linux/iomap.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,25 @@ static inline const struct iomap *iomap_iter_srcmap(const struct iomap_iter *i)
256256
return &i->iomap;
257257
}
258258

259+
/*
260+
* Check if the range needs to be unshared for a FALLOC_FL_UNSHARE_RANGE
261+
* operation.
262+
*
263+
* Don't bother with blocks that are not shared to start with; or mappings that
264+
* cannot be shared, such as inline data, delalloc reservations, holes or
265+
* unwritten extents.
266+
*
267+
* Note that we use srcmap directly instead of iomap_iter_srcmap as unsharing
268+
* requires providing a separate source map, and the presence of one is a good
269+
* indicator that unsharing is needed, unlike IOMAP_F_SHARED which can be set
270+
* for any data that goes into the COW fork for XFS.
271+
*/
272+
static inline bool iomap_want_unshare_iter(const struct iomap_iter *iter)
273+
{
274+
return (iter->iomap.flags & IOMAP_F_SHARED) &&
275+
iter->srcmap.type == IOMAP_MAPPED;
276+
}
277+
259278
ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from,
260279
const struct iomap_ops *ops, void *private);
261280
int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops);
@@ -267,7 +286,6 @@ void iomap_invalidate_folio(struct folio *folio, size_t offset, size_t len);
267286
bool iomap_dirty_folio(struct address_space *mapping, struct folio *folio);
268287
int iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len,
269288
const struct iomap_ops *ops);
270-
bool iomap_want_unshare_iter(const struct iomap_iter *iter);
271289
int iomap_zero_range(struct inode *inode, loff_t pos, loff_t len,
272290
bool *did_zero, const struct iomap_ops *ops);
273291
int iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero,

0 commit comments

Comments
 (0)