CIFS VFS
Quoted 6 lines · Matthew Wilcox
Quoted 1 line · Steven French
8) Byte Range and File locks
there's some changes in progress around file locking in 2.5... let me know your requirements.
If I can place ncpfs's requirements here...
For ncpfs easiest interface would be one which:
(1) does not merge locks; Netware does not do that, you must release exact records you locked, otherwise unlock will fail.
(2) first resolve locks locally, and then, if you succesfully obtained lock locally, consult filesystem's lock method; ncpfs must do it that way because of there is only one server filehandle for each opened file, and so from server's view there is only one entity on connection.
I would be also satisfied with interface F_GETLK uses: call default posix_test_lock only if filesystem returned LOCK_USE_CLNT: in such case filesystem can return < 0 on failure, LOCK_USE_CLNT when lock succeeded, but kernel should do local bookkeeping itself, or 0 when lock succeeded, and inode's i_flock was already updated.
If current method (first call filesystem, then obtain lock locally) is going to stay, then I believe that we should call F_UNLOCK when filesystem's lock succeeded, but local posix_lock_file failed (either due to EAGAIN or EINTR or ...). Otherwise server is never notified that lock was not acquired by workstation, and will be never released.
Petr Vandrovec [email protected]
Quoted 1 line · Petr Vandrovec
If I can place ncpfs's requirements here...
Certainly! Happy to hear them.
Quoted 2 lines
(1) does not merge locks; Netware does not do that, you must release exact records you locked, otherwise unlock will fail.
Yeah, NFS v4 has the same problem (potentially).
Quoted 5 lines
(2) first resolve locks locally, and then, if you succesfully obtained lock locally, consult filesystem's lock method; ncpfs must do it that way because of there is only one server filehandle for each opened file, and so from server's view there is only one entity on connection.
How about this: if filesystem provides its own ->lock method, locks.c promises to leave i_flock member alone? That way your ->lock method can do all this by itself.
The major problem with this is removing locks on file close. Either we need a magic value for PID that means PID_ANY or we need a new f_op method. I favour the magic PID_ANY flag myself.
Quoted 11 lines
I would be also satisfied with interface
F_GETLKuses: call defaultposix_test_lockonly if filesystem returnedLOCK_USE_CLNT: in such case filesystem can return < 0 on failure,LOCK_USE_CLNTwhen lock succeeded, but kernel should do local bookkeeping itself, or 0 when lock succeeded, and inode'si_flockwas already updated.If current method (first call filesystem, then obtain lock locally) is going to stay, then I believe that we should call
F_UNLOCKwhen filesystem's lock succeeded, but localposix_lock_filefailed (either due to EAGAIN or EINTR or ...). Otherwise server is never notified that lock was not acquired by workstation, and will be never released.
I think the scheme I propose will work fine for you, since you'll still be able to call the local file locking code so you have a record of what locks you've set on the server (necessary for crash recovery, i guess?)
I'm not averse to having some kind of split/merge lock library functions in fs/locks.c either, even if they're not directly used by the local file locking code. I think several network filesystems will need this behaviour.
Signature · 1 line
Revolutions do not require corporate support.
Quoted 11 lines · Matthew Wilcox
Quoted 5 lines · Petr Vandrovec
(2) first resolve locks locally, and then, if you succesfully obtained lock locally, consult filesystem's lock method; ncpfs must do it that way because of there is only one server filehandle for each opened file, and so from server's view there is only one entity on connection.
How about this: if filesystem provides its own ->lock method,
locks.cpromises to leavei_flockmember alone? That way your ->lock method can do all this by itself.
Yes, it would work. Although same as for CIFS applies - all locks are mandatory, not advisory - but it should not matter for locking, as properly written apps work same way on both system, and if someone tries to read locked file, he'll get what he deserves...
Quoted 3 lines
The major problem with this is removing locks on file close. Either we need a magic value for PID that means
PID_ANYor we need a newf_opmethod. I favour the magicPID_ANYflag myself.
ncpfs can be happy with "standardized" contents of i_flock, so VFS can peek at list of locks placed on file by local workstation.
Quoted 9 lines
Quoted 5 lines
If current method (first call filesystem, then obtain lock locally) is going to stay, then I believe that we should call
F_UNLOCKwhen filesystem's lock succeeded, but localposix_lock_filefailed (either due to EAGAIN or EINTR or ...). Otherwise server is never notified that lock was not acquired by workstation, and will be never released.I think the scheme I propose will work fine for you, since you'll still be able to call the local file locking code so you have a record of what locks you've set on the server (necessary for crash recovery, i guess?)
Just make sure that if you call filesystem's lock, you do not call posix_lock_file. As there is currently only one lock's user (nfs), it should cause no problems to move posix_lock_file at the end of nfs_lock instead of doing it in caller.
Quoted 4 lines
I'm not averse to having some kind of split/merge lock library functions in
fs/locks.ceither, even if they're not directly used by the local file locking code. I think several network filesystems will need this behaviour.
Petr Vandrovec [email protected]