[sheepdog] [PATCH] md: fix move_object
Liu Yuan
namei.unix at gmail.com
Wed May 15 09:28:04 CEST 2013
From: Liu Yuan <tailai.ly at taobao.com>
Recovery thread and main thread might try to recover the same object.
Either one succeeds, the other will fail and proceed and end up trying
to move the object to where it is already in place, in this case we
simply return.
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/md.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/sheep/md.c b/sheep/md.c
index 6317044..69210e2 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -513,6 +513,14 @@ static int check_and_move(uint64_t oid, uint32_t epoch, char *path)
if (get_old_new_path(oid, epoch, path, old, new) < 0)
return SD_RES_EIO;
+ /*
+ * Recovery thread and main thread might try to recover the same object.
+ * Either one succeeds, the other will fail and proceed and end up
+ * trying to move the object to where it is already in place, in this
+ * case we simply return.
+ */
+ if (!strcmp(old, new))
+ return SD_RES_SUCCESS;
/* We can't use rename(2) accross device */
if (move_object(oid, old, new) < 0) {
--
1.7.9.5
More information about the sheepdog
mailing list