mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
File locking changes for v6.3
-----BEGIN PGP SIGNATURE----- iQJHBAABCAAxFiEES8DXskRxsqGE6vXTAA5oQRlWghUFAmPuC5kTHGpsYXl0b25A a2VybmVsLm9yZwAKCRAADmhBGVaCFdXpEADFN/loTtcANLPQmLmgmJLDuZr2zKrf aziMJRjqGMx6BLdwBgX8/XGBNwpG4tkVbI+zdRoVHkpcayMDpLq0dnrvi79a/dGU fBrI72ZDMd/S9lzbodObHMziLqvgFthsPm9ldVAZ2Kt400KKNE+ozcveiC3yVGy0 n1k5BSt/78abzpqut5whVgJBooHtUMCh3XvBJPKwgOneHfAXCm+jqaXlKKpKlpZj s2OUyn8BLfNkTgpAZ88L5Rkf0mftjziL6C8KOMy1hvOsyiP0IkwLuQ/kO+2H0Ate p3tbOGvUT+n1gYpFYBDLnuWB4G8+CVPxfoO6KGhwT4OlCJpPlNCM8O+w/A/dKn4I 858spkpYPMy91lEkcrRLRkg/MARWGTgZ3k76fp3OWNnfruWd6ekMlYKx9n6CIy34 Aoc3Svy9KeA7oRrbRDltmw3UVmz53GcDo337ZL1J6Jph3s86dMG7AwGYvoDfKuKK b0oNK5db5v50scBnRHX6UWejE5fSnnHvgC7pU57u08odCVEUALB+r8f04vmkxcVJ Qed7lolQdFzn9ddaOXzpg5KeCe/cX3p4IPZSTHad7CPr8gswmC135DfXCr64x2hC 5jyNzKbe/x+7B2xCweHmEk4ojt8IU3UaYxLJoQkNeVr8rEGC9gqZgkSDe7BnTpOf wT0ijzhy2u5RKg== =Zhf3 -----END PGP SIGNATURE----- Merge tag 'locks-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux Pull file locking updates from Jeff Layton: "The main change here is that I've broken out most of the file locking definitions into a new header file. I also went ahead and completed the removal of locks_inode function" * tag 'locks-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux: fs: remove locks_inode filelock: move file locking definitions to separate header file
This commit is contained in:
commit
575a7e0f81
@ -73,6 +73,7 @@
|
||||
#include <linux/syscalls.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/cred.h>
|
||||
#include <linux/fcntl.h>
|
||||
#include <linux/eventpoll.h>
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/stat.h>
|
||||
|
@ -451,7 +451,7 @@ static int afs_do_setlk_check(struct afs_vnode *vnode, struct key *key,
|
||||
*/
|
||||
static int afs_do_setlk(struct file *file, struct file_lock *fl)
|
||||
{
|
||||
struct inode *inode = locks_inode(file);
|
||||
struct inode *inode = file_inode(file);
|
||||
struct afs_vnode *vnode = AFS_FS_I(inode);
|
||||
enum afs_flock_mode mode = AFS_FS_S(inode->i_sb)->flock_mode;
|
||||
afs_lock_type_t type;
|
||||
@ -701,7 +701,7 @@ error:
|
||||
*/
|
||||
static int afs_do_unlk(struct file *file, struct file_lock *fl)
|
||||
{
|
||||
struct afs_vnode *vnode = AFS_FS_I(locks_inode(file));
|
||||
struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
|
||||
int ret;
|
||||
|
||||
_enter("{%llx:%llu},%u", vnode->fid.vid, vnode->fid.vnode, fl->fl_type);
|
||||
@ -721,7 +721,7 @@ static int afs_do_unlk(struct file *file, struct file_lock *fl)
|
||||
*/
|
||||
static int afs_do_getlk(struct file *file, struct file_lock *fl)
|
||||
{
|
||||
struct afs_vnode *vnode = AFS_FS_I(locks_inode(file));
|
||||
struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
|
||||
struct key *key = afs_file_key(file);
|
||||
int ret, lock_count;
|
||||
|
||||
@ -763,7 +763,7 @@ error:
|
||||
*/
|
||||
int afs_lock(struct file *file, int cmd, struct file_lock *fl)
|
||||
{
|
||||
struct afs_vnode *vnode = AFS_FS_I(locks_inode(file));
|
||||
struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
|
||||
enum afs_flock_operation op;
|
||||
int ret;
|
||||
|
||||
@ -798,7 +798,7 @@ int afs_lock(struct file *file, int cmd, struct file_lock *fl)
|
||||
*/
|
||||
int afs_flock(struct file *file, int cmd, struct file_lock *fl)
|
||||
{
|
||||
struct afs_vnode *vnode = AFS_FS_I(locks_inode(file));
|
||||
struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
|
||||
enum afs_flock_operation op;
|
||||
int ret;
|
||||
|
||||
@ -843,7 +843,7 @@ int afs_flock(struct file *file, int cmd, struct file_lock *fl)
|
||||
*/
|
||||
static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl)
|
||||
{
|
||||
struct afs_vnode *vnode = AFS_FS_I(locks_inode(fl->fl_file));
|
||||
struct afs_vnode *vnode = AFS_FS_I(file_inode(fl->fl_file));
|
||||
|
||||
_enter("");
|
||||
|
||||
@ -861,7 +861,7 @@ static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl)
|
||||
*/
|
||||
static void afs_fl_release_private(struct file_lock *fl)
|
||||
{
|
||||
struct afs_vnode *vnode = AFS_FS_I(locks_inode(fl->fl_file));
|
||||
struct afs_vnode *vnode = AFS_FS_I(file_inode(fl->fl_file));
|
||||
|
||||
_enter("");
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/ktime.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/rxrpc.h>
|
||||
#include <linux/key.h>
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <linux/capability.h>
|
||||
#include <linux/fsnotify.h>
|
||||
#include <linux/fcntl.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/security.h>
|
||||
#include <linux/evm.h>
|
||||
#include <linux/ima.h>
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <linux/wait.h>
|
||||
#include <linux/writeback.h>
|
||||
#include <linux/iversion.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
#include "super.h"
|
||||
#include "mds_client.h"
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "super.h"
|
||||
#include "mds_client.h"
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/ceph/pagelist.h>
|
||||
|
||||
static u64 lock_secret;
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/mount.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/init.h>
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <uapi/linux/cifs/cifs_mount.h>
|
||||
#include "../smbfs_common/smb2pdu.h"
|
||||
#include "smb2pdu.h"
|
||||
#include <linux/filelock.h>
|
||||
|
||||
#define SMB_PATH_MAX 260
|
||||
#define CIFS_PORT 445
|
||||
|
@ -15,6 +15,7 @@
|
||||
/* want to reuse a stale file handle and only the caller knows the file info */
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/vfs.h>
|
||||
#include <linux/slab.h>
|
||||
|
@ -9,6 +9,7 @@
|
||||
*
|
||||
*/
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/backing-dev.h>
|
||||
#include <linux/stat.h>
|
||||
#include <linux/fcntl.h>
|
||||
|
@ -7,6 +7,7 @@
|
||||
*
|
||||
*/
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/stat.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/pagemap.h>
|
||||
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/poll.h>
|
||||
#include <linux/dlm.h>
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <linux/mm.h>
|
||||
#include <linux/sched/task.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fdtable.h>
|
||||
#include <linux/capability.h>
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/security.h>
|
||||
#include <linux/cred.h>
|
||||
#include <linux/eventpoll.h>
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <linux/falloc.h>
|
||||
#include <linux/uio.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
static int fuse_send_open(struct fuse_mount *fm, u64 nodeid,
|
||||
unsigned int open_flags, int opcode,
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <linux/mm.h>
|
||||
#include <linux/mount.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/gfs2_ondisk.h>
|
||||
#include <linux/falloc.h>
|
||||
#include <linux/swap.h>
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
#include <linux/export.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/backing-dev.h>
|
||||
#include <linux/hash.h>
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <linux/ethtool.h>
|
||||
#include <linux/falloc.h>
|
||||
#include <linux/mount.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
#include "glob.h"
|
||||
#include "smbfsctl.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/backing-dev.h>
|
||||
#include <linux/writeback.h>
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/vmalloc.h>
|
||||
|
||||
|
@ -188,7 +188,7 @@ __be32 nlmclnt_grant(const struct sockaddr *addr, const struct nlm_lock *lock)
|
||||
continue;
|
||||
if (!rpc_cmp_addr(nlm_addr(block->b_host), addr))
|
||||
continue;
|
||||
if (nfs_compare_fh(NFS_FH(locks_inode(fl_blocked->fl_file)), fh) != 0)
|
||||
if (nfs_compare_fh(NFS_FH(file_inode(fl_blocked->fl_file)), fh) != 0)
|
||||
continue;
|
||||
/* Alright, we found a lock. Set the return status
|
||||
* and wake up the caller
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/nfs_fs.h>
|
||||
#include <linux/utsname.h>
|
||||
#include <linux/freezer.h>
|
||||
@ -130,7 +131,7 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
|
||||
char *nodename = req->a_host->h_rpcclnt->cl_nodename;
|
||||
|
||||
nlmclnt_next_cookie(&argp->cookie);
|
||||
memcpy(&lock->fh, NFS_FH(locks_inode(fl->fl_file)), sizeof(struct nfs_fh));
|
||||
memcpy(&lock->fh, NFS_FH(file_inode(fl->fl_file)), sizeof(struct nfs_fh));
|
||||
lock->caller = nodename;
|
||||
lock->oh.data = req->a_owner;
|
||||
lock->oh.len = snprintf(req->a_owner, sizeof(req->a_owner), "%u@%s",
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define __LOCKD_NETNS_H__
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <net/netns/generic.h>
|
||||
|
||||
struct lockd_net {
|
||||
|
29
fs/locks.c
29
fs/locks.c
@ -52,6 +52,7 @@
|
||||
#include <linux/capability.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fdtable.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/security.h>
|
||||
@ -233,7 +234,7 @@ locks_check_ctx_file_list(struct file *filp, struct list_head *list,
|
||||
char *list_type)
|
||||
{
|
||||
struct file_lock *fl;
|
||||
struct inode *inode = locks_inode(filp);
|
||||
struct inode *inode = file_inode(filp);
|
||||
|
||||
list_for_each_entry(fl, list, fl_list)
|
||||
if (fl->fl_file == filp)
|
||||
@ -887,7 +888,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl)
|
||||
{
|
||||
struct file_lock *cfl;
|
||||
struct file_lock_context *ctx;
|
||||
struct inode *inode = locks_inode(filp);
|
||||
struct inode *inode = file_inode(filp);
|
||||
void *owner;
|
||||
void (*func)(void);
|
||||
|
||||
@ -1330,7 +1331,7 @@ retry:
|
||||
int posix_lock_file(struct file *filp, struct file_lock *fl,
|
||||
struct file_lock *conflock)
|
||||
{
|
||||
return posix_lock_inode(locks_inode(filp), fl, conflock);
|
||||
return posix_lock_inode(file_inode(filp), fl, conflock);
|
||||
}
|
||||
EXPORT_SYMBOL(posix_lock_file);
|
||||
|
||||
@ -1629,7 +1630,7 @@ EXPORT_SYMBOL(lease_get_mtime);
|
||||
int fcntl_getlease(struct file *filp)
|
||||
{
|
||||
struct file_lock *fl;
|
||||
struct inode *inode = locks_inode(filp);
|
||||
struct inode *inode = file_inode(filp);
|
||||
struct file_lock_context *ctx;
|
||||
int type = F_UNLCK;
|
||||
LIST_HEAD(dispose);
|
||||
@ -1667,7 +1668,7 @@ int fcntl_getlease(struct file *filp)
|
||||
static int
|
||||
check_conflicting_open(struct file *filp, const long arg, int flags)
|
||||
{
|
||||
struct inode *inode = locks_inode(filp);
|
||||
struct inode *inode = file_inode(filp);
|
||||
int self_wcount = 0, self_rcount = 0;
|
||||
|
||||
if (flags & FL_LAYOUT)
|
||||
@ -1703,7 +1704,7 @@ static int
|
||||
generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **priv)
|
||||
{
|
||||
struct file_lock *fl, *my_fl = NULL, *lease;
|
||||
struct inode *inode = locks_inode(filp);
|
||||
struct inode *inode = file_inode(filp);
|
||||
struct file_lock_context *ctx;
|
||||
bool is_deleg = (*flp)->fl_flags & FL_DELEG;
|
||||
int error;
|
||||
@ -1819,7 +1820,7 @@ static int generic_delete_lease(struct file *filp, void *owner)
|
||||
{
|
||||
int error = -EAGAIN;
|
||||
struct file_lock *fl, *victim = NULL;
|
||||
struct inode *inode = locks_inode(filp);
|
||||
struct inode *inode = file_inode(filp);
|
||||
struct file_lock_context *ctx;
|
||||
LIST_HEAD(dispose);
|
||||
|
||||
@ -1861,7 +1862,7 @@ static int generic_delete_lease(struct file *filp, void *owner)
|
||||
int generic_setlease(struct file *filp, long arg, struct file_lock **flp,
|
||||
void **priv)
|
||||
{
|
||||
struct inode *inode = locks_inode(filp);
|
||||
struct inode *inode = file_inode(filp);
|
||||
int error;
|
||||
|
||||
if ((!uid_eq(current_fsuid(), inode->i_uid)) && !capable(CAP_LEASE))
|
||||
@ -2350,7 +2351,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
|
||||
struct flock *flock)
|
||||
{
|
||||
struct file_lock *file_lock = locks_alloc_lock();
|
||||
struct inode *inode = locks_inode(filp);
|
||||
struct inode *inode = file_inode(filp);
|
||||
struct file *f;
|
||||
int error;
|
||||
|
||||
@ -2554,7 +2555,7 @@ out:
|
||||
void locks_remove_posix(struct file *filp, fl_owner_t owner)
|
||||
{
|
||||
int error;
|
||||
struct inode *inode = locks_inode(filp);
|
||||
struct inode *inode = file_inode(filp);
|
||||
struct file_lock lock;
|
||||
struct file_lock_context *ctx;
|
||||
|
||||
@ -2591,7 +2592,7 @@ static void
|
||||
locks_remove_flock(struct file *filp, struct file_lock_context *flctx)
|
||||
{
|
||||
struct file_lock fl;
|
||||
struct inode *inode = locks_inode(filp);
|
||||
struct inode *inode = file_inode(filp);
|
||||
|
||||
if (list_empty(&flctx->flc_flock))
|
||||
return;
|
||||
@ -2636,7 +2637,7 @@ void locks_remove_file(struct file *filp)
|
||||
{
|
||||
struct file_lock_context *ctx;
|
||||
|
||||
ctx = locks_inode_context(locks_inode(filp));
|
||||
ctx = locks_inode_context(file_inode(filp));
|
||||
if (!ctx)
|
||||
return;
|
||||
|
||||
@ -2720,7 +2721,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
|
||||
*/
|
||||
|
||||
if (fl->fl_file != NULL)
|
||||
inode = locks_inode(fl->fl_file);
|
||||
inode = file_inode(fl->fl_file);
|
||||
|
||||
seq_printf(f, "%lld: ", id);
|
||||
|
||||
@ -2861,7 +2862,7 @@ static void __show_fd_locks(struct seq_file *f,
|
||||
void show_fd_locks(struct seq_file *f,
|
||||
struct file *filp, struct files_struct *files)
|
||||
{
|
||||
struct inode *inode = locks_inode(filp);
|
||||
struct inode *inode = file_inode(filp);
|
||||
struct file_lock_context *ctx;
|
||||
int id = 0;
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/namei.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/sched/mm.h>
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <linux/swap.h>
|
||||
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
#include "delegation.h"
|
||||
#include "internal.h"
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define NFS4_MAX_LOOP_ON_RECOVER (10)
|
||||
|
||||
#include <linux/seqlock.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
struct idmap;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <linux/nfs_page.h>
|
||||
#include <linux/nfs_mount.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "pnfs.h"
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <linux/freezer.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/iversion.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/sched/mm.h>
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <net/net_namespace.h>
|
||||
#include <net/netns/generic.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
static unsigned int grace_net_id;
|
||||
static DEFINE_SPINLOCK(grace_lock);
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <net/net_namespace.h>
|
||||
#include <net/netns/generic.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/percpu_counter.h>
|
||||
#include <linux/siphash.h>
|
||||
|
||||
|
@ -5356,7 +5356,7 @@ static int nfsd4_check_conflicting_opens(struct nfs4_client *clp,
|
||||
{
|
||||
struct nfs4_ol_stateid *st;
|
||||
struct file *f = fp->fi_deleg_file->nf_file;
|
||||
struct inode *ino = locks_inode(f);
|
||||
struct inode *ino = file_inode(f);
|
||||
int writes;
|
||||
|
||||
writes = atomic_read(&ino->i_writecount);
|
||||
@ -7809,7 +7809,7 @@ check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner)
|
||||
return status;
|
||||
}
|
||||
|
||||
inode = locks_inode(nf->nf_file);
|
||||
inode = file_inode(nf->nf_file);
|
||||
flctx = locks_inode_context(inode);
|
||||
|
||||
if (flctx && !list_empty_careful(&flctx->flc_posix)) {
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/fcntl.h>
|
||||
|
||||
#include <cluster/masklog.h>
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/slab.h>
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <linux/dnotify.h>
|
||||
#include <linux/compat.h>
|
||||
#include <linux/mnt_idmapping.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@ -870,7 +871,7 @@ static int do_dentry_open(struct file *f,
|
||||
if (error)
|
||||
goto cleanup_all;
|
||||
|
||||
error = break_lease(locks_inode(f), f->f_flags);
|
||||
error = break_lease(file_inode(f), f->f_flags);
|
||||
if (error)
|
||||
goto cleanup_all;
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "orangefs-kernel.h"
|
||||
#include "orangefs-bufmap.h"
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/pagemap.h>
|
||||
|
||||
static int flush_racache(struct inode *inode)
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <linux/security.h>
|
||||
#include <linux/evm.h>
|
||||
#include <linux/fsnotify.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <linux/file.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
#include <linux/proc_fs.h>
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/compat.h>
|
||||
#include <asm/unistd.h>
|
||||
#include <linux/filelock.h>
|
||||
|
||||
static bool nsec_valid(long nsec)
|
||||
{
|
||||
|
@ -9,6 +9,7 @@
|
||||
Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
|
||||
*/
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/xattr.h>
|
||||
|
@ -34,6 +34,7 @@ typedef __u32 xfs_nlink_t;
|
||||
#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/swap.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/sched/signal.h>
|
||||
|
439
include/linux/filelock.h
Normal file
439
include/linux/filelock.h
Normal file
@ -0,0 +1,439 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef _LINUX_FILELOCK_H
|
||||
#define _LINUX_FILELOCK_H
|
||||
|
||||
#include <linux/fs.h>
|
||||
|
||||
#define FL_POSIX 1
|
||||
#define FL_FLOCK 2
|
||||
#define FL_DELEG 4 /* NFSv4 delegation */
|
||||
#define FL_ACCESS 8 /* not trying to lock, just looking */
|
||||
#define FL_EXISTS 16 /* when unlocking, test for existence */
|
||||
#define FL_LEASE 32 /* lease held on this file */
|
||||
#define FL_CLOSE 64 /* unlock on close */
|
||||
#define FL_SLEEP 128 /* A blocking lock */
|
||||
#define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */
|
||||
#define FL_UNLOCK_PENDING 512 /* Lease is being broken */
|
||||
#define FL_OFDLCK 1024 /* lock is "owned" by struct file */
|
||||
#define FL_LAYOUT 2048 /* outstanding pNFS layout */
|
||||
#define FL_RECLAIM 4096 /* reclaiming from a reboot server */
|
||||
|
||||
#define FL_CLOSE_POSIX (FL_POSIX | FL_CLOSE)
|
||||
|
||||
/*
|
||||
* Special return value from posix_lock_file() and vfs_lock_file() for
|
||||
* asynchronous locking.
|
||||
*/
|
||||
#define FILE_LOCK_DEFERRED 1
|
||||
|
||||
struct file_lock;
|
||||
|
||||
struct file_lock_operations {
|
||||
void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
|
||||
void (*fl_release_private)(struct file_lock *);
|
||||
};
|
||||
|
||||
struct lock_manager_operations {
|
||||
void *lm_mod_owner;
|
||||
fl_owner_t (*lm_get_owner)(fl_owner_t);
|
||||
void (*lm_put_owner)(fl_owner_t);
|
||||
void (*lm_notify)(struct file_lock *); /* unblock callback */
|
||||
int (*lm_grant)(struct file_lock *, int);
|
||||
bool (*lm_break)(struct file_lock *);
|
||||
int (*lm_change)(struct file_lock *, int, struct list_head *);
|
||||
void (*lm_setup)(struct file_lock *, void **);
|
||||
bool (*lm_breaker_owns_lease)(struct file_lock *);
|
||||
bool (*lm_lock_expirable)(struct file_lock *cfl);
|
||||
void (*lm_expire_lock)(void);
|
||||
};
|
||||
|
||||
struct lock_manager {
|
||||
struct list_head list;
|
||||
/*
|
||||
* NFSv4 and up also want opens blocked during the grace period;
|
||||
* NLM doesn't care:
|
||||
*/
|
||||
bool block_opens;
|
||||
};
|
||||
|
||||
struct net;
|
||||
void locks_start_grace(struct net *, struct lock_manager *);
|
||||
void locks_end_grace(struct lock_manager *);
|
||||
bool locks_in_grace(struct net *);
|
||||
bool opens_in_grace(struct net *);
|
||||
|
||||
/*
|
||||
* struct file_lock has a union that some filesystems use to track
|
||||
* their own private info. The NFS side of things is defined here:
|
||||
*/
|
||||
#include <linux/nfs_fs_i.h>
|
||||
|
||||
/*
|
||||
* struct file_lock represents a generic "file lock". It's used to represent
|
||||
* POSIX byte range locks, BSD (flock) locks, and leases. It's important to
|
||||
* note that the same struct is used to represent both a request for a lock and
|
||||
* the lock itself, but the same object is never used for both.
|
||||
*
|
||||
* FIXME: should we create a separate "struct lock_request" to help distinguish
|
||||
* these two uses?
|
||||
*
|
||||
* The varous i_flctx lists are ordered by:
|
||||
*
|
||||
* 1) lock owner
|
||||
* 2) lock range start
|
||||
* 3) lock range end
|
||||
*
|
||||
* Obviously, the last two criteria only matter for POSIX locks.
|
||||
*/
|
||||
struct file_lock {
|
||||
struct file_lock *fl_blocker; /* The lock, that is blocking us */
|
||||
struct list_head fl_list; /* link into file_lock_context */
|
||||
struct hlist_node fl_link; /* node in global lists */
|
||||
struct list_head fl_blocked_requests; /* list of requests with
|
||||
* ->fl_blocker pointing here
|
||||
*/
|
||||
struct list_head fl_blocked_member; /* node in
|
||||
* ->fl_blocker->fl_blocked_requests
|
||||
*/
|
||||
fl_owner_t fl_owner;
|
||||
unsigned int fl_flags;
|
||||
unsigned char fl_type;
|
||||
unsigned int fl_pid;
|
||||
int fl_link_cpu; /* what cpu's list is this on? */
|
||||
wait_queue_head_t fl_wait;
|
||||
struct file *fl_file;
|
||||
loff_t fl_start;
|
||||
loff_t fl_end;
|
||||
|
||||
struct fasync_struct * fl_fasync; /* for lease break notifications */
|
||||
/* for lease breaks: */
|
||||
unsigned long fl_break_time;
|
||||
unsigned long fl_downgrade_time;
|
||||
|
||||
const struct file_lock_operations *fl_ops; /* Callbacks for filesystems */
|
||||
const struct lock_manager_operations *fl_lmops; /* Callbacks for lockmanagers */
|
||||
union {
|
||||
struct nfs_lock_info nfs_fl;
|
||||
struct nfs4_lock_info nfs4_fl;
|
||||
struct {
|
||||
struct list_head link; /* link in AFS vnode's pending_locks list */
|
||||
int state; /* state of grant or error if -ve */
|
||||
unsigned int debug_id;
|
||||
} afs;
|
||||
struct {
|
||||
struct inode *inode;
|
||||
} ceph;
|
||||
} fl_u;
|
||||
} __randomize_layout;
|
||||
|
||||
struct file_lock_context {
|
||||
spinlock_t flc_lock;
|
||||
struct list_head flc_flock;
|
||||
struct list_head flc_posix;
|
||||
struct list_head flc_lease;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_FILE_LOCKING
|
||||
int fcntl_getlk(struct file *, unsigned int, struct flock *);
|
||||
int fcntl_setlk(unsigned int, struct file *, unsigned int,
|
||||
struct flock *);
|
||||
|
||||
#if BITS_PER_LONG == 32
|
||||
int fcntl_getlk64(struct file *, unsigned int, struct flock64 *);
|
||||
int fcntl_setlk64(unsigned int, struct file *, unsigned int,
|
||||
struct flock64 *);
|
||||
#endif
|
||||
|
||||
int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
|
||||
int fcntl_getlease(struct file *filp);
|
||||
|
||||
/* fs/locks.c */
|
||||
void locks_free_lock_context(struct inode *inode);
|
||||
void locks_free_lock(struct file_lock *fl);
|
||||
void locks_init_lock(struct file_lock *);
|
||||
struct file_lock * locks_alloc_lock(void);
|
||||
void locks_copy_lock(struct file_lock *, struct file_lock *);
|
||||
void locks_copy_conflock(struct file_lock *, struct file_lock *);
|
||||
void locks_remove_posix(struct file *, fl_owner_t);
|
||||
void locks_remove_file(struct file *);
|
||||
void locks_release_private(struct file_lock *);
|
||||
void posix_test_lock(struct file *, struct file_lock *);
|
||||
int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
|
||||
int locks_delete_block(struct file_lock *);
|
||||
int vfs_test_lock(struct file *, struct file_lock *);
|
||||
int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
|
||||
int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
|
||||
bool vfs_inode_has_locks(struct inode *inode);
|
||||
int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl);
|
||||
int __break_lease(struct inode *inode, unsigned int flags, unsigned int type);
|
||||
void lease_get_mtime(struct inode *, struct timespec64 *time);
|
||||
int generic_setlease(struct file *, long, struct file_lock **, void **priv);
|
||||
int vfs_setlease(struct file *, long, struct file_lock **, void **);
|
||||
int lease_modify(struct file_lock *, int, struct list_head *);
|
||||
|
||||
struct notifier_block;
|
||||
int lease_register_notifier(struct notifier_block *);
|
||||
void lease_unregister_notifier(struct notifier_block *);
|
||||
|
||||
struct files_struct;
|
||||
void show_fd_locks(struct seq_file *f,
|
||||
struct file *filp, struct files_struct *files);
|
||||
bool locks_owner_has_blockers(struct file_lock_context *flctx,
|
||||
fl_owner_t owner);
|
||||
|
||||
static inline struct file_lock_context *
|
||||
locks_inode_context(const struct inode *inode)
|
||||
{
|
||||
return smp_load_acquire(&inode->i_flctx);
|
||||
}
|
||||
|
||||
#else /* !CONFIG_FILE_LOCKING */
|
||||
static inline int fcntl_getlk(struct file *file, unsigned int cmd,
|
||||
struct flock __user *user)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int fcntl_setlk(unsigned int fd, struct file *file,
|
||||
unsigned int cmd, struct flock __user *user)
|
||||
{
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
#if BITS_PER_LONG == 32
|
||||
static inline int fcntl_getlk64(struct file *file, unsigned int cmd,
|
||||
struct flock64 *user)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int fcntl_setlk64(unsigned int fd, struct file *file,
|
||||
unsigned int cmd, struct flock64 *user)
|
||||
{
|
||||
return -EACCES;
|
||||
}
|
||||
#endif
|
||||
static inline int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int fcntl_getlease(struct file *filp)
|
||||
{
|
||||
return F_UNLCK;
|
||||
}
|
||||
|
||||
static inline void
|
||||
locks_free_lock_context(struct inode *inode)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void locks_init_lock(struct file_lock *fl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void locks_copy_conflock(struct file_lock *new, struct file_lock *fl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void locks_copy_lock(struct file_lock *new, struct file_lock *fl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void locks_remove_posix(struct file *filp, fl_owner_t owner)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void locks_remove_file(struct file *filp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void posix_test_lock(struct file *filp, struct file_lock *fl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline int posix_lock_file(struct file *filp, struct file_lock *fl,
|
||||
struct file_lock *conflock)
|
||||
{
|
||||
return -ENOLCK;
|
||||
}
|
||||
|
||||
static inline int locks_delete_block(struct file_lock *waiter)
|
||||
{
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static inline int vfs_test_lock(struct file *filp, struct file_lock *fl)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int vfs_lock_file(struct file *filp, unsigned int cmd,
|
||||
struct file_lock *fl, struct file_lock *conf)
|
||||
{
|
||||
return -ENOLCK;
|
||||
}
|
||||
|
||||
static inline int vfs_cancel_lock(struct file *filp, struct file_lock *fl)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline bool vfs_inode_has_locks(struct inode *inode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl)
|
||||
{
|
||||
return -ENOLCK;
|
||||
}
|
||||
|
||||
static inline int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void lease_get_mtime(struct inode *inode,
|
||||
struct timespec64 *time)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline int generic_setlease(struct file *filp, long arg,
|
||||
struct file_lock **flp, void **priv)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int vfs_setlease(struct file *filp, long arg,
|
||||
struct file_lock **lease, void **priv)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int lease_modify(struct file_lock *fl, int arg,
|
||||
struct list_head *dispose)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct files_struct;
|
||||
static inline void show_fd_locks(struct seq_file *f,
|
||||
struct file *filp, struct files_struct *files) {}
|
||||
static inline bool locks_owner_has_blockers(struct file_lock_context *flctx,
|
||||
fl_owner_t owner)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline struct file_lock_context *
|
||||
locks_inode_context(const struct inode *inode)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_FILE_LOCKING */
|
||||
|
||||
static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)
|
||||
{
|
||||
return locks_lock_inode_wait(file_inode(filp), fl);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FILE_LOCKING
|
||||
static inline int break_lease(struct inode *inode, unsigned int mode)
|
||||
{
|
||||
/*
|
||||
* Since this check is lockless, we must ensure that any refcounts
|
||||
* taken are done before checking i_flctx->flc_lease. Otherwise, we
|
||||
* could end up racing with tasks trying to set a new lease on this
|
||||
* file.
|
||||
*/
|
||||
smp_mb();
|
||||
if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))
|
||||
return __break_lease(inode, mode, FL_LEASE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int break_deleg(struct inode *inode, unsigned int mode)
|
||||
{
|
||||
/*
|
||||
* Since this check is lockless, we must ensure that any refcounts
|
||||
* taken are done before checking i_flctx->flc_lease. Otherwise, we
|
||||
* could end up racing with tasks trying to set a new lease on this
|
||||
* file.
|
||||
*/
|
||||
smp_mb();
|
||||
if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))
|
||||
return __break_lease(inode, mode, FL_DELEG);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = break_deleg(inode, O_WRONLY|O_NONBLOCK);
|
||||
if (ret == -EWOULDBLOCK && delegated_inode) {
|
||||
*delegated_inode = inode;
|
||||
ihold(inode);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int break_deleg_wait(struct inode **delegated_inode)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = break_deleg(*delegated_inode, O_WRONLY);
|
||||
iput(*delegated_inode);
|
||||
*delegated_inode = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int break_layout(struct inode *inode, bool wait)
|
||||
{
|
||||
smp_mb();
|
||||
if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))
|
||||
return __break_lease(inode,
|
||||
wait ? O_WRONLY : O_WRONLY | O_NONBLOCK,
|
||||
FL_LAYOUT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* !CONFIG_FILE_LOCKING */
|
||||
static inline int break_lease(struct inode *inode, unsigned int mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int break_deleg(struct inode *inode, unsigned int mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int break_deleg_wait(struct inode **delegated_inode)
|
||||
{
|
||||
BUG();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int break_layout(struct inode *inode, bool wait)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FILE_LOCKING */
|
||||
|
||||
#endif /* _LINUX_FILELOCK_H */
|
@ -1003,135 +1003,11 @@ static inline struct file *get_file(struct file *f)
|
||||
#define MAX_LFS_FILESIZE ((loff_t)LLONG_MAX)
|
||||
#endif
|
||||
|
||||
#define FL_POSIX 1
|
||||
#define FL_FLOCK 2
|
||||
#define FL_DELEG 4 /* NFSv4 delegation */
|
||||
#define FL_ACCESS 8 /* not trying to lock, just looking */
|
||||
#define FL_EXISTS 16 /* when unlocking, test for existence */
|
||||
#define FL_LEASE 32 /* lease held on this file */
|
||||
#define FL_CLOSE 64 /* unlock on close */
|
||||
#define FL_SLEEP 128 /* A blocking lock */
|
||||
#define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */
|
||||
#define FL_UNLOCK_PENDING 512 /* Lease is being broken */
|
||||
#define FL_OFDLCK 1024 /* lock is "owned" by struct file */
|
||||
#define FL_LAYOUT 2048 /* outstanding pNFS layout */
|
||||
#define FL_RECLAIM 4096 /* reclaiming from a reboot server */
|
||||
|
||||
#define FL_CLOSE_POSIX (FL_POSIX | FL_CLOSE)
|
||||
|
||||
/*
|
||||
* Special return value from posix_lock_file() and vfs_lock_file() for
|
||||
* asynchronous locking.
|
||||
*/
|
||||
#define FILE_LOCK_DEFERRED 1
|
||||
|
||||
/* legacy typedef, should eventually be removed */
|
||||
typedef void *fl_owner_t;
|
||||
|
||||
struct file_lock;
|
||||
|
||||
struct file_lock_operations {
|
||||
void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
|
||||
void (*fl_release_private)(struct file_lock *);
|
||||
};
|
||||
|
||||
struct lock_manager_operations {
|
||||
void *lm_mod_owner;
|
||||
fl_owner_t (*lm_get_owner)(fl_owner_t);
|
||||
void (*lm_put_owner)(fl_owner_t);
|
||||
void (*lm_notify)(struct file_lock *); /* unblock callback */
|
||||
int (*lm_grant)(struct file_lock *, int);
|
||||
bool (*lm_break)(struct file_lock *);
|
||||
int (*lm_change)(struct file_lock *, int, struct list_head *);
|
||||
void (*lm_setup)(struct file_lock *, void **);
|
||||
bool (*lm_breaker_owns_lease)(struct file_lock *);
|
||||
bool (*lm_lock_expirable)(struct file_lock *cfl);
|
||||
void (*lm_expire_lock)(void);
|
||||
};
|
||||
|
||||
struct lock_manager {
|
||||
struct list_head list;
|
||||
/*
|
||||
* NFSv4 and up also want opens blocked during the grace period;
|
||||
* NLM doesn't care:
|
||||
*/
|
||||
bool block_opens;
|
||||
};
|
||||
|
||||
struct net;
|
||||
void locks_start_grace(struct net *, struct lock_manager *);
|
||||
void locks_end_grace(struct lock_manager *);
|
||||
bool locks_in_grace(struct net *);
|
||||
bool opens_in_grace(struct net *);
|
||||
|
||||
/* that will die - we need it for nfs_lock_info */
|
||||
#include <linux/nfs_fs_i.h>
|
||||
|
||||
/*
|
||||
* struct file_lock represents a generic "file lock". It's used to represent
|
||||
* POSIX byte range locks, BSD (flock) locks, and leases. It's important to
|
||||
* note that the same struct is used to represent both a request for a lock and
|
||||
* the lock itself, but the same object is never used for both.
|
||||
*
|
||||
* FIXME: should we create a separate "struct lock_request" to help distinguish
|
||||
* these two uses?
|
||||
*
|
||||
* The varous i_flctx lists are ordered by:
|
||||
*
|
||||
* 1) lock owner
|
||||
* 2) lock range start
|
||||
* 3) lock range end
|
||||
*
|
||||
* Obviously, the last two criteria only matter for POSIX locks.
|
||||
*/
|
||||
struct file_lock {
|
||||
struct file_lock *fl_blocker; /* The lock, that is blocking us */
|
||||
struct list_head fl_list; /* link into file_lock_context */
|
||||
struct hlist_node fl_link; /* node in global lists */
|
||||
struct list_head fl_blocked_requests; /* list of requests with
|
||||
* ->fl_blocker pointing here
|
||||
*/
|
||||
struct list_head fl_blocked_member; /* node in
|
||||
* ->fl_blocker->fl_blocked_requests
|
||||
*/
|
||||
fl_owner_t fl_owner;
|
||||
unsigned int fl_flags;
|
||||
unsigned char fl_type;
|
||||
unsigned int fl_pid;
|
||||
int fl_link_cpu; /* what cpu's list is this on? */
|
||||
wait_queue_head_t fl_wait;
|
||||
struct file *fl_file;
|
||||
loff_t fl_start;
|
||||
loff_t fl_end;
|
||||
|
||||
struct fasync_struct * fl_fasync; /* for lease break notifications */
|
||||
/* for lease breaks: */
|
||||
unsigned long fl_break_time;
|
||||
unsigned long fl_downgrade_time;
|
||||
|
||||
const struct file_lock_operations *fl_ops; /* Callbacks for filesystems */
|
||||
const struct lock_manager_operations *fl_lmops; /* Callbacks for lockmanagers */
|
||||
union {
|
||||
struct nfs_lock_info nfs_fl;
|
||||
struct nfs4_lock_info nfs4_fl;
|
||||
struct {
|
||||
struct list_head link; /* link in AFS vnode's pending_locks list */
|
||||
int state; /* state of grant or error if -ve */
|
||||
unsigned int debug_id;
|
||||
} afs;
|
||||
struct {
|
||||
struct inode *inode;
|
||||
} ceph;
|
||||
} fl_u;
|
||||
} __randomize_layout;
|
||||
|
||||
struct file_lock_context {
|
||||
spinlock_t flc_lock;
|
||||
struct list_head flc_flock;
|
||||
struct list_head flc_posix;
|
||||
struct list_head flc_lease;
|
||||
};
|
||||
|
||||
/* The following constant reflects the upper bound of the file/locking space */
|
||||
#ifndef OFFSET_MAX
|
||||
#define OFFSET_MAX type_max(loff_t)
|
||||
@ -1140,216 +1016,6 @@ struct file_lock_context {
|
||||
|
||||
extern void send_sigio(struct fown_struct *fown, int fd, int band);
|
||||
|
||||
#define locks_inode(f) file_inode(f)
|
||||
|
||||
#ifdef CONFIG_FILE_LOCKING
|
||||
extern int fcntl_getlk(struct file *, unsigned int, struct flock *);
|
||||
extern int fcntl_setlk(unsigned int, struct file *, unsigned int,
|
||||
struct flock *);
|
||||
|
||||
#if BITS_PER_LONG == 32
|
||||
extern int fcntl_getlk64(struct file *, unsigned int, struct flock64 *);
|
||||
extern int fcntl_setlk64(unsigned int, struct file *, unsigned int,
|
||||
struct flock64 *);
|
||||
#endif
|
||||
|
||||
extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
|
||||
extern int fcntl_getlease(struct file *filp);
|
||||
|
||||
/* fs/locks.c */
|
||||
void locks_free_lock_context(struct inode *inode);
|
||||
void locks_free_lock(struct file_lock *fl);
|
||||
extern void locks_init_lock(struct file_lock *);
|
||||
extern struct file_lock * locks_alloc_lock(void);
|
||||
extern void locks_copy_lock(struct file_lock *, struct file_lock *);
|
||||
extern void locks_copy_conflock(struct file_lock *, struct file_lock *);
|
||||
extern void locks_remove_posix(struct file *, fl_owner_t);
|
||||
extern void locks_remove_file(struct file *);
|
||||
extern void locks_release_private(struct file_lock *);
|
||||
extern void posix_test_lock(struct file *, struct file_lock *);
|
||||
extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
|
||||
extern int locks_delete_block(struct file_lock *);
|
||||
extern int vfs_test_lock(struct file *, struct file_lock *);
|
||||
extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
|
||||
extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
|
||||
bool vfs_inode_has_locks(struct inode *inode);
|
||||
extern int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl);
|
||||
extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type);
|
||||
extern void lease_get_mtime(struct inode *, struct timespec64 *time);
|
||||
extern int generic_setlease(struct file *, long, struct file_lock **, void **priv);
|
||||
extern int vfs_setlease(struct file *, long, struct file_lock **, void **);
|
||||
extern int lease_modify(struct file_lock *, int, struct list_head *);
|
||||
|
||||
struct notifier_block;
|
||||
extern int lease_register_notifier(struct notifier_block *);
|
||||
extern void lease_unregister_notifier(struct notifier_block *);
|
||||
|
||||
struct files_struct;
|
||||
extern void show_fd_locks(struct seq_file *f,
|
||||
struct file *filp, struct files_struct *files);
|
||||
extern bool locks_owner_has_blockers(struct file_lock_context *flctx,
|
||||
fl_owner_t owner);
|
||||
|
||||
static inline struct file_lock_context *
|
||||
locks_inode_context(const struct inode *inode)
|
||||
{
|
||||
return smp_load_acquire(&inode->i_flctx);
|
||||
}
|
||||
|
||||
#else /* !CONFIG_FILE_LOCKING */
|
||||
static inline int fcntl_getlk(struct file *file, unsigned int cmd,
|
||||
struct flock __user *user)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int fcntl_setlk(unsigned int fd, struct file *file,
|
||||
unsigned int cmd, struct flock __user *user)
|
||||
{
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
#if BITS_PER_LONG == 32
|
||||
static inline int fcntl_getlk64(struct file *file, unsigned int cmd,
|
||||
struct flock64 *user)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int fcntl_setlk64(unsigned int fd, struct file *file,
|
||||
unsigned int cmd, struct flock64 *user)
|
||||
{
|
||||
return -EACCES;
|
||||
}
|
||||
#endif
|
||||
static inline int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int fcntl_getlease(struct file *filp)
|
||||
{
|
||||
return F_UNLCK;
|
||||
}
|
||||
|
||||
static inline void
|
||||
locks_free_lock_context(struct inode *inode)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void locks_init_lock(struct file_lock *fl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void locks_copy_conflock(struct file_lock *new, struct file_lock *fl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void locks_copy_lock(struct file_lock *new, struct file_lock *fl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void locks_remove_posix(struct file *filp, fl_owner_t owner)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void locks_remove_file(struct file *filp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void posix_test_lock(struct file *filp, struct file_lock *fl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline int posix_lock_file(struct file *filp, struct file_lock *fl,
|
||||
struct file_lock *conflock)
|
||||
{
|
||||
return -ENOLCK;
|
||||
}
|
||||
|
||||
static inline int locks_delete_block(struct file_lock *waiter)
|
||||
{
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static inline int vfs_test_lock(struct file *filp, struct file_lock *fl)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int vfs_lock_file(struct file *filp, unsigned int cmd,
|
||||
struct file_lock *fl, struct file_lock *conf)
|
||||
{
|
||||
return -ENOLCK;
|
||||
}
|
||||
|
||||
static inline int vfs_cancel_lock(struct file *filp, struct file_lock *fl)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline bool vfs_inode_has_locks(struct inode *inode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl)
|
||||
{
|
||||
return -ENOLCK;
|
||||
}
|
||||
|
||||
static inline int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void lease_get_mtime(struct inode *inode,
|
||||
struct timespec64 *time)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline int generic_setlease(struct file *filp, long arg,
|
||||
struct file_lock **flp, void **priv)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int vfs_setlease(struct file *filp, long arg,
|
||||
struct file_lock **lease, void **priv)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int lease_modify(struct file_lock *fl, int arg,
|
||||
struct list_head *dispose)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct files_struct;
|
||||
static inline void show_fd_locks(struct seq_file *f,
|
||||
struct file *filp, struct files_struct *files) {}
|
||||
static inline bool locks_owner_has_blockers(struct file_lock_context *flctx,
|
||||
fl_owner_t owner)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline struct file_lock_context *
|
||||
locks_inode_context(const struct inode *inode)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_FILE_LOCKING */
|
||||
|
||||
static inline struct inode *file_inode(const struct file *f)
|
||||
{
|
||||
return f->f_inode;
|
||||
@ -1360,11 +1026,6 @@ static inline struct dentry *file_dentry(const struct file *file)
|
||||
return d_real(file->f_path.dentry, file_inode(file));
|
||||
}
|
||||
|
||||
static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)
|
||||
{
|
||||
return locks_lock_inode_wait(locks_inode(filp), fl);
|
||||
}
|
||||
|
||||
struct fasync_struct {
|
||||
rwlock_t fa_lock;
|
||||
int magic;
|
||||
@ -2624,96 +2285,6 @@ extern struct kobject *fs_kobj;
|
||||
|
||||
#define MAX_RW_COUNT (INT_MAX & PAGE_MASK)
|
||||
|
||||
#ifdef CONFIG_FILE_LOCKING
|
||||
static inline int break_lease(struct inode *inode, unsigned int mode)
|
||||
{
|
||||
/*
|
||||
* Since this check is lockless, we must ensure that any refcounts
|
||||
* taken are done before checking i_flctx->flc_lease. Otherwise, we
|
||||
* could end up racing with tasks trying to set a new lease on this
|
||||
* file.
|
||||
*/
|
||||
smp_mb();
|
||||
if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))
|
||||
return __break_lease(inode, mode, FL_LEASE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int break_deleg(struct inode *inode, unsigned int mode)
|
||||
{
|
||||
/*
|
||||
* Since this check is lockless, we must ensure that any refcounts
|
||||
* taken are done before checking i_flctx->flc_lease. Otherwise, we
|
||||
* could end up racing with tasks trying to set a new lease on this
|
||||
* file.
|
||||
*/
|
||||
smp_mb();
|
||||
if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))
|
||||
return __break_lease(inode, mode, FL_DELEG);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = break_deleg(inode, O_WRONLY|O_NONBLOCK);
|
||||
if (ret == -EWOULDBLOCK && delegated_inode) {
|
||||
*delegated_inode = inode;
|
||||
ihold(inode);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int break_deleg_wait(struct inode **delegated_inode)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = break_deleg(*delegated_inode, O_WRONLY);
|
||||
iput(*delegated_inode);
|
||||
*delegated_inode = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int break_layout(struct inode *inode, bool wait)
|
||||
{
|
||||
smp_mb();
|
||||
if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))
|
||||
return __break_lease(inode,
|
||||
wait ? O_WRONLY : O_WRONLY | O_NONBLOCK,
|
||||
FL_LAYOUT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* !CONFIG_FILE_LOCKING */
|
||||
static inline int break_lease(struct inode *inode, unsigned int mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int break_deleg(struct inode *inode, unsigned int mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int break_deleg_wait(struct inode **delegated_inode)
|
||||
{
|
||||
BUG();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int break_layout(struct inode *inode, bool wait)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FILE_LOCKING */
|
||||
|
||||
/* fs/open.c */
|
||||
struct audit_names;
|
||||
struct filename {
|
||||
|
@ -312,7 +312,7 @@ static inline struct file *nlmsvc_file_file(struct nlm_file *file)
|
||||
|
||||
static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
|
||||
{
|
||||
return locks_inode(nlmsvc_file_file(file));
|
||||
return file_inode(nlmsvc_file_file(file));
|
||||
}
|
||||
|
||||
static inline int __nlm_privileged_request4(const struct sockaddr *sap)
|
||||
@ -372,7 +372,7 @@ static inline int nlm_privileged_requester(const struct svc_rqst *rqstp)
|
||||
static inline int nlm_compare_locks(const struct file_lock *fl1,
|
||||
const struct file_lock *fl2)
|
||||
{
|
||||
return locks_inode(fl1->fl_file) == locks_inode(fl2->fl_file)
|
||||
return file_inode(fl1->fl_file) == file_inode(fl2->fl_file)
|
||||
&& fl1->fl_pid == fl2->fl_pid
|
||||
&& fl1->fl_owner == fl2->fl_owner
|
||||
&& fl1->fl_start == fl2->fl_start
|
||||
|
@ -11,6 +11,7 @@
|
||||
#define LOCKD_XDR_H
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/filelock.h>
|
||||
#include <linux/nfs.h>
|
||||
#include <linux/sunrpc/xdr.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user