Re: [PATCH] ext4: protect journal inode's blocks using block_validity

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

 



On Tue 09-04-19 23:38:59, Theodore Ts'o wrote:
> Add the blocks which belong to the journal inode to block_validity's
> system zone so attempts to deallocate or overwrite the journal due a
> corrupted file system where the journal blocks are also claimed by
> another inode.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202879
> Signed-off-by: Theodore Ts'o <tytso@xxxxxxx>
> ---
>  fs/ext4/block_validity.c | 48 ++++++++++++++++++++++++++++++++++++++++
>  fs/ext4/inode.c          |  4 ++++
>  2 files changed, 52 insertions(+)

The patch looks good to me just two suggestions:

...
> +	while (i < num) {
> +		map.m_lblk = i;
> +		map.m_len = num - i;
> +		n = ext4_map_blocks(NULL, inode, &map, 0);
> +		if (n < 0) {
> +			err = n;
> +			break;
> +		}
> +		if (n == 0) {
> +			i++;

map.m_len actually contains the hole length so you can do
			i += map.m_len;
to skip the whole hole at once.

> @@ -171,6 +213,12 @@ int ext4_setup_system_zone(struct super_block *sb)
>  		if (ret)
>  			return ret;
>  	}
> +	if (ext4_has_feature_journal(sb) && sbi->s_es->s_journal_inum) {
> +		ret = ext4_protect_reserved_inode(sb,
> +				le32_to_cpu(sbi->s_es->s_journal_inum));
> +		if (ret)
> +			return ret;
> +	}
>  

I guess we could protect resize inode the same way?

								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