Commit 0c1f91f27140cf3b6e38dc4e892adac241c73a20
1 parent
0e98728fa3
Exists in
master
and in
39 other branches
ceph: unwind canceled flock state
If we request a lock and then abort (e.g., ^C), we need to send a matching unlock request to the MDS to unwind our lock attempt to avoid indefinitely blocking other clients. Reported-by: Brian Chrisman <brchrisman@gmail.com> Signed-off-by: Sage Weil <sage@newdream.net>
Showing 1 changed file with 16 additions and 10 deletions Side-by-side Diff
fs/ceph/locks.c
... | ... | @@ -33,11 +33,10 @@ |
33 | 33 | length = fl->fl_end - fl->fl_start + 1; |
34 | 34 | |
35 | 35 | dout("ceph_lock_message: rule: %d, op: %d, pid: %llu, start: %llu, " |
36 | - "length: %llu, wait: %d, type`: %d", (int)lock_type, | |
36 | + "length: %llu, wait: %d, type: %d", (int)lock_type, | |
37 | 37 | (int)operation, (u64)fl->fl_pid, fl->fl_start, |
38 | 38 | length, wait, fl->fl_type); |
39 | 39 | |
40 | - | |
41 | 40 | req->r_args.filelock_change.rule = lock_type; |
42 | 41 | req->r_args.filelock_change.type = cmd; |
43 | 42 | req->r_args.filelock_change.pid = cpu_to_le64((u64)fl->fl_pid); |
... | ... | @@ -71,7 +70,7 @@ |
71 | 70 | } |
72 | 71 | ceph_mdsc_put_request(req); |
73 | 72 | dout("ceph_lock_message: rule: %d, op: %d, pid: %llu, start: %llu, " |
74 | - "length: %llu, wait: %d, type`: %d, err code %d", (int)lock_type, | |
73 | + "length: %llu, wait: %d, type: %d, err code %d", (int)lock_type, | |
75 | 74 | (int)operation, (u64)fl->fl_pid, fl->fl_start, |
76 | 75 | length, wait, fl->fl_type, err); |
77 | 76 | return err; |
78 | 77 | |
79 | 78 | |
... | ... | @@ -110,16 +109,20 @@ |
110 | 109 | dout("mds locked, locking locally"); |
111 | 110 | err = posix_lock_file(file, fl, NULL); |
112 | 111 | if (err && (CEPH_MDS_OP_SETFILELOCK == op)) { |
113 | - /* undo! This should only happen if the kernel detects | |
114 | - * local deadlock. */ | |
112 | + /* undo! This should only happen if | |
113 | + * the kernel detects local | |
114 | + * deadlock. */ | |
115 | 115 | ceph_lock_message(CEPH_LOCK_FCNTL, op, file, |
116 | 116 | CEPH_LOCK_UNLOCK, 0, fl); |
117 | - dout("got %d on posix_lock_file, undid lock", err); | |
117 | + dout("got %d on posix_lock_file, undid lock", | |
118 | + err); | |
118 | 119 | } |
119 | 120 | } |
120 | 121 | |
121 | - } else { | |
122 | - dout("mds returned error code %d", err); | |
122 | + } else if (err == -ERESTARTSYS) { | |
123 | + dout("undoing lock\n"); | |
124 | + ceph_lock_message(CEPH_LOCK_FCNTL, op, file, | |
125 | + CEPH_LOCK_UNLOCK, 0, fl); | |
123 | 126 | } |
124 | 127 | return err; |
125 | 128 | } |
... | ... | @@ -156,8 +159,11 @@ |
156 | 159 | file, CEPH_LOCK_UNLOCK, 0, fl); |
157 | 160 | dout("got %d on flock_lock_file_wait, undid lock", err); |
158 | 161 | } |
159 | - } else { | |
160 | - dout("mds error code %d", err); | |
162 | + } else if (err == -ERESTARTSYS) { | |
163 | + dout("undoing lock\n"); | |
164 | + ceph_lock_message(CEPH_LOCK_FLOCK, | |
165 | + CEPH_MDS_OP_SETFILELOCK, | |
166 | + file, CEPH_LOCK_UNLOCK, 0, fl); | |
161 | 167 | } |
162 | 168 | return err; |
163 | 169 | } |