From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
Zwane Mwaikambo <zwane@arm.linux.org.uk>,
Theodore Ts'o <tytso@mit.edu>,
Randy Dunlap <rdunlap@xenotime.net>,
Dave Jones <davej@redhat.com>,
Chuck Wolber <chuckw@quantumlinux.com>,
Chris Wedgwood <reviews@ml.cw.f00f.org>,
Michael Krufky <mkrufky@linuxtv.org>,
Chuck Ebbert <cebbert@redhat.com>,
Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Eric Sandeen <sandeen@redhat.com>,
linux-ext4@vger.kernel.org, Greg Kroah-Hartman <gregkh@suse.de>
Subject: [patch 37/60] ext4: fix ext4_free_inode() vs. ext4_claim_inode() race
Date: Tue, 09 Jun 2009 17:14:05 -0700 [thread overview]
Message-ID: <20090610002348.220859343@blue.kroah.org> (raw)
In-Reply-To: <20090610032135.GA19346@kroah.com>
[-- Attachment #1: ext4-fix-ext4_free_inode-vs.-ext4_claim_inode-race.patch --]
[-- Type: text/plain, Size: 2229 bytes --]
-stable review patch. If anyone has any objections, please let us know.
------------------
From: Eric Sandeen <sandeen@redhat.com>
(cherry picked from commit 7ce9d5d1f3c8736511daa413c64985a05b2feee3)
I was seeing fsck errors on inode bitmaps after a 4 thread
dbench run on a 4 cpu machine:
Inode bitmap differences: -50736 -(50752--50753) etc...
I believe that this is because ext4_free_inode() uses atomic
bitops, and although ext4_new_inode() *used* to also use atomic
bitops for synchronization, commit
393418676a7602e1d7d3f6e560159c65c8cbd50e changed this to use
the sb_bgl_lock, so that we could also synchronize against
read_inode_bitmap and initialization of uninit inode tables.
However, that change left ext4_free_inode using atomic bitops,
which I think leaves no synchronization between setting &
unsetting bits in the inode table.
The below patch fixes it for me, although I wonder if we're
getting at all heavy-handed with this spinlock...
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/ext4/ialloc.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -188,7 +188,7 @@ void ext4_free_inode (handle_t *handle,
struct ext4_group_desc * gdp;
struct ext4_super_block * es;
struct ext4_sb_info *sbi;
- int fatal = 0, err;
+ int fatal = 0, err, cleared;
ext4_group_t flex_group;
if (atomic_read(&inode->i_count) > 1) {
@@ -242,10 +242,12 @@ void ext4_free_inode (handle_t *handle,
goto error_return;
/* Ok, now we can actually update the inode bitmaps.. */
- if (!ext4_clear_bit_atomic(sb_bgl_lock(sbi, block_group),
- bit, bitmap_bh->b_data))
- ext4_error (sb, "ext4_free_inode",
- "bit already cleared for inode %lu", ino);
+ spin_lock(sb_bgl_lock(sbi, block_group));
+ cleared = ext4_clear_bit(bit, bitmap_bh->b_data);
+ spin_unlock(sb_bgl_lock(sbi, block_group));
+ if (!cleared)
+ ext4_error(sb, "ext4_free_inode",
+ "bit already cleared for inode %lu", ino);
else {
gdp = ext4_get_group_desc (sb, block_group, &bh2);
next parent reply other threads:[~2009-06-10 3:35 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090610001328.251476848@blue.kroah.org>
[not found] ` <20090610032135.GA19346@kroah.com>
2009-06-10 0:14 ` Greg KH [this message]
2009-06-10 0:14 ` [patch 38/60] ext4: fix header check in ext4_ext_search_right() for deep extent trees Greg KH
2009-06-10 0:14 ` [patch 39/60] ext4: Print the find_group_flex() warning only once Greg KH
2009-06-10 0:14 ` [patch 40/60] ext4: fix bogus BUG_ONs in in mballoc code Greg KH
2009-06-10 0:14 ` [patch 41/60] ext4: fix bb_prealloc_list corruption due to wrong group locking Greg KH
2009-06-10 0:14 ` [patch 42/60] ext4: dont inherit inappropriate inode flags from parent Greg KH
2009-06-10 0:14 ` [patch 43/60] ext4: tighten restrictions on inode flags Greg KH
2009-06-10 0:14 ` [patch 44/60] ext4: return -EIO not -ESTALE on directory traversal through deleted inode Greg KH
2009-06-10 0:14 ` [patch 45/60] ext4: Add fine print for the 32000 subdirectory limit Greg KH
2009-06-10 0:14 ` [patch 46/60] ext4: add EXT4_IOC_ALLOC_DA_BLKS ioctl Greg KH
2009-06-10 0:14 ` [patch 47/60] ext4: Automatically allocate delay allocated blocks on close Greg KH
2009-06-10 0:14 ` [patch 48/60] ext4: Automatically allocate delay allocated blocks on rename Greg KH
2009-06-10 0:14 ` [patch 49/60] ext4: Fix discard of inode prealloc space with delayed allocation Greg KH
2009-06-10 0:14 ` [patch 50/60] ext4: Check for an valid i_mode when reading the inode from disk Greg KH
2009-06-10 0:14 ` [patch 51/60] jbd2: Update locking coments Greg KH
2009-06-10 0:14 ` [patch 52/60] ext4: fix typo which causes a memory leak on error path Greg KH
2009-06-10 0:14 ` [patch 53/60] ext4: fix locking typo in mballoc which could cause soft lockup hangs Greg KH
2009-06-10 0:14 ` [patch 54/60] ext4: really print the find_group_flex fallback warning only once Greg KH
2009-06-10 0:14 ` [patch 55/60] ext4: Fix softlockup caused by illegal i_file_acl value in on-disk inode Greg KH
2009-06-10 0:14 ` [patch 56/60] ext4: Ignore i_file_acl_high unless EXT4_FEATURE_INCOMPAT_64BIT is present Greg KH
2009-06-10 0:14 ` [patch 57/60] ext4: Fix sub-block zeroing for writes into preallocated extents Greg KH
2009-06-10 0:14 ` [patch 58/60] ext4: Use a fake block number for delayed new buffer_head Greg KH
2009-06-10 0:14 ` [patch 59/60] ext4: Clear the unwritten buffer_head flag after the extent is initialized Greg KH
2009-06-10 0:14 ` [patch 60/60] ext4: Fix race in ext4_inode_info.i_cached_extent Greg KH
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=20090610002348.220859343@blue.kroah.org \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=cavokz@gmail.com \
--cc=cebbert@redhat.com \
--cc=chuckw@quantumlinux.com \
--cc=davej@redhat.com \
--cc=eteo@redhat.com \
--cc=jake@lwn.net \
--cc=jmforbes@linuxtx.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkrufky@linuxtv.org \
--cc=rbranco@la.checkpoint.com \
--cc=rdunlap@xenotime.net \
--cc=reviews@ml.cw.f00f.org \
--cc=sandeen@redhat.com \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=w@1wt.eu \
--cc=zwane@arm.linux.org.uk \
/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).