History

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.

Christoph Hellwig committed 7 years ago

Commit 3590c4d1 parent dcd61583 files · +13 −6Browse files

Unified · Split

3 files
  1. fs/iomap/buffered-io.c +11 −4
  2. fs/xfs/xfs_reflink.c +1 −1
  3. include/linux/iomap.h +1 −1
fs/iomap/buffered-io.c+11−4
@@ -887,12 +887,19 @@ __iomap_read_page(struct inode *inode, loff_t offset) · 886 unmodified lines
887}887}
888 888
889static loff_t889static loff_t
890iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,890iomap_unshare_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
891 struct iomap *iomap)891 struct iomap *iomap)
892{892{
893 long status = 0;893 long status = 0;
894 ssize_t written = 0;894 ssize_t written = 0;
895 895
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
896 do {903 do {
897 struct page *page, *rpage;904 struct page *page, *rpage;
898 unsigned long offset; /* Offset into pagecache page */905 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, · 33 unmodified lines
932}939}
933 940
934int941int
935iomap_file_dirty(struct inode *inode, loff_t pos, loff_t len,942iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len,
936 const struct iomap_ops *ops)943 const struct iomap_ops *ops)
937{944{
938 loff_t ret;945 loff_t ret;
939 946
940 while (len) {947 while (len) {
941 ret = iomap_apply(inode, pos, len, IOMAP_WRITE, ops, NULL,948 ret = iomap_apply(inode, pos, len, IOMAP_WRITE, ops, NULL,
942 iomap_dirty_actor);949 iomap_unshare_actor);
943 if (ret <= 0)950 if (ret <= 0)
944 return ret;951 return ret;
945 pos += ret;952 pos += ret;
@@ -948,7 +955,7 @@ iomap_file_dirty(struct inode *inode, loff_t pos, loff_t len, · 2 unmodified lines
948 955
949 return 0;956 return 0;
950}957}
951EXPORT_SYMBOL_GPL(iomap_file_dirty);958EXPORT_SYMBOL_GPL(iomap_file_unshare);
952 959
953static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset,960static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset,
954 unsigned bytes, struct iomap *iomap)961 unsigned bytes, struct iomap *iomap)
fs/xfs/xfs_reflink.c+1−1
@@ -1442,7 +1442,7 @@ xfs_reflink_dirty_extents( · 1441 unmodified lines
1442 flen = XFS_FSB_TO_B(mp, rlen);1442 flen = XFS_FSB_TO_B(mp, rlen);
1443 if (fpos + flen > isize)1443 if (fpos + flen > isize)
1444 flen = isize - fpos;1444 flen = isize - fpos;
1445 error = iomap_file_dirty(VFS_I(ip), fpos, flen,1445 error = iomap_file_unshare(VFS_I(ip), fpos, flen,
1446 &xfs_iomap_ops);1446 &xfs_iomap_ops);
1447 xfs_ilock(ip, XFS_ILOCK_EXCL);1447 xfs_ilock(ip, XFS_ILOCK_EXCL);
1448 if (error)1448 if (error)
include/linux/iomap.h+1−1
@@ -168,7 +168,7 @@ int iomap_migrate_page(struct address_space *mapping, struct page *newpage, · 167 unmodified lines
168#else168#else
169#define iomap_migrate_page NULL169#define iomap_migrate_page NULL
170#endif170#endif
171int iomap_file_dirty(struct inode *inode, loff_t pos, loff_t len,171int iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len,
172 const struct iomap_ops *ops);172 const struct iomap_ops *ops);
173int iomap_zero_range(struct inode *inode, loff_t pos, loff_t len,173int iomap_zero_range(struct inode *inode, loff_t pos, loff_t len,
174 bool *did_zero, const struct iomap_ops *ops);174 bool *did_zero, const struct iomap_ops *ops);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t