[sheepdog] [PATCH] sheep journal:fix the parameter type of 'size' passed to 'int prealloc(int fd, uint32_t size)'

张灿群 zhangcanqun_sd at 163.com
Thu Apr 9 09:30:21 CEST 2015

When i start sheep daemon with journal,the daemon couldn't start.
sheep -j dir=/sdac,size=160G,skip=1  -l dir=/var/log/,level=err,format=server  /sdad/ -n -D -y -p 7000 -c zookeeper:host-0-31:2181,host-0-32:2181,host-0-38:2181
Apr 09 14:49:35  ERROR [main] prealloc(120) failed to preallocate space, Invalid argument
Apr 09 14:49:35  ERROR [main] prealloc(121) size is 0    // I printf the value
Apr 09 14:49:35  ERROR [main] create_journal_file(73) prealloc journal_file0 Invalid argument

so the value of 'size' was corrupted when the type changed.

diff --git a/include/util.h b/include/util.h
index c5b5ac9..bad09fb 100644
--- a/include/util.h
+++ b/include/util.h
@@ -93,7 +93,7 @@ void *xzalloc(size_t size);
 void *xrealloc(void *ptr, size_t size);
 void *xcalloc(size_t nmemb, size_t size);
 void *xvalloc(size_t size);
-int prealloc(int fd, uint32_t size);
+int prealloc(int fd, uint64_t size);
 ssize_t xread(int fd, void *buf, size_t len);
 ssize_t xwrite(int fd, const void *buf, size_t len);
 ssize_t xpread(int fd, void *buf, size_t count, off_t offset);
diff --git a/lib/util.c b/lib/util.c
index aad6d96..583f394 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -112,7 +112,7 @@ void *xvalloc(size_t size)
 /* preallocate the whole object */
-int prealloc(int fd, uint32_t size)
+int prealloc(int fd, uint64_t size)
        int ret = xfallocate(fd, 0, 0, size);
        if (ret < 0) {

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/sheepdog/attachments/20150409/9f8a0173/attachment-0003.html>

More information about the sheepdog mailing list