xfs
[Top] [All Lists]

Re: Difference between XFS_IOC_FREESP and XFS_IOC_UNRESVSP

To: ian.nelson@xxxxxxxxxxxx
Subject: Re: Difference between XFS_IOC_FREESP and XFS_IOC_UNRESVSP
From: Steve Lord <lord@xxxxxxx>
Date: Tue, 09 Oct 2001 13:32:11 -0500
Cc: Eric Sandeen <sandeen@xxxxxxx>, "linux-xfs@xxxxxxxxxxx" <linux-xfs@xxxxxxxxxxx>
In-reply-to: Message from "Ian S. Nelson" <ian.nelson@xxxxxxxxxxxx> of "Mon, 08 Oct 2001 15:29:38 MDT." <3BC21AC2.499CBA57@xxxxxxxxxxxx>
Sender: owner-linux-xfs@xxxxxxxxxxx
> So the fcntl is different from the ioctl?

No, Irix uses fcntl for these calls, we made them ioctl calls on Linux.

> 
> What I'm trying to do is poke a hole in a file where there used to be data.  
> The
> specific application is with a big long stream of mpeg data and we want to
> truncate it from the front to avoid running out of disk space.
> 
> 
> Here is my function:
> 
> int trim(int fd, unsigned long long offset)
> {
>         struct xfs_flock64 flock;
>         int rc;
> 
>         flock.l_whence = 0;
>         flock.l_start = 0;
>         flock.l_len = offset;
> 
>         rc = ioctl( fd, XFS_IOC_UNRESVSP, &flock );
>         printf("rc: %d\n", rc);
> }
> 
> 
> When I put an XFS_IOC_FREESP in then it makes a zero length file.  If I put
> XFS_IOC_UNRESVSP in then it looks like it pokes a hole in the whole file.  Am
>  I
> trying to do something that XFS on linux won't do?

To remove space from a file you should use UNRESVSP, FREESP will only work
at the end of the file I think.

You say UNRESVSP is poking a hole in the whole file, are you saying that
the complete contents disappear? Can you run the xfs_bmap -v command on
the file before and after your program? This will report what the extents
look like and should report the space being removed.

Note that neither call can change the file offset of the data, so you
cannot remove the first Mbyte from a file and have what used to be the
second Mbyte appear as the start of the file, you can merely free the
space used by the first Mbyte.

It is entirely possible you are hitting a bug in the XFS linux code here,
these calls are not frequently used.

Steve




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