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

Re: [Cluster-devel] [PATCH] fsck.gfs2: special handling for gfs1 sb update



Hi Abhi,

On Mon, Feb 24, 2014 at 10:15:15PM -0500, Abhijith Das wrote:
> Since the gfs2_sb structure doesn't contain all the gfs1 fields,
> updating using lgfs2_sb_write overwrites some gfs1 fields with
> zeros and breaks the filesystem.
> 
> We need to update only the gfs2_sb fields and leave the rest as-is.
> 
> Signed-off-by: Abhi Das <adas redhat com>
> 
> diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
> index 0f33aa6..cf45a5c 100644
> --- a/gfs2/fsck/initialize.c
> +++ b/gfs2/fsck/initialize.c
> @@ -60,6 +60,9 @@ static int block_mounters(struct gfs2_sbd *sdp, int block_em)
>  		}
>  	}
>  
> +	if (sdp->gfs1)
> +		return lgfs2_sb_update(sdp);
> +
>  	if (lgfs2_sb_write(&sdp->sd_sb, sdp->device_fd, sdp->bsize)) {
>  		stack;
>  		return -1;
> diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
> index 6372128..a20e369 100644
> --- a/gfs2/libgfs2/libgfs2.h
> +++ b/gfs2/libgfs2/libgfs2.h
> @@ -754,6 +754,7 @@ static inline unsigned int rgrp_size(struct rgrp_tree *rgrp)
>  extern int build_master(struct gfs2_sbd *sdp);
>  extern void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize);
>  extern int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize);
> +extern int lgfs2_sb_update(struct gfs2_sbd *sbp);
>  extern int build_journal(struct gfs2_sbd *sdp, int j,
>  			 struct gfs2_inode *jindex);
>  extern int build_jindex(struct gfs2_sbd *sdp);
> diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
> index 2cc9a98..641d875 100644
> --- a/gfs2/libgfs2/structures.c
> +++ b/gfs2/libgfs2/structures.c
> @@ -105,6 +105,17 @@ void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize)
>  #endif
>  }
>  
> +int lgfs2_sb_update(struct gfs2_sbd *sbp)
> +{
> +	struct gfs2_buffer_head *bh;
> +
> +	bh = bread(sbp, GFS2_SB_ADDR >> sbp->sd_fsb2bb_shift);

Perhaps it should return non-zero if bh == NULL. bread() is one of those cases where libgfs2 still calls exit() in an error path but that's going to change at some point (I promise!).

> +	gfs2_sb_out(&sbp->sd_sb, bh->b_data);

I think a bmodified(bh); might be needed here too. I've been slowing pushing the gfs2_buffer_head usage out of ondisk.c and the long term plan is to replace them entirely but until then we'll need to set them modified explicitly in some cases.

Cheers,
Andy

> +	brelse(bh);
> +	fsync(sbp->device_fd); /* make sure the change gets to disk ASAP */
> +	return 0;
> +}
> +
>  int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize)
>  {
>  	int i, err = -1;
> 


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