bcachefs icon indicating copy to clipboard operation
bcachefs copied to clipboard

bcachefs: fix initial page state after falloc

Open dlrobertson opened this issue 4 years ago • 3 comments

On a new page reservation check if the backing extent was already allocated before adding to the number of sectors we will allocate. It is possible to write to a page that is beyond the inode i_size that is also backed by an allocated extent. This can happen when fallocate is used with FALLOC_FL_KEEP_SIZE.

Signed-off-by: Dan Robertson [email protected]

dlrobertson avatar Jun 09 '21 02:06 dlrobertson

Updated and seems to pass xfstests.

dlrobertson avatar Jun 18 '21 00:06 dlrobertson

Updated to only run the btree check if the page is not uptodate. I kept the check in the page state creation to ensure this check isn't run often.

dlrobertson avatar Jun 29 '21 12:06 dlrobertson

I think i have an idea for a better implementation of this. We don't seem to call write_begin for a buffered write. I think if we add that, i might be able to work something out there so that we essentially run the extra code added to __bch2_page_state_create that checks the btree for reserved sectors in write_begin when needed.

dlrobertson avatar Jul 10 '21 23:07 dlrobertson