1VFS_LOCK_FILE(9)                 The Linux VFS                VFS_LOCK_FILE(9)
2
3
4

NAME

6       vfs_lock_file - file byte range lock
7

SYNOPSIS

9       int vfs_lock_file(struct file * filp, unsigned int cmd,
10                         struct file_lock * fl, struct file_lock * conf);
11

ARGUMENTS

13       filp
14           The file to apply the lock to
15
16       cmd
17           type of locking operation (F_SETLK, F_GETLK, etc.)
18
19       fl
20           The lock to be applied
21
22       conf
23           Place to return a copy of the conflicting lock, if found.
24

DESCRIPTION

26       A caller that doesn't care about the conflicting lock may pass NULL as
27       the final argument.
28
29       If the filesystem defines a private ->lock method, then conf will be
30       left unchanged; so a caller that cares should initialize it to some
31       acceptable default.
32
33       To avoid blocking kernel daemons, such as lockd, that need to acquire
34       POSIX locks, the ->lock interface may return asynchronously, before the
35       lock has been granted or denied by the underlying filesystem, if (and
36       only if) lm_grant is set. Callers expecting ->lock to return
37       asynchronously will only use F_SETLK, not F_SETLKW; they will set
38       FL_SLEEP if (and only if) the request is for a blocking lock. When
39       ->lock does return asynchronously, it must return FILE_LOCK_DEFERRED,
40       and call ->lm_grant when the lock request completes. If the request is
41       for non-blocking lock the file system should return FILE_LOCK_DEFERRED
42       then try to get the lock and call the callback routine with the result.
43       If the request timed out the callback routine will return a nonzero
44       return code and the file system should release the lock. The file
45       system is also responsible to keep a corresponding posix lock when it
46       grants a lock so the VFS can find out which locks are locally held and
47       do the correct lock cleanup when required. The underlying filesystem
48       must not drop the kernel lock or call ->lm_grant before returning to
49       the caller with a FILE_LOCK_DEFERRED return code.
50
52Kernel Hackers Manual 3.10         June 2019                  VFS_LOCK_FILE(9)
Impressum