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
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, · 33 unmodified lines
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, · 2 unmodified lines
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+1−1
@@ -1442,7 +1442,7 @@ xfs_reflink_dirty_extents( · 1441 unmodified lines
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+1−1
@@ -168,7 +168,7 @@ int iomap_migrate_page(struct address_space *mapping, struct page *newpage, · 167 unmodified lines
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);

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