[sheepdog] [PATCH v1 0/4] create onode before uploading object completed

Robin Dong robin.k.dong at gmail.com
Fri Feb 21 07:47:29 CET 2014


From: Robin Dong <sanbai at taobao.com>

At present, the implemention of swift interface for creating object in sheepdog
is:

1. lock container
2. check whether the onode with same object name is exists.
3. unlock container
4. upload object
5. create onode

this sequence have a problem: if two clients uploading same objects
concurrently, it will create two objects with same names in container.
To avoid duplicated names, we must put "create onode" operation in container
lock regions.

Therefore we need to change the processes of creating object to:

1. lock container
2. check whether the onode is exists.
3. allocate data space for object, and create onode, then write it done
4. unlock container
5. upload object

this routine will avoid uploading duplicated objects.

There is an exception on the new routine: if the client halt the uploading
progress, we will have a "uploading uncompleted" onode.

The solution is: we can add code for onode to identify its status.
A new onode will be set to "INIT", and after uploading completed, the onode will
be set to  "COMPLETED". So, when users try to use swift interface to GET a
"uncompleted" object, sheep will find out the onode is "INIT" which means
"not completed", so sheep will return "partial content"for http request,
and user could DELETE the object and upload it again.

Signed-off-by: Robin Dong <sanbai at taobao.com>
---
Robin Dong (4):
  sheep/http: add nolock version for some functions
  sheep/http: change routine of kv_create_object()
  sheep/cluster: let local implementation of lock() support embedding
  sheep/http: add flag for onode

 sheep/cluster/local.c |   3 +
 sheep/http/kv.c       | 257 +++++++++++++++++++++++++++++++++++++-------------
 sheep/http/swift.c    |   3 +
 3 files changed, 197 insertions(+), 66 deletions(-)

-- 
1.7.12.4




More information about the sheepdog mailing list