My mistake. It looks like the unreservespace is working correctly now...
xfs_bmap
says there is a hole and it now looks like there is one in the file.
thanks,
Ian
"Ian S. Nelson" wrote:
> Steve Lord wrote:
>
> > > So the fcntl is different from the ioctl?
> >
> > No, Irix uses fcntl for these calls, we made them ioctl calls on Linux.
>
> good, I was starting to sweat that a little. I thought they were implemented
> in
> 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.
>
> I will do that immediately and post a follow up as soon as I'm done.
>
> > 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.
>
> That is exactly what I want. I'm building a TiVo and so we are always
> recording
> what is on live TV so that the user can pause it and go back. We just want
> to be
> able to free space if the user leaves the box on for a week and never changes
> channel or does something to cause us to start the recording over. With our
> MPEG
> indexing, I think it's actually easier to have a sparse file of the same
> "length"
> and then to just remember that we cut the front out of it...
>
> Thank you for you help and I'll post a follow up in a few minutes.
>
> Ian Nelson
>
> > It is entirely possible you are hitting a bug in the XFS linux code here,
> > these calls are not frequently used.
> >
> > Steve
|