Skip to content

Commit 64100d8

Browse files
fdmananaopsiff
authored andcommitted
btrfs: fix lost error when running device stats on multiple devices fs
[ Upstream commit 1c37d896b12dfd0d4c96e310b0033c6676933917 ] 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: 733f4fb ("Btrfs: read device stats on mount, write modified ones during commit") Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit e3387416ad6b2f3a6d52fdb474096dec899e98d0) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent ec23e5b commit 64100d8

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

fs/btrfs/volumes.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7641,8 +7641,9 @@ int btrfs_run_dev_stats(struct btrfs_trans_handle *trans)
76417641
smp_rmb();
76427642

76437643
ret = update_dev_stat_item(trans, device);
7644-
if (!ret)
7645-
atomic_sub(stats_cnt, &device->dev_stats_ccnt);
7644+
if (ret)
7645+
break;
7646+
atomic_sub(stats_cnt, &device->dev_stats_ccnt);
76467647
}
76477648
mutex_unlock(&fs_devices->device_list_mutex);
76487649

0 commit comments

Comments
 (0)