tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: struct file reference at VFS level



On Thu, Apr 28, 2016 at 09:54:05AM +0200, J. Hannken-Illjes wrote:
> In your example process 2 writes without locking, is it part of your
> proposed semantics to add an implicit lock/unlock to read and write
> operations?

The given scenario is a test case for mandatory lock support. Process 2 
does not acquire a lock and tries to write to a locked part. With advisory
locks, the write succeeds, but with mandatory locks, it must fail. We
use O_NONBLOCK for convenience so that it fails immediatly, but this is
not a requirement for the test.

> Wouldn't it be better to put the mandatory locking at the file->vnode
> level, operations vn_read() and vn_write()?

Do you mean that instead of providing support so that filesystems 
can implement mandatory locks, we should just implement it above VFS
for all filesystems? That would work for local filesystems, but I 
understand it cannot be done for distributed filesystems, as the 
local kernel knows nothing about locks set by other machines: you 
need to let the filesystem handle it.

> Could you explain the proposed semantics in detail?

We have this:
https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt

-- 
Emmanuel Dreyfus
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index