On Wed, Nov 29, 2023 at 08:08:37AM +1100, Dave Chinner wrote: > > But places that use buf_get and manually fill in data only use it in a > > few cases. > > Yes. the caller of buf_get always needs to set XBF_DONE if it is > initialising a new buffer ready for it to be written. It should be > done before the caller drops the buffer lock so that no other lookup > can see the buffer in the state of "contains valid data but does not > have XBF_DONE set". That makes sense, but we do have a whole bunch of weird things going on as well: - xfs_buf_ioend_handle_error sets XBF_DONE when retrying or failing - xfs_buf_ioend sets XBF_DONE on successful write completion as well - xfs_buf_ioend_fail drops XBF_DONE for any I/O failure - xfs_do_force_shutdown sets XBF_DONE on the super block buffer on a foced shutdown - xfs_trans_get_buf_map sets XBF_DONE on a forced shutdown So there's definitively a bunch of weird things not fully in line with the straight forward answer.