Skip to content

Commit 5ad448c

Browse files
Andreas GruenbacherDarrick J. Wong
authored andcommitted
iomap: iomap_read_inline_data cleanup
Change iomap_read_inline_data to return 0 or an error code; this simplifies the callers. Add a description. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> [djwong: document the return value of iomap_read_inline_data explicitly] Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
1 parent d8af404 commit 5ad448c

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

fs/iomap/buffered-io.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,16 @@ struct iomap_readpage_ctx {
205205
struct readahead_control *rac;
206206
};
207207

208-
static loff_t iomap_read_inline_data(const struct iomap_iter *iter,
208+
/**
209+
* iomap_read_inline_data - copy inline data into the page cache
210+
* @iter: iteration structure
211+
* @page: page to copy to
212+
*
213+
* Copy the inline data in @iter into @page and zero out the rest of the page.
214+
* Only a single IOMAP_INLINE extent is allowed at the end of each file.
215+
* Returns zero for success to complete the read, or the usual negative errno.
216+
*/
217+
static int iomap_read_inline_data(const struct iomap_iter *iter,
209218
struct page *page)
210219
{
211220
const struct iomap *iomap = iomap_iter_srcmap(iter);
@@ -214,7 +223,7 @@ static loff_t iomap_read_inline_data(const struct iomap_iter *iter,
214223
void *addr;
215224

216225
if (PageUptodate(page))
217-
return PAGE_SIZE - poff;
226+
return 0;
218227

219228
if (WARN_ON_ONCE(size > PAGE_SIZE - poff))
220229
return -EIO;
@@ -231,7 +240,7 @@ static loff_t iomap_read_inline_data(const struct iomap_iter *iter,
231240
memset(addr + size, 0, PAGE_SIZE - poff - size);
232241
kunmap_local(addr);
233242
iomap_set_range_uptodate(page, poff, PAGE_SIZE - poff);
234-
return PAGE_SIZE - poff;
243+
return 0;
235244
}
236245

237246
static inline bool iomap_block_needs_zeroing(const struct iomap_iter *iter,
@@ -256,13 +265,8 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter,
256265
unsigned poff, plen;
257266
sector_t sector;
258267

259-
if (iomap->type == IOMAP_INLINE) {
260-
loff_t ret = iomap_read_inline_data(iter, page);
261-
262-
if (ret < 0)
263-
return ret;
264-
return 0;
265-
}
268+
if (iomap->type == IOMAP_INLINE)
269+
return iomap_read_inline_data(iter, page);
266270

267271
/* zero post-eof blocks as the page may be mapped */
268272
iop = iomap_page_create(iter->inode, page);
@@ -587,15 +591,10 @@ static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos,
587591
static int iomap_write_begin_inline(const struct iomap_iter *iter,
588592
struct page *page)
589593
{
590-
int ret;
591-
592594
/* needs more work for the tailpacking case; disable for now */
593595
if (WARN_ON_ONCE(iomap_iter_srcmap(iter)->offset != 0))
594596
return -EIO;
595-
ret = iomap_read_inline_data(iter, page);
596-
if (ret < 0)
597-
return ret;
598-
return 0;
597+
return iomap_read_inline_data(iter, page);
599598
}
600599

601600
static int iomap_write_begin(const struct iomap_iter *iter, loff_t pos,

0 commit comments

Comments
 (0)