[sheepdog] [PATCH 3/3] md: make MD support as always enabled
Liu Yuan
namei.unix at gmail.com
Wed Apr 17 11:24:04 CEST 2013
From: Liu Yuan <tailai.ly at taobao.com>
Currently, we can plug new disks even MD isn't enabled. Following process
$ sheep /store # MD isn't enabled
$ collie node md plug /new_disk
will cause big trouble because plugging will succeed and force a recovery where
old /store isn't counted in the disk arrays.
To avoid such random careless opertaion and keep simplicity, this patch:
Make MD support as always enabled then the interface to be more upgradeing friendly:
$ sheep /store # will enable MD and meta-store and object-store will share the same /store
$ sheep /metastore,/disk1{,.../diskN,...} # works as before
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/md.c | 14 --------------
sheep/sheep_priv.h | 1 -
sheep/store.c | 16 +++++++++++++---
3 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/sheep/md.c b/sheep/md.c
index 5d148cd..cafe1bc 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -327,8 +327,6 @@ reinit:
}
calculate_vdisks(md_disks, md_nr_disks, total);
md_nr_vds = disks_to_vdisks(md_disks, md_nr_disks, md_vds);
- if (!sys->enable_md)
- sys->enable_md = true;
return total;
}
@@ -338,9 +336,6 @@ char *get_object_path(uint64_t oid)
struct vdisk *vd;
char *p;
- if (!sys->enable_md)
- return obj_path;
-
pthread_rwlock_rdlock(&md_lock);
vd = oid_to_vdisk(oid);
p = md_disks[vd->idx].path;
@@ -363,9 +358,6 @@ int for_each_object_in_wd(int (*func)(uint64_t oid, char *path, void *arg),
{
int i, ret = SD_RES_SUCCESS;
- if (!sys->enable_md)
- return for_each_object_in_path(obj_path, func, cleanup, arg);
-
pthread_rwlock_rdlock(&md_lock);
for (i = 0; i < md_nr_disks; i++) {
ret = for_each_object_in_path(md_disks[i].path, func,
@@ -381,9 +373,6 @@ int for_each_obj_path(int (*func)(char *path))
{
int i, ret = SD_RES_SUCCESS;
- if (!sys->enable_md)
- return func(obj_path);
-
pthread_rwlock_rdlock(&md_lock);
for (i = 0; i < md_nr_disks; i++) {
ret = func(md_disks[i].path);
@@ -430,9 +419,6 @@ int md_handle_eio(char *fault_path)
{
struct md_work *mw;
- if (!sys->enable_md)
- return SD_RES_EIO;
-
if (nr_online_disks() == 0)
return SD_RES_EIO;
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 4a3cd2e..715b02f 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -125,7 +125,6 @@ struct cluster_info {
bool backend_dio;
/* upgrade data layout before starting service if necessary*/
bool upgrade;
- bool enable_md;
};
struct siocb {
diff --git a/sheep/store.c b/sheep/store.c
index d95eb01..0960a66 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -297,9 +297,19 @@ static int init_obj_path(const char *base_path, char *argp)
/* Eat up the first component */
strtok(argp, ",");
- while ((p = strtok(NULL, ",")))
- md_add_disk(p);
-
+ p = strtok(NULL, ",");
+ if (!p) {
+ /*
+ * If We have only one path, meta-store and object-store share
+ * it. This is helpful to upgrade old sheep cluster to
+ * the MD-enabled.
+ */
+ md_add_disk(obj_path);
+ } else {
+ do {
+ md_add_disk(p);
+ } while ((p = strtok(NULL, ",")));
+ }
return init_path(obj_path, NULL);
}
--
1.7.9.5
More information about the sheepdog
mailing list