Linux 2.6.36 compat, fs_struct->lock type change

In the linux-2.6.36 kernel the fs_struct lock was changed from a
rwlock_t to a spinlock_t.  If the kernel would export the set_fs_pwd()
symbol by default this would not have caused us any issues, but they
don't.  So we're forced to add a new autoconf check which sets the
HAVE_FS_STRUCT_SPINLOCK define when a spinlock_t is used.  We can
then correctly use either spin_lock or write_lock in our custom
set_fs_pwd() implementation.
This commit is contained in:
Brian Behlendorf
2010-11-09 11:15:32 -08:00
parent a50cede388
commit 9b2048c26b
4 changed files with 176 additions and 8 deletions
+16 -8
View File
@@ -617,16 +617,24 @@ EXPORT_SYMBOL(releasef);
void
set_fs_pwd(struct fs_struct *fs, struct path *path)
{
struct path old_pwd;
struct path old_pwd;
write_lock(&fs->lock);
old_pwd = fs->pwd;
fs->pwd = *path;
path_get(path);
write_unlock(&fs->lock);
# ifdef HAVE_FS_STRUCT_SPINLOCK
spin_lock(&fs->lock);
old_pwd = fs->pwd;
fs->pwd = *path;
path_get(path);
spin_unlock(&fs->lock);
# else
write_lock(&fs->lock);
old_pwd = fs->pwd;
fs->pwd = *path;
path_get(path);
write_unlock(&fs->lock);
# endif /* HAVE_FS_STRUCT_SPINLOCK */
if (old_pwd.dentry)
path_put(&old_pwd);
if (old_pwd.dentry)
path_put(&old_pwd);
}
# else
/* Used from 2.6.11 - 2.6.24 */