devtmpfs: Convert dirlock to a mutex
PATCH 1/1 devtmpfs: Convert dirlock to a mutex
devtmpfs has a rw_lock dirlock which serializes delete_path and create_path.
This code was obviously never tested with the usual set of debugging facilities enabled. In the dirlock held sections the code calls:
- vfs functions which take mutexes
- kmalloc(, GFP_KERNEL)
In both code pathes the might sleep warning triggers and spams dmesg.
Convert the rw_lock to a mutex. There is no reason why this needs to be a rwlock.
--- drivers/base/devtmpfs.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/base/devtmpfs.c +5 -7
@@ -32,7 +32,7 @@ static int dev_mount = 1;static int dev_mount;#endif -static rwlock_t dirlock; +static DEFINE_MUTEX (dirlock);static int __init mount_param (char *str) {
@@ -93,7 +93,7 @@ static int create_path(const char *nodep {int err; -read_lock (&dirlock); +mutex_lock (&dirlock); err =dev_mkdir (nodepath,0755 );if (err == -ENOENT ) {char *path;
@@ -117,7 +117,7 @@ static int create_path(const char *nodep }kfree (path); } -read_unlock (&dirlock); +mutex_unlock (&dirlock);return err; }
@@ -229,7 +229,7 @@ static int delete_path(const char *nodepif (!path)return -ENOMEM ; -write_lock (&dirlock); +mutex_lock (&dirlock);for (;;) {char *base;
@@ -241,7 +241,7 @@ static int delete_path(const char *nodepif (err)break ; } -write_unlock (&dirlock); +mutex_unlock (&dirlock);kfree (path);return err;
@@ -352,8 +352,6 @@ int __init devtmpfs_init(void)int err;struct vfsmount *mnt; -rwlock_init (&dirlock); - err =register_filesystem (&dev_fs_type);if (err) { printk(KERN_ERR "devtmpfs: unable to register devtmpfs "
Quoted 6 lines · Thomas Gleixner
devtmpfs has a
rw_lockdirlock which serializesdelete_pathandcreate_path.This code was obviously never tested with the usual set of debugging facilities enabled. In the dirlock held sections the code calls:
Quoted 7 lines
- vfs functions which take mutexes
-kmalloc(, GFP_KERNEL)In both code pathes the might sleep warning triggers and spams dmesg.
Convert the
rw_lockto a mutex. There is no reason why this needs to be a rwlock.
Many thanks, this is correct. I'll go queue it up.
greg k-h
[email protected]
Appliedpatch devtmpfs-convert-dirlock-to-a-mutex.patch added to gregkh-2.6 tree
In reply to Thomas GleixnerThis is a note to let you know that I've just added the patch titled
Subject: devtmpfs: Convert dirlock to a mutex
to my gregkh-2.6 tree. Its filename is
devtmpfs-convert-dirlock-to-a-mutex.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Quoted 1 line
From [email protected] Thu Dec 17 06:44:07 2009
From: Thomas Gleixner <[email protected]>
Date: Wed, 16 Dec 2009 21:31:33 -0000
Subject: devtmpfs: Convert dirlock to a mutex
To: LKML <[email protected]>
Cc: Kay Sievers <[email protected]>, Greg Kroah-Hartman <[email protected]>
Message-ID: <[email protected]>
devtmpfs has a rw_lock dirlock which serializes delete_path and create_path.
This code was obviously never tested with the usual set of debugging facilities enabled. In the dirlock held sections the code calls:
- vfs functions which take mutexes
- kmalloc(, GFP_KERNEL)
In both code pathes the might sleep warning triggers and spams dmesg.
Convert the rw_lock to a mutex. There is no reason why this needs to be a rwlock.
--- drivers/base/devtmpfs.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/base/devtmpfs.c +5 -7
@@ -32,7 +32,7 @@ static int dev_mount = 1;static int dev_mount;#endif -static rwlock_t dirlock; +static DEFINE_MUTEX (dirlock);static int __init mount_param (char *str) {
@@ -93,7 +93,7 @@ static int create_path(const char *nodep {int err; -read_lock (&dirlock); +mutex_lock (&dirlock); err =dev_mkdir (nodepath,0755 );if (err == -ENOENT ) {char *path;
@@ -117,7 +117,7 @@ static int create_path(const char *nodep }kfree (path); } -read_unlock (&dirlock); +mutex_unlock (&dirlock);return err; }
@@ -229,7 +229,7 @@ static int delete_path(const char *nodepif (!path)return -ENOMEM ; -write_lock (&dirlock); +mutex_lock (&dirlock);for (;;) {char *base;
@@ -241,7 +241,7 @@ static int delete_path(const char *nodepif (err)break ; } -write_unlock (&dirlock); +mutex_unlock (&dirlock);kfree (path);return err;
@@ -352,8 +352,6 @@ int __init devtmpfs_init(void)int err;struct vfsmount *mnt; -rwlock_init (&dirlock); - err =register_filesystem (&dev_fs_type);if (err) { printk(KERN_ERR "devtmpfs: unable to register devtmpfs "