summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Malevich <jam@daterainc.com>2015-01-14 16:36:49 -0800
committerJacob Malevich <jam@daterainc.com>2015-01-14 16:36:49 -0800
commitb765c10d0ccabc123b42ec52c6c9e5692d437a3d (patch)
tree90457b2fc44337439cc8e7157957e30071c0d4e3
parentaa3e2d589dc0363bdc118bce90d97dc4fd4712c0 (diff)
bcacheadm: ioctl refactor
add-devs, rm-devs, and set-failed no longer need the cacheset uuid. The cacheset already comes with the bcache_extent0 chardev. Change-Id: I32572e865361d3c6ce759cf53f19d3f0e4cf04ce Signed-off-by: Jacob Malevich <jam@daterainc.com>
-rw-r--r--bcache.c15
-rw-r--r--bcache.h4
-rw-r--r--bcacheadm.c24
3 files changed, 12 insertions, 31 deletions
diff --git a/bcache.c b/bcache.c
index 7807f7c..4bdbc6e 100644
--- a/bcache.c
+++ b/bcache.c
@@ -1180,12 +1180,12 @@ err:
return err;
}
-char *add_devices(char *const *devs, char *uuid)
+char *add_devices(char *const *devs)
{
int ret, bcachefd;
char *err = NULL;
- bcachefd = open("/dev/bcache", O_RDWR);
+ bcachefd = open("/dev/bcache_extent0", O_RDWR);
if (bcachefd < 0) {
err = "Can't open bcache device";
goto err;
@@ -1193,7 +1193,6 @@ char *add_devices(char *const *devs, char *uuid)
struct bch_ioctl_add_disks ia;
ia.devs = devs;
- ia.uuid = uuid;
ret = ioctl(bcachefd, BCH_IOCTL_ADD_DISKS, &ia);
if (ret < 0) {
@@ -1213,7 +1212,7 @@ char *remove_device(const char *dev, bool force)
int ret, bcachefd;
char *err = NULL;
- bcachefd = open("/dev/bcache", O_RDWR);
+ bcachefd = open("/dev/bcache_extent0", O_RDWR);
if (bcachefd < 0) {
err = "Can't open bcache device";
goto err;
@@ -1236,22 +1235,20 @@ err:
return err;
}
-char *device_set_failed(const char *dev_uuid, const char *set_uuid) {
+char *device_set_failed(const char *dev_uuid) {
int ret, bcachefd;
char *err = NULL;
- uuid_le dev, set;
+ uuid_le dev;
struct bch_ioctl_disk_failed df;
- bcachefd = open("/dev/bcache", O_RDWR);
+ bcachefd = open("/dev/bcache_extent0", O_RDWR);
if (bcachefd < 0) {
err = "Can't open bcache device";
goto err;
}
uuid_parse(dev_uuid, dev.b);
- uuid_parse(set_uuid, set.b);
df.dev_uuid = dev;
- df.set_uuid = set;
ret = ioctl(bcachefd, BCH_IOCTL_SET_DISK_FAILED, &df);
if (ret < 0) {
diff --git a/bcache.h b/bcache.h
index 0133bef..d409ee2 100644
--- a/bcache.h
+++ b/bcache.h
@@ -106,11 +106,11 @@ char *unregister_bcache(char *const *);
char *probe(char *, int);
char *read_stat_dir(DIR *, char *, char *, char *);
char *find_matching_uuid(char *, char *, const char*);
-char *add_devices(char *const *, char *);
+char *add_devices(char *const *);
char *remove_device(const char *, bool);
char *bcache_get_capacity(const char *, const char *, bool);
char *dev_name(const char *);
-char *device_set_failed(const char *dev_uuid, const char *set_uuid);
+char *device_set_failed(const char *dev_uuid);
#define csum_set(i, type) \
({ \
diff --git a/bcacheadm.c b/bcacheadm.c
index 97e5732..e92acbd 100644
--- a/bcacheadm.c
+++ b/bcacheadm.c
@@ -58,9 +58,6 @@ char *metadata_replicas = 0;
char *data_replicas = 0;
char *tier = 0;
-/* add-dev globals */
-char *add_dev_uuid = NULL;
-
/* rm-dev globals */
bool force_remove = false;
@@ -100,7 +97,6 @@ bool stats_day = false;
bool stats_total = false;
/* set_failed globals */
-static const char *failed_uuid = NULL;
static const char *dev_failed_uuid = NULL;
/* make-bcache option setters */
@@ -205,7 +201,6 @@ static NihOption bcache_unregister_options[] = {
};
static NihOption bcache_add_device_options[] = {
- {'u', "set", N_("cacheset uuid"), NULL, "UUID", &add_dev_uuid, NULL},
NIH_OPTION_LAST
};
@@ -259,7 +254,6 @@ static NihOption stats_options[] = {
};
static NihOption set_failed_options[] = {
- {'u', "set", N_("cache_set UUID"), NULL, "UUID", &failed_uuid, NULL},
{'d', "dev", N_("dev UUID"), NULL, "UUID", &dev_failed_uuid, NULL},
NIH_OPTION_LAST
};
@@ -422,12 +416,7 @@ int bcache_add_devices(NihCommand *command, char *const *args)
{
char *err;
- if (!add_dev_uuid) {
- printf("Must specify a cacheset uuid to add the disk to\n");
- return -1;
- }
-
- err = add_devices(args, add_dev_uuid);
+ err = add_devices(args);
if (err) {
printf("bcache_add_devices error: %s\n", err);
return -1;
@@ -804,17 +793,12 @@ int bcache_set_failed(NihCommand *command, char *const *args)
int i;
char *err = NULL;
- if (!failed_uuid) {
- printf("Pass in a cacheset uuid\n");
- return -1;
- }
-
if (!dev_failed_uuid) {
printf("Pass in a dev uuid\n");
return -1;
}
- err = device_set_failed(dev_failed_uuid, failed_uuid);
+ err = device_set_failed(dev_failed_uuid);
if (err) {
printf("bcache_set_failed_ioctl error: %s\n", err);
return -1;
@@ -841,7 +825,7 @@ static NihCommand commands[] = {
"Unregisters a list of devices",
N_("Unregisters a list of devices"),
NULL, bcache_unregister_options, bcache_unregister},
- {"add-devs", N_("add-devs --set=UUID --tier=# <list of devices>"),
+ {"add-devs", N_("add-devs --tier=# <list of devices>"),
"Adds a list of devices to a cacheset",
N_("Adds a list of devices to a cacheset"),
NULL, bcache_add_device_options, bcache_add_devices},
@@ -873,7 +857,7 @@ static NihCommand commands[] = {
"List various bcache statistics",
N_("List various bcache statistics"),
NULL, stats_options, bcache_stats},
- {"set-failed", N_("set-failed --set=UUID --dev=UUID"),
+ {"set-failed", N_("set-failed --dev=UUID"),
"Sets a device to the FAILED state",
N_("Sets a device to the FAILED state"),
NULL, set_failed_options, bcache_set_failed},