From: "Yan, Zheng" <zheng.z.yan@intel.com>
To: Sage Weil <sage@inktank.com>
Cc: ceph-devel@vger.kernel.org, greg@inktank.com
Subject: Re: [PATCH 07/30] mds: fix straydn race
Date: Mon, 27 May 2013 10:09:47 +0800 [thread overview]
Message-ID: <51A2C06B.7000802@intel.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1305230943310.32642@cobra.newdream.net>
updated version
---
From 6cd1c8c076d7afa1c4e2bd247e34cee45b3ef562 Mon Sep 17 00:00:00 2001
From: "Yan, Zheng" <zheng.z.yan@intel.com>
Date: Fri, 5 Apr 2013 19:50:35 +0800
Subject: [PATCH 07/33] mds: fix straydn race
For unlink/rename request, the target dentry's linkage may change
before all locks are acquired. So we need check if the existing stray
dentry is valid.
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
---
src/mds/Mutation.cc | 7 +++++++
src/mds/Mutation.h | 1 +
src/mds/Server.cc | 49 ++++++++++++++++++++++++++++++-------------------
src/mds/Server.h | 1 +
4 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/src/mds/Mutation.cc b/src/mds/Mutation.cc
index 4e4f69c..3916b2a 100644
--- a/src/mds/Mutation.cc
+++ b/src/mds/Mutation.cc
@@ -30,6 +30,13 @@ void Mutation::pin(MDSCacheObject *o)
}
}
+void Mutation::unpin(MDSCacheObject *o)
+{
+ assert(pins.count(o));
+ o->put(MDSCacheObject::PIN_REQUEST);
+ pins.erase(o);
+}
+
void Mutation::set_stickydirs(CInode *in)
{
if (stickydirs.count(in) == 0) {
diff --git a/src/mds/Mutation.h b/src/mds/Mutation.h
index de122a5..c0bea19 100644
--- a/src/mds/Mutation.h
+++ b/src/mds/Mutation.h
@@ -113,6 +113,7 @@ struct Mutation {
// pin items in cache
void pin(MDSCacheObject *o);
+ void unpin(MDSCacheObject *o);
void set_stickydirs(CInode *in);
void drop_pins();
diff --git a/src/mds/Server.cc b/src/mds/Server.cc
index 63401e8..42db7ad 100644
--- a/src/mds/Server.cc
+++ b/src/mds/Server.cc
@@ -1797,6 +1797,24 @@ CDentry* Server::prepare_null_dentry(MDRequest *mdr, CDir *dir, const string& dn
return dn;
}
+CDentry* Server::prepare_stray_dentry(MDRequest *mdr, CInode *in)
+{
+ CDentry *straydn = mdr->straydn;
+ if (straydn) {
+ string name;
+ in->name_stray_dentry(name);
+ if (straydn->get_name() == name)
+ return straydn;
+
+ assert(!mdr->done_locking);
+ mdr->unpin(straydn);
+ }
+
+ straydn = mdcache->get_or_create_stray_dentry(in);
+ mdr->straydn = straydn;
+ mdr->pin(straydn);
+ return straydn;
+}
/** prepare_new_inode
*
@@ -4899,18 +4917,14 @@ void Server::handle_client_unlink(MDRequest *mdr)
}
// -- create stray dentry? --
- CDentry *straydn = mdr->straydn;
+ CDentry *straydn = NULL;
if (dnl->is_primary()) {
- if (!straydn) {
- straydn = mdcache->get_or_create_stray_dentry(dnl->get_inode());
- mdr->pin(straydn);
- mdr->straydn = straydn;
- }
- } else if (straydn)
- straydn = NULL;
- if (straydn)
+ straydn = prepare_stray_dentry(mdr, dnl->get_inode());
dout(10) << " straydn is " << *straydn << dendl;
-
+ } else if (mdr->straydn) {
+ mdr->unpin(mdr->straydn);
+ mdr->straydn = NULL;
+ }
// lock
set<SimpleLock*> rdlocks, wrlocks, xlocks;
@@ -5650,17 +5664,14 @@ void Server::handle_client_rename(MDRequest *mdr)
dout(10) << " this is a link merge" << dendl;
// -- create stray dentry? --
- CDentry *straydn = mdr->straydn;
+ CDentry *straydn = NULL;
if (destdnl->is_primary() && !linkmerge) {
- if (!straydn) {
- straydn = mdcache->get_or_create_stray_dentry(destdnl->get_inode());
- mdr->pin(straydn);
- mdr->straydn = straydn;
- }
- } else if (straydn)
- straydn = NULL;
- if (straydn)
+ straydn = prepare_stray_dentry(mdr, destdnl->get_inode());
dout(10) << " straydn is " << *straydn << dendl;
+ } else if (mdr->straydn) {
+ mdr->unpin(mdr->straydn);
+ mdr->straydn = NULL;
+ }
// -- prepare witness list --
/*
diff --git a/src/mds/Server.h b/src/mds/Server.h
index 15c8077..ffe9256 100644
--- a/src/mds/Server.h
+++ b/src/mds/Server.h
@@ -120,6 +120,7 @@ public:
CDir *validate_dentry_dir(MDRequest *mdr, CInode *diri, const string& dname);
CDir *traverse_to_auth_dir(MDRequest *mdr, vector<CDentry*> &trace, filepath refpath);
CDentry *prepare_null_dentry(MDRequest *mdr, CDir *dir, const string& dname, bool okexist=false);
+ CDentry *prepare_stray_dentry(MDRequest *mdr, CInode *in);
CInode* prepare_new_inode(MDRequest *mdr, CDir *dir, inodeno_t useino, unsigned mode,
ceph_file_layout *layout=NULL);
void journal_allocated_inos(MDRequest *mdr, EMetaBlob *blob);
--
1.8.1.4
next prev parent reply other threads:[~2013-05-27 2:09 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-23 8:06 [PATCH 0/30] mds: lookup-by-ino & fixes Yan, Zheng
2013-05-23 8:06 ` [PATCH 01/30] mds: journal new subtrees created by rename Yan, Zheng
2013-05-23 8:06 ` [PATCH 02/30] mds: fix underwater dentry cleanup Yan, Zheng
2013-05-23 8:06 ` [PATCH 03/30] mds: don't stop at export bounds when journaling dir context Yan, Zheng
2013-05-23 8:06 ` [PATCH 04/30] mds: adjust subtree auth if import aborts in PREPPED state Yan, Zheng
2013-05-23 8:06 ` [PATCH 05/30] mds: fix uncommitted master wait Yan, Zheng
2013-05-23 8:06 ` [PATCH 06/30] mds: fix slave commit tracking Yan, Zheng
2013-05-23 8:06 ` [PATCH 07/30] mds: fix straydn race Yan, Zheng
2013-05-23 16:44 ` Sage Weil
2013-05-27 2:09 ` Yan, Zheng [this message]
2013-05-23 8:06 ` [PATCH 08/30] mds: fix import cancel race Yan, Zheng
2013-05-23 8:06 ` [PATCH 09/30] mds: fix typo in Server::do_rename_rollback Yan, Zheng
2013-05-23 8:06 ` [PATCH 10/30] mds: remove buggy cache rejoin code Yan, Zheng
2013-05-23 8:06 ` [PATCH 11/30] mds: unfreeze inode when after rename rollback finishes Yan, Zheng
2013-05-23 8:06 ` [PATCH 12/30] mds: send slave request after target MDS is active Yan, Zheng
2013-05-23 8:06 ` [PATCH 13/30] mds: export CInode::STATE_NEEDSRECOVER Yan, Zheng
2013-05-23 17:59 ` Sage Weil
2013-05-27 2:11 ` Yan, Zheng
2013-05-23 8:06 ` [PATCH 14/30] mds: export CInode:mds_caps_wanted Yan, Zheng
2013-05-23 18:04 ` Sage Weil
2013-05-27 2:12 ` Yan, Zheng
2013-05-23 8:06 ` [PATCH 15/30] mds: notify auth MDS when cap_wanted changes Yan, Zheng
2013-05-23 8:06 ` [PATCH 16/30] mds: fix Locker::request_inode_file_caps() Yan, Zheng
2013-05-23 8:06 ` [PATCH 17/30] mds: defer releasing cap if necessary Yan, Zheng
2013-05-23 8:06 ` [PATCH 18/30] mds: don't issue Fc cap from replica Yan, Zheng
2013-05-23 18:11 ` Sage Weil
2013-05-27 2:13 ` Yan, Zheng
2013-05-23 8:06 ` [PATCH 19/30] mds: fix check for base inode discovery Yan, Zheng
2013-05-23 8:06 ` [PATCH 20/30] mds: slient MDCache::trim_non_auth() Yan, Zheng
2013-05-23 8:06 ` [PATCH 21/30] mds: warn on unconnected snap realms Yan, Zheng
2013-05-23 8:06 ` [PATCH 22/30] mds: reorder EMetaBlob::add_primary_dentry's parameters Yan, Zheng
2013-05-23 8:06 ` [PATCH 23/30] mds: journal backtrace update in EMetaBlob::fullbit Yan, Zheng
2013-05-28 3:08 ` Yan, Zheng
2013-05-23 8:06 ` [PATCH 24/30] mds: rename last_renamed_version to backtrace_version Yan, Zheng
2013-05-23 8:06 ` [PATCH 25/30] mds: bring back old style backtrace handling Yan, Zheng
2013-05-23 22:58 ` Sage Weil
2013-05-24 0:57 ` Yan, Zheng
2013-05-24 1:01 ` Sage Weil
2013-05-27 2:17 ` Yan, Zheng
2013-05-27 20:08 ` Sage Weil
2013-05-28 6:04 ` Yan, Zheng
2013-05-23 8:06 ` [PATCH 26/30] mds: update backtraces when unlinking inodes Yan, Zheng
2013-05-23 8:06 ` [PATCH 27/30] mds: remove old backtrace handling Yan, Zheng
2013-05-23 22:46 ` Sage Weil
2013-05-27 2:15 ` Yan, Zheng
2013-05-23 8:06 ` [PATCH 28/30] mds: move fetch_backtrace() to class MDCache Yan, Zheng
2013-05-23 8:06 ` [PATCH 29/30] mds: open inode by ino Yan, Zheng
2013-05-27 2:23 ` Yan, Zheng
2013-05-23 8:06 ` [PATCH 30/30] mds: open missing cap inodes Yan, Zheng
2013-05-23 18:22 ` [PATCH 0/30] mds: lookup-by-ino & fixes Sage Weil
2013-05-24 8:44 ` Yan, Zheng
2013-05-27 19:21 ` Sage Weil
2013-05-28 3:03 ` Yan, Zheng
2013-05-30 0:10 ` Sage Weil
2013-05-27 2:56 ` Yan, Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51A2C06B.7000802@intel.com \
--to=zheng.z.yan@intel.com \
--cc=ceph-devel@vger.kernel.org \
--cc=greg@inktank.com \
--cc=sage@inktank.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.