From: Liu Yuan <tailai...@taobao.com>

This is for tests sciprts.

Signed-off-by: Liu Yuan <tailai...@taobao.com>
---
 collie/collie.c |    1 +
 collie/vdi.c    |   12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/collie/collie.c b/collie/collie.c
index b112b73..32c044a 100644
--- a/collie/collie.c
+++ b/collie/collie.c
@@ -38,6 +38,7 @@ static const struct sd_option collie_options[] = {
        {'s', "snapshot", 1, "specify a snapshot id or tag name"},
        {'x', "exclusive", 0, "write in an exclusive mode"},
        {'d', "delete", 0, "delete a key"},
+       {'C', "cache", 0, "enable object cache"},
 
        /* cluster options */
        {'b', "store", 1, "specify backend store"},
diff --git a/collie/vdi.c b/collie/vdi.c
index e4f4f65..2fff634 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -23,6 +23,7 @@ struct vdi_cmd_data {
        int exclusive;
        int delete;
        int prealloc;
+       int cache;
 } vdi_cmd_data = { ~0, };
 
 struct get_vdi_info {
@@ -1248,6 +1249,9 @@ static int vdi_write(int argc, char **argv)
                        flags = SD_FLAG_CMD_COW;
                }
 
+               if (vdi_cmd_data.cache)
+                       flags |= SD_FLAG_CMD_CACHE;
+
                remain = len;
                while (remain > 0) {
                        ret = read(STDIN_FILENO, buf + (len - remain), remain);
@@ -1281,7 +1285,8 @@ static int vdi_write(int argc, char **argv)
 
                if (create) {
                        ret = sd_write_object(vid_to_vdi_oid(vid), 0, &vid, 
sizeof(vid),
-                                             SD_INODE_HEADER_SIZE + 
sizeof(vid) * idx, 0,
+                                             SD_INODE_HEADER_SIZE + 
sizeof(vid) * idx,
+                                             flags & ~SD_FLAG_CMD_COW,
                                              inode->nr_copies, 0);
                        if (ret) {
                                ret = EXIT_FAILURE;
@@ -1505,7 +1510,7 @@ static struct subcommand vdi_cmd[] = {
         NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG, 
vdi_resize},
        {"read", "<vdiname> [<offset> [<len>]]", "saph", "read data from an 
image",
         NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG, vdi_read},
-       {"write", "<vdiname> [<offset> [<len>]]", "aph", "write data to an 
image",
+       {"write", "<vdiname> [<offset> [<len>]]", "apCh", "write data to an 
image",
         NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG, vdi_write},
        {NULL,},
 };
@@ -1539,6 +1544,9 @@ static int vdi_parser(int ch, char *opt)
        case 'd':
                vdi_cmd_data.delete = 1;
                break;
+       case 'C':
+               vdi_cmd_data.cache = 1;
+               break;
        }
 
        return 0;
-- 
1.7.10.2

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

Reply via email to