}
/*
- * prepare to perform part of a write to a page
+ * Prepare to perform part of a write to a page. Note that len may extend
+ * beyond the end of the page.
*/
int afs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
unsigned long priv;
unsigned f, from;
unsigned t, to;
- pgoff_t index;
int ret;
_enter("{%llx:%llu},%llx,%x",
if (ret < 0)
return ret;
- index = folio_index(folio);
- from = pos - index * PAGE_SIZE;
+ from = offset_in_folio(folio, pos);
+ len = min_t(size_t, len, folio_size(folio) - from);
to = from + len;
try_again:
}
/*
- * finalise part of a write to a page
+ * Finalise part of a write to a page. Note that len may extend beyond the end
+ * of the page.
*/
int afs_write_end(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned copied,