Hi, attached patch contains a fix to WAPBL deallocation structure exhaustion and panic (kern/47146), and avoids need to do slow partial truncates in loop, fixing kern/49175. Patch changes wapbl_register_deallocation() to fail with EAGAIN when we run into the limit, and change ffs_truncate() and ffs_indirtrunc() to bail out early as well when this happens. Callers were updated to either explicitly not care, or loop with transaction restart when required by semantics (inactive, setattr). There is one place in code really can't easily cope with failure, in fragment extension code, when we deallocate the previous fragment block. Since that particular condition is very rare (happens at most 7 times during file lifetime, and only when filesystem is very fragmented), I've added just forced registration there. There are some slight semantics changes. ffs_indirtrunc() now always holds block buf for upper indirect node when descending, and the block is written only when everything is done. Also, code assumes that nothing in ffs_truncate() triggers EAGAIN for other purpose. Besides this, the partial deallocation might leave holes in the file, as code deallocates the whole indirect blocks before the last partial one. I think this is okay even for dirs, so this shouldn't cause problem. I plan to commit this sometime tomorrow. Comments welcome. Jaromir
Attachment:
wapbl_fix_dealloc.patch
Description: Binary data