Commit 353448f3 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix buffered write path for generic/275

Per fstests generic/275, on -ENOSPC we're supposed write until the
filesystem is full - i.e. do a partial write instead of failing the full
write.

This is a partial fix for the buffered write path: we'll still fail on a
page boundary.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent c167f9e5
......@@ -1656,10 +1656,21 @@ static int __bch2_buffered_write(struct bch_inode_info *inode,
goto out;
}
/*
* XXX: per POSIX and fstests generic/275, on -ENOSPC we're
* supposed to write as much as we have disk space for.
*
* On failure here we should still write out a partial page if
* we aren't completely out of disk space - we don't do that
* yet:
*/
ret = bch2_page_reservation_get(c, inode, page, &res,
pg_offset, pg_len);
if (ret)
goto out;
if (unlikely(ret)) {
if (!reserved)
goto out;
break;
}
reserved += pg_len;
}
......@@ -1668,10 +1679,10 @@ static int __bch2_buffered_write(struct bch_inode_info *inode,
for (i = 0; i < nr_pages; i++)
flush_dcache_page(pages[i]);
while (copied < len) {
while (copied < reserved) {
struct page *page = pages[(offset + copied) >> PAGE_SHIFT];
unsigned pg_offset = (offset + copied) & (PAGE_SIZE - 1);
unsigned pg_len = min_t(unsigned, len - copied,
unsigned pg_len = min_t(unsigned, reserved - copied,
PAGE_SIZE - pg_offset);
unsigned pg_copied = copy_page_from_iter_atomic(page,
pg_offset, pg_len, iter);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment