[sheepdog] [PATCH] Revert sbd: use kstrtoul() instead of strict_strtoul()

2015-02-01 Thread Hitoshi Mitake
This reverts commit 9eed807bb06e02cd7a574d36c7c458884292da72 for
backward compatibility.

Signed-off-by: Hitoshi Mitake mitake.hito...@lab.ntt.co.jp
---
 sbd/sheep_block_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sbd/sheep_block_device.c b/sbd/sheep_block_device.c
index d82ff43..eaee932 100644
--- a/sbd/sheep_block_device.c
+++ b/sbd/sheep_block_device.c
@@ -290,7 +290,7 @@ static ssize_t sbd_remove(struct bus_type *bus, const char 
*buf,
unsigned long ul;
int target_id, ret;
 
-   ret = kstrtoul(buf, 10, ul);
+   ret = strict_strtoul(buf, 10, ul);
if (ret)
return ret;
 
-- 
1.9.1

-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
https://lists.wpkg.org/mailman/listinfo/sheepdog


Re: [sheepdog] [PATCH] sbd: use kstrtoul() instead of strict_strtoul()

2015-02-01 Thread Hitoshi Mitake
At Sat, 31 Jan 2015 16:47:19 +0800,
Liu Yuan wrote:
 
 On Tue, Jan 20, 2015 at 11:46:32AM +0900, Hitoshi Mitake wrote:
  Cc: hujianyang hujiany...@huawei.com
  Signed-off-by: Hitoshi Mitake mitake.hito...@lab.ntt.co.jp
  ---
   sbd/sheep_block_device.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
  
  diff --git a/sbd/sheep_block_device.c b/sbd/sheep_block_device.c
  index eaee932..d82ff43 100644
  --- a/sbd/sheep_block_device.c
  +++ b/sbd/sheep_block_device.c
  @@ -290,7 +290,7 @@ static ssize_t sbd_remove(struct bus_type *bus, const 
  char *buf,
  unsigned long ul;
  int target_id, ret;
   
  -   ret = strict_strtoul(buf, 10, ul);
  +   ret = kstrtoul(buf, 10, ul);
  if (ret)
  return ret;
 
 I need to warn you of that:
 
 As far as I can remember, old kernel don't support kstrtoul such as famouse
 2.6.32. For compability issue, I chose strict_strtoul instead. In other words,
 this patch will break SBD with old kernel, shipped on many distributions such
 as centos 6.
 
 As as general practice for kernel module, we'd better use old function. 
 Actually
 the later kernel just macro strict_strtoul as kstrtoul().
 
 Thanks
 Yuan
 -- 
 sheepdog mailing list
 sheepdog@lists.wpkg.org
 https://lists.wpkg.org/mailman/listinfo/sheepdog

OK, I revert this one.

Thanks,
Hitoshi
-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
https://lists.wpkg.org/mailman/listinfo/sheepdog


Re: [sheepdog] [PATCH] Revert sbd: use kstrtoul() instead of strict_strtoul()

2015-02-01 Thread Hitoshi Mitake
At Sun,  1 Feb 2015 19:46:50 +0900,
Hitoshi Mitake wrote:
 
 This reverts commit 9eed807bb06e02cd7a574d36c7c458884292da72 for
 backward compatibility.
 
 Signed-off-by: Hitoshi Mitake mitake.hito...@lab.ntt.co.jp
 ---
  sbd/sheep_block_device.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Applied this one.

Thanks,
Hitoshi

 
 diff --git a/sbd/sheep_block_device.c b/sbd/sheep_block_device.c
 index d82ff43..eaee932 100644
 --- a/sbd/sheep_block_device.c
 +++ b/sbd/sheep_block_device.c
 @@ -290,7 +290,7 @@ static ssize_t sbd_remove(struct bus_type *bus, const 
 char *buf,
   unsigned long ul;
   int target_id, ret;
  
 - ret = kstrtoul(buf, 10, ul);
 + ret = strict_strtoul(buf, 10, ul);
   if (ret)
   return ret;
  
 -- 
 1.9.1
 
-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
https://lists.wpkg.org/mailman/listinfo/sheepdog


[sheepdog] Build failed in Jenkins: sheepdog-build #621

2015-02-01 Thread sheepdog-jenkins
See http://jenkins.sheepdog-project.org:8080/job/sheepdog-build/621/changes

Changes:

[mitake.hitoshi] Revert sbd: use kstrtoul() instead of strict_strtoul()

--
[...truncated 57 lines...]
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking for ANSI C header files... (cached) yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking for unistd.h... (cached) yes
checking for sys/types.h... (cached) yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking sys/sockio.h usability... no
checking sys/sockio.h presence... no
checking for sys/sockio.h... no
checking utmpx.h usability... yes
checking utmpx.h presence... yes
checking for utmpx.h... yes
checking urcu.h usability... yes
checking urcu.h presence... yes
checking for urcu.h... yes
checking urcu/uatomic.h usability... yes
checking urcu/uatomic.h presence... yes
checking for urcu/uatomic.h... yes
checking for an ANSI C-conforming const... yes
checking for uid_t in sys/types.h... yes
checking for inline... inline
checking for size_t... (cached) yes
checking whether time.h and sys/time.h may both be included... yes
checking for working volatile... yes
checking size of short... 2
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking sys/eventfd.h usability... yes
checking sys/eventfd.h presence... yes
checking for sys/eventfd.h... yes
checking sys/signalfd.h usability... yes
checking sys/signalfd.h presence... yes
checking for sys/signalfd.h... yes
checking sys/timerfd.h usability... yes
checking sys/timerfd.h presence... yes
checking for sys/timerfd.h... yes
checking whether closedir returns void... no
checking for error_at_line... yes
checking for mbstate_t... yes
checking for working POSIX fnmatch... yes
checking for pid_t... yes
checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking whether gcc needs -traditional... no
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for working memcmp... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible realloc... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking for sys/socket.h... (cached) yes
checking types of arguments for select... int,fd_set *,struct timeval *
checking return type of signal handlers... void
checking for vprintf... yes
checking for _doprnt... no
checking for alarm... yes
checking for alphasort... yes
checking for atexit... yes
checking for bzero... yes
checking for dup2... yes
checking for endgrent... yes
checking for endpwent... yes
checking for fcntl... yes
checking for getcwd... yes
checking for getpeerucred... no
checking for getpeereid... no
checking for gettimeofday... yes
checking for inet_ntoa... yes
checking for memmove... yes
checking for memset... yes
checking for mkdir... yes
checking for scandir... yes
checking for select... yes
checking for socket... yes
checking 

[sheepdog] [PATCH] sheep: fix vid wrap around

2015-02-01 Thread fukumoto . yoshifumi
From: FUKUMOTO Yoshifumi fukumoto.yoshif...@lab.ntt.co.jp

If a vid of a vdi reaches the max number of vid space, creating the snapshot of
the vdi fails.

Example:
$ dog vdi create 00471718 1G
$ dog vdi snapshot 00471718   (repeat 7 times)
failed to read a response
Failed to create snapshot for 00471718: I/O error

This patch fixes the problem.

Signed-off-by: FUKUMOTO Yoshifumi fukumoto.yoshif...@lab.ntt.co.jp
---
 sheep/vdi.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/sheep/vdi.c b/sheep/vdi.c
index 2889df6..4113a4f 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -1398,15 +1398,20 @@ static int fill_vdi_info_range(uint32_t left, uint32_t 
right,
uint32_t i;
const char *name = iocb-name;
 
+   if (!right)
+   return SD_RES_NO_VDI;
inode = malloc(SD_INODE_HEADER_SIZE);
if (!inode) {
sd_err(failed to allocate memory);
ret = SD_RES_NO_MEM;
goto out;
}
-   for (i = right - 1; i  i = left; i--) {
-   if (!test_bit(i, sys-vdi_inuse))
+   for (i = right - 1; i = left; i--) {
+   if (!test_bit(i, sys-vdi_inuse)) {
+   if (!i)
+   break;
continue;
+   }
 
ret = sd_read_object(vid_to_vdi_oid(i), (char *)inode,
 SD_INODE_HEADER_SIZE, 0);
@@ -1420,9 +1425,13 @@ static int fill_vdi_info_range(uint32_t left, uint32_t 
right,
/* Read, delete, clone on snapshots */
if (!vdi_is_snapshot(inode)) {
vdi_found = true;
+   if (!i)
+   break;
continue;
}
if (!vdi_tag_match(iocb, inode))
+   if (!i)
+   break;
continue;
} else {
/*
@@ -1438,6 +1447,8 @@ static int fill_vdi_info_range(uint32_t left, uint32_t 
right,
info-vid = inode-vdi_id;
goto out;
}
+   if (!i)
+   break;
}
ret = vdi_found ? SD_RES_NO_TAG : SD_RES_NO_VDI;
 out:
@@ -1458,7 +1469,7 @@ static int fill_vdi_info(unsigned long left, unsigned 
long right,
switch (ret) {
case SD_RES_NO_VDI:
case SD_RES_NO_TAG:
-   ret = fill_vdi_info_range(left, SD_NR_VDIS - 1, iocb, info);
+   ret = fill_vdi_info_range(left, SD_NR_VDIS, iocb, info);
break;
default:
break;
-- 
1.9.1


-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
https://lists.wpkg.org/mailman/listinfo/sheepdog


Re: [sheepdog] [PATCH] dog: fix to allocate a buffer of backup data for restoring

2015-02-01 Thread Hitoshi Mitake
At Fri, 30 Jan 2015 09:55:30 +0900,
Teruaki Ishizaki wrote:
 
 When a VDI was restored from backup data, the buffer which
 was loaded backup data into was not allocated appropriately.
 
 This patch fixes to allocate the buffer adequately
 
 Signed-off-by: Teruaki Ishizaki ishizaki.teru...@lab.ntt.co.jp
 ---
  dog/vdi.c |5 +
  1 files changed, 5 insertions(+), 0 deletions(-)

Applied, thanks.
Hitoshi

 
 diff --git a/dog/vdi.c b/dog/vdi.c
 index 67e2f0b..4fee789 100644
 --- a/dog/vdi.c
 +++ b/dog/vdi.c
 @@ -2536,6 +2536,7 @@ static uint32_t do_restore(const char *vdiname, int 
 snapid, const char *tag)
  {
   int ret;
   uint32_t vid;
 + uint32_t object_size;
   struct backup_hdr hdr;
   struct obj_backup *backup = xzalloc(sizeof(*backup));
   struct sd_inode *inode = xzalloc(sizeof(*inode));
 @@ -2563,6 +2564,9 @@ static uint32_t do_restore(const char *vdiname, int 
 snapid, const char *tag)
   goto out;
   }
  
 + object_size = (UINT32_C(1)  inode-block_size_shift);
 + backup-data = xzalloc(sizeof(uint8_t) * object_size);
 +
   while (true) {
   ret = xread(STDIN_FILENO, backup,
   sizeof(*backup) - sizeof(backup-data));
 @@ -2592,6 +2596,7 @@ static uint32_t do_restore(const char *vdiname, int 
 snapid, const char *tag)
   break;
   }
   }
 + free(backup-data);
  out:
   free(backup);
   free(inode);
 -- 
 1.7.1
 
 -- 
 sheepdog mailing list
 sheepdog@lists.wpkg.org
 https://lists.wpkg.org/mailman/listinfo/sheepdog
-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
https://lists.wpkg.org/mailman/listinfo/sheepdog


Re: [sheepdog] [PATCH v4] sheepdog: selectable object size support

2015-02-01 Thread Liu Yuan
On Tue, Jan 27, 2015 at 05:35:27PM +0900, Teruaki Ishizaki wrote:
 Previously, qemu block driver of sheepdog used hard-coded VDI object size.
 This patch enables users to handle block_size_shift value for
 calculating VDI object size.
 
 When you start qemu, you don't need to specify additional command option.
 
 But when you create the VDI which doesn't have default object size
 with qemu-img command, you specify block_size_shift option.
 
 If you want to create a VDI of 8MB(1  23) object size,
 you need to specify following command option.
 
  # qemu-img create -o block_size_shift=23 sheepdog:test1 100M

Is it possible to make this option more user friendly? such as

 $ qemu-img create -o object_size=8M sheepdog:test 1G

Thanks
Yuan
-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
https://lists.wpkg.org/mailman/listinfo/sheepdog


[sheepdog] [PATCH 3/3] dog: add a new option to specify the vid space

2015-02-01 Thread Takafumi Fujieda
This patch adds a new option -s bits to dog cluster format to
specify the VID space size.
dog cluster info -v shows the specified VID space size.

Signed-off-by: Takafumi Fujieda fujieda.takaf...@lab.ntt.co.jp
---
 dog/cluster.c |   28 +++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/dog/cluster.c b/dog/cluster.c
index d4a45ec..97c5b3b 100644
--- a/dog/cluster.c
+++ b/dog/cluster.c
@@ -24,6 +24,7 @@ static struct sd_option cluster_options[] = {
{'f', force, false, do not prompt for confirmation},
{'m', multithread, false,
 use multi-thread for 'cluster snapshot save'},
+   {'s', vid_space, true, specify the VID space size},
{'t', strict, false,
 do not serve write request if number of nodes is not sufficient},
{'z', block_size_shift, true, specify the shift num of default
@@ -96,6 +97,10 @@ static int cluster_format(int argc, char **argv)
uint32_t old_nr_vdis;
unsigned long *vdi_inuse = NULL;
size_t bmp_size;
+   if (!cluster_cmd_data.vid_space)
+   new_space = SD_VID_SPACE;
+   else
+   new_space = (uint8_t)cluster_cmd_data.vid_space;
 
rb_for_each_entry(n, sd_nroot, rb) {
struct sd_req info_req;
@@ -177,6 +182,7 @@ static int cluster_format(int argc, char **argv)
hdr.cluster.copies = cluster_cmd_data.copies;
hdr.cluster.copy_policy = cluster_cmd_data.copy_policy;
hdr.cluster.block_size_shift = cluster_cmd_data.block_size_shift;
+   hdr.cluster.vid_space = new_space;
hdr.cluster.ctime = (uint64_t) tv.tv_sec  32 | tv.tv_usec * 1000;
 
if (strlen(cluster_cmd_data.name))
@@ -281,6 +287,12 @@ retry:
printf(%s\n, sd_strerror(rsp-result));
 
if (verbose) {
+   /* show cluster vid space size */
+   if (logs-vid_space) {
+   if (!raw_output)
+   printf(Cluster VID space size: );
+   printf(%d\n, logs-vid_space);
+   }
/* show cluster backend store */
if (!raw_output)
printf(Cluster store: );
@@ -841,7 +853,7 @@ failure:
 static struct subcommand cluster_cmd[] = {
{info, NULL, aprhvT, show cluster information,
 NULL, CMD_NEED_NODELIST, cluster_info, cluster_options},
-   {format, NULL, bctaphzTV, create a Sheepdog store,
+   {format, NULL, bctaphzsTV, create a Sheepdog store,
 NULL, CMD_NEED_NODELIST, cluster_format, cluster_options},
{shutdown, NULL, aphT, stop Sheepdog,
 NULL, 0, cluster_shutdown, cluster_options},
@@ -865,6 +877,7 @@ static struct subcommand cluster_cmd[] = {
 static int cluster_parser(int ch, const char *opt)
 {
uint32_t block_size_shift;
+   uint32_t vid_space;
switch (ch) {
case 'b':
pstrcpy(cluster_cmd_data.name, sizeof(cluster_cmd_data.name),
@@ -889,6 +902,19 @@ static int cluster_parser(int ch, const char *opt)
break;
case 'm':
cluster_cmd_data.multithread = true;
+   case 's':
+   vid_space = (uint32_t)atoi(opt);
+   if (vid_space  26) {
+   sd_err(VID space size is limited to 26 bits.
+Please set VID space size lower than 26);
+   exit(EXIT_FAILURE);
+   } else if (vid_space  24) {
+   sd_err(VID space size is larger than 24 bits.
+Please set VID space size larger than 24);
+   exit(EXIT_FAILURE);
+   }
+   cluster_cmd_data.vid_space = vid_space;
+   break;
case 't':
cluster_cmd_data.strict = true;
break;
-- 
1.7.1

-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
https://lists.wpkg.org/mailman/listinfo/sheepdog


[sheepdog] [PATCH 1/3] sheep, dog: add vid space variables to the structs

2015-02-01 Thread Takafumi Fujieda
This patch adds new variables to some structs (cluster_info,
system_info, etc...) to store the vid space size.

Signed-off-by: Takafumi Fujieda fujieda.takaf...@lab.ntt.co.jp
---
 dog/cluster.c|1 +
 dog/farm/farm.h  |3 ++-
 include/internal_proto.h |6 --
 include/sheepdog_proto.h |   10 ++
 sheep/config.c   |4 +++-
 sheep/sheep_priv.h   |2 ++
 6 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/dog/cluster.c b/dog/cluster.c
index 6a2db6e..2b6864a 100644
--- a/dog/cluster.c
+++ b/dog/cluster.c
@@ -37,6 +37,7 @@ static struct cluster_cmd_data {
uint8_t copy_policy;
uint8_t multithread;
uint8_t block_size_shift;
+   uint8_t vid_space;
bool force;
bool strict;
char name[STORE_LEN];
diff --git a/dog/farm/farm.h b/dog/farm/farm.h
index 6b96c5e..ca25e6f 100644
--- a/dog/farm/farm.h
+++ b/dog/farm/farm.h
@@ -41,7 +41,8 @@ struct snap_log_hdr {
uint8_t copy_number;
uint8_t copy_policy;
uint8_t block_size_shift;
-   uint8_t reserved[21];
+   uint8_t vid_space;
+   uint8_t reserved[20];
 };
 
 struct snap_log {
diff --git a/include/internal_proto.h b/include/internal_proto.h
index 6b24b5c..6637568 100644
--- a/include/internal_proto.h
+++ b/include/internal_proto.h
@@ -219,7 +219,8 @@ struct cluster_info {
uint8_t copy_policy;
enum sd_status status : 8;
uint8_t block_size_shift;
-   uint8_t __pad[3];
+   uint8_t vid_space;
+   uint8_t __pad[2];
uint8_t store[STORE_LEN];
 
/* Node list at cluster_info-epoch */
@@ -234,7 +235,8 @@ struct epoch_log {
uint8_t  disable_recovery;
uint8_t  nr_copies;
uint8_t  copy_policy;
-   uint8_t  __pad[3];
+   uint8_t  vid_space;
+   uint8_t  __pad[2];
uint16_t flags;
char drv_name[STORE_LEN];
struct sd_node nodes[0];
diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index bf3e9df..5db2394 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -101,6 +101,7 @@
  * 60 - 63 ( 4 bits): object type identifier space
  */
 
+#define SD_VID_SPACE 24
 #define VDI_SPACE_SHIFT   32
 #define SD_VDI_MASK 0x00FF
 #define VDI_BIT (UINT64_C(1)  63)
@@ -115,7 +116,7 @@
 #define SD_MAX_VDI_ATTR_KEY_LEN 256U
 #define SD_MAX_VDI_ATTR_VALUE_LEN 65536U
 #define SD_MAX_SNAPSHOT_TAG_LEN 256U
-#define SD_NR_VDIS   (1U  24)
+#define SD_NR_VDIS   (1U  SD_VID_SPACE)
 #define SD_DATA_OBJ_SIZE (UINT64_C(1)  22)
 #define SD_OLD_MAX_VDI_SIZE (SD_DATA_OBJ_SIZE * OLD_MAX_DATA_OBJS)
 #define SD_MAX_VDI_SIZE (SD_DATA_OBJ_SIZE * MAX_DATA_OBJS)
@@ -180,7 +181,8 @@ struct sd_req {
uint32_ttag;
uint32_tnodes_nr;
uint8_t block_size_shift;
-   uint8_t reserved[3];
+   uint8_t vid_space;
+   uint8_t reserved[2];
} cluster;
struct {
uint32_told_vid;
@@ -258,11 +260,11 @@ struct sd_rsp {
uint8_t digest[20];
} hash;
struct {
-   uint32_t__pad1;
+   uint32_t__pad;
uint8_t nr_copies;
uint8_t copy_policy;
uint8_t block_size_shift;
-   uint8_t __pad2;
+   uint8_t vid_space;
} cluster_default;
 
uint32_t__pad[8];
diff --git a/sheep/config.c b/sheep/config.c
index 9518109..548a1e8 100644
--- a/sheep/config.c
+++ b/sheep/config.c
@@ -12,7 +12,7 @@
 #include sheep_priv.h
 
 #define SD_FORMAT_VERSION 0x0006
-#define SD_CONFIG_SIZE 40
+#define SD_CONFIG_SIZE 48
 
 static struct sheepdog_config {
uint64_t ctime;
@@ -24,6 +24,8 @@ static struct sheepdog_config {
uint8_t block_size_shift;
uint16_t version;
uint64_t space;
+   uint8_t vid_space;
+   uint8_t _pad[7];
 } config;
 
 char *config_path;
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 3399a36..5608cbc 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -130,6 +130,8 @@ struct system_info {
 
uint64_t disk_space;
 
+   uint32_t nr_vdis;
+   uint64_t vdi_mask;
DECLARE_BITMAP(vdi_inuse, SD_NR_VDIS);
DECLARE_BITMAP(vdi_deleted, SD_NR_VDIS);
 
-- 
1.7.1

-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
https://lists.wpkg.org/mailman/listinfo/sheepdog


[sheepdog] [PATCH 2/3] sheep, dog: make vid space size variable

2015-02-01 Thread Takafumi Fujieda
This patch changes vid space size from constant to variable.
The vid space size value is assigned to the variables (member of
cluster_info and system_info) only at cluster_make_fs or reloading
config file.
Not the constants, but the variables are always refered.

Signed-off-by: Takafumi Fujieda fujieda.takaf...@lab.ntt.co.jp
---
 dog/cluster.c |   38 +++---
 dog/common.c  |   32 +---
 dog/dog.h |3 ++-
 dog/farm/farm.c   |   16 +++-
 dog/node.c|3 ++-
 dog/vdi.c |   22 +++---
 include/sheepdog_proto.h  |8 
 sheep/config.c|   16 +++-
 sheep/gateway.c   |   23 +--
 sheep/group.c |   10 --
 sheep/journal.c   |3 ++-
 sheep/nfs/fs.c|4 ++--
 sheep/nfs/nfs.c   |4 ++--
 sheep/object_cache.c  |   13 +++--
 sheep/object_list_cache.c |2 +-
 sheep/ops.c   |   35 ---
 sheep/plain_store.c   |   25 +++--
 sheep/recovery.c  |   10 ++
 sheep/request.c   |3 ++-
 sheep/sheep_priv.h|4 ++--
 sheep/vdi.c   |   43 ++-
 sheepfs/volume.c  |2 +-
 22 files changed, 224 insertions(+), 95 deletions(-)

diff --git a/dog/cluster.c b/dog/cluster.c
index 2b6864a..d4a45ec 100644
--- a/dog/cluster.c
+++ b/dog/cluster.c
@@ -71,9 +71,9 @@ static int list_store(void)
return EXIT_SYSFAIL;
 }
 
-static bool no_vdi(const unsigned long *vdis)
+static bool no_vdi(const unsigned long *vdis, uint32_t nr_vdis)
 {
-   return find_next_bit(vdis, SD_NR_VDIS, 0) == SD_NR_VDIS;
+   return find_next_bit(vdis, nr_vdis, 0) == nr_vdis;
 }
 
 #define FORMAT_PRINT   \
@@ -90,8 +90,12 @@ static int cluster_format(int argc, char **argv)
struct sd_rsp *rsp = (struct sd_rsp *)hdr;
struct timeval tv;
char store_name[STORE_LEN];
-   static DECLARE_BITMAP(vdi_inuse, SD_NR_VDIS);
struct sd_node *n;
+   uint8_t new_space = 0;
+   uint8_t old_space = 0;
+   uint32_t old_nr_vdis;
+   unsigned long *vdi_inuse = NULL;
+   size_t bmp_size;
 
rb_for_each_entry(n, sd_nroot, rb) {
struct sd_req info_req;
@@ -110,6 +114,17 @@ static int cluster_format(int argc, char **argv)
return EXIT_FAILURE;
}
 
+   if (!old_space)
+   if (!cinfo.vid_space)
+   old_space = SD_VID_SPACE;
+   else
+   old_space = cinfo.vid_space;
+   else
+   if (cinfo.vid_space  old_space != cinfo.vid_space) {
+   sd_err(there are nodes have different VID 
space);
+   return EXIT_FAILURE;
+   }
+
if (n-nr_vnodes != 0) {
if ((cinfo.flags  SD_CLUSTER_FLAG_AUTO_VNODES)
 cluster_cmd_data.fixed_vnodes) {
@@ -136,19 +151,25 @@ static int cluster_format(int argc, char **argv)
confirm(info);
}
 
+   old_nr_vdis = (1U  old_space);
+   bmp_size = sizeof(unsigned long) * BITS_TO_LONGS(old_nr_vdis);
+   vdi_inuse = (unsigned long *)malloc(bmp_size);
+
sd_init_req(hdr, SD_OP_READ_VDIS);
-   hdr.data_length = sizeof(vdi_inuse);
+   hdr.data_length = bmp_size;
 
ret = dog_exec_req(sd_nid, hdr, vdi_inuse);
if (ret  0)
return EXIT_SYSFAIL;
if (rsp-result != SD_RES_SUCCESS) {
sd_err(%s, sd_strerror(rsp-result));
+   free(vdi_inuse);
return EXIT_FAILURE;
}
 
-   if (!no_vdi(vdi_inuse))
+   if (!no_vdi(vdi_inuse, old_nr_vdis))
confirm(FORMAT_PRINT);
+   free(vdi_inuse);
 
gettimeofday(tv, NULL);
 
@@ -401,7 +422,8 @@ static void fill_cb(struct sd_index *idx, void *arg, int 
ignore)
 
 static void fill_object_tree(uint32_t vid, const char *name, const char *tag,
 uint32_t snapid, uint32_t flags,
-const struct sd_inode *i, void *data)
+const struct sd_inode *i, void *data,
+uint32_t nr_vdis)
 {
uint64_t vdi_oid = vid_to_vdi_oid(vid), vmstate_oid;
uint32_t vdi_id;
@@ -548,6 +570,7 @@ static int load_snapshot(int argc, char **argv)
cluster_cmd_data.copies = hdr.copy_number;
cluster_cmd_data.copy_policy = hdr.copy_policy;
cluster_cmd_data.block_size_shift = hdr.block_size_shift;
+   cluster_cmd_data.vid_space = hdr.vid_space;
if (cluster_format(0, NULL) != SD_RES_SUCCESS)
  

[sheepdog] [PATCH 0/3] sheep, dog: configurable vid space

2015-02-01 Thread Takafumi Fujieda
Current, deleted vids are not reused, without cutting relations.
If snapshots of many online vdis in a cluster are created continuously,
the vid space will be exhausted.

These patches make vid space size configurable from 24 bits to 26 bits
by using the reserved bits in the oid.
A new option -s bits is added to dog cluster format for specify the vid 
space size.
(The default vid space size is 24 bits)

These patches don't care compatibility of object files and cluster snapshot data
created under different vid spaces.
If you want to change your cluster's vid space keeping existing vdis,
the cluster must be shutdowned and all vdis should be outputted
by using qemu-img and dog vdi backup.

Takafumi Fujieda (3):
  sheep, dog: add vid space variables to the structs
  sheep, dog: make vid space size variable
  dog: add a new option to specify the vid space

 dog/cluster.c |   67 +++-
 dog/common.c  |   32 +-
 dog/dog.h |3 +-
 dog/farm/farm.c   |   16 ++-
 dog/farm/farm.h   |3 +-
 dog/node.c|3 +-
 dog/vdi.c |   22 ++-
 include/internal_proto.h  |6 +++-
 include/sheepdog_proto.h  |   18 +++-
 sheep/config.c|   20 -
 sheep/gateway.c   |   23 +---
 sheep/group.c |   10 +-
 sheep/journal.c   |3 +-
 sheep/nfs/fs.c|4 +-
 sheep/nfs/nfs.c   |4 +-
 sheep/object_cache.c  |   13 +
 sheep/object_list_cache.c |2 +-
 sheep/ops.c   |   35 +++-
 sheep/plain_store.c   |   25 ++---
 sheep/recovery.c  |   10 ---
 sheep/request.c   |3 +-
 sheep/sheep_priv.h|6 +++-
 sheep/vdi.c   |   43 +---
 sheepfs/volume.c  |2 +-
 24 files changed, 269 insertions(+), 104 deletions(-)

-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
https://lists.wpkg.org/mailman/listinfo/sheepdog