[sheepdog] [PATCH 1/2] farm: fix read_working_object()

Liu Yuan namei.unix at gmail.com
Wed May 23 11:03:59 CEST 2012


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

We should clear O_DIRECT flag for vdi object

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/farm/farm.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/sheep/farm/farm.c b/sheep/farm/farm.c
index fdb237e..1575d24 100644
--- a/sheep/farm/farm.c
+++ b/sheep/farm/farm.c
@@ -348,12 +348,15 @@ static void *read_working_object(uint64_t oid, uint64_t offset,
 {
 	void *buf = NULL;
 	char path[PATH_MAX];
-	int fd;
+	int fd, flags = def_open_flags;
 	size_t size;
 
 	snprintf(path, sizeof(path), "%s%016" PRIx64, obj_path, oid);
 
-	fd = open(path, def_open_flags);
+	if (is_vdi_obj(oid))
+		flags &= ~O_DIRECT;
+
+	fd = open(path, flags);
 	if (fd < 0) {
 		dprintf("object %"PRIx64" not found\n", oid);
 		goto out;
@@ -367,7 +370,8 @@ static void *read_working_object(uint64_t oid, uint64_t offset,
 
 	size = xpread(fd, buf, length, offset);
 	if (length != size) {
-		eprintf("object read error. %m\n");
+		eprintf("size %zu len %"PRIu32" off %"PRIu64" %m\n", size,
+			length, offset);
 		free(buf);
 		buf = NULL;
 		goto out;
-- 
1.7.10.2




More information about the sheepdog mailing list