develoment workflow: how to avoid duplicate work ?

Valentin Vidic Valentin.Vidic at CARNet.hr
Sun Jun 3 23:33:03 EDT 2018


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.
> But while release is being called, the ioctl call from T1 may still
> be running, right ?

Indeed, I did a quick test and close can return in userspace before
ioctl has finished.  But in kernel space release does not even start
until ioctl has finished.  So it seems there exists some mechanism to
delay release until all operations on a file descriptor have finished?

View from userspace:

1528082878 opened file 3
1528082878 ioctl start 3
1528082879 close start 3
1528082879 close return 0
1528082883 ioctl return 0

View from kernelspace:

[215422.216734] pi433 pi433.0: ioctl: sleep
[215427.296761] pi433 pi433.0: ioctl: start
[215427.296772] pi433 pi433.0: ioctl: rdtx
[215427.296783] pi433 pi433.0: ioctl: rdtx done
[215427.296792] pi433 pi433.0: ioctl: return 0
[215427.296807] pi433 pi433.0: release: start
[215427.296816] pi433 pi433.0: release: return

-- 
Valentin



More information about the Kernelnewbies mailing list