From 06a2d7a269b2940d3018071c58831385580a32f3 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 15 Dec 2010 10:56:18 -0800 Subject: [PATCH] mds: Save straydn in mdr so it's consistent across retry attempts. Otherwise, we could choose new stray dirs and fail to get all the locks we needed (while leaving old strays locked forever!). Signed-off-by: Greg Farnum --- src/mds/MDCache.h | 7 ++++--- src/mds/Server.cc | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 957dceb2273e9..7b2b94998e5c3 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -259,6 +259,7 @@ struct MDRequest : public Mutation { // store up to two sets of dn vectors, inode pointers, for request path1 and path2. vector dn[2]; + CDentry *straydn; CInode *in[2]; snapid_t snapid; @@ -323,7 +324,7 @@ struct MDRequest : public Mutation { MDRequest() : ref(1), session(0), item_session_request(this), - client_request(0), snapid(CEPH_NOSNAP), tracei(0), tracedn(0), + client_request(0), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0), alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false), slave_request(0), internal_op(-1), @@ -334,7 +335,7 @@ struct MDRequest : public Mutation { Mutation(ri), ref(1), session(0), item_session_request(this), - client_request(req), snapid(CEPH_NOSNAP), tracei(0), tracedn(0), + client_request(req), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0), alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false), slave_request(0), internal_op(-1), @@ -345,7 +346,7 @@ struct MDRequest : public Mutation { Mutation(ri, by), ref(1), session(0), item_session_request(this), - client_request(0), snapid(CEPH_NOSNAP), tracei(0), tracedn(0), + client_request(0), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0), alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false), slave_request(0), internal_op(-1), diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 35af027dc6ea2..c02526ac5e226 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -4045,12 +4045,16 @@ void Server::handle_client_unlink(MDRequest *mdr) } } - CDentry *straydn = 0; - if (dnl->is_primary()) { + // -- create stray dentry? -- + CDentry *straydn = mdr->straydn; + if (dnl->is_primary() && !straydn) { straydn = mdcache->get_or_create_stray_dentry(dnl->get_inode()); - mdr->pin(straydn); // pin it. - dout(10) << " straydn is " << *straydn << dendl; + mdr->pin(straydn); + mdr->straydn = straydn; } + if (straydn) + dout(10) << " straydn is " << *straydn << dendl; + // lock set rdlocks, wrlocks, xlocks; @@ -4499,12 +4503,14 @@ void Server::handle_client_rename(MDRequest *mdr) dout(10) << " this is a link merge" << dendl; // -- create stray dentry? -- - CDentry *straydn = 0; - if (destdnl->is_primary() && !linkmerge) { + CDentry *straydn = mdr->straydn; + if (destdnl->is_primary() && !linkmerge && !straydn) { straydn = mdcache->get_or_create_stray_dentry(destdnl->get_inode()); mdr->pin(straydn); - dout(10) << "straydn is " << *straydn << dendl; + mdr->straydn = straydn; } + if (straydn) + dout(10) << " straydn is " << *straydn << dendl; // -- prepare witness list -- /* -- 2.39.5