[sheepdog-users] n copies > n nodes
Liu Yuan
namei.unix at gmail.com
Fri Mar 15 08:58:58 CET 2013
On 03/15/2013 02:56 PM, MORITA Kazutaka wrote:
> Then other functions that call write_object() have the same problem.
> I wonder if we should change get_req_copy_number() so that it returns
> a smaller number only when cluster mode is unsafe.
get_req_copy_number just tries hard to get the correct copies to work on. I think we shouldn't rely on the failure of write to backend to check if this operation is valid. If we are failed, we can't easily remove the objects that are partially written to backend store. This is two deep in the write path, we'd better exclude this write as early as possible.
The point of nohalt or quorum is to let cluster keep running for a short period for the crash events that make the number of nodes in the cluster is less than nr_copies. Allow creating VDI with required copies larger than alive nodes is nonsense. How about following patch:
f8770d90579f026c7881f974a5f8 Mon Sep 17 00:00:00 2001
From: Liu Yuan <tailai.ly at taobao.com>
Date: Fri, 15 Mar 2013 15:57:53 +0800
Subject: [PATCH v2] collie: don't create VDI when there are not enough nodes
If we have less nodes than required copies, just error return.
Reported-by: Valerio Pachera <sirio81 at gmail.com>
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
collie/vdi.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/collie/vdi.c b/collie/vdi.c
index 94acca9..d06c29c 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -514,7 +514,7 @@ static int vdi_create(int argc, char **argv)
uint64_t size;
uint32_t vid;
uint64_t oid;
- int idx, max_idx, ret;
+ int idx, max_idx, ret, nr_copies = vdi_cmd_data.nr_copies;
struct sheepdog_inode *inode = NULL;
if (!argv[optind]) {
@@ -529,6 +529,12 @@ static int vdi_create(int argc, char **argv)
return EXIT_USAGE;
}
+ if (nr_copies > sd_nodes_nr) {
+ fprintf(stderr, "There are not enough nodes(%d) to hold "
+ "the copies(%d)\n", sd_nodes_nr, nr_copies);
+ return EXIT_USAGE;
+ }
+
ret = do_vdi_create(vdiname, size, 0, &vid, false,
vdi_cmd_data.nr_copies);
if (ret != EXIT_SUCCESS || !vdi_cmd_data.prealloc)
@@ -1938,7 +1944,7 @@ static struct subcommand vdi_cmd[] = {
NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
vdi_check, vdi_options},
{"create", "<vdiname> <size>", "Pcaph", "create an image",
- NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
+ NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
vdi_create, vdi_options},
{"snapshot", "<vdiname>", "saph", "create a snapshot",
NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
--
1.7.9.5
More information about the sheepdog-users
mailing list