]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dm cache: drop redundant origin size check
authorLi Chen <me@linux.beauty>
Wed, 10 Dec 2025 03:17:56 +0000 (11:17 +0800)
committerMikulas Patocka <mpatocka@redhat.com>
Sun, 4 Jan 2026 19:35:32 +0000 (20:35 +0100)
The cache target already exposes the origin device through
cache_iterate_devices(), which allows dm-table to call
device_area_is_invalid() and verify that the mapping fits inside the
underlying block device.

The explicit ti->len > origin_sectors test in parse_origin_dev() is
therefore redundant. Drop this check and rely on the core device
validation instead. This changes the user-visible error string when the
origin is too small, but preserves the failure behaviour.

Signed-off-by: Li Chen <me@linux.beauty>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-cache-target.c

index a10d75a562db02efc7c51fb6780f2f3eb2ea9005..350a0aa53365a2115b713c94df1bc419f5da260d 100644 (file)
@@ -2099,7 +2099,6 @@ static int parse_cache_dev(struct cache_args *ca, struct dm_arg_set *as,
 static int parse_origin_dev(struct cache_args *ca, struct dm_arg_set *as,
                            char **error)
 {
-       sector_t origin_sectors;
        int r;
 
        if (!at_least_one_arg(as, error))
@@ -2112,12 +2111,6 @@ static int parse_origin_dev(struct cache_args *ca, struct dm_arg_set *as,
                return r;
        }
 
-       origin_sectors = get_dev_size(ca->origin_dev);
-       if (ca->ti->len > origin_sectors) {
-               *error = "Device size larger than cached device";
-               return -EINVAL;
-       }
-
        return 0;
 }