Function referenced from multiple places,
it should not be defined plain_store.c, so move to the appropriate location.

Signed-off-by: Masaki Saeki <saeki.mas...@po.ntts.co.jp>
---
 include/util.h      |    1 +
 lib/util.c          |   16 ++++++++++++++++
 sheep/md.c          |   11 +++++++++++
 sheep/plain_store.c |   27 ---------------------------
 sheep/sheep_priv.h  |    2 --
 5 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/include/util.h b/include/util.h
index f214d89..aba7b32 100644
--- a/include/util.h
+++ b/include/util.h
@@ -93,6 +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);
 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 96efde2..73cf1af 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -111,6 +111,22 @@ void *xvalloc(size_t size)
        return ret;
 }
 
+/* preallocate the whole object */
+int prealloc(int fd, uint32_t size)
+{
+       int ret = xfallocate(fd, 0, 0, size);
+       if (ret < 0) {
+               if (errno != ENOSYS && errno != EOPNOTSUPP) {
+                       sd_err("failed to preallocate space, %m");
+                       return ret;
+               }
+
+               return xftruncate(fd, size);
+       }
+
+       return 0;
+}
+
 static ssize_t _read(int fd, void *buf, size_t len)
 {
        ssize_t nr;
diff --git a/sheep/md.c b/sheep/md.c
index a90fdb9..15687b2 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -142,6 +142,17 @@ static struct disk *path_to_disk(const char *path)
        return rb_search(&md.root, &key, rb, disk_cmp);
 }
 
+size_t get_store_objsize(uint64_t oid)
+{
+       if (is_erasure_oid(oid)) {
+               uint8_t policy = get_vdi_copy_policy(oid_to_vid(oid));
+               int d;
+               ec_policy_to_dp(policy, &d, NULL);
+               return get_vdi_object_size(oid_to_vid(oid)) / d;
+       }
+       return get_objsize(oid, get_vdi_object_size(oid_to_vid(oid)));
+}
+
 static int get_total_object_size(uint64_t oid, const char *wd, uint32_t epoch,
                                 uint8_t ec_index, struct vnode_info *vinfo,
                                 void *total)
diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index 92f9a14..fef01ec 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -381,33 +381,6 @@ int default_read(uint64_t oid, const struct siocb *iocb)
        return ret;
 }
 
-/* Preallocate the whole object to get a better filesystem layout. */
-int prealloc(int fd, uint32_t size)
-{
-       int ret = xfallocate(fd, 0, 0, size);
-       if (ret < 0) {
-               if (errno != ENOSYS && errno != EOPNOTSUPP) {
-                       sd_err("failed to preallocate space, %m");
-                       return ret;
-               }
-
-               return xftruncate(fd, size);
-       }
-
-       return 0;
-}
-
-size_t get_store_objsize(uint64_t oid)
-{
-       if (is_erasure_oid(oid)) {
-               uint8_t policy = get_vdi_copy_policy(oid_to_vid(oid));
-               int d;
-               ec_policy_to_dp(policy, &d, NULL);
-               return get_vdi_object_size(oid_to_vid(oid)) / d;
-       }
-       return get_objsize(oid, get_vdi_object_size(oid_to_vid(oid)));
-}
-
 int default_create_and_write(uint64_t oid, const struct siocb *iocb)
 {
        char path[PATH_MAX], tmp_path[PATH_MAX];
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 46d0ba9..f102fc7 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -455,8 +455,6 @@ int local_req_wait(struct request_iocb *iocb);
 
 void local_request_init(void);
 
-int prealloc(int fd, uint32_t size);
-
 int objlist_cache_insert(uint64_t oid);
 void objlist_cache_remove(uint64_t oid);
 
-- 
1.7.1



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

Reply via email to