On 2015/03/18 11:50, Saeki Masaki wrote:
On 2015/03/18 10:44, Liu Yuan wrote:
On Tue, Mar 17, 2015 at 06:03:26PM +0900, Saeki Masaki wrote:
Current sheepdog stores whole objects in single directory like 
"/var/lib/sheepdog/obj"
This mechanism is difficult to handle massive files when increasing cluster 
volume.

In particular, inode object having special informations about VDI,
so it is preferable to divide.

new storage type named "tree"
It separates the inode object and data object.

How to use ,
specify the --store option at the time format

dog cluster format --store tree

v2: refactor using common functions for store driver
     use check_store_type to identify tree store_driver

Signed-off-by: Masaki Saeki <[email protected]>
---
  sheep/Makefile.am         |    2 +-
  sheep/sheep_priv.h        |   21 ++
  sheep/store/common.c      |    5 +
  sheep/store/md.c          |   14 +
  sheep/store/plain_store.c |    1 +
  sheep/store/tree_store.c  |  757 +++++++++++++++++++++++++++++++++++++++++++++
  6 files changed, 799 insertions(+), 1 deletions(-)
  create mode 100644 sheep/store/tree_store.c

diff --git a/sheep/Makefile.am b/sheep/Makefile.am
index 3ddd761..9dedb03 100644
--- a/sheep/Makefile.am
+++ b/sheep/Makefile.am
@@ -28,7 +28,7 @@ sheep_SOURCES        = sheep.c group.c request.c gateway.c 
vdi.c \
                journal.c ops.c recovery.c cluster/local.c \
                object_cache.c object_list_cache.c \
                store/common.c store/md.c \
-              store/plain_store.c \
+              store/plain_store.c store/tree_store.c \
                config.c migrate.c

  if BUILD_HTTP
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index e58901f..51e686f 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -84,6 +84,11 @@ enum REQUST_STATUS {
      REQUEST_DROPPED
  };

+enum store_id {
+    PLAIN_STORE,
+    TREE_STORE
+};
+
  struct request_iocb {
      uint32_t count;
      int efd;
@@ -235,6 +240,7 @@ struct vdi_info {

  struct store_driver {
      struct list_node list;
+    enum store_id id;
      const char *name;
      int (*init)(void);
      bool (*exist)(uint64_t oid, uint8_t ec_index);
@@ -269,6 +275,20 @@ int default_format(void);
  int default_remove_object(uint64_t oid, uint8_t ec_index);
  int default_get_hash(uint64_t oid, uint32_t epoch, uint8_t *sha1);
  int default_purge_obj(void);
+
+int tree_init(void);
+bool tree_exist(uint64_t oid, uint8_t ec_index);
+int tree_create_and_write(uint64_t oid, const struct siocb *iocb);
+int tree_write(uint64_t oid, const struct siocb *iocb);
+int tree_read(uint64_t oid, const struct siocb *iocb);
+int tree_link(uint64_t oid, uint32_t tgt_epoch);
+int tree_update_epoch(uint32_t epoch);
+int tree_cleanup(void);
+int tree_format(void);
+int tree_remove_object(uint64_t oid, uint8_t ec_index);
+int tree_get_hash(uint64_t oid, uint32_t epoch, uint8_t *sha1);
+int tree_purge_obj(void);
+
  int for_each_object_in_wd(int (*func)(uint64_t, const char *, uint32_t,
                        uint8_t, struct vnode_info *, void *),
                bool, void *);
@@ -404,6 +424,7 @@ void queue_cluster_request(struct request *req);
  int prepare_iocb(uint64_t oid, const struct siocb *iocb, bool create);
  int err_to_sderr(const char *path, uint64_t oid, int err);
  int discard(int fd, uint64_t start, uint32_t end);
+bool check_store_type(enum store_id id);

Better rename check_store_type as store_id_match(enum store_id)


  int update_epoch_log(uint32_t epoch, struct sd_node *nodes, size_t nr_nodes);
  int inc_and_log_epoch(void);
diff --git a/sheep/store/common.c b/sheep/store/common.c
index 8959392..aa2858d 100644
--- a/sheep/store/common.c
+++ b/sheep/store/common.c
@@ -102,6 +102,11 @@ int discard(int fd, uint64_t start, uint32_t end)
      return ret;
  }

+bool check_store_type(enum store_id id)
+{
+    return (sd_store->id == id);
+}
+
  int update_epoch_log(uint32_t epoch, struct sd_node *nodes, size_t nr_nodes)
  {
      int ret, len, nodes_len;
diff --git a/sheep/store/md.c b/sheep/store/md.c
index 87ab759..ed95c98 100644
--- a/sheep/store/md.c
+++ b/sheep/store/md.c
@@ -212,6 +212,20 @@ static int for_each_object_in_path(const char *path,
          if (unlikely(!strncmp(d->d_name, ".", 1)))
              continue;

I think for_each_object_in_path family might be moved to common.c


I try to check the code for the above comments,
for_each_object_in_wd and for_each_object_in_stale use "md.lock"
So it is not suitable for moving to common.c.

Although I think there is room to improve in the future,
But I think that we should step on the stage.

Regards, Saeki.

(snip)

It seems that tree.c and plain.c still share a great portion of lines. It is
okay to keep them for fast development, but I hope later we can drag as many
lines as possible to common.c.

Thanks,
Yuan


Thank for your advice.
I'll make patch reflecting the noted.

Thanks,Saeki.





--
sheepdog mailing list
[email protected]
https://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to