Linux 6.9-rc1
[linux-2.6-microblaze.git] / fs / dlm / user.c
index d9c09fc..9f9b684 100644 (file)
@@ -145,6 +145,24 @@ static void compat_output(struct dlm_lock_result *res,
 }
 #endif
 
+/* should held proc->asts_spin lock */
+void dlm_purge_lkb_callbacks(struct dlm_lkb *lkb)
+{
+       struct dlm_callback *cb, *safe;
+
+       list_for_each_entry_safe(cb, safe, &lkb->lkb_callbacks, list) {
+               list_del(&cb->list);
+               kref_put(&cb->ref, dlm_release_callback);
+       }
+
+       clear_bit(DLM_IFL_CB_PENDING_BIT, &lkb->lkb_iflags);
+
+       /* invalidate */
+       dlm_callback_set_last_ptr(&lkb->lkb_last_cast, NULL);
+       dlm_callback_set_last_ptr(&lkb->lkb_last_cb, NULL);
+       lkb->lkb_last_bast_mode = -1;
+}
+
 /* Figure out if this lock is at the end of its life and no longer
    available for the application to use.  The lkb still exists until
    the final ast is read.  A lock becomes EOL in three situations:
@@ -788,7 +806,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
        struct dlm_lkb *lkb;
        DECLARE_WAITQUEUE(wait, current);
        struct dlm_callback *cb;
-       int rv, copy_lvb = 0;
+       int rv, ret, copy_lvb = 0;
        int old_mode, new_mode;
 
        if (count == sizeof(struct dlm_device_version)) {
@@ -888,9 +906,9 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
                trace_dlm_ast(lkb->lkb_resource->res_ls, lkb);
        }
 
-       rv = copy_result_to_user(lkb->lkb_ua,
-                                test_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags),
-                                cb->flags, cb->mode, copy_lvb, buf, count);
+       ret = copy_result_to_user(lkb->lkb_ua,
+                                 test_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags),
+                                 cb->flags, cb->mode, copy_lvb, buf, count);
 
        kref_put(&cb->ref, dlm_release_callback);
 
@@ -898,7 +916,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
        if (rv == DLM_DEQUEUE_CALLBACK_LAST)
                dlm_put_lkb(lkb);
 
-       return rv;
+       return ret;
 }
 
 static __poll_t device_poll(struct file *file, poll_table *wait)