Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Iliopoulos <ailiopoulos@suse.com>2019-03-20 01:02:53 +0100
committerAnthony Iliopoulos <ailiopoulos@suse.com>2019-03-20 01:02:53 +0100
commit125ebab21611ac389f7ae6152ed747f29476c1ae (patch)
tree0b7c8688b187e668e24947e0e9d9a2d069035206
parent05d288553914536e889de886b778b87ae0d9998f (diff)
vfs: Add iomap_seek_hole and iomap_seek_data helpers
(bsc#1070995).
-rw-r--r--patches.fixes/vfs-Add-iomap_seek_hole-and-iomap_seek_data-helpers.patch146
-rw-r--r--series.conf1
2 files changed, 147 insertions, 0 deletions
diff --git a/patches.fixes/vfs-Add-iomap_seek_hole-and-iomap_seek_data-helpers.patch b/patches.fixes/vfs-Add-iomap_seek_hole-and-iomap_seek_data-helpers.patch
new file mode 100644
index 0000000000..9ba253a80a
--- /dev/null
+++ b/patches.fixes/vfs-Add-iomap_seek_hole-and-iomap_seek_data-helpers.patch
@@ -0,0 +1,146 @@
+From 0ed3b0d45fd39142e418220f518c8959c1a5f596 Mon Sep 17 00:00:00 2001
+From: Andreas Gruenbacher <agruenba@redhat.com>
+Date: Thu, 29 Jun 2017 11:43:21 -0700
+Subject: [PATCH] vfs: Add iomap_seek_hole and iomap_seek_data helpers
+Git-commit: 0ed3b0d45fd39142e418220f518c8959c1a5f596
+Patch-mainline: v4.13-rc1
+References: bsc#1070995
+
+Filesystems can use this for implementing lseek SEEK_HOLE / SEEK_DATA
+support via iomap.
+
+Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
+[hch: split functions, coding style cleanups]
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/iomap.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++
+ include/linux/iomap.h | 4 +++
+ 2 files changed, 98 insertions(+)
+
+diff --git a/fs/iomap.c b/fs/iomap.c
+index 4b10892967a5..432eed8f091f 100644
+--- a/fs/iomap.c
++++ b/fs/iomap.c
+@@ -584,6 +584,100 @@ int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fi,
+ }
+ EXPORT_SYMBOL_GPL(iomap_fiemap);
+
++static loff_t
++iomap_seek_hole_actor(struct inode *inode, loff_t offset, loff_t length,
++ void *data, struct iomap *iomap)
++{
++ switch (iomap->type) {
++ case IOMAP_UNWRITTEN:
++ offset = page_cache_seek_hole_data(inode, offset, length,
++ SEEK_HOLE);
++ if (offset < 0)
++ return length;
++ /* fall through */
++ case IOMAP_HOLE:
++ *(loff_t *)data = offset;
++ return 0;
++ default:
++ return length;
++ }
++}
++
++loff_t
++iomap_seek_hole(struct inode *inode, loff_t offset, const struct iomap_ops *ops)
++{
++ loff_t size = i_size_read(inode);
++ loff_t length = size - offset;
++ loff_t ret;
++
++ /* Nothing to be found beyond the end of the file. */
++ if (offset >= size)
++ return -ENXIO;
++
++ while (length > 0) {
++ ret = iomap_apply(inode, offset, length, IOMAP_REPORT, ops,
++ &offset, iomap_seek_hole_actor);
++ if (ret < 0)
++ return ret;
++ if (ret == 0)
++ break;
++
++ offset += ret;
++ length -= ret;
++ }
++
++ return offset;
++}
++EXPORT_SYMBOL_GPL(iomap_seek_hole);
++
++static loff_t
++iomap_seek_data_actor(struct inode *inode, loff_t offset, loff_t length,
++ void *data, struct iomap *iomap)
++{
++ switch (iomap->type) {
++ case IOMAP_HOLE:
++ return length;
++ case IOMAP_UNWRITTEN:
++ offset = page_cache_seek_hole_data(inode, offset, length,
++ SEEK_DATA);
++ if (offset < 0)
++ return length;
++ /*FALLTHRU*/
++ default:
++ *(loff_t *)data = offset;
++ return 0;
++ }
++}
++
++loff_t
++iomap_seek_data(struct inode *inode, loff_t offset, const struct iomap_ops *ops)
++{
++ loff_t size = i_size_read(inode);
++ loff_t length = size - offset;
++ loff_t ret;
++
++ /* Nothing to be found beyond the end of the file. */
++ if (offset >= size)
++ return -ENXIO;
++
++ while (length > 0) {
++ ret = iomap_apply(inode, offset, length, IOMAP_REPORT, ops,
++ &offset, iomap_seek_data_actor);
++ if (ret < 0)
++ return ret;
++ if (ret == 0)
++ break;
++
++ offset += ret;
++ length -= ret;
++ }
++
++ if (length <= 0)
++ return -ENXIO;
++ return offset;
++}
++EXPORT_SYMBOL_GPL(iomap_seek_data);
++
+ /*
+ * Private flags for iomap_dio, must not overlap with the public ones in
+ * iomap.h:
+diff --git a/include/linux/iomap.h b/include/linux/iomap.h
+index f753e788da31..8a03f5dcd89b 100644
+--- a/include/linux/iomap.h
++++ b/include/linux/iomap.h
+@@ -83,6 +83,10 @@ int iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero,
+ int iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops);
+ int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
+ loff_t start, loff_t len, const struct iomap_ops *ops);
++loff_t iomap_seek_hole(struct inode *inode, loff_t offset,
++ const struct iomap_ops *ops);
++loff_t iomap_seek_data(struct inode *inode, loff_t offset,
++ const struct iomap_ops *ops);
+
+ /*
+ * Flags for direct I/O ->end_io:
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index 9d2becc586..2d509091ae 100644
--- a/series.conf
+++ b/series.conf
@@ -3560,6 +3560,7 @@
patches.fixes/xfs-remove-double-underscore-integer-types.patch
patches.fixes/xfs-check-if-an-inode-is-cached-and-allocated.patch
patches.fixes/vfs-Add-page_cache_seek_hole_data-helper.patch
+ patches.fixes/vfs-Add-iomap_seek_hole-and-iomap_seek_data-helpers.patch
patches.drivers/ipmi_ssif-unlock-on-allocation-failure
patches.drivers/0007-ipmi_ssif-remove-redundant-null-check-on-array-clien.patch
patches.drivers/0008-ipmi-Use-the-proper-default-value-for-register-size-.patch