From: Zuzana Petrova <zpetrova@suse.cz>
To: linux-kernel@vger.kernel.org
Cc: Michael Gaughen <mgaughen@polyserve.com>
Subject: [PATCH] fs:lock_rename()/unlock_rename() can lead to deadlock in distributed fs.
Date: Mon, 27 Jun 2005 11:24:49 +0200 [thread overview]
Message-ID: <20050627092448.GA8822@lilac.suse.cz> (raw)
The problem with lock_rename() is that it compares parent directory dentries
when trying to decide how many inode i_sem semaphores to acquire. That works
fine on a single node system, but not in a distributed environment, on a
distributed filesystem.
The problem with rename(2) in a cluster, is that there is no guarantee that
path_lookup()s will return a coherent path structure while at the same time
renames, on another node, are executing on that same path hierarchy. In our
case, in do_rename(), the parent directory path_lookup()s find/create unique
dentries for the old_dir and new_dir, however, because a rename(2) on another
node was executing, both dentries end up pointing to the same inode.
When lock_rename(new_dir, old_dir) is called, the dentries don't match, so we
end up in a code path that tries to acquire the inode i_sem of both the
old_dir and new_dir, but since they point to the same inode, the second
attempt to acquire the same i_sem results in a deadlock.
A fix would be to compare the dentries ->d_inode field instead. Patch for
kernel 2.6.12.1 attached.
Author of the patch is Michael Gaughen <mgaughen@polyserve.com>
--
Zuzana Petrova
===================================================================
#
# This patch changes lock_rename()/unlock_rename() to compare the inodes
# referenced by the dentries. The problem with distributed filesystems is
# that there is no guarantee the path_lookup() will return valid path dentry
# components at the same time rename(2)s of that same path hierarchy are
# executing on another node. So there are cases where the dentries, passed
# to lock_rename()/unlock_rename(), are different, but refer to the same
# inode. In that case, the check for equivalent dentries will fail, and an
# attempt to acquire each of the dentries inode will be made, resulting in
# a deadlock since the inodes are the same.
#
--- linux-2.6.11.12.old/fs/namei.c 2005-03-11 13:56:30.877725438 +0100
+++ linux-2.6.11.12/fs/namei.c 2005-03-11 14:01:49.196080914 +0100
@@ -1197,7 +1197,7 @@ lock_rename(
{
struct dentry *p;
- if (p1 == p2) {
+ if (p1->d_inode == p2->d_inode) {
down(&p1->d_inode->i_sem);
return NULL;
}
@@ -1228,7 +1228,7 @@
void unlock_rename(struct dentry *p1, struct dentry *p2)
{
up(&p1->d_inode->i_sem);
- if (p1 != p2) {
+ if (p1->d_inode != p2->d_inode) {
up(&p2->d_inode->i_sem);
up(&p1->d_inode->i_sb->s_vfs_rename_sem);
}
next reply other threads:[~2005-06-27 9:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-27 9:24 Zuzana Petrova [this message]
2005-06-27 9:39 ` [PATCH] fs:lock_rename()/unlock_rename() can lead to deadlock in distributed fs Christoph Hellwig
2005-06-27 16:15 Nikita Danilov
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=20050627092448.GA8822@lilac.suse.cz \
--to=zpetrova@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mgaughen@polyserve.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).