btrfs: refactor the zoned device handling in cow_file_range
authorChristoph Hellwig <hch@lst.de>
Wed, 28 Jun 2023 15:31:41 +0000 (17:31 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Aug 2023 12:52:16 +0000 (14:52 +0200)
commit6e144bf16ba07dff649e6bd6afd79d2e353f6216
treef1d464dfb857fa57501d00e597f79d26ae8b7cb7
parent44962ca37c8cf882ba72e4cd67f30eaecb920a52
btrfs: refactor the zoned device handling in cow_file_range

Handling of the done_offset to cow_file_range is a bit confusing, as
it is not updated at all when the function succeeds, and the -EAGAIN
status is used bother for the case where we need to wait for a zone
finish and the one where the allocation was partially successful.

Change the calling convention so that done_offset is always updated,
and 0 is returned if some allocation was successful (partial allocation
can still only happen for zoned devices), and waiting for a zone
finish is done internally in cow_file_range instead of the caller.

Also write a comment explaining the logic.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c