Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andreas Gruenbacher and committed by
Darrick J. Wong
5ad448ce d8af404f

+15 -16
+15 -16
fs/iomap/buffered-io.c
··· 205 205 struct readahead_control *rac; 206 206 }; 207 207 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, 209 218 struct page *page) 210 219 { 211 220 const struct iomap *iomap = iomap_iter_srcmap(iter); ··· 223 214 void *addr; 224 215 225 216 if (PageUptodate(page)) 226 - return PAGE_SIZE - poff; 217 + return 0; 227 218 228 219 if (WARN_ON_ONCE(size > PAGE_SIZE - poff)) 229 220 return -EIO; ··· 240 231 memset(addr + size, 0, PAGE_SIZE - poff - size); 241 232 kunmap_local(addr); 242 233 iomap_set_range_uptodate(page, poff, PAGE_SIZE - poff); 243 - return PAGE_SIZE - poff; 234 + return 0; 244 235 } 245 236 246 237 static inline bool iomap_block_needs_zeroing(const struct iomap_iter *iter, ··· 265 256 unsigned poff, plen; 266 257 sector_t sector; 267 258 268 - if (iomap->type == IOMAP_INLINE) { 269 - loff_t ret = iomap_read_inline_data(iter, page); 270 - 271 - if (ret < 0) 272 - return ret; 273 - return 0; 274 - } 259 + if (iomap->type == IOMAP_INLINE) 260 + return iomap_read_inline_data(iter, page); 275 261 276 262 /* zero post-eof blocks as the page may be mapped */ 277 263 iop = iomap_page_create(iter->inode, page); ··· 591 587 static int iomap_write_begin_inline(const struct iomap_iter *iter, 592 588 struct page *page) 593 589 { 594 - int ret; 595 - 596 590 /* needs more work for the tailpacking case; disable for now */ 597 591 if (WARN_ON_ONCE(iomap_iter_srcmap(iter)->offset != 0)) 598 592 return -EIO; 599 - ret = iomap_read_inline_data(iter, page); 600 - if (ret < 0) 601 - return ret; 602 - return 0; 593 + return iomap_read_inline_data(iter, page); 603 594 } 604 595 605 596 static int iomap_write_begin(const struct iomap_iter *iter, loff_t pos,