Commit b5744805 authored by Theodore Ts'o's avatar Theodore Ts'o

jbd2: Remove GFP_ATOMIC kmalloc from inside spinlock critical region

Fix jbd2_dev_to_name(), a function used when pretty-printting jbd2 and
ext4 tracepoints.
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 627ad9fd
...@@ -2410,6 +2410,7 @@ const char *jbd2_dev_to_name(dev_t device) ...@@ -2410,6 +2410,7 @@ const char *jbd2_dev_to_name(dev_t device)
int i = hash_32(device, CACHE_SIZE_BITS); int i = hash_32(device, CACHE_SIZE_BITS);
char *ret; char *ret;
struct block_device *bd; struct block_device *bd;
static struct devname_cache *new_dev;
rcu_read_lock(); rcu_read_lock();
if (devcache[i] && devcache[i]->device == device) { if (devcache[i] && devcache[i]->device == device) {
...@@ -2419,20 +2420,20 @@ const char *jbd2_dev_to_name(dev_t device) ...@@ -2419,20 +2420,20 @@ const char *jbd2_dev_to_name(dev_t device)
} }
rcu_read_unlock(); rcu_read_unlock();
new_dev = kmalloc(sizeof(struct devname_cache), GFP_KERNEL);
if (!new_dev)
return "NODEV-ALLOCFAILURE"; /* Something non-NULL */
spin_lock(&devname_cache_lock); spin_lock(&devname_cache_lock);
if (devcache[i]) { if (devcache[i]) {
if (devcache[i]->device == device) { if (devcache[i]->device == device) {
kfree(new_dev);
ret = devcache[i]->devname; ret = devcache[i]->devname;
spin_unlock(&devname_cache_lock); spin_unlock(&devname_cache_lock);
return ret; return ret;
} }
call_rcu(&devcache[i]->rcu, free_devcache); call_rcu(&devcache[i]->rcu, free_devcache);
} }
devcache[i] = kmalloc(sizeof(struct devname_cache), GFP_KERNEL); devcache[i] = new_dev;
if (!devcache[i]) {
spin_unlock(&devname_cache_lock);
return "NODEV-ALLOCFAILURE"; /* Something non-NULL */
}
devcache[i]->device = device; devcache[i]->device = device;
bd = bdget(device); bd = bdget(device);
if (bd) { if (bd) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment