xfs
[Top] [All Lists]

Re: [PATCH, RFC] xfstests: random fallocate calls in fsx

To: Eric Sandeen <sandeen@xxxxxxxxxxx>
Subject: Re: [PATCH, RFC] xfstests: random fallocate calls in fsx
From: "Josef 'Jeff' Sipek" <jeffpc@xxxxxxxxxxxxxx>
Date: Wed, 3 Jun 2009 19:19:39 -0400
Cc: xfs mailing list <xfs@xxxxxxxxxxx>
In-reply-to: <4A0B420E.3070908@xxxxxxxxxxx>
References: <4A0B420E.3070908@xxxxxxxxxxx>
User-agent: Mutt/1.5.18 (2008-05-17)
Good idea.

On Wed, May 13, 2009 at 04:56:30PM -0500, Eric Sandeen wrote:
> Seems to work for me.  Any comments/suggestions?
> 
> I can probably make it fall back to the xfs ioctl if fallocate
> isn't supported, if strongly desired.

Is the ioctl going away anytime soon? If not, it might be worth having fsx
use _both_ if possible, or just the ioctl if fallocate doesn't seem to be
available.

> @@ -770,6 +788,64 @@ dotruncate(unsigned size)
>       }
>  }
>  
> +#ifdef FALLOCATE
> +/* fallocate is basically a no-op unless extending, then a lot like a 
> truncate */
> +void
> +dofallocate(unsigned offset, unsigned length)
> +{
> +     unsigned end_offset;
> +     int keep_size;
> +
> +        if (length == 0) {
> +                if (!quiet && testcalls > simulatedopcount)
> +                        prt("skipping zero length fallocate\n");
> +                log4(OP_SKIPPED, OP_FALLOCATE, offset, length);
> +                return;
> +        }
> +
> +     keep_size = random() % 2;
> +
> +     end_offset = keep_size ? 0 : offset + length;

I prefer seeing explicit ( ) in this case.

...
-- 
Reality is merely an illusion, albeit a very persistent one.
                - Albert Einstein

<Prev in Thread] Current Thread [Next in Thread>