Re: [PATCH v2 07/12] jbd2: add fast_commit space check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu 10-08-23 16:54:12, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@xxxxxxxxxx>
> 
> If JBD2_FEATURE_INCOMPAT_FAST_COMMIT bit is set, it means the journal
> have fast commit records need to recover, so the fast commit size
> should not be too large, and the leftover normal journal size should
> never less than JBD2_MIN_JOURNAL_BLOCKS. If it happens, the
> journal->j_last is likely to be wrong and will probably lead to
> incorrect journal recovery. So add a check into the
> journal_check_superblock(), and drop the pointless check when
> initializing the fastcommit parameters.
> 
> Signed-off-by: Zhang Yi <yi.zhang@xxxxxxxxxx>

Just one small note below. With that fixed feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

> @@ -1389,6 +1390,14 @@ static int journal_check_superblock(journal_t *journal)
>  		return err;
>  	}
>  
> +	num_fc_blks = jbd2_has_feature_fast_commit(journal) ?
> +				jbd2_journal_get_num_fc_blks(sb) : 0;
> +	if (be32_to_cpu(sb->s_maxlen) < JBD2_MIN_JOURNAL_BLOCKS + num_fc_blks) {

To avoid possible overflow of the right hand side, we should probably do
the check like:

	if (be32_to_cpu(sb->s_maxlen) < JBD2_MIN_JOURNAL_BLOCKS ||
	    be32_to_cpu(sb->s_maxlen) - JBD2_MIN_JOURNAL_BLOCKS < num_fc_blks) {
		...
	}

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux