[PATCH 2/3] chunkd: pass data-length to PUT backend init

Jeff Garzik <[email protected]> Thu, 15 Jul 2010 14:20:45 -0400
Newsgroups org.kernel.vger.hail-devel
Message-ID <[email protected]>
commit 7a032e72bee324d8503d0c296aa940b05c8a12b2
Author: Jeff Garzik <[email protected]>
Date:   Thu Jul 15 13:50:30 2010 -0400

    chunkd: Pass PUT data length to new-object backend storage method
    
    It is useful to know the size of the object at creation time.
    
    Signed-off-by: Jeff Garzik <[email protected]>

 chunkd/be-fs.c  |    1 +
 chunkd/chunkd.h |    4 +++-
 chunkd/object.c |    6 ++++--
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/chunkd/be-fs.c b/chunkd/be-fs.c
index 5c97388..671c8fd 100644
--- a/chunkd/be-fs.c
+++ b/chunkd/be-fs.c
@@ -316,6 +316,7 @@ static bool key_valid(const void *key, size_t key_len)
 
 struct backend_obj *fs_obj_new(uint32_t table_id,
 			       const void *key, size_t key_len,
+			       uint64_t data_len,
 			       enum chunk_errcode *err_code)
 {
 	struct fs_obj *obj;
diff --git a/chunkd/chunkd.h b/chunkd/chunkd.h
index 1e3741a..f0cd409 100644
--- a/chunkd/chunkd.h
+++ b/chunkd/chunkd.h
@@ -258,7 +258,9 @@ struct fs_obj_lister {
 extern int fs_open(void);
 extern void fs_close(void);
 extern void fs_free(void);
-extern struct backend_obj *fs_obj_new(uint32_t table_id, const void *kbuf, size_t klen,
+extern struct backend_obj *fs_obj_new(uint32_t table_id,
+				      const void *kbuf, size_t klen,
+				      uint64_t data_len,
 				      enum chunk_errcode *err_code);
 extern struct backend_obj *fs_obj_open(uint32_t table_id, const char *user,
 				       const void *kbuf, size_t klen,
diff --git a/chunkd/object.c b/chunkd/object.c
index badd199..fb48848 100644
--- a/chunkd/object.c
+++ b/chunkd/object.c
@@ -223,7 +223,8 @@ bool object_put(struct client *cli)
 	if (!cli->out_ce)
 		return cli_err(cli, che_InternalError, true);
 
-	cli->out_bo = fs_obj_new(cli->table_id, cli->key, cli->key_len, &err);
+	cli->out_bo = fs_obj_new(cli->table_id, cli->key, cli->key_len,
+				 content_len, &err);
 	if (!cli->out_bo)
 		return cli_err(cli, err, true);
 
@@ -374,7 +375,8 @@ static void worker_cp_thr(struct worker_info *wi)
 		goto out;
 
 	cli->out_bo = out_obj = fs_obj_new(cli->table_id,
-					   cli->key, cli->key_len, &err);
+					   cli->key, cli->key_len,
+					   obj->size, &err);
 	if (!cli->out_bo)
 		goto out;