VOP_INACTIVE(9): reclaiming space for open but deleted files?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

VOP_INACTIVE(9): reclaiming space for open but deleted files?

Alan Somers-2
VOP_INACTIVE(9) says that the vop can "be used to reclaim space for
‘open but deleted’ files".  What does that mean?  How can you reclaim
space for open files?  I assume it's just a mistake, but I want to
check before I fix the man page.  SVN archaeology shows that the line
has been present since a mass import of man pages in 1997.
-Alan
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: VOP_INACTIVE(9): reclaiming space for open but deleted files?

Conrad Meyer-2
Inactive is called when the last “open” goes away.

On Fri, Mar 15, 2019 at 7:46 AM Alan Somers <[hidden email]> wrote:

> VOP_INACTIVE(9) says that the vop can "be used to reclaim space for
> ‘open but deleted’ files".  What does that mean?  How can you reclaim
> space for open files?  I assume it's just a mistake, but I want to
> check before I fix the man page.  SVN archaeology shows that the line
> has been present since a mass import of man pages in 1997.
> -Alan
> _______________________________________________
> [hidden email] mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "[hidden email]"
>
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: VOP_INACTIVE(9): reclaiming space for open but deleted files?

Konstantin Belousov
In reply to this post by Alan Somers-2
On Fri, Mar 15, 2019 at 08:44:57AM -0600, Alan Somers wrote:
> VOP_INACTIVE(9) says that the vop can "be used to reclaim space for
> ‘open but deleted’ files".  What does that mean?  How can you reclaim
> space for open files?  I assume it's just a mistake, but I want to
> check before I fix the man page.  SVN archaeology shows that the line
> has been present since a mass import of man pages in 1997.

VOP_INACTIVE() call means that the last use count for the vnode is
dereferenced. This can only happen when there is no more open files
using the vnode.

Now consider what happens when you open file, then unlink it while
keeping the file opened. Filesystems usually mark such files with
VV_NOSYNC v_vflag, but there are typically other means to determine that
there is no name for the inode, like UFS i_nlink. On the last close
VOP_INACTIVE() is called (this is not guaranteed but you need to race to
not get the call). Then, if the vnode is not reclaimed, it is put on the
free list and the allocated blocks and other resources linger until the
vnode is reclaim (reclaim absolutely must free space for inodes which
cannot be reached).  If inactive() frees the resources, the temporal
leak is avoided.

As example look at UFS_INACTIVE().  If it detects file with effective link
count of zero, it resets i_mode and calls ffs_vfree() to free inode.  Then
the vnode is reclaimed.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: VOP_INACTIVE(9): reclaiming space for open but deleted files?

Alan Somers-2
On Fri, Mar 15, 2019 at 9:19 AM Konstantin Belousov <[hidden email]> wrote:

>
> On Fri, Mar 15, 2019 at 08:44:57AM -0600, Alan Somers wrote:
> > VOP_INACTIVE(9) says that the vop can "be used to reclaim space for
> > ‘open but deleted’ files".  What does that mean?  How can you reclaim
> > space for open files?  I assume it's just a mistake, but I want to
> > check before I fix the man page.  SVN archaeology shows that the line
> > has been present since a mass import of man pages in 1997.
>
> VOP_INACTIVE() call means that the last use count for the vnode is
> dereferenced. This can only happen when there is no more open files
> using the vnode.
>
> Now consider what happens when you open file, then unlink it while
> keeping the file opened. Filesystems usually mark such files with
> VV_NOSYNC v_vflag, but there are typically other means to determine that
> there is no name for the inode, like UFS i_nlink. On the last close
> VOP_INACTIVE() is called (this is not guaranteed but you need to race to
> not get the call). Then, if the vnode is not reclaimed, it is put on the
> free list and the allocated blocks and other resources linger until the
> vnode is reclaim (reclaim absolutely must free space for inodes which
> cannot be reached).  If inactive() frees the resources, the temporal
> leak is avoided.
>
> As example look at UFS_INACTIVE().  If it detects file with effective link
> count of zero, it resets i_mode and calls ffs_vfree() to free inode.  Then
> the vnode is reclaimed.

Ok, so the man page is talking files which were formerly open but
deleted, but are no longer open.  I find the wording confusing.  It
seems to refer to files that are still open but deleted.

-Alan
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: VOP_INACTIVE(9): reclaiming space for open but deleted files?

Conrad Meyer-2
On Fri, Mar 15, 2019 at 9:26 AM Alan Somers <[hidden email]> wrote:
> Ok, so the man page is talking files which were formerly open but
> deleted, but are no longer open.  I find the wording confusing.  It
> seems to refer to files that are still open but deleted.

Hi Alan,

I totally agree that the wording could be more clear.  If you'd like
to improve it and want a second pair of eyes on the modified text,
feel free to CC me.  I appreciate anything that improves the clarity
of our VFS documentation, especially given how complex VFS is.

(In particular, if Andriy ever deleted
https://wiki.freebsd.org/AndriyGapon/AvgVfsSolarisVsFreeBSD , I would
be lost :-).)

Best,
Conrad
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: VOP_INACTIVE(9): reclaiming space for open but deleted files?

Rozhuk Ivan-2
In reply to this post by Konstantin Belousov
On Fri, 15 Mar 2019 17:19:20 +0200
Konstantin Belousov <[hidden email]> wrote:

> On Fri, Mar 15, 2019 at 08:44:57AM -0600, Alan Somers wrote:
> > VOP_INACTIVE(9) says that the vop can "be used to reclaim space for
> > ‘open but deleted’ files".  What does that mean?  How can you
> > reclaim space for open files?  I assume it's just a mistake, but I
> > want to check before I fix the man page.  SVN archaeology shows
> > that the line has been present since a mass import of man pages in
> > 1997.  
>
> VOP_INACTIVE() call means that the last use count for the vnode is
> dereferenced. This can only happen when there is no more open files
> using the vnode.
>

I was seen another use case: app allocate file to 10gb,
mmap() 4mb, write(), unmap()...many times. 10gb writed. close().
And FreeBSD keep all 10g ram as incative/wired, and dot not allow use it.
Untill file readed or deleted.
That was on 10x, without swap.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: VOP_INACTIVE(9): reclaiming space for open but deleted files?

Konstantin Belousov-3
On Sat, Mar 16, 2019 at 03:55:07AM +0300, Rozhuk Ivan wrote:

> On Fri, 15 Mar 2019 17:19:20 +0200
> Konstantin Belousov <[hidden email]> wrote:
>
> > On Fri, Mar 15, 2019 at 08:44:57AM -0600, Alan Somers wrote:
> > > VOP_INACTIVE(9) says that the vop can "be used to reclaim space for
> > > ‘open but deleted’ files".  What does that mean?  How can you
> > > reclaim space for open files?  I assume it's just a mistake, but I
> > > want to check before I fix the man page.  SVN archaeology shows
> > > that the line has been present since a mass import of man pages in
> > > 1997.  
> >
> > VOP_INACTIVE() call means that the last use count for the vnode is
> > dereferenced. This can only happen when there is no more open files
> > using the vnode.
> >
>
> I was seen another use case: app allocate file to 10gb,
Another case of what ?

> mmap() 4mb, write(), unmap()...many times. 10gb writed. close().
> And FreeBSD keep all 10g ram as incative/wired, and dot not allow use it.
> Untill file readed or deleted.
> That was on 10x, without swap.
So what is the problem ?
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"