From: Li Zefan <lizf@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/5] btrfs: Fix bugs in zlib workspace
Date: Mon, 25 Oct 2010 15:11:43 +0800 [thread overview]
Message-ID: <4CC52DAF.2030203@cn.fujitsu.com> (raw)
In-Reply-To: <4CC52D9A.3030709@cn.fujitsu.com>
- 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>
---
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 b9cd544..e5b8b22 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;
--
1.7.0.1
next prev parent reply other threads:[~2010-10-25 7:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-25 7:11 [PATCH 0/5] btrfs: Add lzo compression support Li Zefan
2010-10-25 7:11 ` Li Zefan [this message]
2010-10-25 7:12 ` [PATCH 2/5] btrfs: Allow to add new compression algorithm Li Zefan
2010-10-25 7:12 ` [PATCH 3/5] btrfs: Add lzo compression support Li Zefan
2010-10-25 7:12 ` [PATCH 4/5] btrfs: Allow to specify compress method when defrag Li Zefan
2010-10-25 7:13 ` [PATCH 5/5] btrfs: Extract duplicate decompress code Li Zefan
2010-10-26 2:13 ` [PATCH 0/5] btrfs: Add lzo compression support Chris Mason
2010-10-26 2:34 ` Li Zefan
2010-11-15 18:55 ` Mitch Harder
2010-11-16 0:57 ` Li Zefan
2010-11-16 18:51 ` Mitch Harder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4CC52DAF.2030203@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).