* [PATCH] ext4: Fix scheduling in atomic on group checksum failure
@ 2016-02-10 13:58 Jan Kara
2016-02-10 17:52 ` Darrick J. Wong
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2016-02-10 13:58 UTC (permalink / raw)
To: Ted Tso; +Cc: Dmitry Vyukov, linux-ext4, Jan Kara, stable
When block group checksum is wrong, we call ext4_error() while holding
group spinlock from ext4_init_block_bitmap() or
ext4_init_inode_bitmap() which results in scheduling while in atomic.
Fix the issue by calling ext4_error() later after dropping the spinlock.
CC: stable@vger.kernel.org
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/balloc.c | 7 ++++---
fs/ext4/ialloc.c | 6 ++++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index ec0668a60678..fe1f50fe764f 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -191,7 +191,6 @@ static int ext4_init_block_bitmap(struct super_block *sb,
/* If checksum is bad mark all blocks used to prevent allocation
* essentially implementing a per-group read-only flag. */
if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) {
- ext4_error(sb, "Checksum bad for group %u", block_group);
grp = ext4_get_group_info(sb, block_group);
if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp))
percpu_counter_sub(&sbi->s_freeclusters_counter,
@@ -442,14 +441,16 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
}
ext4_lock_group(sb, block_group);
if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
-
err = ext4_init_block_bitmap(sb, bh, block_group, desc);
set_bitmap_uptodate(bh);
set_buffer_uptodate(bh);
ext4_unlock_group(sb, block_group);
unlock_buffer(bh);
- if (err)
+ if (err) {
+ ext4_error(sb, "Failed to init block bitmap for group "
+ "%u: %d", block_group, err);
goto out;
+ }
goto verify;
}
ext4_unlock_group(sb, block_group);
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 3fcfd50a2e8a..acc0ad56bf2f 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -76,7 +76,6 @@ static int ext4_init_inode_bitmap(struct super_block *sb,
/* If checksum is bad mark all blocks and inodes use to prevent
* allocation, essentially implementing a per-group read-only flag. */
if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) {
- ext4_error(sb, "Checksum bad for group %u", block_group);
grp = ext4_get_group_info(sb, block_group);
if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp))
percpu_counter_sub(&sbi->s_freeclusters_counter,
@@ -191,8 +190,11 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
set_buffer_verified(bh);
ext4_unlock_group(sb, block_group);
unlock_buffer(bh);
- if (err)
+ if (err) {
+ ext4_error(sb, "Failed to init inode bitmap for group "
+ "%u: %d", block_group, err);
goto out;
+ }
return bh;
}
ext4_unlock_group(sb, block_group);
--
2.6.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: Fix scheduling in atomic on group checksum failure
2016-02-10 13:58 [PATCH] ext4: Fix scheduling in atomic on group checksum failure Jan Kara
@ 2016-02-10 17:52 ` Darrick J. Wong
2016-02-12 4:47 ` Theodore Ts'o
0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2016-02-10 17:52 UTC (permalink / raw)
To: Jan Kara; +Cc: Ted Tso, Dmitry Vyukov, linux-ext4, stable
On Wed, Feb 10, 2016 at 02:58:30PM +0100, Jan Kara wrote:
> When block group checksum is wrong, we call ext4_error() while holding
> group spinlock from ext4_init_block_bitmap() or
> ext4_init_inode_bitmap() which results in scheduling while in atomic.
> Fix the issue by calling ext4_error() later after dropping the spinlock.
>
> CC: stable@vger.kernel.org
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> Signed-off-by: Jan Kara <jack@suse.cz>
Looks ok, so
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/ext4/balloc.c | 7 ++++---
> fs/ext4/ialloc.c | 6 ++++--
> 2 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
> index ec0668a60678..fe1f50fe764f 100644
> --- a/fs/ext4/balloc.c
> +++ b/fs/ext4/balloc.c
> @@ -191,7 +191,6 @@ static int ext4_init_block_bitmap(struct super_block *sb,
> /* If checksum is bad mark all blocks used to prevent allocation
> * essentially implementing a per-group read-only flag. */
> if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) {
> - ext4_error(sb, "Checksum bad for group %u", block_group);
> grp = ext4_get_group_info(sb, block_group);
> if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp))
> percpu_counter_sub(&sbi->s_freeclusters_counter,
> @@ -442,14 +441,16 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
> }
> ext4_lock_group(sb, block_group);
> if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
> -
> err = ext4_init_block_bitmap(sb, bh, block_group, desc);
> set_bitmap_uptodate(bh);
> set_buffer_uptodate(bh);
> ext4_unlock_group(sb, block_group);
> unlock_buffer(bh);
> - if (err)
> + if (err) {
> + ext4_error(sb, "Failed to init block bitmap for group "
> + "%u: %d", block_group, err);
> goto out;
> + }
> goto verify;
> }
> ext4_unlock_group(sb, block_group);
> diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
> index 3fcfd50a2e8a..acc0ad56bf2f 100644
> --- a/fs/ext4/ialloc.c
> +++ b/fs/ext4/ialloc.c
> @@ -76,7 +76,6 @@ static int ext4_init_inode_bitmap(struct super_block *sb,
> /* If checksum is bad mark all blocks and inodes use to prevent
> * allocation, essentially implementing a per-group read-only flag. */
> if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) {
> - ext4_error(sb, "Checksum bad for group %u", block_group);
> grp = ext4_get_group_info(sb, block_group);
> if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp))
> percpu_counter_sub(&sbi->s_freeclusters_counter,
> @@ -191,8 +190,11 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
> set_buffer_verified(bh);
> ext4_unlock_group(sb, block_group);
> unlock_buffer(bh);
> - if (err)
> + if (err) {
> + ext4_error(sb, "Failed to init inode bitmap for group "
> + "%u: %d", block_group, err);
> goto out;
> + }
> return bh;
> }
> ext4_unlock_group(sb, block_group);
> --
> 2.6.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: Fix scheduling in atomic on group checksum failure
2016-02-10 17:52 ` Darrick J. Wong
@ 2016-02-12 4:47 ` Theodore Ts'o
0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2016-02-12 4:47 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Jan Kara, Dmitry Vyukov, linux-ext4, stable
On Wed, Feb 10, 2016 at 09:52:46AM -0800, Darrick J. Wong wrote:
> On Wed, Feb 10, 2016 at 02:58:30PM +0100, Jan Kara wrote:
> > When block group checksum is wrong, we call ext4_error() while holding
> > group spinlock from ext4_init_block_bitmap() or
> > ext4_init_inode_bitmap() which results in scheduling while in atomic.
> > Fix the issue by calling ext4_error() later after dropping the spinlock.
> >
> > CC: stable@vger.kernel.org
> > Reported-by: Dmitry Vyukov <dvyukov@google.com>
> > Signed-off-by: Jan Kara <jack@suse.cz>
>
> Looks ok, so
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Applied, thanks.
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-12 4:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-10 13:58 [PATCH] ext4: Fix scheduling in atomic on group checksum failure Jan Kara
2016-02-10 17:52 ` Darrick J. Wong
2016-02-12 4:47 ` Theodore Ts'o
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).