diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b011753ce8bb8cbf85c08a8322f11d58a59cefe1..f93ac3d7e997f3fe1438ea244038dd929fd22c6a 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4769,8 +4769,8 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, goto error; } - if (devs_max && ndevs > devs_max) - ndevs = devs_max; + ndevs = min(ndevs, devs_max); + /* * the primary goal is to maximize the number of stripes, so use as many * devices as possible, even if the stripes are not maximum sized.