summaryrefslogtreecommitdiff
path: root/include/linux/iomap.h
diff options
context:
space:
mode:
authorGao Xiang <hsiangkao@linux.alibaba.com>2021-08-03 19:38:22 +0300
committerDarrick J. Wong <djwong@kernel.org>2021-08-03 19:43:13 +0300
commit69f4a26c1e0c7c5e5e77c5bd7b271743c124c545 (patch)
tree4e944b086cefaeb1145a09dad8c16a72fdff2619 /include/linux/iomap.h
parentc1b79f11f4ec27d3b3197a9584950a3be178c717 (diff)
downloadlinux-69f4a26c1e0c7c5e5e77c5bd7b271743c124c545.tar.xz
iomap: support reading inline data from non-zero pos
The existing inline data support only works for cases where the entire file is stored as inline data. For larger files, EROFS stores the initial blocks separately and the remainder of the file ("file tail") adjacent to the inode. Generalise inline data to allow reading the inline file tail. Tails may not cross a page boundary in memory. We currently have no filesystems that support tails and writing, so that case is currently disabled (see iomap_write_begin_inline). Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'include/linux/iomap.h')
-rw-r--r--include/linux/iomap.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 479c1da3e221..b8ec145b2975 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -98,6 +98,24 @@ iomap_sector(struct iomap *iomap, loff_t pos)
}
/*
+ * Returns the inline data pointer for logical offset @pos.
+ */
+static inline void *iomap_inline_data(struct iomap *iomap, loff_t pos)
+{
+ return iomap->inline_data + pos - iomap->offset;
+}
+
+/*
+ * Check if the mapping's length is within the valid range for inline data.
+ * This is used to guard against accessing data beyond the page inline_data
+ * points at.
+ */
+static inline bool iomap_inline_data_valid(struct iomap *iomap)
+{
+ return iomap->length <= PAGE_SIZE - offset_in_page(iomap->inline_data);
+}
+
+/*
* When a filesystem sets page_ops in an iomap mapping it returns, page_prepare
* and page_done will be called for each page written to. This only applies to
* buffered writes as unbuffered writes will not typically have pages