Skip to content

Commit 3590c4d

Browse files
Christoph Hellwigdjwong
authored andcommitted
iomap: ignore non-shared or non-data blocks in xfs_file_dirty
xfs_file_dirty is used to unshare reflink blocks. Rename the function to xfs_file_unshare to better document that purpose, and skip iomaps that are not shared and don't need zeroing. This will allow to simplify the caller. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent dcd6158 commit 3590c4d

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

fs/iomap/buffered-io.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -887,12 +887,19 @@ __iomap_read_page(struct inode *inode, loff_t offset)
887887
}
888888

889889
static loff_t
890-
iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
890+
iomap_unshare_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
891891
struct iomap *iomap)
892892
{
893893
long status = 0;
894894
ssize_t written = 0;
895895

896+
/* don't bother with blocks that are not shared to start with */
897+
if (!(iomap->flags & IOMAP_F_SHARED))
898+
return length;
899+
/* don't bother with holes or unwritten extents */
900+
if (iomap->type == IOMAP_HOLE || iomap->type == IOMAP_UNWRITTEN)
901+
return length;
902+
896903
do {
897904
struct page *page, *rpage;
898905
unsigned long offset; /* Offset into pagecache page */
@@ -932,14 +939,14 @@ iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
932939
}
933940

934941
int
935-
iomap_file_dirty(struct inode *inode, loff_t pos, loff_t len,
942+
iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len,
936943
const struct iomap_ops *ops)
937944
{
938945
loff_t ret;
939946

940947
while (len) {
941948
ret = iomap_apply(inode, pos, len, IOMAP_WRITE, ops, NULL,
942-
iomap_dirty_actor);
949+
iomap_unshare_actor);
943950
if (ret <= 0)
944951
return ret;
945952
pos += ret;
@@ -948,7 +955,7 @@ iomap_file_dirty(struct inode *inode, loff_t pos, loff_t len,
948955

949956
return 0;
950957
}
951-
EXPORT_SYMBOL_GPL(iomap_file_dirty);
958+
EXPORT_SYMBOL_GPL(iomap_file_unshare);
952959

953960
static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset,
954961
unsigned bytes, struct iomap *iomap)

fs/xfs/xfs_reflink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ xfs_reflink_dirty_extents(
14421442
flen = XFS_FSB_TO_B(mp, rlen);
14431443
if (fpos + flen > isize)
14441444
flen = isize - fpos;
1445-
error = iomap_file_dirty(VFS_I(ip), fpos, flen,
1445+
error = iomap_file_unshare(VFS_I(ip), fpos, flen,
14461446
&xfs_iomap_ops);
14471447
xfs_ilock(ip, XFS_ILOCK_EXCL);
14481448
if (error)

include/linux/iomap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ int iomap_migrate_page(struct address_space *mapping, struct page *newpage,
168168
#else
169169
#define iomap_migrate_page NULL
170170
#endif
171-
int iomap_file_dirty(struct inode *inode, loff_t pos, loff_t len,
171+
int iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len,
172172
const struct iomap_ops *ops);
173173
int iomap_zero_range(struct inode *inode, loff_t pos, loff_t len,
174174
bool *did_zero, const struct iomap_ops *ops);

0 commit comments

Comments
 (0)