[sheepdog] [PATCH 2/9] sheep: remove '-s' option

Liu Yuan namei.unix at gmail.com
Sun May 26 15:40:34 CEST 2013


We use '-s' option as a hint of weighting. This actually doesn's stop sheep from
using extar space that '-s' specifies. Ask users to give weight hint is
nonsense if we can weight the node transparently.

'-s' would be meaningless too when we add reweight support.

This is a prepare patch for reweight patch.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/sheep.c       |   14 +--------
 tests/010           |    4 +--
 tests/016           |    4 +--
 tests/016.out       |    8 ++---
 tests/042           |    2 +-
 tests/042.out       |   82 ++++++++++++++++++++++++++++-----------------------
 tests/044           |    4 +--
 tests/044.out       |    8 ++---
 tests/054           |   12 ++++++--
 tests/058           |    6 ++--
 tests/058.out       |   16 +++++-----
 tests/common.filter |    7 ++++-
 12 files changed, 88 insertions(+), 79 deletions(-)

diff --git a/sheep/sheep.c b/sheep/sheep.c
index 7326b3b..2461f16 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -56,7 +56,6 @@ static struct sd_option sheep_options[] = {
 	{'o', "stdout", false, "log to stdout instead of shared logger"},
 	{'p', "port", true, "specify the TCP port on which to listen"},
 	{'P', "pidfile", true, "create a pid file"},
-	{'s', "disk-space", true, "specify the free disk space in megabytes"},
 	{'u', "upgrade", false, "upgrade to the latest data layout"},
 	{'v', "version", false, "show the version"},
 	{'w', "enable-cache", true, "enable object cache"},
@@ -498,7 +497,7 @@ int main(int argc, char **argv)
 	char *dir, *p, *pid_file = NULL, *bindaddr = NULL, path[PATH_MAX],
 	     *argp = NULL;
 	bool is_daemon = true, to_stdout = false, explicit_addr = false;
-	int64_t zone = -1, free_space = 0;
+	int64_t zone = -1;
 	struct cluster_driver *cdrv;
 	struct option *long_options;
 	const char *log_format = "default";
@@ -573,17 +572,6 @@ int main(int argc, char **argv)
 			}
 			sys->this_node.zone = zone;
 			break;
-		case 's':
-			free_space = strtoll(optarg, &p, 10);
-			if (optarg == p || free_space <= 0 ||
-			    UINT64_MAX < free_space || *p != '\0') {
-				fprintf(stderr, "Invalid free space size '%s': "
-					"must be an integer between 0 and "
-					"%"PRIu64"\n", optarg, UINT64_MAX);
-				exit(1);
-			}
-			sys->disk_space = free_space * 1024 * 1024;
-			break;
 		case 'u':
 			sys->upgrade = true;
 			break;
diff --git a/tests/010 b/tests/010
index b8f9c36..6800c2e 100755
--- a/tests/010
+++ b/tests/010
@@ -16,7 +16,7 @@ status=1        # failure is the default!
 _cleanup
 
 for i in `seq 0 4`; do
-    _start_sheep $i '-s 100'
+    _start_sheep $i
 done
 
 _wait_for_sheep 5
@@ -56,7 +56,7 @@ ls $STORE/*/obj/* | _filter_store | sort
 
 $COLLIE cluster recover disable
 for i in `seq 3 7`; do
-    _start_sheep $i '-s 100'
+    _start_sheep $i
 done
 
 _wait_for_sheep 8
diff --git a/tests/016 b/tests/016
index ae9608b..52a8bb8 100755
--- a/tests/016
+++ b/tests/016
@@ -16,7 +16,7 @@ status=1        # failure is the default!
 _cleanup
 
 for i in 0 1 2; do
-    _start_sheep $i "-s 4096"
+    _start_sheep $i
 done
 
 _wait_for_sheep 3
@@ -45,4 +45,4 @@ echo there should be no vdi
 $COLLIE vdi list
 
 echo there should be no object
-$COLLIE node info
+$COLLIE node info | _filter_node_info
diff --git a/tests/016.out b/tests/016.out
index f142181..271e028 100644
--- a/tests/016.out
+++ b/tests/016.out
@@ -4,9 +4,9 @@ there should be no vdi
   Name        Id    Size    Used  Shared    Creation time   VDI id  Copies  Tag
 there should be no object
 Id	Size	Used	Use%
- 0	4.0 GB	12 MB	  0%
- 1	4.0 GB	12 MB	  0%
- 2	4.0 GB	12 MB	  0%
-Total	12 GB	36 MB	  0%
+0 MASKED GB 12 MB MASKED
+1 MASKED GB 12 MB MASKED
+2 MASKED GB 12 MB MASKED
+Total MASKED GB 36 MB MASKED
 
 Total virtual image size	0.0 MB
diff --git a/tests/042 b/tests/042
index 576bf9e..7cbcb04 100755
--- a/tests/042
+++ b/tests/042
@@ -28,7 +28,7 @@ ln -s $STORE/0/sheep2.log $STORE/2/sheep.log
 ln -s $STORE/0/sheep3.log $STORE/3/sheep.log
 
 for i in `seq 0 3`; do
-    _start_sheep $i "-s $((1024 * 1024))"
+    _start_sheep $i
 done
 
 _wait_for_sheep 4
diff --git a/tests/042.out b/tests/042.out
index 8f697c9..93677f8 100644
--- a/tests/042.out
+++ b/tests/042.out
@@ -47,57 +47,57 @@ Failed to write VDI
 Failed to create VDI test2: Failed to write to requested VDI
 Failed to create VDI test3: Failed to write to requested VDI
 Id	Size	Used	Use%
- 0	1.0 TB	96 MB	  0%
- 1	1.0 TB	80 MB	  0%
- 2	1.0 TB	0.0 MB	  0%
- 3	1.0 TB	8.0 MB	  0%
-Total	4.0 TB	184 MB	  0%
+ 0	982 MB	104 MB	 10%
+ 1	982 MB	104 MB	 10%
+ 2	14 MB	4.0 MB	 28%
+ 3	14 MB	4.0 MB	 28%
+Total	1.9 GB	216 MB	 10%
 
 Total virtual image size	200 MB
 M   Id   Host:Port         V-Nodes       Zone
--    0   127.0.0.1:7000      	64          0
--    1   127.0.0.1:7001      	64          1
--    2   127.0.0.1:7002      	64          2
--    3   127.0.0.1:7003      	64          3
+-    0   127.0.0.1:7000      	126          0
+-    1   127.0.0.1:7001      	126          1
+-    2   127.0.0.1:7002      	 2          2
+-    3   127.0.0.1:7003      	 2          3
 Id	Size	Used	Use%
- 0	1.0 TB	96 MB	  0%
- 1	1.0 TB	80 MB	  0%
- 2	1.0 TB	0.0 MB	  0%
- 3	1.0 TB	8.0 MB	  0%
-Total	4.0 TB	184 MB	  0%
+ 0	982 MB	104 MB	 10%
+ 1	982 MB	104 MB	 10%
+ 2	14 MB	4.0 MB	 28%
+ 3	14 MB	4.0 MB	 28%
+Total	1.9 GB	216 MB	 10%
 
 Total virtual image size	200 MB
 M   Id   Host:Port         V-Nodes       Zone
--    0   127.0.0.1:7000      	64          0
--    1   127.0.0.1:7001      	64          1
--    2   127.0.0.1:7002      	64          2
--    3   127.0.0.1:7003      	64          3
+-    0   127.0.0.1:7000      	126          0
+-    1   127.0.0.1:7001      	126          1
+-    2   127.0.0.1:7002      	 2          2
+-    3   127.0.0.1:7003      	 2          3
 Id	Size	Used	Use%
- 0	1.0 TB	96 MB	  0%
- 1	1.0 TB	80 MB	  0%
- 2	1.0 TB	0.0 MB	  0%
- 3	1.0 TB	8.0 MB	  0%
-Total	4.0 TB	184 MB	  0%
+ 0	982 MB	104 MB	 10%
+ 1	982 MB	104 MB	 10%
+ 2	14 MB	4.0 MB	 28%
+ 3	14 MB	4.0 MB	 28%
+Total	1.9 GB	216 MB	 10%
 
 Total virtual image size	200 MB
 M   Id   Host:Port         V-Nodes       Zone
--    0   127.0.0.1:7000      	64          0
--    1   127.0.0.1:7001      	64          1
--    2   127.0.0.1:7002      	64          2
--    3   127.0.0.1:7003      	64          3
+-    0   127.0.0.1:7000      	126          0
+-    1   127.0.0.1:7001      	126          1
+-    2   127.0.0.1:7002      	 2          2
+-    3   127.0.0.1:7003      	 2          3
 Id	Size	Used	Use%
- 0	1.0 TB	96 MB	  0%
- 1	1.0 TB	80 MB	  0%
- 2	1.0 TB	0.0 MB	  0%
- 3	1.0 TB	8.0 MB	  0%
-Total	4.0 TB	184 MB	  0%
+ 0	982 MB	104 MB	 10%
+ 1	982 MB	104 MB	 10%
+ 2	14 MB	4.0 MB	 28%
+ 3	14 MB	4.0 MB	 28%
+Total	1.9 GB	216 MB	 10%
 
 Total virtual image size	200 MB
 M   Id   Host:Port         V-Nodes       Zone
--    0   127.0.0.1:7000      	64          0
--    1   127.0.0.1:7001      	64          1
--    2   127.0.0.1:7002      	64          2
--    3   127.0.0.1:7003      	64          3
+-    0   127.0.0.1:7000      	126          0
+-    1   127.0.0.1:7001      	126          1
+-    2   127.0.0.1:7002      	 2          2
+-    3   127.0.0.1:7003      	 2          3
 STORE/0/obj/00fd32fc00000000
 STORE/0/obj/00fd32fc00000001
 STORE/0/obj/00fd32fc00000002
@@ -118,29 +118,37 @@ STORE/0/obj/00fd34af00000005
 STORE/0/obj/00fd34af00000006
 STORE/0/obj/00fd34af00000007
 STORE/0/obj/00fd34af00000008
+STORE/0/obj/00fd34af00000009
 STORE/0/obj/00fd34af0000000a
 STORE/0/obj/80fd32fc00000000
 STORE/0/obj/80fd34af00000000
+STORE/0/obj/80fd366200000000
 STORE/0/obj/80fd381500000000
 STORE/1/obj/00fd32fc00000000
 STORE/1/obj/00fd32fc00000001
 STORE/1/obj/00fd32fc00000002
 STORE/1/obj/00fd32fc00000003
+STORE/1/obj/00fd32fc00000004
 STORE/1/obj/00fd32fc00000005
 STORE/1/obj/00fd32fc00000006
 STORE/1/obj/00fd32fc00000007
 STORE/1/obj/00fd32fc00000008
+STORE/1/obj/00fd32fc00000009
+STORE/1/obj/00fd32fc0000000a
 STORE/1/obj/00fd34af00000000
 STORE/1/obj/00fd34af00000001
 STORE/1/obj/00fd34af00000002
 STORE/1/obj/00fd34af00000003
 STORE/1/obj/00fd34af00000004
+STORE/1/obj/00fd34af00000005
 STORE/1/obj/00fd34af00000006
+STORE/1/obj/00fd34af00000007
+STORE/1/obj/00fd34af00000008
 STORE/1/obj/00fd34af00000009
 STORE/1/obj/00fd34af0000000a
 STORE/1/obj/80fd32fc00000000
 STORE/1/obj/80fd34af00000000
 STORE/1/obj/80fd366200000000
 STORE/1/obj/80fd381500000000
-STORE/3/obj/80fd32fc00000000
+STORE/2/obj/80fd32fc00000000
 STORE/3/obj/80fd34af00000000
diff --git a/tests/044 b/tests/044
index a774bb5..c823ed5 100755
--- a/tests/044
+++ b/tests/044
@@ -20,7 +20,7 @@ fi
 _cleanup
 
 for i in 0 1 2; do
-    _start_sheep $i '-s 4096 -w size=1000'
+    _start_sheep $i "-w size=1000"
 done
 
 _wait_for_sheep 3
@@ -80,6 +80,6 @@ echo there should be no vdi
 $COLLIE vdi list
 
 echo there should be no object
-$COLLIE node info
+$COLLIE node info | _filter_node_info
 
 find $STORE/*/cache -type f | sort
diff --git a/tests/044.out b/tests/044.out
index c5edb88..49c19d4 100644
--- a/tests/044.out
+++ b/tests/044.out
@@ -4,9 +4,9 @@ there should be no vdi
   Name        Id    Size    Used  Shared    Creation time   VDI id  Copies  Tag
 there should be no object
 Id	Size	Used	Use%
- 0	4.0 GB	144 MB	  3%
- 1	4.0 GB	144 MB	  3%
- 2	4.0 GB	144 MB	  3%
-Total	12 GB	432 MB	  3%
+0 MASKED GB 144 MB MASKED
+1 MASKED GB 144 MB MASKED
+2 MASKED GB 144 MB MASKED
+Total MASKED GB 432 MB MASKED
 
 Total virtual image size	0.0 MB
diff --git a/tests/054 b/tests/054
index 80a404c..0649021 100755
--- a/tests/054
+++ b/tests/054
@@ -12,10 +12,18 @@ status=1        # failure is the default!
 . ./common.rc
 . ./common.filter
 
+_need_to_be_root
+
 _cleanup
+
+_make_device 0 $((1024 ** 3))
+_make_device 1 $((2 * 1024 ** 3))
+_make_device 2 $((3 * 1024 ** 3))
+_make_device 3 $((3 * 1024 ** 3))
+
 #start three in different size
 for i in 0 1 2; do
-	_start_sheep $i "-s $(($i+1))000"
+	_start_sheep $i
 done
 _wait_for_sheep 3
 $COLLIE cluster format
@@ -25,7 +33,7 @@ $COLLIE vdi create test 100M -P
 $COLLIE cluster info | _filter_cluster_info
 
 #start recovery
- _start_sheep 3 "-s 3000"
+_start_sheep 3
 
 _wait_for_sheep 4
 _wait_for_sheep_recovery 0
diff --git a/tests/058 b/tests/058
index 0eddc81..5c47fbc 100755
--- a/tests/058
+++ b/tests/058
@@ -15,16 +15,16 @@ status=1        # failure is the default!
 _cleanup
 
 for i in 0 1 2; do
-	_start_sheep $i "-s 1000"
+	_start_sheep $i
 done
 _wait_for_sheep 3
 $COLLIE cluster format
 sleep 1
 $COLLIE vdi create test 100M -P
-$COLLIE node info
+$COLLIE node info | _filter_node_info
 qemu-io -c "discard 0 100m" sheepdog:test | _filter_qemu_io
 $COLLIE vdi check test
 for i in `seq 0 24`; do
 	$COLLIE vdi object test -i $i;
 done
-$COLLIE node info
+$COLLIE node info | _filter_node_info
diff --git a/tests/058.out b/tests/058.out
index f736eaa..1243a8d 100644
--- a/tests/058.out
+++ b/tests/058.out
@@ -1,10 +1,10 @@
 QA output created by 058
 using backend plain store
 Id	Size	Used	Use%
- 0	1000 MB	104 MB	 10%
- 1	1000 MB	104 MB	 10%
- 2	1000 MB	104 MB	 10%
-Total	2.9 GB	312 MB	 10%
+0 MASKED GB 104 MB MASKED
+1 MASKED GB 104 MB MASKED
+2 MASKED GB 104 MB MASKED
+Total MASKED GB 312 MB MASKED
 
 Total virtual image size	100 MB
 discard 104857600/104857600 bytes at offset 0
@@ -36,9 +36,9 @@ The inode object 0x7c2b25 idx 22 is not allocated
 The inode object 0x7c2b25 idx 23 is not allocated
 The inode object 0x7c2b25 idx 24 is not allocated
 Id	Size	Used	Use%
- 0	1000 MB	4.0 MB	  0%
- 1	1000 MB	4.0 MB	  0%
- 2	1000 MB	4.0 MB	  0%
-Total	2.9 GB	12 MB	  0%
+0 MASKED GB 4.0 MB MASKED
+1 MASKED GB 4.0 MB MASKED
+2 MASKED GB 4.0 MB MASKED
+Total MASKED GB 12 MB MASKED
 
 Total virtual image size	100 MB
diff --git a/tests/common.filter b/tests/common.filter
index 019f952..13ceb9e 100644
--- a/tests/common.filter
+++ b/tests/common.filter
@@ -165,7 +165,12 @@ _filter_store()
 
 _filter_md_info()
 {
-	awk '{if ($4 ~ /^[0-9]+$/) $4="MASKED";print $0}' | _filter_store
+	awk '{if ($4 ~ /^[0-9.]+$/) $4="MASKED";print $0}' | _filter_store
+}
+
+_filter_node_info()
+{
+	awk '{if ($2 ~ /^[0-9.]+$/) {$2="MASKED";$6="MASKED"};print $0}'
 }
 
 # make sure this script returns success
-- 
1.7.9.5



More information about the sheepdog mailing list