projects
/
cascardo
/
linux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'ovl/misc' into work.misc
[cascardo/linux.git]
/
fs
/
locks.c
diff --git
a/fs/locks.c
b/fs/locks.c
index
ee1b15f
..
b242d5b
100644
(file)
--- a/
fs/locks.c
+++ b/
fs/locks.c
@@
-139,6
+139,11
@@
#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT))
#define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK)
#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT))
#define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK)
+static inline bool is_remote_lock(struct file *filp)
+{
+ return likely(!(filp->f_path.dentry->d_sb->s_flags & MS_NOREMOTELOCK));
+}
+
static bool lease_breaking(struct file_lock *fl)
{
return fl->fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING);
static bool lease_breaking(struct file_lock *fl)
{
return fl->fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING);
@@
-791,7
+796,7
@@
posix_test_lock(struct file *filp, struct file_lock *fl)
{
struct file_lock *cfl;
struct file_lock_context *ctx;
{
struct file_lock *cfl;
struct file_lock_context *ctx;
- struct inode *inode =
file
_inode(filp);
+ struct inode *inode =
locks
_inode(filp);
ctx = smp_load_acquire(&inode->i_flctx);
if (!ctx || list_empty_careful(&ctx->flc_posix)) {
ctx = smp_load_acquire(&inode->i_flctx);
if (!ctx || list_empty_careful(&ctx->flc_posix)) {
@@
-1192,7
+1197,7
@@
static int posix_lock_inode(struct inode *inode, struct file_lock *request,
int posix_lock_file(struct file *filp, struct file_lock *fl,
struct file_lock *conflock)
{
int posix_lock_file(struct file *filp, struct file_lock *fl,
struct file_lock *conflock)
{
- return posix_lock_inode(
file
_inode(filp), fl, conflock);
+ return posix_lock_inode(
locks
_inode(filp), fl, conflock);
}
EXPORT_SYMBOL(posix_lock_file);
}
EXPORT_SYMBOL(posix_lock_file);
@@
-1232,7
+1237,7
@@
static int posix_lock_inode_wait(struct inode *inode, struct file_lock *fl)
int locks_mandatory_locked(struct file *file)
{
int ret;
int locks_mandatory_locked(struct file *file)
{
int ret;
- struct inode *inode =
file
_inode(file);
+ struct inode *inode =
locks
_inode(file);
struct file_lock_context *ctx;
struct file_lock *fl;
struct file_lock_context *ctx;
struct file_lock *fl;
@@
-1572,7
+1577,7
@@
EXPORT_SYMBOL(lease_get_mtime);
int fcntl_getlease(struct file *filp)
{
struct file_lock *fl;
int fcntl_getlease(struct file *filp)
{
struct file_lock *fl;
- struct inode *inode =
file
_inode(filp);
+ struct inode *inode =
locks
_inode(filp);
struct file_lock_context *ctx;
int type = F_UNLCK;
LIST_HEAD(dispose);
struct file_lock_context *ctx;
int type = F_UNLCK;
LIST_HEAD(dispose);
@@
-1580,7
+1585,7
@@
int fcntl_getlease(struct file *filp)
ctx = smp_load_acquire(&inode->i_flctx);
if (ctx && !list_empty_careful(&ctx->flc_lease)) {
spin_lock(&ctx->flc_lock);
ctx = smp_load_acquire(&inode->i_flctx);
if (ctx && !list_empty_careful(&ctx->flc_lease)) {
spin_lock(&ctx->flc_lock);
- time_out_leases(
file_inode(filp)
, &dispose);
+ time_out_leases(
inode
, &dispose);
list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
if (fl->fl_file != filp)
continue;
list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
if (fl->fl_file != filp)
continue;
@@
-1613,7
+1618,8
@@
check_conflicting_open(const struct dentry *dentry, const long arg, int flags)
if (flags & FL_LAYOUT)
return 0;
if (flags & FL_LAYOUT)
return 0;
- if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0))
+ if ((arg == F_RDLCK) &&
+ (atomic_read(&d_real_inode(dentry)->i_writecount) > 0))
return -EAGAIN;
if ((arg == F_WRLCK) && ((d_count(dentry) > 1) ||
return -EAGAIN;
if ((arg == F_WRLCK) && ((d_count(dentry) > 1) ||
@@
-1628,7
+1634,7
@@
generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
{
struct file_lock *fl, *my_fl = NULL, *lease;
struct dentry *dentry = filp->f_path.dentry;
{
struct file_lock *fl, *my_fl = NULL, *lease;
struct dentry *dentry = filp->f_path.dentry;
- struct inode *inode =
file_inode(filp)
;
+ struct inode *inode =
dentry->d_inode
;
struct file_lock_context *ctx;
bool is_deleg = (*flp)->fl_flags & FL_DELEG;
int error;
struct file_lock_context *ctx;
bool is_deleg = (*flp)->fl_flags & FL_DELEG;
int error;
@@
-1742,7
+1748,7
@@
static int generic_delete_lease(struct file *filp, void *owner)
{
int error = -EAGAIN;
struct file_lock *fl, *victim = NULL;
{
int error = -EAGAIN;
struct file_lock *fl, *victim = NULL;
- struct inode *inode =
file
_inode(filp);
+ struct inode *inode =
locks
_inode(filp);
struct file_lock_context *ctx;
LIST_HEAD(dispose);
struct file_lock_context *ctx;
LIST_HEAD(dispose);
@@
-1782,7
+1788,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)
{
int generic_setlease(struct file *filp, long arg, struct file_lock **flp,
void **priv)
{
- struct inode *inode =
file
_inode(filp);
+ struct inode *inode =
locks
_inode(filp);
int error;
if ((!uid_eq(current_fsuid(), inode->i_uid)) && !capable(CAP_LEASE))
int error;
if ((!uid_eq(current_fsuid(), inode->i_uid)) && !capable(CAP_LEASE))
@@
-1830,7
+1836,7
@@
EXPORT_SYMBOL(generic_setlease);
int
vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv)
{
int
vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv)
{
- if (filp->f_op->setlease)
+ if (filp->f_op->setlease
&& is_remote_lock(filp)
)
return filp->f_op->setlease(filp, arg, lease, priv);
else
return generic_setlease(filp, arg, lease, priv);
return filp->f_op->setlease(filp, arg, lease, priv);
else
return generic_setlease(filp, arg, lease, priv);
@@
-1979,7
+1985,7
@@
SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
if (error)
goto out_free;
if (error)
goto out_free;
- if (f.file->f_op->flock)
+ if (f.file->f_op->flock
&& is_remote_lock(f.file)
)
error = f.file->f_op->flock(f.file,
(can_sleep) ? F_SETLKW : F_SETLK,
lock);
error = f.file->f_op->flock(f.file,
(can_sleep) ? F_SETLKW : F_SETLK,
lock);
@@
-2005,7
+2011,7
@@
SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
*/
int vfs_test_lock(struct file *filp, struct file_lock *fl)
{
*/
int vfs_test_lock(struct file *filp, struct file_lock *fl)
{
- if (filp->f_op->lock)
+ if (filp->f_op->lock
&& is_remote_lock(filp)
)
return filp->f_op->lock(filp, F_GETLK, fl);
posix_test_lock(filp, fl);
return 0;
return filp->f_op->lock(filp, F_GETLK, fl);
posix_test_lock(filp, fl);
return 0;
@@
-2129,7
+2135,7
@@
out:
*/
int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf)
{
*/
int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf)
{
- if (filp->f_op->lock)
+ if (filp->f_op->lock
&& is_remote_lock(filp)
)
return filp->f_op->lock(filp, cmd, fl);
else
return posix_lock_file(filp, fl, conf);
return filp->f_op->lock(filp, cmd, fl);
else
return posix_lock_file(filp, fl, conf);
@@
-2191,7
+2197,7
@@
int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
if (file_lock == NULL)
return -ENOLCK;
if (file_lock == NULL)
return -ENOLCK;
- inode =
file
_inode(filp);
+ inode =
locks
_inode(filp);
/*
* This might block, so we do it before checking the inode.
/*
* This might block, so we do it before checking the inode.
@@
-2343,7
+2349,7
@@
int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
if (copy_from_user(&flock, l, sizeof(flock)))
goto out;
if (copy_from_user(&flock, l, sizeof(flock)))
goto out;
- inode =
file
_inode(filp);
+ inode =
locks
_inode(filp);
/* Don't allow mandatory locks on files that may be memory mapped
* and shared.
/* Don't allow mandatory locks on files that may be memory mapped
* and shared.
@@
-2426,6
+2432,7
@@
out:
void locks_remove_posix(struct file *filp, fl_owner_t owner)
{
int error;
void locks_remove_posix(struct file *filp, fl_owner_t owner)
{
int error;
+ struct inode *inode = locks_inode(filp);
struct file_lock lock;
struct file_lock_context *ctx;
struct file_lock lock;
struct file_lock_context *ctx;
@@
-2434,7
+2441,7
@@
void locks_remove_posix(struct file *filp, fl_owner_t owner)
* posix_lock_file(). Another process could be setting a lock on this
* file at the same time, but we wouldn't remove that lock anyway.
*/
* posix_lock_file(). Another process could be setting a lock on this
* file at the same time, but we wouldn't remove that lock anyway.
*/
- ctx = smp_load_acquire(&
file_inode(filp)
->i_flctx);
+ ctx = smp_load_acquire(&
inode
->i_flctx);
if (!ctx || list_empty(&ctx->flc_posix))
return;
if (!ctx || list_empty(&ctx->flc_posix))
return;
@@
-2452,7
+2459,7
@@
void locks_remove_posix(struct file *filp, fl_owner_t owner)
if (lock.fl_ops && lock.fl_ops->fl_release_private)
lock.fl_ops->fl_release_private(&lock);
if (lock.fl_ops && lock.fl_ops->fl_release_private)
lock.fl_ops->fl_release_private(&lock);
- trace_locks_remove_posix(
file_inode(filp)
, &lock, error);
+ trace_locks_remove_posix(
inode
, &lock, error);
}
EXPORT_SYMBOL(locks_remove_posix);
}
EXPORT_SYMBOL(locks_remove_posix);
@@
-2469,12
+2476,12
@@
locks_remove_flock(struct file *filp, struct file_lock_context *flctx)
.fl_type = F_UNLCK,
.fl_end = OFFSET_MAX,
};
.fl_type = F_UNLCK,
.fl_end = OFFSET_MAX,
};
- struct inode *inode =
file
_inode(filp);
+ struct inode *inode =
locks
_inode(filp);
if (list_empty(&flctx->flc_flock))
return;
if (list_empty(&flctx->flc_flock))
return;
- if (filp->f_op->flock)
+ if (filp->f_op->flock
&& is_remote_lock(filp)
)
filp->f_op->flock(filp, F_SETLKW, &fl);
else
flock_lock_inode(inode, &fl);
filp->f_op->flock(filp, F_SETLKW, &fl);
else
flock_lock_inode(inode, &fl);
@@
-2508,7
+2515,7
@@
void locks_remove_file(struct file *filp)
{
struct file_lock_context *ctx;
{
struct file_lock_context *ctx;
- ctx = smp_load_acquire(&
file
_inode(filp)->i_flctx);
+ ctx = smp_load_acquire(&
locks
_inode(filp)->i_flctx);
if (!ctx)
return;
if (!ctx)
return;
@@
-2552,7
+2559,7
@@
EXPORT_SYMBOL(posix_unblock_lock);
*/
int vfs_cancel_lock(struct file *filp, struct file_lock *fl)
{
*/
int vfs_cancel_lock(struct file *filp, struct file_lock *fl)
{
- if (filp->f_op->lock)
+ if (filp->f_op->lock
&& is_remote_lock(filp)
)
return filp->f_op->lock(filp, F_CANCELLK, fl);
return 0;
}
return filp->f_op->lock(filp, F_CANCELLK, fl);
return 0;
}
@@
-2580,7
+2587,7
@@
static void lock_get_status(struct seq_file *f, struct file_lock *fl,
fl_pid = fl->fl_pid;
if (fl->fl_file != NULL)
fl_pid = fl->fl_pid;
if (fl->fl_file != NULL)
- inode =
file
_inode(fl->fl_file);
+ inode =
locks
_inode(fl->fl_file);
seq_printf(f, "%lld:%s ", id, pfx);
if (IS_POSIX(fl)) {
seq_printf(f, "%lld:%s ", id, pfx);
if (IS_POSIX(fl)) {
@@
-2682,7
+2689,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)
{
void show_fd_locks(struct seq_file *f,
struct file *filp, struct files_struct *files)
{
- struct inode *inode =
file
_inode(filp);
+ struct inode *inode =
locks
_inode(filp);
struct file_lock_context *ctx;
int id = 0;
struct file_lock_context *ctx;
int id = 0;