summaryrefslogtreecommitdiffstats
path: root/fs/ceph/locks.c
diff options
context:
space:
mode:
authorYan, Zheng2014-03-04 08:50:06 +0100
committerSage Weil2014-04-05 06:07:09 +0200
commiteb70c0ce4e877c6854c682c0fc009d7875994942 (patch)
tree3d37db9d4ab5567f9f9122ecf3796bec0875ef4c /fs/ceph/locks.c
parentceph: use fl->fl_type to decide flock operation (diff)
downloadkernel-qcow2-linux-eb70c0ce4e877c6854c682c0fc009d7875994942.tar.gz
kernel-qcow2-linux-eb70c0ce4e877c6854c682c0fc009d7875994942.tar.xz
kernel-qcow2-linux-eb70c0ce4e877c6854c682c0fc009d7875994942.zip
ceph: forbid mandatory file lock
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Diffstat (limited to 'fs/ceph/locks.c')
-rw-r--r--fs/ceph/locks.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index 133e0063da64..f91a569a20fb 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -87,6 +87,12 @@ int ceph_lock(struct file *file, int cmd, struct file_lock *fl)
u8 wait = 0;
u16 op = CEPH_MDS_OP_SETFILELOCK;
+ if (!(fl->fl_flags & FL_POSIX))
+ return -ENOLCK;
+ /* No mandatory locks */
+ if (__mandatory_lock(file->f_mapping->host) && fl->fl_type != F_UNLCK)
+ return -ENOLCK;
+
fl->fl_nspid = get_pid(task_tgid(current));
dout("ceph_lock, fl_pid:%d", fl->fl_pid);
@@ -133,6 +139,12 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl)
int err;
u8 wait = 0;
+ if (!(fl->fl_flags & FL_FLOCK))
+ return -ENOLCK;
+ /* No mandatory locks */
+ if (__mandatory_lock(file->f_mapping->host) && fl->fl_type != F_UNLCK)
+ return -ENOLCK;
+
fl->fl_nspid = get_pid(task_tgid(current));
dout("ceph_flock, fl_pid:%d", fl->fl_pid);