[Ocfs2-tools-devel] [PATCH 1/1] Fix a wrong usage of "startblk" during offline resize and backup super.

Joel Becker Joel.Becker at oracle.com
Tue Nov 6 13:08:12 PST 2007


On Tue, Nov 06, 2007 at 02:27:33PM +0800, Tao Ma wrote:
> During offline resize, opts.num_blocks indicates the block count for
> the ocfs2 volume, not the increased block count. But update_backup_super
> use the wrong meaning by mistake. So when we increase the block into a
> a number which isn't aligned with cluster size, startblk will overflow
> since fs->fs_blocks will be lower than num_blocks and no backup super
> blocks will be allocated since ocfs2_set_backup_super will never be
> called.
> 
> So record the old_blocks when we do offline resize and that is the
> really start offset for the new blocks.
> 
> Signed-off-by: Tao Ma <tao.ma at oracle.com>

Looks pretty straightforward to me.

Signed-off-by: Joel Becker <joel.becker at oracle.com>

> ---
>  tunefs.ocfs2/tunefs.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/tunefs.ocfs2/tunefs.c b/tunefs.ocfs2/tunefs.c
> index 85070f7..6b2db21 100644
> --- a/tunefs.ocfs2/tunefs.c
> +++ b/tunefs.ocfs2/tunefs.c
> @@ -1195,12 +1195,12 @@ static errcode_t refresh_backup_super(ocfs2_filesys *fs)
>  	return ret;
>  }
>  
> -static errcode_t update_backup_super(ocfs2_filesys *fs, uint64_t newblocks)
> +static errcode_t update_backup_super(ocfs2_filesys *fs, uint64_t startblk,
> +				     uint64_t newblocks)
>  {
>  	errcode_t ret;
>  	int num, i;
>  	uint64_t *new_backup_super, blocks[OCFS2_MAX_BACKUP_SUPERBLOCKS];
> -	uint64_t startblk = fs->fs_blocks - newblocks;
>  
>  	num = ocfs2_get_backup_super_offset(fs, blocks, ARRAY_SIZE(blocks));
>  	if (!num)
> @@ -1259,6 +1259,7 @@ int main(int argc, char **argv)
>  	uint16_t max_slots;
>  	uint64_t def_jrnl_size = 0;
>  	uint64_t num_clusters;
> +	uint64_t old_blocks = 0;
>  	int dirty = 0;
>  	char old_uuid[OCFS2_VOL_UUID_LEN * 2 + 1];
>  	char new_uuid[OCFS2_VOL_UUID_LEN * 2 + 1];
> @@ -1540,6 +1541,7 @@ int main(int argc, char **argv)
>  
>  	/* update volume size */
>  	if (opts.num_blocks) {
> +		old_blocks = fs->fs_blocks;
>  		ret = update_volume_size(fs, &upd_blocks);
>  		if (ret) {
>  			com_err(opts.progname, ret,
> @@ -1559,7 +1561,7 @@ int main(int argc, char **argv)
>  	    OCFS2_HAS_COMPAT_FEATURE(OCFS2_RAW_SB(fs->fs_super),
>  				     OCFS2_FEATURE_COMPAT_BACKUP_SB))) {
>  		block_signals(SIG_BLOCK);
> -		ret = update_backup_super(fs, opts.num_blocks);
> +		ret = update_backup_super(fs, old_blocks, opts.num_blocks);
>  		block_signals(SIG_UNBLOCK);
>  		if (ret) {
>  			com_err(opts.progname, ret,
> -- 
> 1.5.3.2.g4f337
> 
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> http://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel

-- 

"Well-timed silence hath more eloquence than speech."  
         - Martin Fraquhar Tupper

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127



More information about the Ocfs2-tools-devel mailing list