]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
loop: Refactor loop_set_status() size calculation
authorMartijn Coenen <maco@android.com>
Fri, 1 Mar 2024 01:30:24 +0000 (09:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Apr 2024 10:50:10 +0000 (12:50 +0200)
commite6189dfedef6b39a868f4f238f3940e2848ee793
tree969c68d7377a8bc04c1827cc437140e9d6c73cc5
parentbf6bec6f4679ccc713c69fa343b7b82879b0755b
loop: Refactor loop_set_status() size calculation

[ Upstream commit b0bd158dd630bd47640e0e418c062cda1e0da5ad ]

figure_loop_size() calculates the loop size based on the passed in
parameters, but at the same time it updates the offset and sizelimit
parameters in the loop device configuration. That is a somewhat
unexpected side effect of a function with this name, and it is only only
needed by one of the two callers of this function - loop_set_status().

Move the lo_offset and lo_sizelimit assignment back into loop_set_status(),
and use the newly factored out functions to validate and apply the newly
calculated size. This allows us to get rid of figure_loop_size() in a
follow-up commit.

Signed-off-by: Martijn Coenen <maco@android.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/loop.c