Re: [PATCH] fs:lock_rename()/unlock_rename() can lead to deadlock in distributed fs.

From: Nikita Danilov
Date: Mon Jun 27 2005 - 11:22:23 EST


Zuzana Petrova writes:
> 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.

reiser4 had identical patch before pseudo files were disabled. It even
went into -mm:

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.9-rc1/2.6.9-rc1-mm1/broken-out/reiser4-aliased-dir.patch

Nikita.

>
> Author of the patch is Michael Gaughen <mgaughen@xxxxxxxxxxxxx>
>
> --
> Zuzana Petrova

Nikita.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/