linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Check for non-zero journal inum in ext4_calculate_overhead
@ 2020-03-16  9:30 Ritesh Harjani
  2020-03-17 11:17 ` Jan Kara
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ritesh Harjani @ 2020-03-16  9:30 UTC (permalink / raw)
  To: linux-ext4
  Cc: tytso, jack, adilger.kernel, linux-fsdevel, Ritesh Harjani,
	Harish Sriram

While calculating overhead for internal journal, also check
that j_inum shouldn't be 0. Otherwise we get below error with
xfstests generic/050 with external journal (XXX_LOGDEV config) enabled.

It could be simply reproduced with loop device with an external journal
and marking blockdev as RO before mounting.

[ 3337.146838] EXT4-fs error (device pmem1p2): ext4_get_journal_inode:4634: comm mount: inode #0: comm mount: iget: illegal inode #
------------[ cut here ]------------
generic_make_request: Trying to write to read-only block-device pmem1p2 (partno 2)
WARNING: CPU: 107 PID: 115347 at block/blk-core.c:788 generic_make_request_checks+0x6b4/0x7d0
CPU: 107 PID: 115347 Comm: mount Tainted: G             L   --------- -t - 4.18.0-167.el8.ppc64le #1
NIP:  c0000000006f6d44 LR: c0000000006f6d40 CTR: 0000000030041dd4
<...>
NIP [c0000000006f6d44] generic_make_request_checks+0x6b4/0x7d0
LR [c0000000006f6d40] generic_make_request_checks+0x6b0/0x7d0
<...>
Call Trace:
generic_make_request_checks+0x6b0/0x7d0 (unreliable)
generic_make_request+0x3c/0x420
submit_bio+0xd8/0x200
submit_bh_wbc+0x1e8/0x250
__sync_dirty_buffer+0xd0/0x210
ext4_commit_super+0x310/0x420 [ext4]
__ext4_error+0xa4/0x1e0 [ext4]
__ext4_iget+0x388/0xe10 [ext4]
ext4_get_journal_inode+0x40/0x150 [ext4]
ext4_calculate_overhead+0x5a8/0x610 [ext4]
ext4_fill_super+0x3188/0x3260 [ext4]
mount_bdev+0x778/0x8f0
ext4_mount+0x28/0x50 [ext4]
mount_fs+0x74/0x230
vfs_kern_mount.part.6+0x6c/0x250
do_mount+0x2fc/0x1280
sys_mount+0x158/0x180
system_call+0x5c/0x70
EXT4-fs (pmem1p2): no journal found
EXT4-fs (pmem1p2): can't get journal size
EXT4-fs (pmem1p2): mounted filesystem without journal. Opts: dax,norecovery

Reported-by: Harish Sriram <harish@linux.ibm.com>
Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
---
 fs/ext4/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index de5398c07161..5dc65b7583cb 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3609,7 +3609,8 @@ int ext4_calculate_overhead(struct super_block *sb)
 	 */
 	if (sbi->s_journal && !sbi->journal_bdev)
 		overhead += EXT4_NUM_B2C(sbi, sbi->s_journal->j_maxlen);
-	else if (ext4_has_feature_journal(sb) && !sbi->s_journal) {
+	else if (ext4_has_feature_journal(sb) && !sbi->s_journal && j_inum) {
+		/* j_inum for internal journal is non-zero */
 		j_inode = ext4_get_journal_inode(sb, j_inum);
 		if (j_inode) {
 			j_blocks = j_inode->i_size >> sb->s_blocksize_bits;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ext4: Check for non-zero journal inum in ext4_calculate_overhead
  2020-03-16  9:30 [PATCH] ext4: Check for non-zero journal inum in ext4_calculate_overhead Ritesh Harjani
@ 2020-03-17 11:17 ` Jan Kara
  2020-03-18 18:27 ` Eric Sandeen
  2020-03-24  1:52 ` Theodore Y. Ts'o
  2 siblings, 0 replies; 5+ messages in thread
From: Jan Kara @ 2020-03-17 11:17 UTC (permalink / raw)
  To: Ritesh Harjani
  Cc: linux-ext4, tytso, jack, adilger.kernel, linux-fsdevel, Harish Sriram

On Mon 16-03-20 15:00:38, Ritesh Harjani wrote:
> While calculating overhead for internal journal, also check
> that j_inum shouldn't be 0. Otherwise we get below error with
> xfstests generic/050 with external journal (XXX_LOGDEV config) enabled.
> 
> It could be simply reproduced with loop device with an external journal
> and marking blockdev as RO before mounting.
> 
> [ 3337.146838] EXT4-fs error (device pmem1p2): ext4_get_journal_inode:4634: comm mount: inode #0: comm mount: iget: illegal inode #
> ------------[ cut here ]------------
> generic_make_request: Trying to write to read-only block-device pmem1p2 (partno 2)
> WARNING: CPU: 107 PID: 115347 at block/blk-core.c:788 generic_make_request_checks+0x6b4/0x7d0
> CPU: 107 PID: 115347 Comm: mount Tainted: G             L   --------- -t - 4.18.0-167.el8.ppc64le #1
> NIP:  c0000000006f6d44 LR: c0000000006f6d40 CTR: 0000000030041dd4
> <...>
> NIP [c0000000006f6d44] generic_make_request_checks+0x6b4/0x7d0
> LR [c0000000006f6d40] generic_make_request_checks+0x6b0/0x7d0
> <...>
> Call Trace:
> generic_make_request_checks+0x6b0/0x7d0 (unreliable)
> generic_make_request+0x3c/0x420
> submit_bio+0xd8/0x200
> submit_bh_wbc+0x1e8/0x250
> __sync_dirty_buffer+0xd0/0x210
> ext4_commit_super+0x310/0x420 [ext4]
> __ext4_error+0xa4/0x1e0 [ext4]
> __ext4_iget+0x388/0xe10 [ext4]
> ext4_get_journal_inode+0x40/0x150 [ext4]
> ext4_calculate_overhead+0x5a8/0x610 [ext4]
> ext4_fill_super+0x3188/0x3260 [ext4]
> mount_bdev+0x778/0x8f0
> ext4_mount+0x28/0x50 [ext4]
> mount_fs+0x74/0x230
> vfs_kern_mount.part.6+0x6c/0x250
> do_mount+0x2fc/0x1280
> sys_mount+0x158/0x180
> system_call+0x5c/0x70
> EXT4-fs (pmem1p2): no journal found
> EXT4-fs (pmem1p2): can't get journal size
> EXT4-fs (pmem1p2): mounted filesystem without journal. Opts: dax,norecovery
> 
> Reported-by: Harish Sriram <harish@linux.ibm.com>
> Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>

The patch looks good to me. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/super.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index de5398c07161..5dc65b7583cb 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -3609,7 +3609,8 @@ int ext4_calculate_overhead(struct super_block *sb)
>  	 */
>  	if (sbi->s_journal && !sbi->journal_bdev)
>  		overhead += EXT4_NUM_B2C(sbi, sbi->s_journal->j_maxlen);
> -	else if (ext4_has_feature_journal(sb) && !sbi->s_journal) {
> +	else if (ext4_has_feature_journal(sb) && !sbi->s_journal && j_inum) {
> +		/* j_inum for internal journal is non-zero */
>  		j_inode = ext4_get_journal_inode(sb, j_inum);
>  		if (j_inode) {
>  			j_blocks = j_inode->i_size >> sb->s_blocksize_bits;
> -- 
> 2.21.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ext4: Check for non-zero journal inum in ext4_calculate_overhead
  2020-03-16  9:30 [PATCH] ext4: Check for non-zero journal inum in ext4_calculate_overhead Ritesh Harjani
  2020-03-17 11:17 ` Jan Kara
@ 2020-03-18 18:27 ` Eric Sandeen
  2020-03-19  4:36   ` Ritesh Harjani
  2020-03-24  1:52 ` Theodore Y. Ts'o
  2 siblings, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2020-03-18 18:27 UTC (permalink / raw)
  To: Ritesh Harjani, linux-ext4
  Cc: tytso, jack, adilger.kernel, linux-fsdevel, Harish Sriram

On 3/16/20 4:30 AM, Ritesh Harjani wrote:
> While calculating overhead for internal journal, also check
> that j_inum shouldn't be 0. Otherwise we get below error with
> xfstests generic/050 with external journal (XXX_LOGDEV config) enabled.
> 
> It could be simply reproduced with loop device with an external journal
> and marking blockdev as RO before mounting.
> 
> [ 3337.146838] EXT4-fs error (device pmem1p2): ext4_get_journal_inode:4634: comm mount: inode #0: comm mount: iget: illegal inode #
> ------------[ cut here ]------------
> generic_make_request: Trying to write to read-only block-device pmem1p2 (partno 2)

I think this 2nd error comes from:

static void save_error_info(struct super_block *sb, const char *func,
                            unsigned int line)
{
        __save_error_info(sb, func, line);
        ext4_commit_super(sb, 1);
}

__save_error_info() returns if bdev_read_only() but then we try to commit the super
anyway.  Shouldn't save_error_info() return early if bdev_read_only()?

(that'd be a separate patch, I'll send it)

-Eric


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ext4: Check for non-zero journal inum in ext4_calculate_overhead
  2020-03-18 18:27 ` Eric Sandeen
@ 2020-03-19  4:36   ` Ritesh Harjani
  0 siblings, 0 replies; 5+ messages in thread
From: Ritesh Harjani @ 2020-03-19  4:36 UTC (permalink / raw)
  To: Eric Sandeen, linux-ext4
  Cc: tytso, jack, adilger.kernel, linux-fsdevel, Harish Sriram



On 3/18/20 11:57 PM, Eric Sandeen wrote:
> On 3/16/20 4:30 AM, Ritesh Harjani wrote:
>> While calculating overhead for internal journal, also check
>> that j_inum shouldn't be 0. Otherwise we get below error with
>> xfstests generic/050 with external journal (XXX_LOGDEV config) enabled.
>>
>> It could be simply reproduced with loop device with an external journal
>> and marking blockdev as RO before mounting.
>>
>> [ 3337.146838] EXT4-fs error (device pmem1p2): ext4_get_journal_inode:4634: comm mount: inode #0: comm mount: iget: illegal inode #
>> ------------[ cut here ]------------
>> generic_make_request: Trying to write to read-only block-device pmem1p2 (partno 2)
> 
> I think this 2nd error comes from:
> 
> static void save_error_info(struct super_block *sb, const char *func,
>                              unsigned int line)
> {
>          __save_error_info(sb, func, line);
>          ext4_commit_super(sb, 1);
> }
> 
> __save_error_info() returns if bdev_read_only() but then we try to commit the super
> anyway.  Shouldn't save_error_info() return early if bdev_read_only()?
> 
> (that'd be a separate patch, I'll send it)

Thanks. Sounds good to me.


> 
> -Eric
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ext4: Check for non-zero journal inum in ext4_calculate_overhead
  2020-03-16  9:30 [PATCH] ext4: Check for non-zero journal inum in ext4_calculate_overhead Ritesh Harjani
  2020-03-17 11:17 ` Jan Kara
  2020-03-18 18:27 ` Eric Sandeen
@ 2020-03-24  1:52 ` Theodore Y. Ts'o
  2 siblings, 0 replies; 5+ messages in thread
From: Theodore Y. Ts'o @ 2020-03-24  1:52 UTC (permalink / raw)
  To: Ritesh Harjani
  Cc: linux-ext4, jack, adilger.kernel, linux-fsdevel, Harish Sriram

On Mon, Mar 16, 2020 at 03:00:38PM +0530, Ritesh Harjani wrote:
> While calculating overhead for internal journal, also check
> that j_inum shouldn't be 0. Otherwise we get below error with
> xfstests generic/050 with external journal (XXX_LOGDEV config) enabled.
> 
> It could be simply reproduced with loop device with an external journal
> and marking blockdev as RO before mounting.
> 
> [ 3337.146838] EXT4-fs error (device pmem1p2): ext4_get_journal_inode:4634: comm mount: inode #0: comm mount: iget: illegal inode #
> ------------[ cut here ]------------
> generic_make_request: Trying to write to read-only block-device pmem1p2 (partno 2)
> WARNING: CPU: 107 PID: 115347 at block/blk-core.c:788 generic_make_request_checks+0x6b4/0x7d0
> CPU: 107 PID: 115347 Comm: mount Tainted: G             L   --------- -t - 4.18.0-167.el8.ppc64le #1
> NIP:  c0000000006f6d44 LR: c0000000006f6d40 CTR: 0000000030041dd4
> <...>
> NIP [c0000000006f6d44] generic_make_request_checks+0x6b4/0x7d0
> LR [c0000000006f6d40] generic_make_request_checks+0x6b0/0x7d0
> <...>
> Call Trace:
> generic_make_request_checks+0x6b0/0x7d0 (unreliable)
> generic_make_request+0x3c/0x420
> submit_bio+0xd8/0x200
> submit_bh_wbc+0x1e8/0x250
> __sync_dirty_buffer+0xd0/0x210
> ext4_commit_super+0x310/0x420 [ext4]
> __ext4_error+0xa4/0x1e0 [ext4]
> __ext4_iget+0x388/0xe10 [ext4]
> ext4_get_journal_inode+0x40/0x150 [ext4]
> ext4_calculate_overhead+0x5a8/0x610 [ext4]
> ext4_fill_super+0x3188/0x3260 [ext4]
> mount_bdev+0x778/0x8f0
> ext4_mount+0x28/0x50 [ext4]
> mount_fs+0x74/0x230
> vfs_kern_mount.part.6+0x6c/0x250
> do_mount+0x2fc/0x1280
> sys_mount+0x158/0x180
> system_call+0x5c/0x70
> EXT4-fs (pmem1p2): no journal found
> EXT4-fs (pmem1p2): can't get journal size
> EXT4-fs (pmem1p2): mounted filesystem without journal. Opts: dax,norecovery
> 
> Reported-by: Harish Sriram <harish@linux.ibm.com>
> Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>

Applied, thanks.

					- Ted

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-24  1:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-16  9:30 [PATCH] ext4: Check for non-zero journal inum in ext4_calculate_overhead Ritesh Harjani
2020-03-17 11:17 ` Jan Kara
2020-03-18 18:27 ` Eric Sandeen
2020-03-19  4:36   ` Ritesh Harjani
2020-03-24  1:52 ` Theodore Y. 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).