[sheepdog] [PATCH] object cache: remove flock for IO request

Liu Yuan namei.unix at gmail.com
Sat Aug 25 11:32:56 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

To quote from Kazutaka:
"It is okay to read the older data if the vm doesn't receive the ack of
the write requests yet."

So we don't need locks either for object cache.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/object_cache.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index d3fada3..a722259 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -319,17 +319,7 @@ static int read_cache_object_noupdate(uint32_t vid, uint32_t idx, void *buf,
 		goto out;
 	}
 
-	if (flock(fd, LOCK_SH) < 0) {
-		ret = SD_RES_EIO;
-		eprintf("%m\n");
-		goto out_close;
-	}
 	size = xpread(fd, buf, count, offset);
-	if (flock(fd, LOCK_UN) < 0) {
-		ret = SD_RES_EIO;
-		eprintf("%m\n");
-		goto out_close;
-	}
 
 	if (size != count) {
 		eprintf("size %zu, count:%zu, offset %jd %m\n",
@@ -366,17 +356,7 @@ static int write_cache_object_noupdate(uint32_t vid, uint32_t idx, void *buf,
 		goto out;
 	}
 
-	if (flock(fd, LOCK_EX) < 0) {
-		ret = SD_RES_EIO;
-		eprintf("%m\n");
-		goto out_close;
-	}
 	size = xpwrite(fd, buf, count, offset);
-	if (flock(fd, LOCK_UN) < 0) {
-		ret = SD_RES_EIO;
-		eprintf("%m\n");
-		goto out_close;
-	}
 
 	if (size != count) {
 		eprintf("size %zu, count:%zu, offset %jd %m\n",
-- 
1.7.1




More information about the sheepdog mailing list