diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2010-10-25 15:11:43 +0800 |
---|---|---|
committer | Li Zefan <lizf@cn.fujitsu.com> | 2010-12-22 23:15:41 +0800 |
commit | 8844355df7f4e091b03cc131e1549631238b397b (patch) | |
tree | 90568648b57f05265def659b7dbf8f45baaaeb65 | |
parent | 83a50de97fe96aca82389e061862ed760ece2283 (diff) | |
download | linux-8844355df7f4e091b03cc131e1549631238b397b.tar.gz linux-8844355df7f4e091b03cc131e1549631238b397b.tar.bz2 linux-8844355df7f4e091b03cc131e1549631238b397b.zip |
btrfs: Fix bugs in zlib workspace
- Fix a race that can result in alloc_workspace > cpus.
- Fix to check num_workspace after wakeup.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
-rw-r--r-- | fs/btrfs/zlib.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c index b9cd5445f71c..e5b8b22e07d6 100644 --- a/fs/btrfs/zlib.c +++ b/fs/btrfs/zlib.c @@ -75,16 +75,19 @@ again: return workspace; } - spin_unlock(&workspace_lock); if (atomic_read(&alloc_workspace) > cpus) { DEFINE_WAIT(wait); + + spin_unlock(&workspace_lock); prepare_to_wait(&workspace_wait, &wait, TASK_UNINTERRUPTIBLE); - if (atomic_read(&alloc_workspace) > cpus) + if (atomic_read(&alloc_workspace) > cpus && !num_workspace) schedule(); finish_wait(&workspace_wait, &wait); goto again; } atomic_inc(&alloc_workspace); + spin_unlock(&workspace_lock); + workspace = kzalloc(sizeof(*workspace), GFP_NOFS); if (!workspace) { ret = -ENOMEM; |