Skip to content

Commit 0e8e95d

Browse files
Yan, ZhengSage Weil
authored andcommitted
ceph: use fl->fl_type to decide flock operation
VFS does not directly pass flock's operation code to filesystem's flock callback. It translates the operation code to the form how posix lock's parameters are presented. Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
1 parent 8c93cd6 commit 0e8e95d

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

‎fs/ceph/locks.c‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ int ceph_lock(struct file *file, int cmd, struct file_lock *fl)
9191
dout("ceph_lock, fl_pid:%d", fl->fl_pid);
9292

9393
/* set wait bit as appropriate, then make command as Ceph expects it*/
94-
if (F_SETLKW == cmd)
95-
wait = 1;
96-
if (F_GETLK == cmd)
94+
if (IS_GETLK(cmd))
9795
op = CEPH_MDS_OP_GETFILELOCK;
96+
else if (IS_SETLKW(cmd))
97+
wait = 1;
9898

9999
if (F_RDLCK == fl->fl_type)
100100
lock_cmd = CEPH_LOCK_SHARED;
@@ -131,20 +131,17 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl)
131131
{
132132
u8 lock_cmd;
133133
int err;
134-
u8 wait = 1;
134+
u8 wait = 0;
135135

136136
fl->fl_nspid = get_pid(task_tgid(current));
137137
dout("ceph_flock, fl_pid:%d", fl->fl_pid);
138138

139-
/* set wait bit, then clear it out of cmd*/
140-
if (cmd & LOCK_NB)
141-
wait = 0;
142-
cmd = cmd & (LOCK_SH | LOCK_EX | LOCK_UN);
143-
/* set command sequence that Ceph wants to see:
144-
shared lock, exclusive lock, or unlock */
145-
if (LOCK_SH == cmd)
139+
if (IS_SETLKW(cmd))
140+
wait = 1;
141+
142+
if (F_RDLCK == fl->fl_type)
146143
lock_cmd = CEPH_LOCK_SHARED;
147-
else if (LOCK_EX == cmd)
144+
else if (F_WRLCK == fl->fl_type)
148145
lock_cmd = CEPH_LOCK_EXCL;
149146
else
150147
lock_cmd = CEPH_LOCK_UNLOCK;

0 commit comments

Comments
 (0)