mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-15 22:41:38 +00:00
dm cache: only allow a single io_mode cache feature to be requested
More than one io_mode feature can be requested when creating a dm cache
device (as is: last one wins). The io_mode selections are incompatible
with one another, we should force them to be selected exclusively. Add
a counter to check for more than one io_mode selection.
Fixes: 629d0a8a1a ("dm cache metadata: add "metadata2" feature")
Signed-off-by: John Pittman <jpittman@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
This commit is contained in:
committed by
Mike Snitzer
parent
6c7413c0f5
commit
af9313c32c
@@ -2250,7 +2250,7 @@ static int parse_features(struct cache_args *ca, struct dm_arg_set *as,
|
|||||||
{0, 2, "Invalid number of cache feature arguments"},
|
{0, 2, "Invalid number of cache feature arguments"},
|
||||||
};
|
};
|
||||||
|
|
||||||
int r;
|
int r, mode_ctr = 0;
|
||||||
unsigned argc;
|
unsigned argc;
|
||||||
const char *arg;
|
const char *arg;
|
||||||
struct cache_features *cf = &ca->features;
|
struct cache_features *cf = &ca->features;
|
||||||
@@ -2264,14 +2264,20 @@ static int parse_features(struct cache_args *ca, struct dm_arg_set *as,
|
|||||||
while (argc--) {
|
while (argc--) {
|
||||||
arg = dm_shift_arg(as);
|
arg = dm_shift_arg(as);
|
||||||
|
|
||||||
if (!strcasecmp(arg, "writeback"))
|
if (!strcasecmp(arg, "writeback")) {
|
||||||
cf->io_mode = CM_IO_WRITEBACK;
|
cf->io_mode = CM_IO_WRITEBACK;
|
||||||
|
mode_ctr++;
|
||||||
|
}
|
||||||
|
|
||||||
else if (!strcasecmp(arg, "writethrough"))
|
else if (!strcasecmp(arg, "writethrough")) {
|
||||||
cf->io_mode = CM_IO_WRITETHROUGH;
|
cf->io_mode = CM_IO_WRITETHROUGH;
|
||||||
|
mode_ctr++;
|
||||||
|
}
|
||||||
|
|
||||||
else if (!strcasecmp(arg, "passthrough"))
|
else if (!strcasecmp(arg, "passthrough")) {
|
||||||
cf->io_mode = CM_IO_PASSTHROUGH;
|
cf->io_mode = CM_IO_PASSTHROUGH;
|
||||||
|
mode_ctr++;
|
||||||
|
}
|
||||||
|
|
||||||
else if (!strcasecmp(arg, "metadata2"))
|
else if (!strcasecmp(arg, "metadata2"))
|
||||||
cf->metadata_version = 2;
|
cf->metadata_version = 2;
|
||||||
@@ -2282,6 +2288,11 @@ static int parse_features(struct cache_args *ca, struct dm_arg_set *as,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode_ctr > 1) {
|
||||||
|
*error = "Duplicate cache io_mode features requested";
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user