Skip to content

Commit 492f537

Browse files
Christoph Hellwigbrauner
authored andcommitted
iomap: pass the iomap to the punch callback
XFS will need to look at the flags in the iomap structure, so pass it down all the way to the callback. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20240910043949.3481298-5-hch@lst.de Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 11596dc commit 492f537

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

fs/iomap/buffered-io.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ EXPORT_SYMBOL_GPL(iomap_file_buffered_write);
10481048

10491049
static int iomap_write_delalloc_ifs_punch(struct inode *inode,
10501050
struct folio *folio, loff_t start_byte, loff_t end_byte,
1051-
iomap_punch_t punch)
1051+
struct iomap *iomap, iomap_punch_t punch)
10521052
{
10531053
unsigned int first_blk, last_blk, i;
10541054
loff_t last_byte;
@@ -1073,7 +1073,7 @@ static int iomap_write_delalloc_ifs_punch(struct inode *inode,
10731073
for (i = first_blk; i <= last_blk; i++) {
10741074
if (!ifs_block_is_dirty(folio, ifs, i)) {
10751075
ret = punch(inode, folio_pos(folio) + (i << blkbits),
1076-
1 << blkbits);
1076+
1 << blkbits, iomap);
10771077
if (ret)
10781078
return ret;
10791079
}
@@ -1085,7 +1085,7 @@ static int iomap_write_delalloc_ifs_punch(struct inode *inode,
10851085

10861086
static int iomap_write_delalloc_punch(struct inode *inode, struct folio *folio,
10871087
loff_t *punch_start_byte, loff_t start_byte, loff_t end_byte,
1088-
iomap_punch_t punch)
1088+
struct iomap *iomap, iomap_punch_t punch)
10891089
{
10901090
int ret = 0;
10911091

@@ -1095,14 +1095,14 @@ static int iomap_write_delalloc_punch(struct inode *inode, struct folio *folio,
10951095
/* if dirty, punch up to offset */
10961096
if (start_byte > *punch_start_byte) {
10971097
ret = punch(inode, *punch_start_byte,
1098-
start_byte - *punch_start_byte);
1098+
start_byte - *punch_start_byte, iomap);
10991099
if (ret)
11001100
return ret;
11011101
}
11021102

11031103
/* Punch non-dirty blocks within folio */
1104-
ret = iomap_write_delalloc_ifs_punch(inode, folio, start_byte,
1105-
end_byte, punch);
1104+
ret = iomap_write_delalloc_ifs_punch(inode, folio, start_byte, end_byte,
1105+
iomap, punch);
11061106
if (ret)
11071107
return ret;
11081108

@@ -1135,7 +1135,7 @@ static int iomap_write_delalloc_punch(struct inode *inode, struct folio *folio,
11351135
*/
11361136
static int iomap_write_delalloc_scan(struct inode *inode,
11371137
loff_t *punch_start_byte, loff_t start_byte, loff_t end_byte,
1138-
iomap_punch_t punch)
1138+
struct iomap *iomap, iomap_punch_t punch)
11391139
{
11401140
while (start_byte < end_byte) {
11411141
struct folio *folio;
@@ -1151,7 +1151,7 @@ static int iomap_write_delalloc_scan(struct inode *inode,
11511151
}
11521152

11531153
ret = iomap_write_delalloc_punch(inode, folio, punch_start_byte,
1154-
start_byte, end_byte, punch);
1154+
start_byte, end_byte, iomap, punch);
11551155
if (ret) {
11561156
folio_unlock(folio);
11571157
folio_put(folio);
@@ -1200,7 +1200,8 @@ static int iomap_write_delalloc_scan(struct inode *inode,
12001200
* the code to subtle off-by-one bugs....
12011201
*/
12021202
static int iomap_write_delalloc_release(struct inode *inode, loff_t start_byte,
1203-
loff_t end_byte, unsigned flags, iomap_punch_t punch)
1203+
loff_t end_byte, unsigned flags, struct iomap *iomap,
1204+
iomap_punch_t punch)
12041205
{
12051206
loff_t punch_start_byte = start_byte;
12061207
loff_t scan_end_byte = min(i_size_read(inode), end_byte);
@@ -1253,7 +1254,7 @@ static int iomap_write_delalloc_release(struct inode *inode, loff_t start_byte,
12531254
WARN_ON_ONCE(data_end > scan_end_byte);
12541255

12551256
error = iomap_write_delalloc_scan(inode, &punch_start_byte,
1256-
start_byte, data_end, punch);
1257+
start_byte, data_end, iomap, punch);
12571258
if (error)
12581259
goto out_unlock;
12591260

@@ -1263,7 +1264,7 @@ static int iomap_write_delalloc_release(struct inode *inode, loff_t start_byte,
12631264

12641265
if (punch_start_byte < end_byte)
12651266
error = punch(inode, punch_start_byte,
1266-
end_byte - punch_start_byte);
1267+
end_byte - punch_start_byte, iomap);
12671268
out_unlock:
12681269
filemap_invalidate_unlock(inode->i_mapping);
12691270
return error;
@@ -1330,7 +1331,7 @@ int iomap_file_buffered_write_punch_delalloc(struct inode *inode,
13301331
return 0;
13311332

13321333
return iomap_write_delalloc_release(inode, start_byte, end_byte, flags,
1333-
punch);
1334+
iomap, punch);
13341335
}
13351336
EXPORT_SYMBOL_GPL(iomap_file_buffered_write_punch_delalloc);
13361337

fs/xfs/xfs_iomap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,8 @@ static int
12121212
xfs_buffered_write_delalloc_punch(
12131213
struct inode *inode,
12141214
loff_t offset,
1215-
loff_t length)
1215+
loff_t length,
1216+
struct iomap *iomap)
12161217
{
12171218
xfs_bmap_punch_delalloc_range(XFS_I(inode), offset, offset + length);
12181219
return 0;

include/linux/iomap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ int iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero,
274274
vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf,
275275
const struct iomap_ops *ops);
276276

277-
typedef int (*iomap_punch_t)(struct inode *inode, loff_t offset, loff_t length);
277+
typedef int (*iomap_punch_t)(struct inode *inode, loff_t offset, loff_t length,
278+
struct iomap *iomap);
278279
int iomap_file_buffered_write_punch_delalloc(struct inode *inode, loff_t pos,
279280
loff_t length, ssize_t written, unsigned flag,
280281
struct iomap *iomap, iomap_punch_t punch);

0 commit comments

Comments
 (0)