iomp = match_offset_to_mapping(page, &iomap,
p_offset);
}
- if (iomp) {
+ if (iomp && startio) {
if (!bh->b_end_io) {
err = map_unwritten(inode, page,
head, bh, p_offset,
goto error;
}
}
- if (startio) {
- bh_arr[cnt++] = bh;
- } else {
- set_buffer_dirty(bh);
- unlock_buffer(bh);
- mark_buffer_dirty(bh);
- }
+ bh_arr[cnt++] = bh;
page_dirty = 0;
}
/*
loff_t delta;
/* For unwritten extents do not report a disk address on
- * the read case.
+ * the read case (treat as if we're reading into a hole).
*/
- if (create || ((iomap.iomap_flags & IOMAP_UNWRITTEN) == 0)) {
+ if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) {
delta = offset - iomap.iomap_offset;
delta >>= inode->i_blkbits;
bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
set_buffer_mapped(bh_result);
}
- if (iomap.iomap_flags & IOMAP_UNWRITTEN) {
- if (create) {
- if (direct)
- bh_result->b_private = inode;
- set_buffer_mapped(bh_result);
- }
+ if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) {
+ if (direct)
+ bh_result->b_private = inode;
set_buffer_unwritten(bh_result);
set_buffer_delay(bh_result);
}
int gfp_mask)
{
struct inode *inode = page->mapping->host;
- int delalloc, unmapped, unwritten;
+ int dirty, delalloc, unmapped, unwritten;
count_page_state(page, &delalloc, &unmapped, &unwritten);
if (!delalloc && !unwritten)
* Never need to allocate space here - we will always
* come back to writepage in that case.
*/
- if (page_state_convert(inode, page, 0, 0) == 0)
+ dirty = page_state_convert(inode, page, 0, 0);
+ if (dirty == 0 && !unwritten)
goto free_buffers;
return 0;