Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

vfs_lock_file(9) [centos man page]

VFS_LOCK_FILE(9)						   The Linux VFS						  VFS_LOCK_FILE(9)

NAME
vfs_lock_file - file byte range lock SYNOPSIS
int vfs_lock_file(struct file * filp, unsigned int cmd, struct file_lock * fl, struct file_lock * conf); ARGUMENTS
filp The file to apply the lock to cmd type of locking operation (F_SETLK, F_GETLK, etc.) fl The lock to be applied conf Place to return a copy of the conflicting lock, if found. DESCRIPTION
A caller that doesn't care about the conflicting lock may pass NULL as the final argument. If the filesystem defines a private ->lock method, then conf will be left unchanged; so a caller that cares should initialize it to some acceptable default. To avoid blocking kernel daemons, such as lockd, that need to acquire POSIX locks, the ->lock interface may return asynchronously, before the lock has been granted or denied by the underlying filesystem, if (and only if) lm_grant is set. Callers expecting ->lock to return asynchronously will only use F_SETLK, not F_SETLKW; they will set FL_SLEEP if (and only if) the request is for a blocking lock. When ->lock does return asynchronously, it must return FILE_LOCK_DEFERRED, and call ->lm_grant when the lock request completes. If the request is for non-blocking lock the file system should return FILE_LOCK_DEFERRED then try to get the lock and call the callback routine with the result. If the request timed out the callback routine will return a nonzero return code and the file system should release the lock. The file system is also responsible to keep a corresponding posix lock when it grants a lock so the VFS can find out which locks are locally held and do the correct lock cleanup when required. The underlying filesystem must not drop the kernel lock or call ->lm_grant before returning to the caller with a FILE_LOCK_DEFERRED return code. COPYRIGHT
Kernel Hackers Manual 3.10 June 2014 VFS_LOCK_FILE(9)

Check Out this Related Man Page

lock_try_write(9r)														lock_try_write(9r)

NAME
lock_try_write - General: Tries to assert a complex lock with write access SYNOPSIS
#include <kern/lock.h> boolean_t lock_try_write( lock_t lock_structptr ); ARGUMENTS
Specifies a pointer to the complex lock structure, lock. This is the lock structure associated with the resource on which you want to try to assert write access. The lock structure is an opaque data structure; that is, its associated members are referenced and manipulated by the Tru64 UNIX operating system and not by the user of the complex lock mechanism. DESCRIPTION
The lock_try_write routine tries to assert a complex lock (without blocking) with write access for the resource associated with the speci- fied lock structure pointer. To release a complex lock with write access successfully asserted by lock_try_write, call the lock_done rou- tine. NOTES
You must call lock_init (once only) prior to calling lock_try_write to initialize the lock structure pointer for the resource. A resource, from the kernel module's standpoint, is data that more than one kernel thread can manipulate. You can store the resource in global vari- ables and in data structure members. RETURN VALUES
The lock_try_write routine returns one of the following values: The attempt to acquire the write complex lock was successful. The attempt to acquire the write complex lock was unsuccessful. FILES
SEE ALSO
Routines: lock_done(9r), lock_terminate(9r), lock_try_read(9r), lock_write(9r) Data Structures: lock(9s) lock_try_write(9r)
Man Page

Featured Tech Videos