cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH dlm-tool 2/2] fs: dlm: implement DLM_PLOCK_OP_CANCEL
Date: Fri, 14 Jul 2023 08:29:25 -0400	[thread overview]
Message-ID: <CAK-6q+jP8dHZM7dpz4bTsg=6a1te+ec8LDMDYLJj2TCEebD5Cw@mail.gmail.com> (raw)
In-Reply-To: <20230713170836.3583715-2-aahringo@redhat.com>

Hi,

On Thu, Jul 13, 2023 at 1:08?PM Alexander Aring <aahringo@redhat.com> wrote:
>
> This patch implements DLM_PLOCK_OP_CANCEL to try to delete waiters for a
> lock request which are waiting to being granted. If the waiter can be
> deleted the reply to the kernel will be replaced from
> DLM_PLOCK_OP_LOCK to the sent DLM_PLOCK_OP_CANCEL and clearing the
> DLM_PLOCK_FL_NO_REPLY flag.
> ---
>  dlm_controld/plock.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
>
> diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
> index ab19e8d7..fd2bd2cf 100644
> --- a/dlm_controld/plock.c
> +++ b/dlm_controld/plock.c
> @@ -9,6 +9,10 @@
>  #include "dlm_daemon.h"
>  #include <linux/dlm_plock.h>
>
> +#ifndef DLM_PLOCK_OP_CANCEL
> +#define DLM_PLOCK_OP_CANCEL 4
> +#endif
> +
>  #ifndef DLM_PLOCK_FL_NO_REPLY
>  #define DLM_PLOCK_FL_NO_REPLY 2
>  #endif
> @@ -136,6 +140,8 @@ static const char *op_str(int optype)
>         switch (optype) {
>         case DLM_PLOCK_OP_LOCK:
>                 return "LK";
> +       case DLM_PLOCK_OP_CANCEL:
> +               return "CL";
>         case DLM_PLOCK_OP_UNLOCK:
>                 return "UN";
>         case DLM_PLOCK_OP_GET:
> @@ -751,6 +757,43 @@ static void do_lock(struct lockspace *ls, struct dlm_plock_info *in,
>         put_resource(ls, r);
>  }
>
> +static int remove_waiter(const struct resource *r, struct dlm_plock_info *in)
> +{
> +       struct lock_waiter *w;
> +
> +       list_for_each_entry(w, &r->waiters, list) {
> +               if (w->info.nodeid == in->nodeid &&
> +                   w->info.fsid == in->fsid &&
> +                   w->info.number == in->number &&
> +                   w->info.owner == in->owner &&
> +                   w->info.pid == in->pid &&
> +                   w->info.start == in->start &&
> +                   w->info.end == in->end &&
> +                   w->info.ex == in->ex) {
> +                       list_del(&w->list);
> +                       free(w);
> +                       return 0;
> +               }
> +       }
> +
> +       return -ENOENT;
> +}
> +
> +static void do_cancel(struct lockspace *ls, struct dlm_plock_info *in,
> +                     struct resource *r)
> +{
> +       int rv;
> +
> +       rv = remove_waiter(r, in);
> +       if (in->nodeid == our_nodeid && rv == 0) {
> +               /* we replacing a reply because we canceled waiter */
> +               in->flags &= ~DLM_PLOCK_FL_NO_REPLY;

I think we should do a copy of "in" here and then clear the flag... it
can have side effects if the ongoing processing will then call
write_result().

At some point dlm_plock_info should be const here...

- Alex


      reply	other threads:[~2023-07-14 12:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-13 17:08 [Cluster-devel] [PATCH dlm-tool 1/2] fs: dlm: handle DLM_PLOCK_FL_NO_REPLY Alexander Aring
2023-07-13 17:08 ` [Cluster-devel] [PATCH dlm-tool 2/2] fs: dlm: implement DLM_PLOCK_OP_CANCEL Alexander Aring
2023-07-14 12:29   ` Alexander Aring [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK-6q+jP8dHZM7dpz4bTsg=6a1te+ec8LDMDYLJj2TCEebD5Cw@mail.gmail.com' \
    --to=aahringo@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).