tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: struct file at VFS level (round 1.5)
On Tue, May 03, 2016 at 05:33:34AM +0200, Emmanuel Dreyfus wrote:
> Christoph Badura <bad%bsd.de@localhost> wrote:
>
> > Mandatory file locking simply is a SMOP for the kernel to add a flag to a
> > vnode that indicates whether mandatory locking is in effect and adding the
> > necessary checks and interaction with file systems to open(2), read(2),
> > write(2) etc. at the syscall level. VOP_ADVLOCK is the right place to
> > handle the necessary interaction with the file systems.[3]
>
> Please tell me if I understood your point of view correctly: you mean
> that mandatory locks should be implemented above VFS, by turning for
> instance a write operation into VOP_ADVLOCK then on success VOP_WRITE?
Yes. Mandatory locking is pretty much like:
- for the read case
off = current_file_offset
VOP_ADVLOCK(F_RDLCK, off, size_of_read)
VOP_READ(...)
VOP_ADVLOCK(F_UNLCK, off, size_of_read)
- for the write case
off = current_file_offset
VOP_ADVLOCK(F_WRLCK, off, size_of_write)
VOP_WRITE(...)
VOP_ADVLOCK(F_UNLCK, off, size_of_write)
Except that it is unclear to me how the F_UNLCK interacts with overlapping
read locks set explicitly by the process. I.e. is the pre-existing read-lock
split or truncated? But I guess it is OK to have the same lossage as with
advisory locks.
--chris
Home |
Main Index |
Thread Index |
Old Index