Skip to contentSkip to conversation

dlm: shutdown sctp sock always timeouts

Question Glass Su 2 participants 3 messages Apr 29, 2025

lore
Share & tools
lore

Glass Su

author
#0 lore raw

Hi dlm folks
Recently out team found a dlm timeout bug with lvmlockd. When sctp is used by dlm as underlying
protocol, there always are ~10s timeout for dlm to finish dlm_release_lockspace():

Each connection costs DLM_SHUTDOWN_WAIT_TIMEOUT to be shutdown:

Quoted 1 line

38794 Apr 11 08:46:54 sapcrt-as2 kern.err kernel: [T1171911] dlm: Connection 000000001c3b445d shutdown timed out, will force close

It's caused by the following code from fs/dlm/lowcomms.c when releasing a lockspace:

static void shutdown_connection(struct connection *con, bool and_other) {
...

        ret = kernel_sock_shutdown(con->sock, SHUT_WR);
        up_read(&con->sock_lock);
        if (ret) {
                log_print("Connection %p failed to shutdown: %d will force close",
                          con, ret);
                goto force_close;
        } else {
                ret = wait_event_timeout(con->shutdown_wait, !con->sock,
                                         DLM_SHUTDOWN_WAIT_TIMEOUT);
                if (ret == 0) {
                        log_print("Connection %p shutdown timed out, will force close",
                                  con);
                        goto force_close;
                }
        }

        return;

force_close:

        close_connection(con, false);
}

The problem is after kernel_sock_shutdown(), shutdown_connection() is waiting con->sock to be NULL(closed) until DLM_SHUTDOWN_WAIT_TIMEOUT but there is no other wake_up(&con->shutdown_wait) unless the one in process_recv_sockets().

Assume there are two nodes in the cluster. kernel_sock_shutdown() is called by node A, sctp sock will send SHUTDOWN to node B. When NODE B receives the SHUTDOWN signal, sctp layer sends SHUTDOWN ACK to NODE A. At the moment, NODE A is waiting the connection to be closed until timeout. However, lowcomms_state_change() only handles RCV_SHUTDOWN case, in NODE A, sk->sk_shutdown is SEND_SHUTDOWN even the lower sctp layer received SHUTDOWN ACK from NODE B.

Then we noticed there is commit 54fbe0c15d9a ("fs: dlm: bring back previous shutdown handling”). Before the commit, sctp socks are not shutdown gracefully, all sctp socks are closed ungracefully. The commit message says “This patch( mostly* reverts commit 4f567acb0b86”.

The commits introduces the issue, so my question is that is the behavior change of sctp intentional? It seems reasonable for the graceful shutdown of sctp socks change though.

—
Su

#1 lore raw

Hi,

Quoted 49 lines · Glass Su

Hi dlm folks
Recently out team found a dlm timeout bug with lvmlockd. When sctp is used by dlm as underlying
protocol, there always are ~10s timeout for dlm to finish dlm_release_lockspace():

Each connection costs DLM_SHUTDOWN_WAIT_TIMEOUT to be shutdown:

Quoted 1 line

38794 Apr 11 08:46:54 sapcrt-as2 kern.err kernel: [T1171911] dlm: Connection 000000001c3b445d shutdown timed out, will force close

It's caused by the following code from fs/dlm/lowcomms.c when releasing a lockspace:

static void shutdown_connection(struct connection *con, bool and_other) {
...

        ret = kernel_sock_shutdown(con->sock, SHUT_WR);
        up_read(&con->sock_lock);
        if (ret) {
                log_print("Connection %p failed to shutdown: %d will force close",
                          con, ret);
                goto force_close;
        } else {
                ret = wait_event_timeout(con->shutdown_wait, !con->sock,
                                         DLM_SHUTDOWN_WAIT_TIMEOUT);
                if (ret == 0) {
                        log_print("Connection %p shutdown timed out, will force close",
                                  con);
                        goto force_close;
                }
        }

        return;

force_close:

        close_connection(con, false);
}

The problem is after kernel_sock_shutdown(), shutdown_connection() is waiting con->sock to be NULL(closed) until DLM_SHUTDOWN_WAIT_TIMEOUT but there is no other wake_up(&con->shutdown_wait) unless the one in process_recv_sockets().

Assume there are two nodes in the cluster. kernel_sock_shutdown() is called by node A, sctp sock will send SHUTDOWN to node B. When NODE B receives the SHUTDOWN signal, sctp layer sends SHUTDOWN ACK to NODE A. At the moment, NODE A is waiting the connection to be closed until timeout. However, lowcomms_state_change() only handles RCV_SHUTDOWN case, in NODE A, sk->sk_shutdown is SEND_SHUTDOWN even the lower sctp layer received SHUTDOWN ACK from NODE B.

Quoted 6 lines

Then we noticed there is commit 54fbe0c15d9a ("fs: dlm: bring back previous shutdown handling”). Before the commit, sctp socks are not shutdown gracefully, all sctp socks are closed ungracefully. The commit message says “This patch( mostly* reverts commit 4f567acb0b86”.

The commits introduces the issue, so my question is that is the behavior change of sctp intentional? It seems reasonable for the graceful shutdown of sctp socks change though.

I will try to reproduce this issue, but SCTP does not have any graceful shutdown functionality. This does not exist in SCTP, there should be a way to fake it [0], to at least get a EOF (recv 0 bytes) on the other end.
With graceful shutdown I also mean half-closed sockets e.g. being able to still receive but not transmit anymore until the other node tells EOF, but as I said there are changes that everything works like it would have such functionality.

- Alex

[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/dlm/lowcomms.c?h=v6.15-rc4#n531

author
#2 lore raw
Quoted 60 lines · Alexander Aring

Hi,

Quoted 53 lines · Glass Su

Hi dlm folks
Recently out team found a dlm timeout bug with lvmlockd. When sctp is used by dlm as underlying protocol, there always are ~10s timeout for dlm to finish dlm_release_lockspace():

Each connection costs DLM_SHUTDOWN_WAIT_TIMEOUT to be shutdown:

Quoted 1 line

38794 Apr 11 08:46:54 sapcrt-as2 kern.err kernel: [T1171911] dlm: Connection 000000001c3b445d shutdown timed out, will force close

It's caused by the following code from fs/dlm/lowcomms.c when releasing a lockspace:

static void shutdown_connection(struct connection *con, bool and_other) {
...

      ret = kernel_sock_shutdown(con->sock, SHUT_WR);
      up_read(&con->sock_lock);
      if (ret) {
              log_print("Connection %p failed to shutdown: %d will force close",
                        con, ret);
              goto force_close;
      } else {
              ret = wait_event_timeout(con->shutdown_wait, !con->sock,
                                       DLM_SHUTDOWN_WAIT_TIMEOUT);
              if (ret == 0) {
                      log_print("Connection %p shutdown timed out, will force close",
                                con);
                      goto force_close;
              }
      }

      return;

force_close:

      close_connection(con, false);
}

The problem is after kernel_sock_shutdown(), shutdown_connection() is waiting con->sock to be NULL(closed) until DLM_SHUTDOWN_WAIT_TIMEOUT but there is no other wake_up(&con->shutdown_wait) unless the one in process_recv_sockets().

Assume there are two nodes in the cluster. kernel_sock_shutdown() is called by node A, sctp sock will send SHUTDOWN to node B. When NODE B receives the SHUTDOWN signal, sctp layer sends SHUTDOWN ACK to NODE A. At the moment, NODE A is waiting the connection to be closed until timeout. However, lowcomms_state_change() only handles RCV_SHUTDOWN case, in NODE A, sk->sk_shutdown is SEND_SHUTDOWN even the lower sctp layer received SHUTDOWN ACK from NODE B.

Then we noticed there is commit 54fbe0c15d9a ("fs: dlm: bring back previous shutdown handling”). Before the commit, sctp socks are not shutdown gracefully, all sctp socks are closed ungracefully. The commit message says “This patch( mostly* reverts commit 4f567acb0b86”.

Quoted 7 lines
Quoted 2 lines

The commits introduces the issue, so my question is that is the behavior change of sctp intentional? It seems reasonable for the graceful shutdown of sctp socks change though.

I will try to reproduce this issue, but SCTP does not have any graceful shutdown functionality. This does not exist in SCTP, there should be a way to fake it [0], to at least get a EOF (recv 0 bytes) on the other end.

I am noob about network but rfc4960[1] says that SCTP supports graceful close. Linux doesn’t implement it?

[1]: https://datatracker.ietf.org/doc/html/rfc4960#section-9

Quoted 4 lines

With graceful shutdown I also mean half-closed sockets e.g. being able to still receive but not transmit anymore until the other node tells EOF, but as I said there are changes that everything works like it would have such functionality.

Nod.

Quoted 4 lines

- Alex

[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/dlm/lowcomms.c?h=v6.15-rc4#n531