ceph: forbid mandatory file lock
authorYan, Zheng <zheng.z.yan@intel.com>
Tue, 4 Mar 2014 07:50:06 +0000 (15:50 +0800)
committerSage Weil <sage@inktank.com>
Sat, 5 Apr 2014 04:07:09 +0000 (21:07 -0700)
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
fs/ceph/locks.c

index 133e0063da647256843cf3ef72c39b2790098325..f91a569a20fbc9ea54ca8a345b7e5ecb95bba59d 100644 (file)
@@ -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);