On Wed, Sep 08, 2004 at 01:25:29PM +0200, Miguel Angel de Vega wrote:
> Hi all!
>
> I'm trying to do a program that preallocate a file and fill it, but when I
> use
> xfs_bmap on the file gives me the same number of holes that if I don't do
> preallocation. To preallocate I use de ioctl call with XFS_IOC_RESVSP64 in
> this way:
Could you post the "xfs_bmap -v" output after the preallocate?
And would be a good idea to do some error checking in your
program (esp. to make sure the preallocate is succeeding).
> int main(int argc, char **argv)
> {
> int oflags = O_CREAT|O_TRUNC|O_WRONLY;
> int fd=0;
> xfs_flock64_t flck;
> if(argc < 3)
> {
> printf("usage: %s [filename] [numbytes]\n", argv[0]);
> exit (1);
> }
>
> int numImages = atoll(argv[2]);
>
> int aux = 66;
> long long int bufferSize = 720 * 576 * 2;
Thats an odd write buffer size (829440 bytes?)... why that?
> int buffer[bufferSize];
> bzero(buffer, bufferSize);
>
>
> flck.l_whence = SEEK_SET;
> flck.l_start = 0LL;
> flck.l_len = numImages * bufferSize;
>
> fd = open(argv[1], oflags, 0600);
> int res = ioctl(fd, XFS_IOC_RESVSP64, &flck);
So, add an exit(0) here and then grab the verbose xfs_bmap output,
that'll show the extent layout before your writes.
> for(int i = 0; i < numImages; i++)
> write(fd, buffer, bufferSize);
>
> close(fd);
> exit( 0 );
> }
Also, is your filesystem anywhere near full? Perhaps the
allocator is just unable to find contiguous chunks?
Actually it'll probably be easier to figure out the behavior
you're seeing using xfs_io, e.g:
[root@bruce fsgqa]# xfs_io -f /scratch/xfs5/test
xfs_io> resvsp 0 100m
xfs_io> bmap -v
/scratch/xfs5/test:
EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET TOTAL FLAGS
0: [0..204799]: 104..204903 0 (104..204903) 204800 10000
xfs_io> pwrite -b 829440 0 100m
wrote 104857600/104857600 bytes at offset 0
100 MiB, 127 ops; 00:00:01.375355 (72.709 MiB/sec and 92.3398 ops/sec)
xfs_io> fsync
xfs_io> bmap -v
/scratch/xfs5/test:
EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET TOTAL
0: [0..204799]: 104..204903 0 (104..204903) 204800
xfs_io>
So, sounds like you're not seeing that sort of layout?
What does the above produce on your filesystem?
cheers.
--
Nathan
|