Commit 1c37d896 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba
Browse files

btrfs: fix lost error when running device stats on multiple devices fs



Whenever we get an error updating the device stats item for a device in
btrfs_run_dev_stats() we allow the loop to go to the next device, and if
updating the stats item for the next device succeeds, we end up losing
the error we had from the previous device.

Fix this by breaking out of the loop once we get an error and make sure
it's returned to the caller. Since we are in the transaction commit path
(and in the critical section actually), returning the error will result
in a transaction abort.

Fixes: 733f4fbb ("Btrfs: read device stats on mount, write modified ones during commit")
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent a85b46db
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -8099,7 +8099,8 @@ int btrfs_run_dev_stats(struct btrfs_trans_handle *trans)
		smp_rmb();

		ret = update_dev_stat_item(trans, device);
		if (!ret)
		if (ret)
			break;
		atomic_sub(stats_cnt, &device->dev_stats_ccnt);
	}
	mutex_unlock(&fs_devices->device_list_mutex);