Thomas Gleixner | 7336d0e | 2019-05-31 01:09:56 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 2 | /* |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 3 | * Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 6 | #include <linux/fs.h> |
Jeff Layton | 5970e15 | 2022-11-20 09:15:34 -0500 | [diff] [blame] | 7 | #include <linux/filelock.h> |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 8 | #include <linux/miscdevice.h> |
Al Viro | bd01f84 | 2006-10-19 17:23:57 -0400 | [diff] [blame] | 9 | #include <linux/poll.h> |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 10 | #include <linux/dlm.h> |
| 11 | #include <linux/dlm_plock.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 13 | |
Alexander Aring | 8c95006 | 2023-08-01 14:09:42 -0400 | [diff] [blame] | 14 | #include <trace/events/dlm.h> |
| 15 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 16 | #include "dlm_internal.h" |
| 17 | #include "lockspace.h" |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 18 | |
Alexander Aring | 314a554 | 2022-04-04 16:06:36 -0400 | [diff] [blame] | 19 | static DEFINE_SPINLOCK(ops_lock); |
| 20 | static LIST_HEAD(send_list); |
| 21 | static LIST_HEAD(recv_list); |
| 22 | static DECLARE_WAIT_QUEUE_HEAD(send_wq); |
| 23 | static DECLARE_WAIT_QUEUE_HEAD(recv_wq); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 24 | |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 25 | struct plock_async_data { |
| 26 | void *fl; |
| 27 | void *file; |
| 28 | struct file_lock flc; |
| 29 | int (*callback)(struct file_lock *fl, int result); |
| 30 | }; |
| 31 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 32 | struct plock_op { |
| 33 | struct list_head list; |
| 34 | int done; |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 35 | struct dlm_plock_info info; |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 36 | /* if set indicates async handling */ |
| 37 | struct plock_async_data *data; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 38 | }; |
| 39 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 40 | static inline void set_version(struct dlm_plock_info *info) |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 41 | { |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 42 | info->version[0] = DLM_PLOCK_VERSION_MAJOR; |
| 43 | info->version[1] = DLM_PLOCK_VERSION_MINOR; |
| 44 | info->version[2] = DLM_PLOCK_VERSION_PATCH; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Alexander Aring | dc52cd2 | 2023-07-20 08:22:41 -0400 | [diff] [blame] | 47 | static struct plock_op *plock_lookup_waiter(const struct dlm_plock_info *info) |
| 48 | { |
| 49 | struct plock_op *op = NULL, *iter; |
| 50 | |
| 51 | list_for_each_entry(iter, &recv_list, list) { |
| 52 | if (iter->info.fsid == info->fsid && |
| 53 | iter->info.number == info->number && |
| 54 | iter->info.owner == info->owner && |
| 55 | iter->info.pid == info->pid && |
| 56 | iter->info.start == info->start && |
| 57 | iter->info.end == info->end && |
| 58 | iter->info.ex == info->ex && |
| 59 | iter->info.wait) { |
| 60 | op = iter; |
| 61 | break; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | return op; |
| 66 | } |
| 67 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 68 | static int check_version(struct dlm_plock_info *info) |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 69 | { |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 70 | if ((DLM_PLOCK_VERSION_MAJOR != info->version[0]) || |
| 71 | (DLM_PLOCK_VERSION_MINOR < info->version[1])) { |
| 72 | log_print("plock device version mismatch: " |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 73 | "kernel (%u.%u.%u), user (%u.%u.%u)", |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 74 | DLM_PLOCK_VERSION_MAJOR, |
| 75 | DLM_PLOCK_VERSION_MINOR, |
| 76 | DLM_PLOCK_VERSION_PATCH, |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 77 | info->version[0], |
| 78 | info->version[1], |
| 79 | info->version[2]); |
| 80 | return -EINVAL; |
| 81 | } |
| 82 | return 0; |
| 83 | } |
| 84 | |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 85 | static void dlm_release_plock_op(struct plock_op *op) |
| 86 | { |
| 87 | kfree(op->data); |
| 88 | kfree(op); |
| 89 | } |
| 90 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 91 | static void send_op(struct plock_op *op) |
| 92 | { |
| 93 | set_version(&op->info); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 94 | spin_lock(&ops_lock); |
| 95 | list_add_tail(&op->list, &send_list); |
| 96 | spin_unlock(&ops_lock); |
| 97 | wake_up(&send_wq); |
| 98 | } |
| 99 | |
Alexander Aring | 568f915 | 2023-07-20 08:22:40 -0400 | [diff] [blame] | 100 | static int do_lock_cancel(const struct dlm_plock_info *orig_info) |
David Teigland | 901025d | 2011-03-02 14:20:04 -0600 | [diff] [blame] | 101 | { |
| 102 | struct plock_op *op; |
Alexander Aring | 568f915 | 2023-07-20 08:22:40 -0400 | [diff] [blame] | 103 | int rv; |
David Teigland | 901025d | 2011-03-02 14:20:04 -0600 | [diff] [blame] | 104 | |
| 105 | op = kzalloc(sizeof(*op), GFP_NOFS); |
| 106 | if (!op) |
Alexander Aring | 568f915 | 2023-07-20 08:22:40 -0400 | [diff] [blame] | 107 | return -ENOMEM; |
David Teigland | 901025d | 2011-03-02 14:20:04 -0600 | [diff] [blame] | 108 | |
Alexander Aring | 568f915 | 2023-07-20 08:22:40 -0400 | [diff] [blame] | 109 | op->info = *orig_info; |
| 110 | op->info.optype = DLM_PLOCK_OP_CANCEL; |
| 111 | op->info.wait = 0; |
David Teigland | 901025d | 2011-03-02 14:20:04 -0600 | [diff] [blame] | 112 | |
David Teigland | 901025d | 2011-03-02 14:20:04 -0600 | [diff] [blame] | 113 | send_op(op); |
Alexander Aring | 568f915 | 2023-07-20 08:22:40 -0400 | [diff] [blame] | 114 | wait_event(recv_wq, (op->done != 0)); |
| 115 | |
| 116 | rv = op->info.rv; |
| 117 | |
| 118 | dlm_release_plock_op(op); |
| 119 | return rv; |
David Teigland | 901025d | 2011-03-02 14:20:04 -0600 | [diff] [blame] | 120 | } |
| 121 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 122 | int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file, |
| 123 | int cmd, struct file_lock *fl) |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 124 | { |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 125 | struct plock_async_data *op_data; |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 126 | struct dlm_ls *ls; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 127 | struct plock_op *op; |
| 128 | int rv; |
| 129 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 130 | ls = dlm_find_lockspace_local(lockspace); |
| 131 | if (!ls) |
| 132 | return -EINVAL; |
| 133 | |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 134 | op = kzalloc(sizeof(*op), GFP_NOFS); |
| 135 | if (!op) { |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 136 | rv = -ENOMEM; |
| 137 | goto out; |
| 138 | } |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 139 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 140 | op->info.optype = DLM_PLOCK_OP_LOCK; |
David Teigland | 3a2a9c9 | 2006-04-25 15:45:51 -0400 | [diff] [blame] | 141 | op->info.pid = fl->fl_pid; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 142 | op->info.ex = (fl->fl_type == F_WRLCK); |
Alexander Aring | 6bd4a2b | 2023-11-13 16:24:10 -0500 | [diff] [blame] | 143 | op->info.wait = !!(fl->fl_flags & FL_SLEEP); |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 144 | op->info.fsid = ls->ls_global_id; |
| 145 | op->info.number = number; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 146 | op->info.start = fl->fl_start; |
| 147 | op->info.end = fl->fl_end; |
Alexander Aring | dbee1ad | 2023-11-13 16:24:09 -0500 | [diff] [blame] | 148 | op->info.owner = (__u64)(long)fl->fl_owner; |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 149 | /* async handling */ |
J. Bruce Fields | 8fb47a4 | 2011-07-20 20:21:59 -0400 | [diff] [blame] | 150 | if (fl->fl_lmops && fl->fl_lmops->lm_grant) { |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 151 | op_data = kzalloc(sizeof(*op_data), GFP_NOFS); |
| 152 | if (!op_data) { |
| 153 | dlm_release_plock_op(op); |
| 154 | rv = -ENOMEM; |
| 155 | goto out; |
| 156 | } |
| 157 | |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 158 | op_data->callback = fl->fl_lmops->lm_grant; |
| 159 | locks_init_lock(&op_data->flc); |
| 160 | locks_copy_lock(&op_data->flc, fl); |
| 161 | op_data->fl = fl; |
| 162 | op_data->file = file; |
| 163 | |
| 164 | op->data = op_data; |
Alexander Aring | a800ba7 | 2022-04-04 16:06:33 -0400 | [diff] [blame] | 165 | |
| 166 | send_op(op); |
| 167 | rv = FILE_LOCK_DEFERRED; |
| 168 | goto out; |
David Teigland | 2066b58 | 2007-12-06 09:35:25 -0600 | [diff] [blame] | 169 | } |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 170 | |
| 171 | send_op(op); |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 172 | |
Alexander Aring | 0f2b1cb | 2023-05-19 11:21:27 -0400 | [diff] [blame] | 173 | if (op->info.wait) { |
Alexander Aring | 568f915 | 2023-07-20 08:22:40 -0400 | [diff] [blame] | 174 | rv = wait_event_interruptible(recv_wq, (op->done != 0)); |
Alexander Aring | 0f2b1cb | 2023-05-19 11:21:27 -0400 | [diff] [blame] | 175 | if (rv == -ERESTARTSYS) { |
| 176 | spin_lock(&ops_lock); |
| 177 | /* recheck under ops_lock if we got a done != 0, |
| 178 | * if so this interrupt case should be ignored |
| 179 | */ |
| 180 | if (op->done != 0) { |
| 181 | spin_unlock(&ops_lock); |
| 182 | goto do_lock_wait; |
| 183 | } |
Alexander Aring | b92a4e3 | 2022-06-22 14:45:09 -0400 | [diff] [blame] | 184 | spin_unlock(&ops_lock); |
Alexander Aring | c847f4e | 2023-05-19 11:21:25 -0400 | [diff] [blame] | 185 | |
Alexander Aring | 568f915 | 2023-07-20 08:22:40 -0400 | [diff] [blame] | 186 | rv = do_lock_cancel(&op->info); |
| 187 | switch (rv) { |
| 188 | case 0: |
| 189 | /* waiter was deleted in user space, answer will never come |
| 190 | * remove original request. The original request must be |
| 191 | * on recv_list because the answer of do_lock_cancel() |
| 192 | * synchronized it. |
| 193 | */ |
| 194 | spin_lock(&ops_lock); |
| 195 | list_del(&op->list); |
| 196 | spin_unlock(&ops_lock); |
| 197 | rv = -EINTR; |
| 198 | break; |
| 199 | case -ENOENT: |
| 200 | /* cancellation wasn't successful but op should be done */ |
| 201 | fallthrough; |
| 202 | default: |
| 203 | /* internal error doing cancel we need to wait */ |
| 204 | goto wait; |
| 205 | } |
| 206 | |
Alexander Aring | 0f2b1cb | 2023-05-19 11:21:27 -0400 | [diff] [blame] | 207 | log_debug(ls, "%s: wait interrupted %x %llx pid %d", |
| 208 | __func__, ls->ls_global_id, |
| 209 | (unsigned long long)number, op->info.pid); |
Alexander Aring | 0f2b1cb | 2023-05-19 11:21:27 -0400 | [diff] [blame] | 210 | dlm_release_plock_op(op); |
| 211 | goto out; |
| 212 | } |
| 213 | } else { |
Alexander Aring | 568f915 | 2023-07-20 08:22:40 -0400 | [diff] [blame] | 214 | wait: |
Alexander Aring | 0f2b1cb | 2023-05-19 11:21:27 -0400 | [diff] [blame] | 215 | wait_event(recv_wq, (op->done != 0)); |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 216 | } |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 217 | |
Alexander Aring | b92a4e3 | 2022-06-22 14:45:09 -0400 | [diff] [blame] | 218 | do_lock_wait: |
| 219 | |
Alexander Aring | a559790 | 2022-04-04 16:06:31 -0400 | [diff] [blame] | 220 | WARN_ON(!list_empty(&op->list)); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 221 | |
| 222 | rv = op->info.rv; |
| 223 | |
| 224 | if (!rv) { |
Benjamin Coddington | 4f65636 | 2015-10-22 13:38:14 -0400 | [diff] [blame] | 225 | if (locks_lock_file_wait(file, fl) < 0) |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 226 | log_error(ls, "dlm_posix_lock: vfs lock error %llx", |
| 227 | (unsigned long long)number); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 228 | } |
| 229 | |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 230 | dlm_release_plock_op(op); |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 231 | out: |
| 232 | dlm_put_lockspace(ls); |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 233 | return rv; |
| 234 | } |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 235 | EXPORT_SYMBOL_GPL(dlm_posix_lock); |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 236 | |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 237 | /* Returns failure iff a successful lock operation should be canceled */ |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 238 | static int dlm_plock_callback(struct plock_op *op) |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 239 | { |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 240 | struct plock_async_data *op_data = op->data; |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 241 | struct file *file; |
| 242 | struct file_lock *fl; |
| 243 | struct file_lock *flc; |
Joe Perches | d0449b9 | 2014-08-22 10:18:42 -0400 | [diff] [blame] | 244 | int (*notify)(struct file_lock *fl, int result) = NULL; |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 245 | int rv = 0; |
| 246 | |
Alexander Aring | a559790 | 2022-04-04 16:06:31 -0400 | [diff] [blame] | 247 | WARN_ON(!list_empty(&op->list)); |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 248 | |
| 249 | /* check if the following 2 are still valid or make a copy */ |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 250 | file = op_data->file; |
| 251 | flc = &op_data->flc; |
| 252 | fl = op_data->fl; |
| 253 | notify = op_data->callback; |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 254 | |
| 255 | if (op->info.rv) { |
Joe Perches | d0449b9 | 2014-08-22 10:18:42 -0400 | [diff] [blame] | 256 | notify(fl, op->info.rv); |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 257 | goto out; |
| 258 | } |
| 259 | |
| 260 | /* got fs lock; bookkeep locally as well: */ |
| 261 | flc->fl_flags &= ~FL_SLEEP; |
| 262 | if (posix_lock_file(file, flc, NULL)) { |
| 263 | /* |
| 264 | * This can only happen in the case of kmalloc() failure. |
| 265 | * The filesystem's own lock is the authoritative lock, |
| 266 | * so a failure to get the lock locally is not a disaster. |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 267 | * As long as the fs cannot reliably cancel locks (especially |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 268 | * in a low-memory situation), we're better off ignoring |
| 269 | * this failure than trying to recover. |
| 270 | */ |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 271 | log_print("dlm_plock_callback: vfs lock error %llx file %p fl %p", |
| 272 | (unsigned long long)op->info.number, file, fl); |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 273 | } |
| 274 | |
Joe Perches | d0449b9 | 2014-08-22 10:18:42 -0400 | [diff] [blame] | 275 | rv = notify(fl, 0); |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 276 | if (rv) { |
| 277 | /* XXX: We need to cancel the fs lock here: */ |
Alexander Aring | 99c58d6 | 2023-07-20 08:22:39 -0400 | [diff] [blame] | 278 | log_print("%s: lock granted after lock request failed; dangling lock!", |
| 279 | __func__); |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 280 | goto out; |
| 281 | } |
| 282 | |
| 283 | out: |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 284 | dlm_release_plock_op(op); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 285 | return rv; |
| 286 | } |
| 287 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 288 | int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file, |
| 289 | struct file_lock *fl) |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 290 | { |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 291 | struct dlm_ls *ls; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 292 | struct plock_op *op; |
| 293 | int rv; |
David Teigland | 9000831 | 2013-04-05 10:57:15 +0100 | [diff] [blame] | 294 | unsigned char fl_flags = fl->fl_flags; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 295 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 296 | ls = dlm_find_lockspace_local(lockspace); |
| 297 | if (!ls) |
| 298 | return -EINVAL; |
| 299 | |
David Teigland | 573c24c | 2009-11-30 16:34:43 -0600 | [diff] [blame] | 300 | op = kzalloc(sizeof(*op), GFP_NOFS); |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 301 | if (!op) { |
| 302 | rv = -ENOMEM; |
| 303 | goto out; |
| 304 | } |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 305 | |
David Teigland | 9000831 | 2013-04-05 10:57:15 +0100 | [diff] [blame] | 306 | /* cause the vfs unlock to return ENOENT if lock is not found */ |
| 307 | fl->fl_flags |= FL_EXISTS; |
| 308 | |
Benjamin Coddington | 4f65636 | 2015-10-22 13:38:14 -0400 | [diff] [blame] | 309 | rv = locks_lock_file_wait(file, fl); |
David Teigland | 9000831 | 2013-04-05 10:57:15 +0100 | [diff] [blame] | 310 | if (rv == -ENOENT) { |
| 311 | rv = 0; |
| 312 | goto out_free; |
| 313 | } |
| 314 | if (rv < 0) { |
| 315 | log_error(ls, "dlm_posix_unlock: vfs unlock error %d %llx", |
| 316 | rv, (unsigned long long)number); |
| 317 | } |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 318 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 319 | op->info.optype = DLM_PLOCK_OP_UNLOCK; |
David Teigland | 3a2a9c9 | 2006-04-25 15:45:51 -0400 | [diff] [blame] | 320 | op->info.pid = fl->fl_pid; |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 321 | op->info.fsid = ls->ls_global_id; |
| 322 | op->info.number = number; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 323 | op->info.start = fl->fl_start; |
| 324 | op->info.end = fl->fl_end; |
Alexander Aring | dbee1ad | 2023-11-13 16:24:09 -0500 | [diff] [blame] | 325 | op->info.owner = (__u64)(long)fl->fl_owner; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 326 | |
David Teigland | 901025d | 2011-03-02 14:20:04 -0600 | [diff] [blame] | 327 | if (fl->fl_flags & FL_CLOSE) { |
| 328 | op->info.flags |= DLM_PLOCK_FL_CLOSE; |
| 329 | send_op(op); |
| 330 | rv = 0; |
| 331 | goto out; |
| 332 | } |
| 333 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 334 | send_op(op); |
| 335 | wait_event(recv_wq, (op->done != 0)); |
| 336 | |
Alexander Aring | a559790 | 2022-04-04 16:06:31 -0400 | [diff] [blame] | 337 | WARN_ON(!list_empty(&op->list)); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 338 | |
| 339 | rv = op->info.rv; |
| 340 | |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 341 | if (rv == -ENOENT) |
| 342 | rv = 0; |
| 343 | |
David Teigland | 9000831 | 2013-04-05 10:57:15 +0100 | [diff] [blame] | 344 | out_free: |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 345 | dlm_release_plock_op(op); |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 346 | out: |
| 347 | dlm_put_lockspace(ls); |
David Teigland | 9000831 | 2013-04-05 10:57:15 +0100 | [diff] [blame] | 348 | fl->fl_flags = fl_flags; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 349 | return rv; |
| 350 | } |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 351 | EXPORT_SYMBOL_GPL(dlm_posix_unlock); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 352 | |
Alexander Aring | dc52cd2 | 2023-07-20 08:22:41 -0400 | [diff] [blame] | 353 | /* |
| 354 | * NOTE: This implementation can only handle async lock requests as nfs |
| 355 | * do it. It cannot handle cancellation of a pending lock request sitting |
| 356 | * in wait_event(), but for now only nfs is the only user local kernel |
| 357 | * user. |
| 358 | */ |
| 359 | int dlm_posix_cancel(dlm_lockspace_t *lockspace, u64 number, struct file *file, |
| 360 | struct file_lock *fl) |
| 361 | { |
| 362 | struct dlm_plock_info info; |
| 363 | struct plock_op *op; |
| 364 | struct dlm_ls *ls; |
| 365 | int rv; |
| 366 | |
| 367 | /* this only works for async request for now and nfs is the only |
| 368 | * kernel user right now. |
| 369 | */ |
| 370 | if (WARN_ON_ONCE(!fl->fl_lmops || !fl->fl_lmops->lm_grant)) |
| 371 | return -EOPNOTSUPP; |
| 372 | |
| 373 | ls = dlm_find_lockspace_local(lockspace); |
| 374 | if (!ls) |
| 375 | return -EINVAL; |
| 376 | |
| 377 | memset(&info, 0, sizeof(info)); |
| 378 | info.pid = fl->fl_pid; |
| 379 | info.ex = (fl->fl_type == F_WRLCK); |
| 380 | info.fsid = ls->ls_global_id; |
| 381 | dlm_put_lockspace(ls); |
| 382 | info.number = number; |
| 383 | info.start = fl->fl_start; |
| 384 | info.end = fl->fl_end; |
Alexander Aring | dbee1ad | 2023-11-13 16:24:09 -0500 | [diff] [blame] | 385 | info.owner = (__u64)(long)fl->fl_owner; |
Alexander Aring | dc52cd2 | 2023-07-20 08:22:41 -0400 | [diff] [blame] | 386 | |
| 387 | rv = do_lock_cancel(&info); |
| 388 | switch (rv) { |
| 389 | case 0: |
| 390 | spin_lock(&ops_lock); |
| 391 | /* lock request to cancel must be on recv_list because |
| 392 | * do_lock_cancel() synchronizes it. |
| 393 | */ |
| 394 | op = plock_lookup_waiter(&info); |
| 395 | if (WARN_ON_ONCE(!op)) { |
Alexander Aring | e717f2e | 2023-08-01 14:09:38 -0400 | [diff] [blame] | 396 | spin_unlock(&ops_lock); |
Alexander Aring | dc52cd2 | 2023-07-20 08:22:41 -0400 | [diff] [blame] | 397 | rv = -ENOLCK; |
| 398 | break; |
| 399 | } |
| 400 | |
| 401 | list_del(&op->list); |
| 402 | spin_unlock(&ops_lock); |
| 403 | WARN_ON(op->info.optype != DLM_PLOCK_OP_LOCK); |
| 404 | op->data->callback(op->data->fl, -EINTR); |
| 405 | dlm_release_plock_op(op); |
| 406 | rv = -EINTR; |
| 407 | break; |
| 408 | case -ENOENT: |
| 409 | /* if cancel wasn't successful we probably were to late |
| 410 | * or it was a non-blocking lock request, so just unlock it. |
| 411 | */ |
| 412 | rv = dlm_posix_unlock(lockspace, number, file, fl); |
| 413 | break; |
| 414 | default: |
| 415 | break; |
| 416 | } |
| 417 | |
| 418 | return rv; |
| 419 | } |
| 420 | EXPORT_SYMBOL_GPL(dlm_posix_cancel); |
| 421 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 422 | int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file, |
| 423 | struct file_lock *fl) |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 424 | { |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 425 | struct dlm_ls *ls; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 426 | struct plock_op *op; |
| 427 | int rv; |
| 428 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 429 | ls = dlm_find_lockspace_local(lockspace); |
| 430 | if (!ls) |
| 431 | return -EINVAL; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 432 | |
David Teigland | 573c24c | 2009-11-30 16:34:43 -0600 | [diff] [blame] | 433 | op = kzalloc(sizeof(*op), GFP_NOFS); |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 434 | if (!op) { |
| 435 | rv = -ENOMEM; |
| 436 | goto out; |
| 437 | } |
| 438 | |
| 439 | op->info.optype = DLM_PLOCK_OP_GET; |
David Teigland | 3a2a9c9 | 2006-04-25 15:45:51 -0400 | [diff] [blame] | 440 | op->info.pid = fl->fl_pid; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 441 | op->info.ex = (fl->fl_type == F_WRLCK); |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 442 | op->info.fsid = ls->ls_global_id; |
| 443 | op->info.number = number; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 444 | op->info.start = fl->fl_start; |
| 445 | op->info.end = fl->fl_end; |
Alexander Aring | dbee1ad | 2023-11-13 16:24:09 -0500 | [diff] [blame] | 446 | op->info.owner = (__u64)(long)fl->fl_owner; |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 447 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 448 | send_op(op); |
| 449 | wait_event(recv_wq, (op->done != 0)); |
| 450 | |
Alexander Aring | a559790 | 2022-04-04 16:06:31 -0400 | [diff] [blame] | 451 | WARN_ON(!list_empty(&op->list)); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 452 | |
David Teigland | a7a2ff8 | 2007-06-08 17:01:40 -0500 | [diff] [blame] | 453 | /* info.rv from userspace is 1 for conflict, 0 for no-conflict, |
| 454 | -ENOENT if there are no locks on the file */ |
| 455 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 456 | rv = op->info.rv; |
| 457 | |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 458 | fl->fl_type = F_UNLCK; |
| 459 | if (rv == -ENOENT) |
| 460 | rv = 0; |
David Teigland | a7a2ff8 | 2007-06-08 17:01:40 -0500 | [diff] [blame] | 461 | else if (rv > 0) { |
Jeff Layton | 20d5a39 | 2009-01-21 11:34:50 -0500 | [diff] [blame] | 462 | locks_init_lock(fl); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 463 | fl->fl_type = (op->info.ex) ? F_WRLCK : F_RDLCK; |
Jeff Layton | 20d5a39 | 2009-01-21 11:34:50 -0500 | [diff] [blame] | 464 | fl->fl_flags = FL_POSIX; |
Alexander Aring | 92655fbd | 2023-05-19 11:21:24 -0400 | [diff] [blame] | 465 | fl->fl_pid = op->info.pid; |
| 466 | if (op->info.nodeid != dlm_our_nodeid()) |
| 467 | fl->fl_pid = -fl->fl_pid; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 468 | fl->fl_start = op->info.start; |
| 469 | fl->fl_end = op->info.end; |
David Teigland | a7a2ff8 | 2007-06-08 17:01:40 -0500 | [diff] [blame] | 470 | rv = 0; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 471 | } |
| 472 | |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 473 | dlm_release_plock_op(op); |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 474 | out: |
| 475 | dlm_put_lockspace(ls); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 476 | return rv; |
| 477 | } |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 478 | EXPORT_SYMBOL_GPL(dlm_posix_get); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 479 | |
| 480 | /* a read copies out one plock request from the send list */ |
| 481 | static ssize_t dev_read(struct file *file, char __user *u, size_t count, |
| 482 | loff_t *ppos) |
| 483 | { |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 484 | struct dlm_plock_info info; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 485 | struct plock_op *op = NULL; |
| 486 | |
| 487 | if (count < sizeof(info)) |
| 488 | return -EINVAL; |
| 489 | |
| 490 | spin_lock(&ops_lock); |
| 491 | if (!list_empty(&send_list)) { |
Alexander Aring | 976a062 | 2022-06-22 14:45:04 -0400 | [diff] [blame] | 492 | op = list_first_entry(&send_list, struct plock_op, list); |
David Teigland | 901025d | 2011-03-02 14:20:04 -0600 | [diff] [blame] | 493 | if (op->info.flags & DLM_PLOCK_FL_CLOSE) |
| 494 | list_del(&op->list); |
| 495 | else |
Alexander Aring | 57e2c2f | 2023-05-24 12:02:04 -0400 | [diff] [blame] | 496 | list_move_tail(&op->list, &recv_list); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 497 | memcpy(&info, &op->info, sizeof(info)); |
| 498 | } |
| 499 | spin_unlock(&ops_lock); |
| 500 | |
| 501 | if (!op) |
| 502 | return -EAGAIN; |
| 503 | |
Alexander Aring | 8c95006 | 2023-08-01 14:09:42 -0400 | [diff] [blame] | 504 | trace_dlm_plock_read(&info); |
| 505 | |
David Teigland | 901025d | 2011-03-02 14:20:04 -0600 | [diff] [blame] | 506 | /* there is no need to get a reply from userspace for unlocks |
| 507 | that were generated by the vfs cleaning up for a close |
| 508 | (the process did not make an unlock call). */ |
| 509 | |
| 510 | if (op->info.flags & DLM_PLOCK_FL_CLOSE) |
Alexander Aring | bcbb4ba | 2022-04-04 16:06:32 -0400 | [diff] [blame] | 511 | dlm_release_plock_op(op); |
David Teigland | 901025d | 2011-03-02 14:20:04 -0600 | [diff] [blame] | 512 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 513 | if (copy_to_user(u, &info, sizeof(info))) |
| 514 | return -EFAULT; |
| 515 | return sizeof(info); |
| 516 | } |
| 517 | |
| 518 | /* a write copies in one plock result that should match a plock_op |
| 519 | on the recv list */ |
| 520 | static ssize_t dev_write(struct file *file, const char __user *u, size_t count, |
| 521 | loff_t *ppos) |
| 522 | { |
Jakob Koschel | dc1acd5 | 2022-04-06 14:05:31 -0400 | [diff] [blame] | 523 | struct plock_op *op = NULL, *iter; |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 524 | struct dlm_plock_info info; |
Jakob Koschel | dc1acd5 | 2022-04-06 14:05:31 -0400 | [diff] [blame] | 525 | int do_callback = 0; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 526 | |
| 527 | if (count != sizeof(info)) |
| 528 | return -EINVAL; |
| 529 | |
| 530 | if (copy_from_user(&info, u, sizeof(info))) |
| 531 | return -EFAULT; |
| 532 | |
Alexander Aring | 8c95006 | 2023-08-01 14:09:42 -0400 | [diff] [blame] | 533 | trace_dlm_plock_write(&info); |
| 534 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 535 | if (check_version(&info)) |
| 536 | return -EINVAL; |
| 537 | |
Alexander Aring | 57e2c2f | 2023-05-24 12:02:04 -0400 | [diff] [blame] | 538 | /* |
| 539 | * The results for waiting ops (SETLKW) can be returned in any |
| 540 | * order, so match all fields to find the op. The results for |
| 541 | * non-waiting ops are returned in the order that they were sent |
| 542 | * to userspace, so match the result with the first non-waiting op. |
| 543 | */ |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 544 | spin_lock(&ops_lock); |
Alexander Aring | 57e2c2f | 2023-05-24 12:02:04 -0400 | [diff] [blame] | 545 | if (info.wait) { |
Alexander Aring | dc52cd2 | 2023-07-20 08:22:41 -0400 | [diff] [blame] | 546 | op = plock_lookup_waiter(&info); |
Alexander Aring | 57e2c2f | 2023-05-24 12:02:04 -0400 | [diff] [blame] | 547 | } else { |
| 548 | list_for_each_entry(iter, &recv_list, list) { |
Alexander Aring | 7c53e84 | 2023-08-24 16:51:42 -0400 | [diff] [blame] | 549 | if (!iter->info.wait && |
| 550 | iter->info.fsid == info.fsid) { |
Alexander Aring | 57e2c2f | 2023-05-24 12:02:04 -0400 | [diff] [blame] | 551 | op = iter; |
| 552 | break; |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | if (op) { |
| 558 | /* Sanity check that op and info match. */ |
| 559 | if (info.wait) |
| 560 | WARN_ON(op->info.optype != DLM_PLOCK_OP_LOCK); |
| 561 | else |
Alexander Aring | 7c53e84 | 2023-08-24 16:51:42 -0400 | [diff] [blame] | 562 | WARN_ON(op->info.number != info.number || |
Alexander Aring | 57e2c2f | 2023-05-24 12:02:04 -0400 | [diff] [blame] | 563 | op->info.owner != info.owner || |
| 564 | op->info.optype != info.optype); |
| 565 | |
| 566 | list_del_init(&op->list); |
| 567 | memcpy(&op->info, &info, sizeof(info)); |
| 568 | if (op->data) |
| 569 | do_callback = 1; |
| 570 | else |
| 571 | op->done = 1; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 572 | } |
| 573 | spin_unlock(&ops_lock); |
| 574 | |
Jakob Koschel | dc1acd5 | 2022-04-06 14:05:31 -0400 | [diff] [blame] | 575 | if (op) { |
David Teigland | c78a87d | 2009-06-18 13:20:24 -0500 | [diff] [blame] | 576 | if (do_callback) |
David Teigland | 817d10b | 2008-05-13 14:28:26 -0500 | [diff] [blame] | 577 | dlm_plock_callback(op); |
Marc Eshel | 586759f | 2006-11-14 16:37:25 -0500 | [diff] [blame] | 578 | else |
| 579 | wake_up(&recv_wq); |
| 580 | } else |
Alexander Aring | c847f4e | 2023-05-19 11:21:25 -0400 | [diff] [blame] | 581 | pr_debug("%s: no op %x %llx", __func__, |
| 582 | info.fsid, (unsigned long long)info.number); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 583 | return count; |
| 584 | } |
| 585 | |
Al Viro | 076ccb7 | 2017-07-03 01:02:18 -0400 | [diff] [blame] | 586 | static __poll_t dev_poll(struct file *file, poll_table *wait) |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 587 | { |
Al Viro | 076ccb7 | 2017-07-03 01:02:18 -0400 | [diff] [blame] | 588 | __poll_t mask = 0; |
Denis Cheng | cee23c7 | 2007-07-25 17:53:58 +0800 | [diff] [blame] | 589 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 590 | poll_wait(file, &send_wq, wait); |
| 591 | |
| 592 | spin_lock(&ops_lock); |
Denis Cheng | cee23c7 | 2007-07-25 17:53:58 +0800 | [diff] [blame] | 593 | if (!list_empty(&send_list)) |
Linus Torvalds | a9a0884 | 2018-02-11 14:34:03 -0800 | [diff] [blame] | 594 | mask = EPOLLIN | EPOLLRDNORM; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 595 | spin_unlock(&ops_lock); |
Denis Cheng | cee23c7 | 2007-07-25 17:53:58 +0800 | [diff] [blame] | 596 | |
| 597 | return mask; |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 598 | } |
| 599 | |
Arjan van de Ven | 00977a5 | 2007-02-12 00:55:34 -0800 | [diff] [blame] | 600 | static const struct file_operations dev_fops = { |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 601 | .read = dev_read, |
| 602 | .write = dev_write, |
| 603 | .poll = dev_poll, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 604 | .owner = THIS_MODULE, |
| 605 | .llseek = noop_llseek, |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 606 | }; |
| 607 | |
| 608 | static struct miscdevice plock_dev_misc = { |
| 609 | .minor = MISC_DYNAMIC_MINOR, |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 610 | .name = DLM_PLOCK_MISC_NAME, |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 611 | .fops = &dev_fops |
| 612 | }; |
| 613 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 614 | int dlm_plock_init(void) |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 615 | { |
| 616 | int rv; |
| 617 | |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 618 | rv = misc_register(&plock_dev_misc); |
| 619 | if (rv) |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 620 | log_print("dlm_plock_init: misc_register failed %d", rv); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 621 | return rv; |
| 622 | } |
| 623 | |
David Teigland | 2402211 | 2008-03-14 15:09:15 -0500 | [diff] [blame] | 624 | void dlm_plock_exit(void) |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 625 | { |
Greg Kroah-Hartman | f368ed6 | 2015-07-30 15:59:57 -0700 | [diff] [blame] | 626 | misc_deregister(&plock_dev_misc); |
Alexander Aring | 67b5da9 | 2023-08-01 14:09:41 -0400 | [diff] [blame] | 627 | WARN_ON(!list_empty(&send_list)); |
| 628 | WARN_ON(!list_empty(&recv_list)); |
David Teigland | 869d81d | 2006-01-17 08:47:12 +0000 | [diff] [blame] | 629 | } |
| 630 | |