[sheepdog-users] n copies > n nodes

Liu Yuan namei.unix at gmail.com
Fri Mar 15 07:17:58 CET 2013


On 03/13/2013 07:23 PM, Valerio Pachera wrote:
> 2013/2/25 MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>:
>> At Sun, 24 Feb 2013 19:17:10 +0900,
> 
> On a cluster with 4 nodes, sheep 0.5.5_186_gf9c15bc, it is still possible
> 
> collie vdi create -c 7 test 5G
> 
> collie vdi object test
> Looking for the inode object 0x7c2b25 with 4 nodes
> 192.168.2.41:7000 has the object (should be 4 copies)
> 192.168.2.42:7000 has the object (should be 4 copies)
> 192.168.2.43:7000 has the object (should be 4 copies)
> 192.168.2.44:7000 has the object (should be 4 copies)
> 
> If sheepdog creates a vdi with copies = nodes when copies > nodes,
> it's ok, but I suggest to print out a warning.
> 

I think we shouldn't allow creating VDI when there are not enough nodes to hold the required copies.
Bellow is the patch to prohibit this behavior. I've pushed to devel branch.

>From 60b61e40cdd8cf96d85a1a7d5279714328548202 Mon Sep 17 00:00:00 2001
From: Liu Yuan <tailai.ly at taobao.com>
Date: Fri, 15 Mar 2013 14:16:02 +0800
Subject: [PATCH] collie: don't create VDI when there are not enough nodes

If we have less nodes than required copies, just return invalid parameters.

Reported-by: Valerio Pachera <sirio81 at gmail.com>
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/ops.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/sheep/ops.c b/sheep/ops.c
index b9634ae..b68e866 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -106,6 +106,9 @@ static int cluster_new_vdi(struct request *req)
 	if (!iocb.nr_copies)
 		iocb.nr_copies = sys->nr_copies;
 
+	if (iocb.nr_copies > req->vinfo->nr_nodes)
+		return SD_RES_INVALID_PARMS;
+
 	ret = add_vdi(&iocb, &vid);
 
 	rsp->vdi.vdi_id = vid;
-- 
1.7.9.5





More information about the sheepdog-users mailing list