diff mbox

[v2,4/5] xfs_repair: zero shared_vn

Message ID 20170120225251.GH12985@birch.djwong.org (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Darrick J. Wong Jan. 20, 2017, 10:52 p.m. UTC
Since shared_vn always has to be zero, zero it at the end of repair.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: reset shared_vn in phase 1 and tell the user about it, per sandeen
---
 repair/phase1.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Eric Sandeen Jan. 20, 2017, 11:08 p.m. UTC | #1
On 1/20/17 4:52 PM, Darrick J. Wong wrote:
> Since shared_vn always has to be zero, zero it at the end of repair.
                                                 ^^^^^^^^^^^^^^^^^^^^

Or at the beginning ;)

> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> v2: reset shared_vn in phase 1 and tell the user about it, per sandeen
> ---
>  repair/phase1.c |   11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/repair/phase1.c b/repair/phase1.c
> index 126d0b3..ee5d3d7 100644
> --- a/repair/phase1.c
> +++ b/repair/phase1.c
> @@ -138,6 +138,17 @@ _("Cannot disable lazy-counters on V5 fs\n"));
>  		}
>  	}
>  
> +	/* shared_vn should be zero */
> +	if (sb->sb_shared_vn) {
> +		if (!no_modify)  {
> +			do_warn(_("resetting shared_vn to zero\n"));
> +			sb->sb_shared_vn = 0;
> +			primary_sb_modified = 1;
> +		} else  {
> +			do_warn(_("would reset shared_vn to zero\n"));
> +		}
> +	}
> +

No other test has the if/else on no modify, they simply say what the problem
is, "correcting" etc, but at the /end/ it says whether or not it's written out:

        if (primary_sb_modified)  {
                if (!no_modify)  {
                        do_warn(_("writing modified primary superblock\n"));
                        write_primary_sb(sb, sb->sb_sectsize);
                } else  {
                        do_warn(_("would write modified primary superblock\n"));
                }
        }

So I think just something like:

+	if (sb->sb_shared_vn) {
+		do_warn(_("superblock has invalid shared_vn, resetting\n"));
+		sb->sb_shared_vn = 0;
+		primary_sb_modified = 1;
+	}

would suffice.

-Eric

>  	if (primary_sb_modified)  {
>  		if (!no_modify)  {
>  			do_warn(_("writing modified primary superblock\n"));
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Darrick J. Wong Jan. 21, 2017, 12:08 a.m. UTC | #2
On Fri, Jan 20, 2017 at 05:08:37PM -0600, Eric Sandeen wrote:
> On 1/20/17 4:52 PM, Darrick J. Wong wrote:
> > Since shared_vn always has to be zero, zero it at the end of repair.
>                                                  ^^^^^^^^^^^^^^^^^^^^
> 
> Or at the beginning ;)

"...at the start of repair."

> 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > v2: reset shared_vn in phase 1 and tell the user about it, per sandeen
> > ---
> >  repair/phase1.c |   11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/repair/phase1.c b/repair/phase1.c
> > index 126d0b3..ee5d3d7 100644
> > --- a/repair/phase1.c
> > +++ b/repair/phase1.c
> > @@ -138,6 +138,17 @@ _("Cannot disable lazy-counters on V5 fs\n"));
> >  		}
> >  	}
> >  
> > +	/* shared_vn should be zero */
> > +	if (sb->sb_shared_vn) {
> > +		if (!no_modify)  {
> > +			do_warn(_("resetting shared_vn to zero\n"));
> > +			sb->sb_shared_vn = 0;
> > +			primary_sb_modified = 1;
> > +		} else  {
> > +			do_warn(_("would reset shared_vn to zero\n"));
> > +		}
> > +	}
> > +
> 
> No other test has the if/else on no modify, they simply say what the problem
> is, "correcting" etc, but at the /end/ it says whether or not it's written out:
> 
>         if (primary_sb_modified)  {
>                 if (!no_modify)  {
>                         do_warn(_("writing modified primary superblock\n"));
>                         write_primary_sb(sb, sb->sb_sectsize);
>                 } else  {
>                         do_warn(_("would write modified primary superblock\n"));
>                 }
>         }
> 

Many of the repairs in later phases /do/ use this paradigm, though none
in this function do that.  I don't really care one way or the other, so
I'll change it to:

> So I think just something like:
> 
> +	if (sb->sb_shared_vn) {
> +		do_warn(_("superblock has invalid shared_vn, resetting\n"));
> +		sb->sb_shared_vn = 0;
> +		primary_sb_modified = 1;
> +	}
> 
> would suffice.

--D

> 
> -Eric
> 
> >  	if (primary_sb_modified)  {
> >  		if (!no_modify)  {
> >  			do_warn(_("writing modified primary superblock\n"));
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/repair/phase1.c b/repair/phase1.c
index 126d0b3..ee5d3d7 100644
--- a/repair/phase1.c
+++ b/repair/phase1.c
@@ -138,6 +138,17 @@  _("Cannot disable lazy-counters on V5 fs\n"));
 		}
 	}
 
+	/* shared_vn should be zero */
+	if (sb->sb_shared_vn) {
+		if (!no_modify)  {
+			do_warn(_("resetting shared_vn to zero\n"));
+			sb->sb_shared_vn = 0;
+			primary_sb_modified = 1;
+		} else  {
+			do_warn(_("would reset shared_vn to zero\n"));
+		}
+	}
+
 	if (primary_sb_modified)  {
 		if (!no_modify)  {
 			do_warn(_("writing modified primary superblock\n"));