From: Sage Weil Date: Mon, 26 May 2008 19:34:49 +0000 (-0700) Subject: synclient: thrashlinks mixup X-Git-Tag: v0.3~170^2~58 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cde2c54d6c78c123e5d96276ed4dc5b3ed7a0f7e;p=ceph.git synclient: thrashlinks mixup --- diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index 1761b306ea0e..93c10bab3836 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -2836,116 +2836,119 @@ int SyntheticClient::thrash_links(const char *basedir, int dirs, int files, int if (time_to_stop()) return 0; - for (int k=0; krename(dst.c_str(), "/tmp") == 0) { + client->rename(src.c_str(), dst.c_str()); + client->rename("/tmp", src.c_str()); + } + continue; + } + + // pick a dest dir string src = basedir; { char t[80]; - for (int d=0; drename(dst.c_str(), "/tmp") == 0) { - client->rename(src.c_str(), dst.c_str()); - client->rename("/tmp", src.c_str()); - } - continue; - } - - // pick a dest dir - string src = basedir; - { - char t[80]; - for (int d=0; dmknod(src.c_str(), 0755); - client->rename(src.c_str(), dst.c_str()); - break; - case 1: - client->mknod(src.c_str(), 0755); - client->unlink(dst.c_str()); - client->link(src.c_str(), dst.c_str()); - break; - case 2: client->unlink(src.c_str()); break; - case 3: client->unlink(dst.c_str()); break; - //case 4: client->mknod(src.c_str(), 0755); break; - //case 5: client->mknod(dst.c_str(), 0755); break; - } + + int o = rand() % 4; + switch (o) { + case 0: + client->mknod(src.c_str(), 0755); + client->rename(src.c_str(), dst.c_str()); + break; + case 1: + client->mknod(src.c_str(), 0755); + client->unlink(dst.c_str()); + client->link(src.c_str(), dst.c_str()); + break; + case 2: client->unlink(src.c_str()); break; + case 3: client->unlink(dst.c_str()); break; + //case 4: client->mknod(src.c_str(), 0755); break; + //case 5: client->mknod(dst.c_str(), 0755); break; + } + } + return 0; } - return 0; - - // now link shit up - for (int i=0; ilink(file.c_str(), ln.c_str()); } - sprintf(f, "/ln.%d", i); - ln += f; - - client->link(file.c_str(), ln.c_str()); } - return 0; }