fs:lock_rename()/unlock_rename() can lead to deadlock in distributed fs.
Quoted 12 lines · Zuzana Petrova
The problem with
lock_rename()is that it compares parent directory dentries when trying to decide how many inodei_semsemaphores 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 theold_dirandnew_dir, however, because a rename(2) on another node was executing, both dentries end up pointing to the same inode.
Quoted 7 lines
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 inodei_semof both theold_dirandnew_dir, but since they point to the same inode, the second attempt to acquire the samei_semresults 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.
Quoted 5 lines
Author of the patch is Michael Gaughen <[email protected]>
--
Zuzana Petrova
Nikita.