public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
Cc: xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH 2/2] xfs_fsr: create extent-based attr to grow forkoff
Date: Fri, 11 May 2012 20:30:37 -0500	[thread overview]
Message-ID: <4FADBD3D.6060503@sandeen.net> (raw)
In-Reply-To: <4F75CAD9.60808@redhat.com>

On 3/30/12 10:01 AM, Eric Sandeen wrote:
> In some cases the target file may have a non-local attribute,
> but the temp file gets assigned a local attribute on creation,
> due to selinux, for example.
> 
> In this case, the large-ish selinux attr will create a forkoff
> in the temp file smaller than the forkoff in the target file,
> because the FMT_EXTENTS attr takes up less space.  There is
> no mechanism to grow the forkoff to match, so we can end up
> failing to swap these 2 inodes if the result is not enough
> data space in the temp inode as a result.
> 
> After testing the target file for a non-local extent, and
> checking to see if the forkoff needs to be grown on the first
> pass, we can add a large attr to knock all attributes of the
> temp file out of local format, and grow the fork offset.
> 
> This passes xfstest 227, and also resolves issues seen on
> a metadata image provided by Gabriel.

Ping on this one?  Would be nice to push it out.

-Eric

> Reported-by: Gabriel VLASIU <gabriel@vlasiu.net>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
> index d83bdc9..e8ab028 100644
> --- a/fsr/xfs_fsr.c
> +++ b/fsr/xfs_fsr.c
> @@ -1022,6 +1022,8 @@ fsr_setup_attr_fork(
>  	struct stat64	tstatbuf;
>  	int		i;
>  	int		diff = 0;
> +	struct fsxattr	fsx;
> +	int		target_attr_local = 0;
>  	int		last_forkoff = 0;
>  	int		no_change_cnt = 0;
>  	int		ret;
> @@ -1052,6 +1054,11 @@ fsr_setup_attr_fork(
>  		return -1;
>  	}
>  
> +	memset(&fsx, 0, sizeof(fsx));
> +	ioctl(fd, XFS_IOC_FSGETXATTR, &fsx);
> +	if (fsx.fsx_nextents == 0)
> +		target_attr_local = 1;
> +
>  	i = 0;
>  	do {
>  		xfs_bstat_t	tbstat;
> @@ -1072,6 +1079,7 @@ fsr_setup_attr_fork(
>  		if (dflag)
>  			fsrprintf(_("orig forkoff %d, temp forkoff %d\n"),
>  					bstatp->bs_forkoff, tbstat.bs_forkoff);
> +		diff = tbstat.bs_forkoff - bstatp->bs_forkoff;
>  
>  		snprintf(name, sizeof(name), "user.%d", i);
>  
> @@ -1086,6 +1094,21 @@ fsr_setup_attr_fork(
>  				return -1;
>  			}
>  			continue;
> +		} else if (i == 0 && diff < 0 && target_attr_local == 0) {
> +			/*
> +			 * A small attr may exist from eg selinux but, if the
> +			 * target is not local, write a big attr to tempfile
> +			 * to knock it out of local format to match target.
> +			 * This should actually increase the temp forkoffset.
> +			 */
> +			char val[2048];
> +			memset(val, 'X', 2048);
> +			ret = fsetxattr(tfd, name, val, 2048, XATTR_CREATE);
> +			if (ret) {
> +				fsrprintf(_("could not set large ATTR\n"));
> +				return -1;
> +			}
> +			continue;
>  		}
>  
>  		/*
> @@ -1100,7 +1123,6 @@ fsr_setup_attr_fork(
>  		last_forkoff = tbstat.bs_forkoff;
>  
>  		/* work out which way to grow the fork */
> -		diff = tbstat.bs_forkoff - bstatp->bs_forkoff;
>  		if (abs(diff) > fsgeom.inodesize - sizeof(struct xfs_dinode)) {
>  			fsrprintf(_("forkoff diff %d too large!\n"), diff);
>  			return -1;
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2012-05-12  1:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-30 14:54 [PATCH 1/2] xfs_fsr: extra debugging info Eric Sandeen
2012-03-30 15:01 ` [PATCH 2/2] xfs_fsr: create extent-based attr to grow forkoff Eric Sandeen
2012-03-30 18:11   ` Eric Sandeen
2012-05-12  1:30   ` Eric Sandeen [this message]
2013-10-10  3:11   ` Eric Sandeen
2013-10-10  3:21     ` Dave Chinner
2013-10-10  3:24       ` Eric Sandeen

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=4FADBD3D.6060503@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=xfs@oss.sgi.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox