On Mon, 04 Jun 2018 05:33:03 +0200, Valentin Vidic said: > On Sun, Jun 03, 2018 at 06:25:56PM -0400, Hugo Lefeuvre wrote: > > The vfs documentation states: release() is "called when the last > > reference to an open file is closed". > > > > Let's say we have a program with threads T1 and T2. > > > > - T1 calls ioctl on a file descriptor FD. > > - (on another processor) T2 closes FD. > > > > Since the last reference to FD was closed by T2, release is called. That's subtly wrong. T2 releases its reference to the file descriptor. > > But while release is being called, the ioctl call from T1 may still > > be running, right ? Remember that ioctl needs an open FD as well - so the ioctl() grabs its own reference, and then *that* reference to the file descriptor stays in place at least until the ioctl() return. At *that* point, the reference count goes to zero and the file is actually closed. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies