All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/4] xfs: don't propagate invalid extent size hints to new files
Date: Fri, 14 May 2021 08:55:33 -0700	[thread overview]
Message-ID: <20210514155533.GJ9675@magnolia> (raw)
In-Reply-To: <YJ5vQ2GHFw2EilJO@bfoster>

On Fri, May 14, 2021 at 08:38:27AM -0400, Brian Foster wrote:
> On Wed, May 12, 2021 at 06:01:53PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > Under the current inode extent size hint validation rules, it's possible
> > to set extent size hints on directories along with an 'inherit' flag so
> > that the values will be propagated to newly created regular files.  (The
> > directories themselves do not care about the hint values.)
> > 
> > For these directories, the alignment of the hint is checked against the
> > data device even if the directory also has the rtinherit hint set, which
> > means that one can set a directory's hint value to something that isn't
> > an integer multiple of the realtime extent size.  This isn't a problem
> > for the directory itself, but the validation routines require rt extent
> > alignment for realtime files.
> > 
> > If the unaligned hint value and the realtime bit are both propagated
> > into a newly created regular realtime file, we end up writing out an
> > incorrect hint that trips the verifiers the next time we try to read the
> > inode buffer, and the fs shuts down.  Fix this by cancelling the hint
> > propagation if it would cause problems.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> 
> Hmm.. this seems a bit unfortunate. Is the purpose of this flag
> cancellation behavior basically to accommodate existing filesystems that
> might have this incompatible combination in place?

Yes.  The incompatible combination when set on a directory is benign,
but setting it on regular files gets us into real trouble, so the goal
here is to end the propagation of the incompatible values.

--D

> Brian
> 
> >  fs/xfs/xfs_inode.c |   19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> > 
> > 
> > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > index 0369eb22c1bb..db81e8c22708 100644
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -689,6 +689,7 @@ xfs_inode_inherit_flags(
> >  	struct xfs_inode	*ip,
> >  	const struct xfs_inode	*pip)
> >  {
> > +	xfs_failaddr_t		failaddr;
> >  	unsigned int		di_flags = 0;
> >  	umode_t			mode = VFS_I(ip)->i_mode;
> >  
> > @@ -728,6 +729,14 @@ xfs_inode_inherit_flags(
> >  	if (pip->i_diflags & XFS_DIFLAG_FILESTREAM)
> >  		di_flags |= XFS_DIFLAG_FILESTREAM;
> >  
> > +	/* Make sure the extsize actually validates properly. */
> > +	failaddr = xfs_inode_validate_extsize(ip->i_mount, ip->i_extsize,
> > +			VFS_I(ip)->i_mode, ip->i_diflags);
> > +	if (failaddr) {
> > +		di_flags &= ~(XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT);
> > +		ip->i_extsize = 0;
> > +	}
> > +
> >  	ip->i_diflags |= di_flags;
> >  }
> >  
> > @@ -737,12 +746,22 @@ xfs_inode_inherit_flags2(
> >  	struct xfs_inode	*ip,
> >  	const struct xfs_inode	*pip)
> >  {
> > +	xfs_failaddr_t		failaddr;
> > +
> >  	if (pip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) {
> >  		ip->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE;
> >  		ip->i_cowextsize = pip->i_cowextsize;
> >  	}
> >  	if (pip->i_diflags2 & XFS_DIFLAG2_DAX)
> >  		ip->i_diflags2 |= XFS_DIFLAG2_DAX;
> > +
> > +	/* Make sure the cowextsize actually validates properly. */
> > +	failaddr = xfs_inode_validate_cowextsize(ip->i_mount, ip->i_cowextsize,
> > +			VFS_I(ip)->i_mode, ip->i_diflags, ip->i_diflags2);
> > +	if (failaddr) {
> > +		ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE;
> > +		ip->i_cowextsize = 0;
> > +	}
> >  }
> >  
> >  /*
> > 
> 

  reply	other threads:[~2021-05-14 15:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13  1:01 [PATCHSET 0/4] xfs: strengthen validation of extent size hints Darrick J. Wong
2021-05-13  1:01 ` [PATCH 1/4] xfs: standardize extent size hint validation Darrick J. Wong
2021-05-14 12:38   ` Brian Foster
2021-05-13  1:01 ` [PATCH 2/4] xfs: don't propagate invalid extent size hints to new files Darrick J. Wong
2021-05-14 12:38   ` Brian Foster
2021-05-14 15:55     ` Darrick J. Wong [this message]
2021-05-13  1:01 ` [PATCH 3/4] xfs: validate extsz hints against rt extent size when rtinherit is set Darrick J. Wong
2021-05-14 12:38   ` Brian Foster
2021-05-14 18:22     ` Darrick J. Wong
2021-05-14 18:51       ` Brian Foster
2021-05-14 20:30         ` Darrick J. Wong
2021-05-13  1:02 ` [PATCH 4/4] xfs: apply rt extent alignment constraints to cow extsize hint Darrick J. Wong
2021-05-14 17:24   ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210514155533.GJ9675@magnolia \
    --to=djwong@kernel.org \
    --cc=bfoster@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.