[sheepdog] [PATCH 4/6] store: return SD_RES_NO_OBJ when object size is zero

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Sep 4 07:03:46 CEST 2012


If clients read objects which is just being created, the size of read
data can be zero and clients get a SD_RES_EIO error.  Sheep leaves
cluster when the SD_RES_EIO error happens, so we should return
SD_RES_NO_OBJ in this case.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/plain_store.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index cd1c41b..dc0e2d8 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -231,14 +231,16 @@ static int default_read_from_path(uint64_t oid, char *path,
 		return err_to_sderr(oid, errno);
 
 	size = xpread(fd, iocb->buf, iocb->length, iocb->offset);
-	if (size != iocb->length) {
+	if (size == 0) {
+		/* the requested object is being created */
+		ret = SD_RES_NO_OBJ;
+	} else if (size != iocb->length) {
 		eprintf("failed to read object %"PRIx64", path=%s, offset=%"
 			PRId64", size=%"PRId32", result=%zd, %m\n", oid, path,
 			iocb->offset, iocb->length, size);
 		ret = SD_RES_EIO;
-		goto out;
 	}
-out:
+
 	close(fd);
 
 	return ret;
-- 
1.7.2.5




More information about the sheepdog mailing list