lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <E88DA3F6-D339-44D6-95A8-75256A8F57CC@dilger.ca>
Date:   Sun, 4 Nov 2018 22:08:37 -0700
From:   Andreas Dilger <adilger@...ger.ca>
To:     Vasily Averin <vvs@...tuozzo.com>
Cc:     Ext4 Developers List <linux-ext4@...r.kernel.org>,
        Theodore Ts'o <tytso@....edu>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] ext4: remove code duplication in
 update_ind/bind/tind_extent_range

On Nov 4, 2018, at 9:41 AM, Vasily Averin <vvs@...tuozzo.com> wrote:
> 
> update_ind/bind/tind_extent_page() differs by one variable and can be
> replaced by unified function. These functions are called by similar way
> and their caller function can be simplified too.

The patch looks quite reasonable, though I'd suggest a couple of very
minor style changes (inline).  You can add to the resubmitted patch:

Reviewed-by: Andreas Dilger <adilger@...ger.ca>

> Signed-off-by: Vasily Averin <vvs@...tuozzo.com>
> ---
> fs/ext4/migrate.c | 111 ++++++++++------------------------------------
> 1 file changed, 23 insertions(+), 88 deletions(-)
> 
> diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
> index 61a9d1927817..02ce99ba32be 100644
> --- a/fs/ext4/migrate.c
> +++ b/fs/ext4/migrate.c
> @@ -109,12 +109,13 @@ static int update_extent_range(handle_t *handle, struct inode *inode,
> 
> static int update_ind_extent_range(handle_t *handle, struct inode *inode,
> 				   ext4_fsblk_t pblock,
> -				   struct migrate_struct *lb)
> +				   struct migrate_struct *lb,
> +				   ext4_lblk_t inc)
> {
> 	struct buffer_head *bh;
> 	__le32 *i_data;
> 	int i, retval = 0;
> -	unsigned long max_entries = inode->i_sb->s_blocksize >> 2;
> +	ext4_lblk_t max_entries = inode->i_sb->s_blocksize >> 2;
> 
> 	bh = sb_bread(inode->i_sb, pblock);
> 	if (!bh)
> @@ -523,34 +464,28 @@ int ext4_ext_migrate(struct inode *inode)
> 
> 	/* 32 bit block address 4 bytes */
> 	max_entries = inode->i_sb->s_blocksize >> 2;
> -	for (i = 0; i < EXT4_NDIR_BLOCKS; i++) {
> +
> +	inc = 1; mult = 1;
> +	for (i = 0; i < EXT4_N_BLOCKS; i++) {
> +		if (i == EXT4_IND_BLOCK)
> +			mult = max_entries;
> +		else if (i > EXT4_IND_BLOCK)
> +			inc = inc * mult;

This should be "inc *= mult".

> 		if (i_data[i]) {
> +			if (i < EXT4_IND_BLOCK)
> +				retval = update_extent_range(handle, tmp_inode,
> 						le32_to_cpu(i_data[i]), &lb);
> +			else
> +				retval = update_ind_extent_range(handle,
> +						tmp_inode,
> +						le32_to_cpu(i_data[i]),
> +						&lb, inc);
> 			if (retval)
> 				goto err_out;
> +
> +		} else if (i < EXT4_TIND_BLOCK)
> +			lb.curr_block += inc * mult;

There should be {} around the else-block to match the if-block.

Cheers, Andreas






Download attachment "signature.asc" of type "application/pgp-signature" (874 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ