Skip to contentSkip to conversation

configfs: Fix symlink() to a removing item

PATCH In review Louis Rilling 2 participants 4 messages Jun 16, 2008 – Jun 17, 2008 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configfs: Fix symlink() to a removing item

Hi, the following patch fixes the symlink bug I mentioned a few days ago. Thanks for your comments.

Louis

Signature · 18 lines
Dr Louis Rilling			Kerlabs
Skype: louis.rilling			Batiment Germanium
Phone: (+33|0) 6 80 89 08 23		80 avenue des Buttes de Coesmes
http://www.kerlabs.com/			35700 Rennes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: configfs-do-not-symlink-to-removing-item.patch
Type: text/x-diff
Size: 3385 bytes
Desc: not available
Url : http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20080616/468a2f8f/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20080616/468a2f8f/attachment-0001.bin 
#1 lore raw
Quoted 8 lines · Louis Rilling

This patch introduces a similar (weird?) behavior as with mkdir failures making rmdir fail: if symlink() races with rmdir() of the parent directory (or its youngest user-created ancestor if parent is a default group) or rmdir() of the target directory, and then fails in configfs_create(), this can make the racing rmdir() fail despite the concerned directory having no user-created entry (resp. no symlink pointing to it or one of its default groups) in the end. If this behavior is found unacceptable, I'll submit a fix in the same spirit as the racing mkdir() fix.

Ahh, but you can't wait on the mutex like you do in mkdir(),
because they're not ordered - it can race rename again.

Joel

Signature · 9 lines
Dort wo man B?cher verbrennt, verbrennt man am Ende auch Mensch.
(Wherever they burn books, they will also end up burning people.)
	- Heinrich Heine

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
#2 lore raw
Quoted 10 lines · Joel Becker
Quoted 8 lines · Louis Rilling

This patch introduces a similar (weird?) behavior as with mkdir failures making rmdir fail: if symlink() races with rmdir() of the parent directory (or its youngest user-created ancestor if parent is a default group) or rmdir() of the target directory, and then fails in configfs_create(), this can make the racing rmdir() fail despite the concerned directory having no user-created entry (resp. no symlink pointing to it or one of its default groups) in the end. If this behavior is found unacceptable, I'll submit a fix in the same spirit as the racing mkdir() fix.

Quoted 2 lines

Ahh, but you can't wait on the mutex like you do in mkdir(),
because they're not ordered - it can race rename again.

Yes I can. In the mkdir() case, rmdir() waits on the mutex of one of the default groups. The symlink case will be handled the same. The difference is that while mkdir() tags the parent with CONFIGFS_USET_IN_MKDIR, symlink() will tag both the parent and the target with CONFIGFS_USET_IN_SYMLINK. [ We can actually merge the two flags in something like CONFIGFS_USET_ATTACHING. ] Since tagging requires only to take configfs_dirent_lock, there will be no deadlock.

I'll send a patch later.

Louis

Signature · 11 lines
Dr Louis Rilling			Kerlabs
Skype: louis.rilling			Batiment Germanium
Phone: (+33|0) 6 80 89 08 23		80 avenue des Buttes de Coesmes
http://www.kerlabs.com/			35700 Rennes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20080617/42ecb234/attachment.bin 
#3 lore raw
Quoted 14 lines · Louis Rilling
Quoted 10 lines · Joel Becker
Quoted 8 lines · Louis Rilling

This patch introduces a similar (weird?) behavior as with mkdir failures making rmdir fail: if symlink() races with rmdir() of the parent directory (or its youngest user-created ancestor if parent is a default group) or rmdir() of the target directory, and then fails in configfs_create(), this can make the racing rmdir() fail despite the concerned directory having no user-created entry (resp. no symlink pointing to it or one of its default groups) in the end. If this behavior is found unacceptable, I'll submit a fix in the same spirit as the racing mkdir() fix.

Quoted 2 lines

Ahh, but you can't wait on the mutex like you do in mkdir(),
because they're not ordered - it can race rename again.

Quoted 6 lines

Yes I can. In the mkdir() case, rmdir() waits on the mutex of one of the default groups. The symlink case will be handled the same. The difference is that while mkdir() tags the parent with CONFIGFS_USET_IN_MKDIR, symlink() will tag both the parent and the target with CONFIGFS_USET_IN_SYMLINK. [ We can actually merge the two flags in something like CONFIGFS_USET_ATTACHING. ] Since tagging requires only to take configfs_dirent_lock, there will be no deadlock.

Hm, you were right, sorry. We can only solve the race with rmdir() removing the item where the symlink is created. For the target item, I don't know yet...

Louis

Signature · 11 lines
Dr Louis Rilling			Kerlabs
Skype: louis.rilling			Batiment Germanium
Phone: (+33|0) 6 80 89 08 23		80 avenue des Buttes de Coesmes
http://www.kerlabs.com/			35700 Rennes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20080617/bd80833f/attachment-0001.bin