VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
2522fe45a186e fs/dlm/lowcomms.c     (Thomas Gleixner           2019-05-28 09:57:20 -0700    1) // SPDX-License-Identifier: GPL-2.0-only
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500    2) /******************************************************************************
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500    3) *******************************************************************************
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500    4) **
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500    5) **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600    6) **  Copyright (C) 2004-2009 Red Hat, Inc.  All rights reserved.
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500    7) **
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500    8) **
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500    9) *******************************************************************************
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   10) ******************************************************************************/
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   11) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   12) /*
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   13)  * lowcomms.c
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   14)  *
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   15)  * This is the "low-level" comms layer.
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   16)  *
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   17)  * It is responsible for sending/receiving messages
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   18)  * from other nodes in the cluster.
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   19)  *
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   20)  * Cluster nodes are referred to by their nodeids. nodeids are
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   21)  * simply 32 bit numbers to the locking module - if they need to
2cf12c0bf261e fs/dlm/lowcomms.c     (Joe Perches               2009-01-22 13:26:47 -0800   22)  * be expanded for the cluster infrastructure then that is its
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   23)  * responsibility. It is this layer's
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   24)  * responsibility to resolve these into IP address or
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   25)  * whatever it needs for inter-node communication.
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   26)  *
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   27)  * The comms level is two kernel threads that deal mainly with
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   28)  * the receiving of messages from other nodes and passing them
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   29)  * up to the mid-level comms layer (which understands the
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   30)  * message format) for execution by the locking core, and
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   31)  * a send thread which does all the setting up of connections
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   32)  * to remote nodes and the sending of data. Threads are not allowed
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   33)  * to send their own data because it may cause them to wait in times
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   34)  * of high load. Also, this way, the sending thread can collect together
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   35)  * messages bound for one node and send them in one block.
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   36)  *
2cf12c0bf261e fs/dlm/lowcomms.c     (Joe Perches               2009-01-22 13:26:47 -0800   37)  * lowcomms will choose to use either TCP or SCTP as its transport layer
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100   38)  * depending on the configuration variable 'protocol'. This should be set
2cf12c0bf261e fs/dlm/lowcomms.c     (Joe Perches               2009-01-22 13:26:47 -0800   39)  * to 0 (default) for TCP or 1 for SCTP. It should be configured using a
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100   40)  * cluster-wide mechanism as it must be the same on all nodes of the cluster
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100   41)  * for the DLM to function.
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   42)  *
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   43)  */
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   44) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   45) #include <asm/ioctls.h>
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   46) #include <net/sock.h>
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   47) #include <net/tcp.h>
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   48) #include <linux/pagemap.h>
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100   49) #include <linux/file.h>
7a936ce71eed7 fs/dlm/lowcomms.c     (Matthias Kaehlcke         2008-05-12 10:04:51 -0500   50) #include <linux/mutex.h>
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100   51) #include <linux/sctp.h>
5a0e3ad6af866 fs/dlm/lowcomms.c     (Tejun Heo                 2010-03-24 17:04:11 +0900   52) #include <linux/slab.h>
2f2d76cc3e938 fs/dlm/lowcomms.c     (Benjamin Poirier          2012-03-08 05:55:59 +0000   53) #include <net/sctp/sctp.h>
44ad532b3277f fs/dlm/lowcomms.c     (Joe Perches               2009-01-22 13:24:49 -0800   54) #include <net/ipv6.h>
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   55) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   56) #include "dlm_internal.h"
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   57) #include "lowcomms.h"
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   58) #include "midcomms.h"
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   59) #include "config.h"
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   60) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100   61) #define NEEDED_RMEM (4*1024*1024)
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600   62) #define CONN_HASH_SIZE 32
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100   63) 
f92c8dd7a0eb1 fs/dlm/lowcomms.c     (Bob Peterson              2010-11-12 11:15:20 -0600   64) /* Number of messages to send before rescheduling */
f92c8dd7a0eb1 fs/dlm/lowcomms.c     (Bob Peterson              2010-11-12 11:15:20 -0600   65) #define MAX_SEND_MSG_COUNT 25
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400   66) #define DLM_SHUTDOWN_WAIT_TIMEOUT msecs_to_jiffies(10000)
f92c8dd7a0eb1 fs/dlm/lowcomms.c     (Bob Peterson              2010-11-12 11:15:20 -0600   67) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   68) struct connection {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   69) 	struct socket *sock;	/* NULL if not connected */
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   70) 	uint32_t nodeid;	/* So we know who we are in the list */
f1f1c1ccf7848 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-24 11:17:59 +0000   71) 	struct mutex sock_mutex;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100   72) 	unsigned long flags;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   73) #define CF_READ_PENDING 1
8a4abb0819769 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:16 +0000   74) #define CF_WRITE_PENDING 2
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100   75) #define CF_INIT_PENDING 4
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100   76) #define CF_IS_OTHERCON 5
063c4c99630c0 fs/dlm/lowcomms.c     (Lars Marowsky-Bree        2009-08-11 16:18:23 -0500   77) #define CF_CLOSE 6
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800   78) #define CF_APP_LIMITED 7
b2a6662932c52 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:50 +0000   79) #define CF_CLOSING 8
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400   80) #define CF_SHUTDOWN 9
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500   81) #define CF_CONNECTED 10
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400   82) #define CF_RECONNECT 11
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400   83) #define CF_DELAY_CONNECT 12
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400   84) #define CF_EOF 13
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000   85) 	struct list_head writequeue;  /* List of outgoing writequeue_entries */
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   86) 	spinlock_t writequeue_lock;
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400   87) 	atomic_t writequeue_cnt;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100   88) 	void (*connect_action) (struct connection *);	/* What to do to connect */
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400   89) 	void (*shutdown_action)(struct connection *con); /* What to do to shutdown */
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400   90) 	bool (*eof_condition)(struct connection *con); /* What to do to eof check */
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   91) 	int retries;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   92) #define MAX_CONNECT_RETRIES 3
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600   93) 	struct hlist_node list;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500   94) 	struct connection *othercon;
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400   95) 	struct connection *sendcon;
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000   96) 	struct work_struct rwork; /* Receive workqueue */
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000   97) 	struct work_struct swork; /* Send workqueue */
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400   98) 	wait_queue_head_t shutdown_wait; /* wait for graceful shutdown */
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400   99) 	unsigned char *rx_buf;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  100) 	int rx_buflen;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  101) 	int rx_leftover;
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400  102) 	struct rcu_head rcu;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  103) };
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  104) #define sock2con(x) ((struct connection *)(x)->sk_user_data)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  105) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  106) struct listen_connection {
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  107) 	struct socket *sock;
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  108) 	struct work_struct rwork;
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  109) };
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  110) 
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500  111) #define DLM_WQ_REMAIN_BYTES(e) (PAGE_SIZE - e->end)
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500  112) #define DLM_WQ_LENGTH_BYTES(e) (e->end - e->offset)
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500  113) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  114) /* An entry waiting to be sent */
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  115) struct writequeue_entry {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  116) 	struct list_head list;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  117) 	struct page *page;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  118) 	int offset;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  119) 	int len;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  120) 	int end;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  121) 	int users;
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  122) 	int idx; /* get()/commit() idx exchange */
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  123) 	struct connection *con;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  124) };
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  125) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  126) struct dlm_node_addr {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  127) 	struct list_head list;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  128) 	int nodeid;
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  129) 	int mark;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  130) 	int addr_count;
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  131) 	int curr_addr_index;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  132) 	struct sockaddr_storage *addr[DLM_MAX_ADDR_COUNT];
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  133) };
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  134) 
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  135) static struct listen_sock_callbacks {
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  136) 	void (*sk_error_report)(struct sock *);
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  137) 	void (*sk_data_ready)(struct sock *);
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  138) 	void (*sk_state_change)(struct sock *);
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  139) 	void (*sk_write_space)(struct sock *);
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  140) } listen_sock;
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  141) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  142) static LIST_HEAD(dlm_node_addrs);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  143) static DEFINE_SPINLOCK(dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  144) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  145) static struct listen_connection listen_con;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  146) static struct sockaddr_storage *dlm_local_addr[DLM_MAX_ADDR_COUNT];
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  147) static int dlm_local_count;
517461630d1c2 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:13 -0500  148) int dlm_allow_conn;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  149) 
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000  150) /* Work queues */
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000  151) static struct workqueue_struct *recv_workqueue;
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000  152) static struct workqueue_struct *send_workqueue;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  153) 
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  154) static struct hlist_head connection_hash[CONN_HASH_SIZE];
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400  155) static DEFINE_SPINLOCK(connections_lock);
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400  156) DEFINE_STATIC_SRCU(connections_srcu);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  157) 
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000  158) static void process_recv_sockets(struct work_struct *work);
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000  159) static void process_send_sockets(struct work_struct *work);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  160) 
0672c3c280efd fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:22 -0500  161) static void sctp_connect_to_sock(struct connection *con);
0672c3c280efd fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:22 -0500  162) static void tcp_connect_to_sock(struct connection *con);
42873c903bd71 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:23 -0500  163) static void dlm_tcp_shutdown(struct connection *con);
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  164) 
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  165) /* This is deliberately very simple because most clusters have simple
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  166)    sequential nodeids, so we should be able to go straight to a connection
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  167)    struct in the array */
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  168) static inline int nodeid_hash(int nodeid)
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  169) {
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  170) 	return nodeid & (CONN_HASH_SIZE-1);
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  171) }
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  172) 
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  173) static struct connection *__find_con(int nodeid, int r)
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  174) {
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  175) 	struct connection *con;
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  176) 
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400  177) 	hlist_for_each_entry_rcu(con, &connection_hash[r], list) {
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  178) 		if (con->nodeid == nodeid)
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  179) 			return con;
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  180) 	}
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400  181) 
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  182) 	return NULL;
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  183) }
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  184) 
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  185) static bool tcp_eof_condition(struct connection *con)
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  186) {
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  187) 	return atomic_read(&con->writequeue_cnt);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  188) }
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  189) 
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  190) static int dlm_con_init(struct connection *con, int nodeid)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  191) {
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  192) 	con->rx_buflen = dlm_config.ci_buffer_size;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  193) 	con->rx_buf = kmalloc(con->rx_buflen, GFP_NOFS);
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  194) 	if (!con->rx_buf)
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  195) 		return -ENOMEM;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  196) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  197) 	con->nodeid = nodeid;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  198) 	mutex_init(&con->sock_mutex);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  199) 	INIT_LIST_HEAD(&con->writequeue);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  200) 	spin_lock_init(&con->writequeue_lock);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  201) 	atomic_set(&con->writequeue_cnt, 0);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  202) 	INIT_WORK(&con->swork, process_send_sockets);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  203) 	INIT_WORK(&con->rwork, process_recv_sockets);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  204) 	init_waitqueue_head(&con->shutdown_wait);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  205) 
42873c903bd71 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:23 -0500  206) 	if (dlm_config.ci_protocol == 0) {
0672c3c280efd fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:22 -0500  207) 		con->connect_action = tcp_connect_to_sock;
42873c903bd71 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:23 -0500  208) 		con->shutdown_action = dlm_tcp_shutdown;
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  209) 		con->eof_condition = tcp_eof_condition;
42873c903bd71 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:23 -0500  210) 	} else {
0672c3c280efd fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:22 -0500  211) 		con->connect_action = sctp_connect_to_sock;
42873c903bd71 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:23 -0500  212) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  213) 
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  214) 	return 0;
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  215) }
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  216) 
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  217) /*
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  218)  * If 'allocation' is zero then we don't attempt to create a new
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  219)  * connection structure for this node.
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  220)  */
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  221) static struct connection *nodeid2con(int nodeid, gfp_t alloc)
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  222) {
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  223) 	struct connection *con, *tmp;
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  224) 	int r, ret;
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  225) 
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  226) 	r = nodeid_hash(nodeid);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  227) 	con = __find_con(nodeid, r);
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  228) 	if (con || !alloc)
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  229) 		return con;
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  230) 
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  231) 	con = kzalloc(sizeof(*con), alloc);
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  232) 	if (!con)
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  233) 		return NULL;
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  234) 
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  235) 	ret = dlm_con_init(con, nodeid);
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  236) 	if (ret) {
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  237) 		kfree(con);
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  238) 		return NULL;
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  239) 	}
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  240) 
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400  241) 	spin_lock(&connections_lock);
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  242) 	/* Because multiple workqueues/threads calls this function it can
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  243) 	 * race on multiple cpu's. Instead of locking hot path __find_con()
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  244) 	 * we just check in rare cases of recently added nodes again
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  245) 	 * under protection of connections_lock. If this is the case we
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  246) 	 * abort our connection creation and return the existing connection.
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  247) 	 */
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  248) 	tmp = __find_con(nodeid, r);
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  249) 	if (tmp) {
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  250) 		spin_unlock(&connections_lock);
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  251) 		kfree(con->rx_buf);
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  252) 		kfree(con);
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  253) 		return tmp;
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  254) 	}
4f2b30fd9b4bd fs/dlm/lowcomms.c     (Alexander Aring           2020-09-30 18:37:29 -0400  255) 
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400  256) 	hlist_add_head_rcu(&con->list, &connection_hash[r]);
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400  257) 	spin_unlock(&connections_lock);
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400  258) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  259) 	return con;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  260) }
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  261) 
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  262) /* Loop round all connections */
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  263) static void foreach_conn(void (*conn_func)(struct connection *c))
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  264) {
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  265) 	int i;
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  266) 	struct connection *con;
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  267) 
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  268) 	for (i = 0; i < CONN_HASH_SIZE; i++) {
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400  269) 		hlist_for_each_entry_rcu(con, &connection_hash[i], list)
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  270) 			conn_func(con);
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600  271) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  272) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  273) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  274) static struct dlm_node_addr *find_node_addr(int nodeid)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  275) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  276) 	struct dlm_node_addr *na;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  277) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  278) 	list_for_each_entry(na, &dlm_node_addrs, list) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  279) 		if (na->nodeid == nodeid)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  280) 			return na;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  281) 	}
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  282) 	return NULL;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  283) }
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  284) 
40c6b83e5a07d fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:27 -0500  285) static int addr_compare(const struct sockaddr_storage *x,
40c6b83e5a07d fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:27 -0500  286) 			const struct sockaddr_storage *y)
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  287) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  288) 	switch (x->ss_family) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  289) 	case AF_INET: {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  290) 		struct sockaddr_in *sinx = (struct sockaddr_in *)x;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  291) 		struct sockaddr_in *siny = (struct sockaddr_in *)y;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  292) 		if (sinx->sin_addr.s_addr != siny->sin_addr.s_addr)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  293) 			return 0;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  294) 		if (sinx->sin_port != siny->sin_port)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  295) 			return 0;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  296) 		break;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  297) 	}
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  298) 	case AF_INET6: {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  299) 		struct sockaddr_in6 *sinx = (struct sockaddr_in6 *)x;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  300) 		struct sockaddr_in6 *siny = (struct sockaddr_in6 *)y;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  301) 		if (!ipv6_addr_equal(&sinx->sin6_addr, &siny->sin6_addr))
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  302) 			return 0;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  303) 		if (sinx->sin6_port != siny->sin6_port)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  304) 			return 0;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  305) 		break;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  306) 	}
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  307) 	default:
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  308) 		return 0;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  309) 	}
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  310) 	return 1;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  311) }
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  312) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  313) static int nodeid_to_addr(int nodeid, struct sockaddr_storage *sas_out,
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  314) 			  struct sockaddr *sa_out, bool try_new_addr,
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  315) 			  unsigned int *mark)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  316) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  317) 	struct sockaddr_storage sas;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  318) 	struct dlm_node_addr *na;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  319) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  320) 	if (!dlm_local_count)
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  321) 		return -1;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  322) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  323) 	spin_lock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  324) 	na = find_node_addr(nodeid);
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  325) 	if (na && na->addr_count) {
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  326) 		memcpy(&sas, na->addr[na->curr_addr_index],
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  327) 		       sizeof(struct sockaddr_storage));
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  328) 
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  329) 		if (try_new_addr) {
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  330) 			na->curr_addr_index++;
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  331) 			if (na->curr_addr_index == na->addr_count)
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  332) 				na->curr_addr_index = 0;
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  333) 		}
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  334) 	}
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  335) 	spin_unlock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  336) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  337) 	if (!na)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  338) 		return -EEXIST;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  339) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  340) 	if (!na->addr_count)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  341) 		return -ENOENT;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  342) 
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  343) 	*mark = na->mark;
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  344) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  345) 	if (sas_out)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  346) 		memcpy(sas_out, &sas, sizeof(struct sockaddr_storage));
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  347) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  348) 	if (!sa_out)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  349) 		return 0;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  350) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  351) 	if (dlm_local_addr[0]->ss_family == AF_INET) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  352) 		struct sockaddr_in *in4  = (struct sockaddr_in *) &sas;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  353) 		struct sockaddr_in *ret4 = (struct sockaddr_in *) sa_out;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  354) 		ret4->sin_addr.s_addr = in4->sin_addr.s_addr;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  355) 	} else {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  356) 		struct sockaddr_in6 *in6  = (struct sockaddr_in6 *) &sas;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  357) 		struct sockaddr_in6 *ret6 = (struct sockaddr_in6 *) sa_out;
4e3fd7a06dc20 fs/dlm/lowcomms.c     (Alexey Dobriyan           2011-11-21 03:39:03 +0000  358) 		ret6->sin6_addr = in6->sin6_addr;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  359) 	}
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  360) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  361) 	return 0;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  362) }
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  363) 
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  364) static int addr_to_nodeid(struct sockaddr_storage *addr, int *nodeid,
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  365) 			  unsigned int *mark)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  366) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  367) 	struct dlm_node_addr *na;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  368) 	int rv = -EEXIST;
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  369) 	int addr_i;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  370) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  371) 	spin_lock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  372) 	list_for_each_entry(na, &dlm_node_addrs, list) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  373) 		if (!na->addr_count)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  374) 			continue;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  375) 
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  376) 		for (addr_i = 0; addr_i < na->addr_count; addr_i++) {
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  377) 			if (addr_compare(na->addr[addr_i], addr)) {
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  378) 				*nodeid = na->nodeid;
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  379) 				*mark = na->mark;
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  380) 				rv = 0;
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  381) 				goto unlock;
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  382) 			}
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  383) 		}
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  384) 	}
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500  385) unlock:
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  386) 	spin_unlock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  387) 	return rv;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  388) }
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  389) 
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  390) /* caller need to held dlm_node_addrs_spin lock */
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  391) static bool dlm_lowcomms_na_has_addr(const struct dlm_node_addr *na,
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  392) 				     const struct sockaddr_storage *addr)
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  393) {
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  394) 	int i;
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  395) 
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  396) 	for (i = 0; i < na->addr_count; i++) {
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  397) 		if (addr_compare(na->addr[i], addr))
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  398) 			return true;
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  399) 	}
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  400) 
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  401) 	return false;
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  402) }
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  403) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  404) int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  405) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  406) 	struct sockaddr_storage *new_addr;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  407) 	struct dlm_node_addr *new_node, *na;
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  408) 	bool ret;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  409) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  410) 	new_node = kzalloc(sizeof(struct dlm_node_addr), GFP_NOFS);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  411) 	if (!new_node)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  412) 		return -ENOMEM;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  413) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  414) 	new_addr = kzalloc(sizeof(struct sockaddr_storage), GFP_NOFS);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  415) 	if (!new_addr) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  416) 		kfree(new_node);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  417) 		return -ENOMEM;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  418) 	}
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  419) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  420) 	memcpy(new_addr, addr, len);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  421) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  422) 	spin_lock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  423) 	na = find_node_addr(nodeid);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  424) 	if (!na) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  425) 		new_node->nodeid = nodeid;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  426) 		new_node->addr[0] = new_addr;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  427) 		new_node->addr_count = 1;
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  428) 		new_node->mark = dlm_config.ci_mark;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  429) 		list_add(&new_node->list, &dlm_node_addrs);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  430) 		spin_unlock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  431) 		return 0;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  432) 	}
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  433) 
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  434) 	ret = dlm_lowcomms_na_has_addr(na, addr);
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  435) 	if (ret) {
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  436) 		spin_unlock(&dlm_node_addrs_spin);
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  437) 		kfree(new_addr);
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  438) 		kfree(new_node);
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  439) 		return -EEXIST;
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  440) 	}
4f19d071f9bee fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:28 -0500  441) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  442) 	if (na->addr_count >= DLM_MAX_ADDR_COUNT) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  443) 		spin_unlock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  444) 		kfree(new_addr);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  445) 		kfree(new_node);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  446) 		return -ENOSPC;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  447) 	}
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  448) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  449) 	na->addr[na->addr_count++] = new_addr;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  450) 	spin_unlock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  451) 	kfree(new_node);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  452) 	return 0;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  453) }
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500  454) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  455) /* Data available on socket or listen socket received a connect */
676d23690fb62 fs/dlm/lowcomms.c     (David S. Miller           2014-04-11 16:15:36 -0400  456) static void lowcomms_data_ready(struct sock *sk)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  457) {
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000  458) 	struct connection *con;
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000  459) 
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000  460) 	read_lock_bh(&sk->sk_callback_lock);
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000  461) 	con = sock2con(sk);
afb853fb4eec3 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-06-01 10:07:26 -0500  462) 	if (con && !test_and_set_bit(CF_READ_PENDING, &con->flags))
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000  463) 		queue_work(recv_workqueue, &con->rwork);
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000  464) 	read_unlock_bh(&sk->sk_callback_lock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  465) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  466) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  467) static void lowcomms_listen_data_ready(struct sock *sk)
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  468) {
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  469) 	queue_work(recv_workqueue, &listen_con.rwork);
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  470) }
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  471) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  472) static void lowcomms_write_space(struct sock *sk)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  473) {
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000  474) 	struct connection *con;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  475) 
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000  476) 	read_lock_bh(&sk->sk_callback_lock);
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000  477) 	con = sock2con(sk);
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800  478) 	if (!con)
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000  479) 		goto out;
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800  480) 
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500  481) 	if (!test_and_set_bit(CF_CONNECTED, &con->flags)) {
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500  482) 		log_print("successful connected to node %d", con->nodeid);
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500  483) 		queue_work(send_workqueue, &con->swork);
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500  484) 		goto out;
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500  485) 	}
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500  486) 
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800  487) 	clear_bit(SOCK_NOSPACE, &con->sock->flags);
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800  488) 
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800  489) 	if (test_and_clear_bit(CF_APP_LIMITED, &con->flags)) {
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800  490) 		con->sock->sk->sk_write_pending--;
9cd3e072b0be1 fs/dlm/lowcomms.c     (Eric Dumazet              2015-11-29 20:03:10 -0800  491) 		clear_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags);
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800  492) 	}
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800  493) 
01da24d3fbed9 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:14 +0000  494) 	queue_work(send_workqueue, &con->swork);
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000  495) out:
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000  496) 	read_unlock_bh(&sk->sk_callback_lock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  497) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  498) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  499) static inline void lowcomms_connect_sock(struct connection *con)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  500) {
063c4c99630c0 fs/dlm/lowcomms.c     (Lars Marowsky-Bree        2009-08-11 16:18:23 -0500  501) 	if (test_bit(CF_CLOSE, &con->flags))
063c4c99630c0 fs/dlm/lowcomms.c     (Lars Marowsky-Bree        2009-08-11 16:18:23 -0500  502) 		return;
61d9102b62129 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:04 +0000  503) 	queue_work(send_workqueue, &con->swork);
61d9102b62129 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:04 +0000  504) 	cond_resched();
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  505) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  506) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  507) static void lowcomms_state_change(struct sock *sk)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  508) {
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  509) 	/* SCTP layer is not calling sk_data_ready when the connection
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  510) 	 * is done, so we catch the signal through here. Also, it
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  511) 	 * doesn't switch socket state when entering shutdown, so we
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  512) 	 * skip the write in that case.
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  513) 	 */
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  514) 	if (sk->sk_shutdown) {
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  515) 		if (sk->sk_shutdown == RCV_SHUTDOWN)
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  516) 			lowcomms_data_ready(sk);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  517) 	} else if (sk->sk_state == TCP_ESTABLISHED) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  518) 		lowcomms_write_space(sk);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  519) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  520) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  521) 
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  522) int dlm_lowcomms_connect_node(int nodeid)
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  523) {
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  524) 	struct connection *con;
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  525) 	int idx;
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  526) 
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  527) 	if (nodeid == dlm_our_nodeid())
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  528) 		return 0;
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  529) 
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  530) 	idx = srcu_read_lock(&connections_srcu);
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  531) 	con = nodeid2con(nodeid, GFP_NOFS);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  532) 	if (!con) {
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  533) 		srcu_read_unlock(&connections_srcu, idx);
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  534) 		return -ENOMEM;
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  535) 	}
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  536) 
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  537) 	lowcomms_connect_sock(con);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  538) 	srcu_read_unlock(&connections_srcu, idx);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  539) 
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  540) 	return 0;
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  541) }
391fbdc5d5271 fs/dlm/lowcomms.c     (Christine Caulfield       2009-05-07 10:54:16 -0500  542) 
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  543) int dlm_lowcomms_nodes_set_mark(int nodeid, unsigned int mark)
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  544) {
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  545) 	struct dlm_node_addr *na;
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  546) 
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  547) 	spin_lock(&dlm_node_addrs_spin);
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  548) 	na = find_node_addr(nodeid);
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  549) 	if (!na) {
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  550) 		spin_unlock(&dlm_node_addrs_spin);
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  551) 		return -ENOENT;
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  552) 	}
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  553) 
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  554) 	na->mark = mark;
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  555) 	spin_unlock(&dlm_node_addrs_spin);
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  556) 
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  557) 	return 0;
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  558) }
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  559) 
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  560) static void lowcomms_error_report(struct sock *sk)
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  561) {
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  562) 	struct connection *con;
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  563) 	struct sockaddr_storage saddr;
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  564) 	void (*orig_report)(struct sock *) = NULL;
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  565) 
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  566) 	read_lock_bh(&sk->sk_callback_lock);
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  567) 	con = sock2con(sk);
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  568) 	if (con == NULL)
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  569) 		goto out;
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  570) 
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  571) 	orig_report = listen_sock.sk_error_report;
1a31833d085a3 fs/dlm/lowcomms.c     (Bob Peterson              2016-01-18 12:29:15 -0500  572) 	if (con->sock == NULL ||
9b2c45d479d0f fs/dlm/lowcomms.c     (Denys Vlasenko            2018-02-12 20:00:20 +0100  573) 	    kernel_getpeername(con->sock, (struct sockaddr *)&saddr) < 0) {
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  574) 		printk_ratelimited(KERN_ERR "dlm: node %d: socket error "
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  575) 				   "sending to node %d, port %d, "
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  576) 				   "sk_err=%d/%d\n", dlm_our_nodeid(),
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  577) 				   con->nodeid, dlm_config.ci_tcp_port,
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  578) 				   sk->sk_err, sk->sk_err_soft);
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  579) 	} else if (saddr.ss_family == AF_INET) {
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  580) 		struct sockaddr_in *sin4 = (struct sockaddr_in *)&saddr;
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  581) 
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  582) 		printk_ratelimited(KERN_ERR "dlm: node %d: socket error "
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  583) 				   "sending to node %d at %pI4, port %d, "
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  584) 				   "sk_err=%d/%d\n", dlm_our_nodeid(),
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  585) 				   con->nodeid, &sin4->sin_addr.s_addr,
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  586) 				   dlm_config.ci_tcp_port, sk->sk_err,
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  587) 				   sk->sk_err_soft);
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  588) 	} else {
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  589) 		struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&saddr;
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  590) 
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  591) 		printk_ratelimited(KERN_ERR "dlm: node %d: socket error "
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  592) 				   "sending to node %d at %u.%u.%u.%u, "
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  593) 				   "port %d, sk_err=%d/%d\n", dlm_our_nodeid(),
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  594) 				   con->nodeid, sin6->sin6_addr.s6_addr32[0],
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  595) 				   sin6->sin6_addr.s6_addr32[1],
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  596) 				   sin6->sin6_addr.s6_addr32[2],
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  597) 				   sin6->sin6_addr.s6_addr32[3],
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  598) 				   dlm_config.ci_tcp_port, sk->sk_err,
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  599) 				   sk->sk_err_soft);
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  600) 	}
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  601) 
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  602) 	/* below sendcon only handling */
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  603) 	if (test_bit(CF_IS_OTHERCON, &con->flags))
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  604) 		con = con->sendcon;
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  605) 
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  606) 	switch (sk->sk_err) {
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  607) 	case ECONNREFUSED:
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  608) 		set_bit(CF_DELAY_CONNECT, &con->flags);
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  609) 		break;
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  610) 	default:
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  611) 		break;
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  612) 	}
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  613) 
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  614) 	if (!test_and_set_bit(CF_RECONNECT, &con->flags))
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  615) 		queue_work(send_workqueue, &con->swork);
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  616) 
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  617) out:
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  618) 	read_unlock_bh(&sk->sk_callback_lock);
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  619) 	if (orig_report)
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  620) 		orig_report(sk);
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  621) }
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  622) 
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  623) /* Note: sk_callback_lock must be locked before calling this function. */
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  624) static void save_listen_callbacks(struct socket *sock)
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  625) {
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  626) 	struct sock *sk = sock->sk;
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  627) 
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  628) 	listen_sock.sk_data_ready = sk->sk_data_ready;
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  629) 	listen_sock.sk_state_change = sk->sk_state_change;
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  630) 	listen_sock.sk_write_space = sk->sk_write_space;
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  631) 	listen_sock.sk_error_report = sk->sk_error_report;
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  632) }
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  633) 
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  634) static void restore_callbacks(struct socket *sock)
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  635) {
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  636) 	struct sock *sk = sock->sk;
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  637) 
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  638) 	write_lock_bh(&sk->sk_callback_lock);
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  639) 	sk->sk_user_data = NULL;
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  640) 	sk->sk_data_ready = listen_sock.sk_data_ready;
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  641) 	sk->sk_state_change = listen_sock.sk_state_change;
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  642) 	sk->sk_write_space = listen_sock.sk_write_space;
cc661fc934a00 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:23 +0000  643) 	sk->sk_error_report = listen_sock.sk_error_report;
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  644) 	write_unlock_bh(&sk->sk_callback_lock);
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  645) }
b3a5bbfd780d9 fs/dlm/lowcomms.c     (Bob Peterson              2015-08-27 09:34:47 -0500  646) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  647) static void add_listen_sock(struct socket *sock, struct listen_connection *con)
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  648) {
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  649) 	struct sock *sk = sock->sk;
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  650) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  651) 	write_lock_bh(&sk->sk_callback_lock);
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  652) 	save_listen_callbacks(sock);
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  653) 	con->sock = sock;
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  654) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  655) 	sk->sk_user_data = con;
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  656) 	sk->sk_allocation = GFP_NOFS;
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  657) 	/* Install a data_ready callback */
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  658) 	sk->sk_data_ready = lowcomms_listen_data_ready;
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  659) 	write_unlock_bh(&sk->sk_callback_lock);
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  660) }
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  661) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  662) /* Make a socket active */
988419a9deab6 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:32 +0000  663) static void add_sock(struct socket *sock, struct connection *con)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  664) {
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  665) 	struct sock *sk = sock->sk;
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  666) 
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  667) 	write_lock_bh(&sk->sk_callback_lock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  668) 	con->sock = sock;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  669) 
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  670) 	sk->sk_user_data = con;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  671) 	/* Install a data_ready callback */
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  672) 	sk->sk_data_ready = lowcomms_data_ready;
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  673) 	sk->sk_write_space = lowcomms_write_space;
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  674) 	sk->sk_state_change = lowcomms_state_change;
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  675) 	sk->sk_allocation = GFP_NOFS;
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  676) 	sk->sk_error_report = lowcomms_error_report;
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500  677) 	write_unlock_bh(&sk->sk_callback_lock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  678) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  679) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  680) /* Add the port number to an IPv6 or 4 sockaddr and return the address
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  681)    length */
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  682) static void make_sockaddr(struct sockaddr_storage *saddr, uint16_t port,
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  683) 			  int *addr_len)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  684) {
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  685) 	saddr->ss_family =  dlm_local_addr[0]->ss_family;
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000  686) 	if (saddr->ss_family == AF_INET) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  687) 		struct sockaddr_in *in4_addr = (struct sockaddr_in *)saddr;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  688) 		in4_addr->sin_port = cpu_to_be16(port);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  689) 		*addr_len = sizeof(struct sockaddr_in);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100  690) 		memset(&in4_addr->sin_zero, 0, sizeof(in4_addr->sin_zero));
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000  691) 	} else {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  692) 		struct sockaddr_in6 *in6_addr = (struct sockaddr_in6 *)saddr;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  693) 		in6_addr->sin6_port = cpu_to_be16(port);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  694) 		*addr_len = sizeof(struct sockaddr_in6);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  695) 	}
01c8cab25863d fs/dlm/lowcomms.c     (Patrick Caulfield         2007-07-17 16:53:15 +0100  696) 	memset((char *)saddr + *addr_len, 0, sizeof(struct sockaddr_storage) - *addr_len);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  697) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  698) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  699) static void dlm_close_sock(struct socket **sock)
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  700) {
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  701) 	if (*sock) {
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  702) 		restore_callbacks(*sock);
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  703) 		sock_release(*sock);
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  704) 		*sock = NULL;
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  705) 	}
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  706) }
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  707) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  708) /* Close a remote connection and tidy up */
0d737a8cfd834 fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:21 -0300  709) static void close_connection(struct connection *con, bool and_other,
0d737a8cfd834 fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:21 -0300  710) 			     bool tx, bool rx)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  711) {
b2a6662932c52 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:50 +0000  712) 	bool closing = test_and_set_bit(CF_CLOSING, &con->flags);
b2a6662932c52 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:50 +0000  713) 
0aa18464c812e fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:02:02 +0000  714) 	if (tx && !closing && cancel_work_sync(&con->swork)) {
0d737a8cfd834 fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:21 -0300  715) 		log_print("canceled swork for node %d", con->nodeid);
0aa18464c812e fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:02:02 +0000  716) 		clear_bit(CF_WRITE_PENDING, &con->flags);
0aa18464c812e fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:02:02 +0000  717) 	}
0aa18464c812e fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:02:02 +0000  718) 	if (rx && !closing && cancel_work_sync(&con->rwork)) {
0d737a8cfd834 fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:21 -0300  719) 		log_print("canceled rwork for node %d", con->nodeid);
0aa18464c812e fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:02:02 +0000  720) 		clear_bit(CF_READ_PENDING, &con->flags);
0aa18464c812e fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:02:02 +0000  721) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  722) 
0d737a8cfd834 fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:21 -0300  723) 	mutex_lock(&con->sock_mutex);
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  724) 	dlm_close_sock(&con->sock);
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  725) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  726) 	if (con->othercon && and_other) {
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000  727) 		/* Will only re-enter once. */
38ef63844ef42 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:38 -0400  728) 		close_connection(con->othercon, false, tx, rx);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  729) 	}
9e5f2825a8b72 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-08-02 14:58:14 +0100  730) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  731) 	con->rx_leftover = 0;
61d96be0f474d fs/dlm/lowcomms.c     (Patrick Caulfield         2007-08-20 15:13:38 +0100  732) 	con->retries = 0;
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500  733) 	clear_bit(CF_CONNECTED, &con->flags);
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  734) 	clear_bit(CF_DELAY_CONNECT, &con->flags);
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  735) 	clear_bit(CF_RECONNECT, &con->flags);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  736) 	clear_bit(CF_EOF, &con->flags);
61d96be0f474d fs/dlm/lowcomms.c     (Patrick Caulfield         2007-08-20 15:13:38 +0100  737) 	mutex_unlock(&con->sock_mutex);
b2a6662932c52 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:50 +0000  738) 	clear_bit(CF_CLOSING, &con->flags);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  739) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  740) 
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  741) static void shutdown_connection(struct connection *con)
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  742) {
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  743) 	int ret;
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  744) 
eec054b5a7cfe fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:19 -0500  745) 	flush_work(&con->swork);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  746) 
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  747) 	mutex_lock(&con->sock_mutex);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  748) 	/* nothing to shutdown */
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  749) 	if (!con->sock) {
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  750) 		mutex_unlock(&con->sock_mutex);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  751) 		return;
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  752) 	}
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  753) 
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  754) 	set_bit(CF_SHUTDOWN, &con->flags);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  755) 	ret = kernel_sock_shutdown(con->sock, SHUT_WR);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  756) 	mutex_unlock(&con->sock_mutex);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  757) 	if (ret) {
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  758) 		log_print("Connection %p failed to shutdown: %d will force close",
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  759) 			  con, ret);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  760) 		goto force_close;
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  761) 	} else {
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  762) 		ret = wait_event_timeout(con->shutdown_wait,
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  763) 					 !test_bit(CF_SHUTDOWN, &con->flags),
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  764) 					 DLM_SHUTDOWN_WAIT_TIMEOUT);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  765) 		if (ret == 0) {
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  766) 			log_print("Connection %p shutdown timed out, will force close",
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  767) 				  con);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  768) 			goto force_close;
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  769) 		}
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  770) 	}
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  771) 
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  772) 	return;
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  773) 
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  774) force_close:
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  775) 	clear_bit(CF_SHUTDOWN, &con->flags);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  776) 	close_connection(con, false, true, true);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  777) }
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  778) 
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  779) static void dlm_tcp_shutdown(struct connection *con)
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  780) {
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  781) 	if (con->othercon)
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  782) 		shutdown_connection(con->othercon);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  783) 	shutdown_connection(con);
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  784) }
055923bf6b486 fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:38 -0400  785) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  786) static int con_realloc_receive_buf(struct connection *con, int newlen)
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  787) {
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  788) 	unsigned char *newbuf;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  789) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  790) 	newbuf = kmalloc(newlen, GFP_NOFS);
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  791) 	if (!newbuf)
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  792) 		return -ENOMEM;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  793) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  794) 	/* copy any leftover from last receive */
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  795) 	if (con->rx_leftover)
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  796) 		memmove(newbuf, con->rx_buf, con->rx_leftover);
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  797) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  798) 	/* swap to new buffer space */
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  799) 	kfree(con->rx_buf);
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  800) 	con->rx_buflen = newlen;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  801) 	con->rx_buf = newbuf;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  802) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  803) 	return 0;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  804) }
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  805) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  806) /* Data received from remote end */
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  807) static int receive_from_sock(struct connection *con)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  808) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  809) 	int call_again_soon = 0;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  810) 	struct msghdr msg;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  811) 	struct kvec iov;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  812) 	int ret, buflen;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  813) 
f1f1c1ccf7848 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-24 11:17:59 +0000  814) 	mutex_lock(&con->sock_mutex);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  815) 
a34fbc6363256 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-02-01 16:46:33 +0000  816) 	if (con->sock == NULL) {
a34fbc6363256 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-02-01 16:46:33 +0000  817) 		ret = -EAGAIN;
a34fbc6363256 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-02-01 16:46:33 +0000  818) 		goto out_close;
a34fbc6363256 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-02-01 16:46:33 +0000  819) 	}
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  820) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  821) 	/* realloc if we get new buffer size to read out */
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  822) 	buflen = dlm_config.ci_buffer_size;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  823) 	if (con->rx_buflen != buflen && con->rx_leftover <= buflen) {
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  824) 		ret = con_realloc_receive_buf(con, buflen);
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  825) 		if (ret < 0)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  826) 			goto out_resched;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  827) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  828) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  829) 	/* calculate new buffer parameter regarding last receive and
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  830) 	 * possible leftover bytes
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  831) 	 */
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  832) 	iov.iov_base = con->rx_buf + con->rx_leftover;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  833) 	iov.iov_len = con->rx_buflen - con->rx_leftover;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  834) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  835) 	memset(&msg, 0, sizeof(msg));
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  836) 	msg.msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  837) 	ret = kernel_recvmsg(con->sock, &msg, &iov, 1, iov.iov_len,
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  838) 			     msg.msg_flags);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  839) 	if (ret <= 0)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  840) 		goto out_close;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  841) 	else if (ret == iov.iov_len)
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300  842) 		call_again_soon = 1;
bd44e2b007bc9 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-22 14:51:33 +0000  843) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  844) 	/* new buflen according readed bytes and leftover from last receive */
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  845) 	buflen = ret + con->rx_leftover;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  846) 	ret = dlm_process_incoming_buffer(con->nodeid, con->rx_buf, buflen);
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  847) 	if (ret < 0)
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  848) 		goto out_close;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  849) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  850) 	/* calculate leftover bytes from process and put it into begin of
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  851) 	 * the receive buffer, so next receive we have the full message
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  852) 	 * at the start address of the receive buffer.
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  853) 	 */
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  854) 	con->rx_leftover = buflen - ret;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  855) 	if (con->rx_leftover) {
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  856) 		memmove(con->rx_buf, con->rx_buf + ret,
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  857) 			con->rx_leftover);
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  858) 		call_again_soon = true;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  859) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  860) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  861) 	if (call_again_soon)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  862) 		goto out_resched;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  863) 
f1f1c1ccf7848 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-24 11:17:59 +0000  864) 	mutex_unlock(&con->sock_mutex);
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000  865) 	return 0;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  866) 
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000  867) out_resched:
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000  868) 	if (!test_and_set_bit(CF_READ_PENDING, &con->flags))
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000  869) 		queue_work(recv_workqueue, &con->rwork);
f1f1c1ccf7848 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-24 11:17:59 +0000  870) 	mutex_unlock(&con->sock_mutex);
bd44e2b007bc9 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-22 14:51:33 +0000  871) 	return -EAGAIN;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  872) 
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000  873) out_close:
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  874) 	if (ret == 0) {
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  875) 		log_print("connection %p got EOF from %d",
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  876) 			  con, con->nodeid);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  877) 
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  878) 		if (con->eof_condition && con->eof_condition(con)) {
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  879) 			set_bit(CF_EOF, &con->flags);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  880) 			mutex_unlock(&con->sock_mutex);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  881) 		} else {
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  882) 			mutex_unlock(&con->sock_mutex);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  883) 			close_connection(con, false, true, false);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  884) 
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  885) 			/* handling for tcp shutdown */
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  886) 			clear_bit(CF_SHUTDOWN, &con->flags);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  887) 			wake_up(&con->shutdown_wait);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  888) 		}
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  889) 
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  890) 		/* signal to breaking receive worker */
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  891) 		ret = -1;
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  892) 	} else {
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400  893) 		mutex_unlock(&con->sock_mutex);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  894) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  895) 	return ret;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  896) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  897) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  898) /* Listening socket is busy, accept a connection */
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  899) static int accept_from_sock(struct listen_connection *con)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  900) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  901) 	int result;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  902) 	struct sockaddr_storage peeraddr;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  903) 	struct socket *newsock;
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  904) 	int len, idx;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  905) 	int nodeid;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  906) 	struct connection *newcon;
bd44e2b007bc9 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-22 14:51:33 +0000  907) 	struct connection *addcon;
3f78cd7d2449a fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:23 -0400  908) 	unsigned int mark;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  909) 
513ef596d43cc fs/dlm/lowcomms.c     (David Teigland            2012-03-30 11:46:08 -0500  910) 	if (!dlm_allow_conn) {
513ef596d43cc fs/dlm/lowcomms.c     (David Teigland            2012-03-30 11:46:08 -0500  911) 		return -1;
513ef596d43cc fs/dlm/lowcomms.c     (David Teigland            2012-03-30 11:46:08 -0500  912) 	}
513ef596d43cc fs/dlm/lowcomms.c     (David Teigland            2012-03-30 11:46:08 -0500  913) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  914) 	if (!con->sock)
3421fb15be01f fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:38 +0000  915) 		return -ENOTCONN;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  916) 
3421fb15be01f fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:38 +0000  917) 	result = kernel_accept(con->sock, &newsock, O_NONBLOCK);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  918) 	if (result < 0)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  919) 		goto accept_err;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  920) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  921) 	/* Get the connected socket's peer */
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  922) 	memset(&peeraddr, 0, sizeof(peeraddr));
9b2c45d479d0f fs/dlm/lowcomms.c     (Denys Vlasenko            2018-02-12 20:00:20 +0100  923) 	len = newsock->ops->getname(newsock, (struct sockaddr *)&peeraddr, 2);
9b2c45d479d0f fs/dlm/lowcomms.c     (Denys Vlasenko            2018-02-12 20:00:20 +0100  924) 	if (len < 0) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  925) 		result = -ECONNABORTED;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  926) 		goto accept_err;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  927) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  928) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  929) 	/* Get the new node's NODEID */
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  930) 	make_sockaddr(&peeraddr, 0, &len);
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  931) 	if (addr_to_nodeid(&peeraddr, &nodeid, &mark)) {
bcaadf5c1ac4f fs/dlm/lowcomms.c     (Masatake YAMATO           2011-07-04 12:25:51 +0900  932) 		unsigned char *b=(unsigned char *)&peeraddr;
617e82e10ccf9 fs/dlm/lowcomms.c     (David Teigland            2007-04-26 13:46:49 -0500  933) 		log_print("connect from non cluster node");
bcaadf5c1ac4f fs/dlm/lowcomms.c     (Masatake YAMATO           2011-07-04 12:25:51 +0900  934) 		print_hex_dump_bytes("ss: ", DUMP_PREFIX_NONE, 
bcaadf5c1ac4f fs/dlm/lowcomms.c     (Masatake YAMATO           2011-07-04 12:25:51 +0900  935) 				     b, sizeof(struct sockaddr_storage));
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  936) 		sock_release(newsock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  937) 		return -1;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  938) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  939) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  940) 	log_print("got connection from %d", nodeid);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  941) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  942) 	/*  Check to see if we already have a connection to this node. This
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  943) 	 *  could happen if the two nodes initiate a connection at roughly
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  944) 	 *  the same time and the connections cross on the wire.
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  945) 	 *  In this case we store the incoming one in "othercon"
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  946) 	 */
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  947) 	idx = srcu_read_lock(&connections_srcu);
748285ccf7ea7 fs/dlm/lowcomms.c     (David Teigland            2009-05-15 10:50:57 -0500  948) 	newcon = nodeid2con(nodeid, GFP_NOFS);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  949) 	if (!newcon) {
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  950) 		srcu_read_unlock(&connections_srcu, idx);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  951) 		result = -ENOMEM;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  952) 		goto accept_err;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  953) 	}
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  954) 
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  955) 	sock_set_mark(newsock->sk, mark);
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500  956) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500  957) 	mutex_lock(&newcon->sock_mutex);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  958) 	if (newcon->sock) {
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000  959) 		struct connection *othercon = newcon->othercon;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  960) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  961) 		if (!othercon) {
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400  962) 			othercon = kzalloc(sizeof(*othercon), GFP_NOFS);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  963) 			if (!othercon) {
617e82e10ccf9 fs/dlm/lowcomms.c     (David Teigland            2007-04-26 13:46:49 -0500  964) 				log_print("failed to allocate incoming socket");
f1f1c1ccf7848 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-24 11:17:59 +0000  965) 				mutex_unlock(&newcon->sock_mutex);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  966) 				srcu_read_unlock(&connections_srcu, idx);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  967) 				result = -ENOMEM;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  968) 				goto accept_err;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  969) 			}
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  970) 
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  971) 			result = dlm_con_init(othercon, nodeid);
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  972) 			if (result < 0) {
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  973) 				kfree(othercon);
2fd8db2dd05d8 fs/dlm/lowcomms.c     (Yang Yingliang            2021-03-27 16:37:04 +0800  974) 				mutex_unlock(&newcon->sock_mutex);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400  975) 				srcu_read_unlock(&connections_srcu, idx);
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  976) 				goto accept_err;
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  977) 			}
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400  978) 
e9a470acd9305 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:11 -0500  979) 			lockdep_set_subclass(&othercon->sock_mutex, 1);
6cde210a97587 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:21 -0500  980) 			newcon->othercon = othercon;
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400  981) 			othercon->sendcon = newcon;
ba3ab3ca68caa fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:37 -0400  982) 		} else {
ba3ab3ca68caa fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:37 -0400  983) 			/* close other sock con if we have something new */
ba3ab3ca68caa fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:37 -0400  984) 			close_connection(othercon, false, true, false);
61d96be0f474d fs/dlm/lowcomms.c     (Patrick Caulfield         2007-08-20 15:13:38 +0100  985) 		}
ba3ab3ca68caa fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:37 -0400  986) 
e9a470acd9305 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:11 -0500  987) 		mutex_lock(&othercon->sock_mutex);
ba3ab3ca68caa fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:37 -0400  988) 		add_sock(newsock, othercon);
ba3ab3ca68caa fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:37 -0400  989) 		addcon = othercon;
ba3ab3ca68caa fs/dlm/lowcomms.c     (Alexander Aring           2020-07-27 09:13:37 -0400  990) 		mutex_unlock(&othercon->sock_mutex);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  991) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  992) 	else {
3735b4b9f1c10 fs/dlm/lowcomms.c     (Bob Peterson              2016-09-23 14:23:26 -0400  993) 		/* accept copies the sk after we've saved the callbacks, so we
3735b4b9f1c10 fs/dlm/lowcomms.c     (Bob Peterson              2016-09-23 14:23:26 -0400  994) 		   don't want to save them a second time or comm errors will
3735b4b9f1c10 fs/dlm/lowcomms.c     (Bob Peterson              2016-09-23 14:23:26 -0400  995) 		   result in calling sk_error_report recursively. */
988419a9deab6 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:32 +0000  996) 		add_sock(newsock, newcon);
bd44e2b007bc9 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-22 14:51:33 +0000  997) 		addcon = newcon;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  998) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500  999) 
b30a624f50d9b fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:10 -0500 1000) 	set_bit(CF_CONNECTED, &addcon->flags);
f1f1c1ccf7848 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-24 11:17:59 +0000 1001) 	mutex_unlock(&newcon->sock_mutex);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1002) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1003) 	/*
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1004) 	 * Add it to the active queue in case we got data
25985edcedea6 fs/dlm/lowcomms.c     (Lucas De Marchi           2011-03-30 22:57:33 -0300 1005) 	 * between processing the accept adding the socket
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1006) 	 * to the read_sockets list
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1007) 	 */
bd44e2b007bc9 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-22 14:51:33 +0000 1008) 	if (!test_and_set_bit(CF_READ_PENDING, &addcon->flags))
bd44e2b007bc9 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-22 14:51:33 +0000 1009) 		queue_work(recv_workqueue, &addcon->rwork);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1010) 
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1011) 	srcu_read_unlock(&connections_srcu, idx);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1012) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1013) 	return 0;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1014) 
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1015) accept_err:
3421fb15be01f fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:38 +0000 1016) 	if (newsock)
3421fb15be01f fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:38 +0000 1017) 		sock_release(newsock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1018) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1019) 	if (result != -EAGAIN)
617e82e10ccf9 fs/dlm/lowcomms.c     (David Teigland            2007-04-26 13:46:49 -0500 1020) 		log_print("error accepting connection from node: %d", result);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1021) 	return result;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1022) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1023) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1024) static void free_entry(struct writequeue_entry *e)
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1025) {
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1026) 	__free_page(e->page);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1027) 	kfree(e);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1028) }
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1029) 
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1030) /*
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1031)  * writequeue_entry_complete - try to delete and free write queue entry
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1032)  * @e: write queue entry to try to delete
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1033)  * @completed: bytes completed
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1034)  *
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1035)  * writequeue_lock must be held.
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1036)  */
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1037) static void writequeue_entry_complete(struct writequeue_entry *e, int completed)
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1038) {
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1039) 	e->offset += completed;
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1040) 	e->len -= completed;
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1041) 
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1042) 	if (e->len == 0 && e->users == 0) {
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1043) 		list_del(&e->list);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1044) 		atomic_dec(&e->con->writequeue_cnt);
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1045) 		free_entry(e);
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1046) 	}
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1047) }
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1048) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1049) /*
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1050)  * sctp_bind_addrs - bind a SCTP socket to all our addresses
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1051)  */
13004e8afedca fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:24 -0500 1052) static int sctp_bind_addrs(struct socket *sock, uint16_t port)
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1053) {
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1054) 	struct sockaddr_storage localaddr;
c0425a4249e9d fs/dlm/lowcomms.c     (Christoph Hellwig         2020-05-29 14:09:42 +0200 1055) 	struct sockaddr *addr = (struct sockaddr *)&localaddr;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1056) 	int i, addr_len, result = 0;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1057) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1058) 	for (i = 0; i < dlm_local_count; i++) {
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1059) 		memcpy(&localaddr, dlm_local_addr[i], sizeof(localaddr));
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1060) 		make_sockaddr(&localaddr, port, &addr_len);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1061) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1062) 		if (!i)
13004e8afedca fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:24 -0500 1063) 			result = kernel_bind(sock, addr, addr_len);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1064) 		else
13004e8afedca fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:24 -0500 1065) 			result = sock_bind_add(sock->sk, addr, addr_len);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1066) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1067) 		if (result < 0) {
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1068) 			log_print("Can't bind to %d addr number %d, %d.\n",
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1069) 				  port, i + 1, result);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1070) 			break;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1071) 		}
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1072) 	}
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1073) 	return result;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1074) }
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1075) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1076) /* Initiate an SCTP association.
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1077)    This is a special case of send_to_sock() in that we don't yet have a
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1078)    peeled-off socket for this association, so we use the listening socket
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1079)    and add the primary IP address of the remote node.
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1080)  */
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1081) static void sctp_connect_to_sock(struct connection *con)
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1082) {
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1083) 	struct sockaddr_storage daddr;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1084) 	int result;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1085) 	int addr_len;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1086) 	struct socket *sock;
9c9f168f5b145 fs/dlm/lowcomms.c     (Alexander Aring           2020-06-26 13:26:50 -0400 1087) 	unsigned int mark;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1088) 
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1089) 	mutex_lock(&con->sock_mutex);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1090) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1091) 	/* Some odd races can cause double-connects, ignore them */
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1092) 	if (con->retries++ > MAX_CONNECT_RETRIES)
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1093) 		goto out;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1094) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1095) 	if (con->sock) {
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1096) 		log_print("node %d already connected.", con->nodeid);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1097) 		goto out;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1098) 	}
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1099) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1100) 	memset(&daddr, 0, sizeof(daddr));
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500 1101) 	result = nodeid_to_addr(con->nodeid, &daddr, NULL, true, &mark);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1102) 	if (result < 0) {
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1103) 		log_print("no address for nodeid %d", con->nodeid);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1104) 		goto out;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1105) 	}
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1106) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1107) 	/* Create a socket to communicate with */
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1108) 	result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1109) 				  SOCK_STREAM, IPPROTO_SCTP, &sock);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1110) 	if (result < 0)
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1111) 		goto socket_err;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1112) 
9c9f168f5b145 fs/dlm/lowcomms.c     (Alexander Aring           2020-06-26 13:26:50 -0400 1113) 	sock_set_mark(sock->sk, mark);
9c9f168f5b145 fs/dlm/lowcomms.c     (Alexander Aring           2020-06-26 13:26:50 -0400 1114) 
988419a9deab6 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:32 +0000 1115) 	add_sock(sock, con);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1116) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1117) 	/* Bind to all addresses. */
13004e8afedca fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:24 -0500 1118) 	if (sctp_bind_addrs(con->sock, 0))
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1119) 		goto bind_err;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1120) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1121) 	make_sockaddr(&daddr, dlm_config.ci_tcp_port, &addr_len);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1122) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1123) 	log_print("connecting to %d", con->nodeid);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1124) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1125) 	/* Turn off Nagle's algorithm */
40ef92c6ec09b fs/dlm/lowcomms.c     (Christoph Hellwig         2020-05-29 14:09:40 +0200 1126) 	sctp_sock_set_nodelay(sock->sk);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1127) 
f706d830154b6 fs/dlm/lowcomms.c     (Gang He                   2018-05-02 10:28:35 -0500 1128) 	/*
f706d830154b6 fs/dlm/lowcomms.c     (Gang He                   2018-05-02 10:28:35 -0500 1129) 	 * Make sock->ops->connect() function return in specified time,
f706d830154b6 fs/dlm/lowcomms.c     (Gang He                   2018-05-02 10:28:35 -0500 1130) 	 * since O_NONBLOCK argument in connect() function does not work here,
f706d830154b6 fs/dlm/lowcomms.c     (Gang He                   2018-05-02 10:28:35 -0500 1131) 	 * then, we should restore the default value of this attribute.
f706d830154b6 fs/dlm/lowcomms.c     (Gang He                   2018-05-02 10:28:35 -0500 1132) 	 */
76ee0785f42af fs/dlm/lowcomms.c     (Christoph Hellwig         2020-05-28 07:12:12 +0200 1133) 	sock_set_sndtimeo(sock->sk, 5);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1134) 	result = sock->ops->connect(sock, (struct sockaddr *)&daddr, addr_len,
da3627c30d229 fs/dlm/lowcomms.c     (Gang He                   2018-05-29 11:09:22 +0800 1135) 				   0);
76ee0785f42af fs/dlm/lowcomms.c     (Christoph Hellwig         2020-05-28 07:12:12 +0200 1136) 	sock_set_sndtimeo(sock->sk, 0);
f706d830154b6 fs/dlm/lowcomms.c     (Gang He                   2018-05-02 10:28:35 -0500 1137) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1138) 	if (result == -EINPROGRESS)
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1139) 		result = 0;
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500 1140) 	if (result == 0) {
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500 1141) 		if (!test_and_set_bit(CF_CONNECTED, &con->flags))
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500 1142) 			log_print("successful connected to node %d", con->nodeid);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1143) 		goto out;
19633c7e204b9 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:20 -0500 1144) 	}
98e1b60ecc441 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:12 -0500 1145) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1146) bind_err:
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1147) 	con->sock = NULL;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1148) 	sock_release(sock);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1149) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1150) socket_err:
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1151) 	/*
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1152) 	 * Some errors are fatal and this list might need adjusting. For other
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1153) 	 * errors we try again until the max number of retries is reached.
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1154) 	 */
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1155) 	if (result != -EHOSTUNREACH &&
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1156) 	    result != -ENETUNREACH &&
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1157) 	    result != -ENETDOWN &&
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1158) 	    result != -EINVAL &&
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1159) 	    result != -EPROTONOSUPPORT) {
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1160) 		log_print("connect %d try %d error %d", con->nodeid,
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1161) 			  con->retries, result);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1162) 		mutex_unlock(&con->sock_mutex);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1163) 		msleep(1000);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1164) 		lowcomms_connect_sock(con);
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1165) 		return;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1166) 	}
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1167) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1168) out:
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1169) 	mutex_unlock(&con->sock_mutex);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1170) }
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1171) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1172) /* Connect a new socket to its peer */
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1173) static void tcp_connect_to_sock(struct connection *con)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1174) {
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1175) 	struct sockaddr_storage saddr, src_addr;
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500 1176) 	unsigned int mark;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1177) 	int addr_len;
a89d63a159b1b fs/dlm/lowcomms.c     (Casey Dahlin              2009-07-14 12:17:51 -0500 1178) 	struct socket *sock = NULL;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1179) 	int result;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1180) 
f1f1c1ccf7848 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-24 11:17:59 +0000 1181) 	mutex_lock(&con->sock_mutex);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1182) 	if (con->retries++ > MAX_CONNECT_RETRIES)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1183) 		goto out;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1184) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1185) 	/* Some odd races can cause double-connects, ignore them */
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1186) 	if (con->sock)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1187) 		goto out;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1188) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1189) 	/* Create a socket to communicate with */
eeb1bd5c40edb fs/dlm/lowcomms.c     (Eric W. Biederman         2015-05-08 21:08:05 -0500 1190) 	result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
eeb1bd5c40edb fs/dlm/lowcomms.c     (Eric W. Biederman         2015-05-08 21:08:05 -0500 1191) 				  SOCK_STREAM, IPPROTO_TCP, &sock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1192) 	if (result < 0)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1193) 		goto out_err;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1194) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1195) 	memset(&saddr, 0, sizeof(saddr));
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500 1196) 	result = nodeid_to_addr(con->nodeid, &saddr, NULL, false, &mark);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1197) 	if (result < 0) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1198) 		log_print("no address for nodeid %d", con->nodeid);
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1199) 		goto out_err;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1200) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1201) 
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500 1202) 	sock_set_mark(sock->sk, mark);
e125fbeb538e5 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:09 -0500 1203) 
988419a9deab6 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:32 +0000 1204) 	add_sock(sock, con);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1205) 
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1206) 	/* Bind to our cluster-known address connecting to avoid
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1207) 	   routing problems */
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1208) 	memcpy(&src_addr, dlm_local_addr[0], sizeof(src_addr));
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1209) 	make_sockaddr(&src_addr, 0, &addr_len);
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1210) 	result = sock->ops->bind(sock, (struct sockaddr *) &src_addr,
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1211) 				 addr_len);
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1212) 	if (result < 0) {
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1213) 		log_print("could not bind for connect: %d", result);
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1214) 		/* This *may* not indicate a critical error */
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1215) 	}
6bd8fedaa16da fs/dlm/lowcomms.c     (Lon Hohberger             2007-10-25 18:51:54 -0400 1216) 
68c817a1c4e21 fs/dlm/lowcomms-tcp.c (David Teigland            2007-01-09 09:41:48 -0600 1217) 	make_sockaddr(&saddr, dlm_config.ci_tcp_port, &addr_len);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1218) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1219) 	log_print("connecting to %d", con->nodeid);
cb2d45da81c86 fs/dlm/lowcomms.c     (David Teigland            2010-11-12 11:12:55 -0600 1220) 
cb2d45da81c86 fs/dlm/lowcomms.c     (David Teigland            2010-11-12 11:12:55 -0600 1221) 	/* Turn off Nagle's algorithm */
12abc5ee7873a fs/dlm/lowcomms.c     (Christoph Hellwig         2020-05-28 07:12:19 +0200 1222) 	tcp_sock_set_nodelay(sock->sk);
cb2d45da81c86 fs/dlm/lowcomms.c     (David Teigland            2010-11-12 11:12:55 -0600 1223) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1224) 	result = sock->ops->connect(sock, (struct sockaddr *)&saddr, addr_len,
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1225) 				   O_NONBLOCK);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1226) 	if (result == -EINPROGRESS)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1227) 		result = 0;
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1228) 	if (result == 0)
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1229) 		goto out;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1230) 
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1231) out_err:
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1232) 	if (con->sock) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1233) 		sock_release(con->sock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1234) 		con->sock = NULL;
a89d63a159b1b fs/dlm/lowcomms.c     (Casey Dahlin              2009-07-14 12:17:51 -0500 1235) 	} else if (sock) {
a89d63a159b1b fs/dlm/lowcomms.c     (Casey Dahlin              2009-07-14 12:17:51 -0500 1236) 		sock_release(sock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1237) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1238) 	/*
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1239) 	 * Some errors are fatal and this list might need adjusting. For other
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1240) 	 * errors we try again until the max number of retries is reached.
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1241) 	 */
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1242) 	if (result != -EHOSTUNREACH &&
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1243) 	    result != -ENETUNREACH &&
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1244) 	    result != -ENETDOWN && 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1245) 	    result != -EINVAL &&
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1246) 	    result != -EPROTONOSUPPORT) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1247) 		log_print("connect %d try %d error %d", con->nodeid,
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1248) 			  con->retries, result);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1249) 		mutex_unlock(&con->sock_mutex);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1250) 		msleep(1000);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1251) 		lowcomms_connect_sock(con);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1252) 		return;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1253) 	}
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1254) out:
f1f1c1ccf7848 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-24 11:17:59 +0000 1255) 	mutex_unlock(&con->sock_mutex);
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1256) 	return;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1257) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1258) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1259) /* On error caller must run dlm_close_sock() for the
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1260)  * listen connection socket.
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1261)  */
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1262) static int tcp_create_listen_sock(struct listen_connection *con,
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1263) 				  struct sockaddr_storage *saddr)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1264) {
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1265) 	struct socket *sock = NULL;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1266) 	int result = 0;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1267) 	int addr_len;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1268) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1269) 	if (dlm_local_addr[0]->ss_family == AF_INET)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1270) 		addr_len = sizeof(struct sockaddr_in);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1271) 	else
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1272) 		addr_len = sizeof(struct sockaddr_in6);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1273) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1274) 	/* Create a socket to communicate with */
eeb1bd5c40edb fs/dlm/lowcomms.c     (Eric W. Biederman         2015-05-08 21:08:05 -0500 1275) 	result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
eeb1bd5c40edb fs/dlm/lowcomms.c     (Eric W. Biederman         2015-05-08 21:08:05 -0500 1276) 				  SOCK_STREAM, IPPROTO_TCP, &sock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1277) 	if (result < 0) {
617e82e10ccf9 fs/dlm/lowcomms.c     (David Teigland            2007-04-26 13:46:49 -0500 1278) 		log_print("Can't create listening comms socket");
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1279) 		goto create_out;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1280) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1281) 
a5b7ab6352bfa fs/dlm/lowcomms.c     (Alexander Aring           2020-06-26 13:26:49 -0400 1282) 	sock_set_mark(sock->sk, dlm_config.ci_mark);
a5b7ab6352bfa fs/dlm/lowcomms.c     (Alexander Aring           2020-06-26 13:26:49 -0400 1283) 
cb2d45da81c86 fs/dlm/lowcomms.c     (David Teigland            2010-11-12 11:12:55 -0600 1284) 	/* Turn off Nagle's algorithm */
12abc5ee7873a fs/dlm/lowcomms.c     (Christoph Hellwig         2020-05-28 07:12:19 +0200 1285) 	tcp_sock_set_nodelay(sock->sk);
cb2d45da81c86 fs/dlm/lowcomms.c     (David Teigland            2010-11-12 11:12:55 -0600 1286) 
b58f0e8f38c0a fs/dlm/lowcomms.c     (Christoph Hellwig         2020-05-28 07:12:09 +0200 1287) 	sock_set_reuseaddr(sock->sk);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1288) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1289) 	add_listen_sock(sock, con);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1290) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1291) 	/* Bind to our port */
68c817a1c4e21 fs/dlm/lowcomms-tcp.c (David Teigland            2007-01-09 09:41:48 -0600 1292) 	make_sockaddr(saddr, dlm_config.ci_tcp_port, &addr_len);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1293) 	result = sock->ops->bind(sock, (struct sockaddr *) saddr, addr_len);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1294) 	if (result < 0) {
617e82e10ccf9 fs/dlm/lowcomms.c     (David Teigland            2007-04-26 13:46:49 -0500 1295) 		log_print("Can't bind to port %d", dlm_config.ci_tcp_port);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1296) 		goto create_out;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1297) 	}
ce3d9544cecac fs/dlm/lowcomms.c     (Christoph Hellwig         2020-05-28 07:12:15 +0200 1298) 	sock_set_keepalive(sock->sk);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1299) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1300) 	result = sock->ops->listen(sock, 5);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1301) 	if (result < 0) {
617e82e10ccf9 fs/dlm/lowcomms.c     (David Teigland            2007-04-26 13:46:49 -0500 1302) 		log_print("Can't listen on port %d", dlm_config.ci_tcp_port);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1303) 		goto create_out;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1304) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1305) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1306) 	return 0;
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1307) 
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1308) create_out:
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1309) 	return result;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1310) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1311) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1312) /* Get local addresses */
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1313) static void init_local(void)
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1314) {
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1315) 	struct sockaddr_storage sas, *addr;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1316) 	int i;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1317) 
30d3a2373f171 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-23 16:26:21 +0100 1318) 	dlm_local_count = 0;
1b189b8889b7d fs/dlm/lowcomms.c     (David Teigland            2012-03-21 09:18:34 -0500 1319) 	for (i = 0; i < DLM_MAX_ADDR_COUNT; i++) {
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1320) 		if (dlm_our_addr(&sas, i))
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1321) 			break;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1322) 
5c93f56f770e6 fs/dlm/lowcomms.c     (Amitoj Kaur Chawla        2016-06-23 10:22:01 +0530 1323) 		addr = kmemdup(&sas, sizeof(*addr), GFP_NOFS);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1324) 		if (!addr)
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1325) 			break;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1326) 		dlm_local_addr[dlm_local_count++] = addr;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1327) 	}
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1328) }
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1329) 
043697f030c5c fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:50 -0400 1330) static void deinit_local(void)
043697f030c5c fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:50 -0400 1331) {
043697f030c5c fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:50 -0400 1332) 	int i;
043697f030c5c fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:50 -0400 1333) 
043697f030c5c fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:50 -0400 1334) 	for (i = 0; i < dlm_local_count; i++)
043697f030c5c fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:50 -0400 1335) 		kfree(dlm_local_addr[i]);
043697f030c5c fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:50 -0400 1336) }
043697f030c5c fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:50 -0400 1337) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1338) /* Initialise SCTP socket and bind to all interfaces
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1339)  * On error caller must run dlm_close_sock() for the
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1340)  * listen connection socket.
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1341)  */
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1342) static int sctp_listen_for_all(struct listen_connection *con)
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1343) {
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1344) 	struct socket *sock = NULL;
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1345) 	int result = -EINVAL;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1346) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1347) 	log_print("Using SCTP for communications");
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1348) 
eeb1bd5c40edb fs/dlm/lowcomms.c     (Eric W. Biederman         2015-05-08 21:08:05 -0500 1349) 	result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1350) 				  SOCK_STREAM, IPPROTO_SCTP, &sock);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1351) 	if (result < 0) {
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1352) 		log_print("Can't create comms socket, check SCTP is loaded");
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1353) 		goto out;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1354) 	}
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1355) 
26cfabf9cdd27 fs/dlm/lowcomms.c     (Christoph Hellwig         2020-05-28 07:12:16 +0200 1356) 	sock_set_rcvbuf(sock->sk, NEEDED_RMEM);
a5b7ab6352bfa fs/dlm/lowcomms.c     (Alexander Aring           2020-06-26 13:26:49 -0400 1357) 	sock_set_mark(sock->sk, dlm_config.ci_mark);
40ef92c6ec09b fs/dlm/lowcomms.c     (Christoph Hellwig         2020-05-29 14:09:40 +0200 1358) 	sctp_sock_set_nodelay(sock->sk);
86e92ad299fb0 fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:14 -0500 1359) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1360) 	add_listen_sock(sock, con);
b81171cb68691 fs/dlm/lowcomms.c     (Bob Peterson              2016-02-05 14:39:02 -0500 1361) 
ee44b4bc054af fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:23 -0300 1362) 	/* Bind to all addresses. */
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1363) 	result = sctp_bind_addrs(con->sock, dlm_config.ci_tcp_port);
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1364) 	if (result < 0)
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1365) 		goto out;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1366) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1367) 	result = sock->ops->listen(sock, 5);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1368) 	if (result < 0) {
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1369) 		log_print("Can't set socket listening");
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1370) 		goto out;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1371) 	}
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1372) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1373) 	return 0;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1374) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1375) out:
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1376) 	return result;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1377) }
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1378) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1379) static int tcp_listen_for_all(void)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1380) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1381) 	/* We don't support multi-homed hosts */
1a26bfafbce0f fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:26 -0500 1382) 	if (dlm_local_count > 1) {
617e82e10ccf9 fs/dlm/lowcomms.c     (David Teigland            2007-04-26 13:46:49 -0500 1383) 		log_print("TCP protocol can't handle multi-homed hosts, "
617e82e10ccf9 fs/dlm/lowcomms.c     (David Teigland            2007-04-26 13:46:49 -0500 1384) 			  "try SCTP");
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1385) 		return -EINVAL;
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1386) 	}
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1387) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1388) 	log_print("Using TCP for communications");
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1389) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1390) 	return tcp_create_listen_sock(&listen_con, dlm_local_addr[0]);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1391) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1392) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1393) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1394) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1395) static struct writequeue_entry *new_writequeue_entry(struct connection *con,
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1396) 						     gfp_t allocation)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1397) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1398) 	struct writequeue_entry *entry;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1399) 
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1400) 	entry = kzalloc(sizeof(*entry), allocation);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1401) 	if (!entry)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1402) 		return NULL;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1403) 
e1a7cbce53f65 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:15 -0500 1404) 	entry->page = alloc_page(allocation | __GFP_ZERO);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1405) 	if (!entry->page) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1406) 		kfree(entry);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1407) 		return NULL;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1408) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1409) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1410) 	entry->con = con;
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1411) 	entry->users = 1;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1412) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1413) 	return entry;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1414) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1415) 
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1416) static struct writequeue_entry *new_wq_entry(struct connection *con, int len,
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1417) 					     gfp_t allocation, char **ppc)
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1418) {
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1419) 	struct writequeue_entry *e;
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1420) 
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1421) 	spin_lock(&con->writequeue_lock);
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1422) 	if (!list_empty(&con->writequeue)) {
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1423) 		e = list_last_entry(&con->writequeue, struct writequeue_entry, list);
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1424) 		if (DLM_WQ_REMAIN_BYTES(e) >= len) {
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1425) 			*ppc = page_address(e->page) + e->end;
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1426) 			e->end += len;
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1427) 			e->users++;
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1428) 			spin_unlock(&con->writequeue_lock);
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1429) 
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1430) 			return e;
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1431) 		}
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1432) 	}
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1433) 	spin_unlock(&con->writequeue_lock);
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1434) 
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1435) 	e = new_writequeue_entry(con, allocation);
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1436) 	if (!e)
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1437) 		return NULL;
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1438) 
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1439) 	*ppc = page_address(e->page);
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1440) 	e->end += len;
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1441) 	atomic_inc(&con->writequeue_cnt);
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1442) 
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1443) 	spin_lock(&con->writequeue_lock);
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1444) 	list_add_tail(&e->list, &con->writequeue);
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1445) 	spin_unlock(&con->writequeue_lock);
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1446) 
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1447) 	return e;
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1448) };
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1449) 
617e82e10ccf9 fs/dlm/lowcomms.c     (David Teigland            2007-04-26 13:46:49 -0500 1450) void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1451) {
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1452) 	struct writequeue_entry *e;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1453) 	struct connection *con;
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1454) 	int idx;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1455) 
c45674fbdda13 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:14 -0500 1456) 	if (len > DEFAULT_BUFFER_SIZE ||
c45674fbdda13 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:14 -0500 1457) 	    len < sizeof(struct dlm_header)) {
c45674fbdda13 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:14 -0500 1458) 		BUILD_BUG_ON(PAGE_SIZE < DEFAULT_BUFFER_SIZE);
692f51c8cbe75 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:18 -0500 1459) 		log_print("failed to allocate a buffer of size %d", len);
c45674fbdda13 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:14 -0500 1460) 		WARN_ON(1);
692f51c8cbe75 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:18 -0500 1461) 		return NULL;
692f51c8cbe75 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:18 -0500 1462) 	}
692f51c8cbe75 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:18 -0500 1463) 
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1464) 	idx = srcu_read_lock(&connections_srcu);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1465) 	con = nodeid2con(nodeid, allocation);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1466) 	if (!con) {
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1467) 		srcu_read_unlock(&connections_srcu, idx);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1468) 		return NULL;
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1469) 	}
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1470) 
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1471) 	e = new_wq_entry(con, len, allocation, ppc);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1472) 	if (!e) {
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1473) 		srcu_read_unlock(&connections_srcu, idx);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1474) 		return NULL;
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1475) 	}
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1476) 
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1477) 	/* we assume if successful commit must called */
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1478) 	e->idx = idx;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1479) 
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1480) 	return e;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1481) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1482) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1483) void dlm_lowcomms_commit_buffer(void *mh)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1484) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1485) 	struct writequeue_entry *e = (struct writequeue_entry *)mh;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1486) 	struct connection *con = e->con;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1487) 	int users;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1488) 
4edde74eedb8b fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-02 17:08:54 +0000 1489) 	spin_lock(&con->writequeue_lock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1490) 	users = --e->users;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1491) 	if (users)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1492) 		goto out;
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1493) 
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1494) 	e->len = DLM_WQ_LENGTH_BYTES(e);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1495) 	spin_unlock(&con->writequeue_lock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1496) 
01da24d3fbed9 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:14 +0000 1497) 	queue_work(send_workqueue, &con->swork);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1498) 	srcu_read_unlock(&connections_srcu, e->idx);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1499) 	return;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1500) 
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1501) out:
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1502) 	spin_unlock(&con->writequeue_lock);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1503) 	srcu_read_unlock(&connections_srcu, e->idx);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1504) 	return;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1505) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1506) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1507) /* Send a message */
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1508) static void send_to_sock(struct connection *con)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1509) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1510) 	int ret = 0;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1511) 	const int msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1512) 	struct writequeue_entry *e;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1513) 	int len, offset;
f92c8dd7a0eb1 fs/dlm/lowcomms.c     (Bob Peterson              2010-11-12 11:15:20 -0600 1514) 	int count = 0;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1515) 
f1f1c1ccf7848 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-24 11:17:59 +0000 1516) 	mutex_lock(&con->sock_mutex);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1517) 	if (con->sock == NULL)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1518) 		goto out_connect;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1519) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1520) 	spin_lock(&con->writequeue_lock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1521) 	for (;;) {
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1522) 		if (list_empty(&con->writequeue))
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1523) 			break;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1524) 
f0747ebf48f36 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:16 -0500 1525) 		e = list_first_entry(&con->writequeue, struct writequeue_entry, list);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1526) 		len = e->len;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1527) 		offset = e->offset;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1528) 		BUG_ON(len == 0 && e->users == 0);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1529) 		spin_unlock(&con->writequeue_lock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1530) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1531) 		ret = 0;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1532) 		if (len) {
1329e3f2c898c fs/dlm/lowcomms.c     (Paolo Bonzini             2009-08-24 13:18:04 -0500 1533) 			ret = kernel_sendpage(con->sock, e->page, offset, len,
1329e3f2c898c fs/dlm/lowcomms.c     (Paolo Bonzini             2009-08-24 13:18:04 -0500 1534) 					      msg_flags);
d66f8277f5340 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-09-14 08:49:21 +0100 1535) 			if (ret == -EAGAIN || ret == 0) {
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800 1536) 				if (ret == -EAGAIN &&
9cd3e072b0be1 fs/dlm/lowcomms.c     (Eric Dumazet              2015-11-29 20:03:10 -0800 1537) 				    test_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags) &&
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800 1538) 				    !test_and_set_bit(CF_APP_LIMITED, &con->flags)) {
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800 1539) 					/* Notify TCP that we're limited by the
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800 1540) 					 * application window size.
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800 1541) 					 */
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800 1542) 					set_bit(SOCK_NOSPACE, &con->sock->flags);
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800 1543) 					con->sock->sk->sk_write_pending++;
b36930dd508e0 fs/dlm/lowcomms.c     (David Miller              2010-11-10 21:56:39 -0800 1544) 				}
d66f8277f5340 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-09-14 08:49:21 +0100 1545) 				cond_resched();
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1546) 				goto out;
9c5bef5849c9f fs/dlm/lowcomms.c     (Ying Xue                  2012-08-13 14:29:55 +0800 1547) 			} else if (ret < 0)
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400 1548) 				goto out;
d66f8277f5340 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-09-14 08:49:21 +0100 1549) 		}
f92c8dd7a0eb1 fs/dlm/lowcomms.c     (Bob Peterson              2010-11-12 11:15:20 -0600 1550) 
f92c8dd7a0eb1 fs/dlm/lowcomms.c     (Bob Peterson              2010-11-12 11:15:20 -0600 1551) 		/* Don't starve people filling buffers */
f92c8dd7a0eb1 fs/dlm/lowcomms.c     (Bob Peterson              2010-11-12 11:15:20 -0600 1552) 		if (++count >= MAX_SEND_MSG_COUNT) {
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1553) 			cond_resched();
f92c8dd7a0eb1 fs/dlm/lowcomms.c     (Bob Peterson              2010-11-12 11:15:20 -0600 1554) 			count = 0;
f92c8dd7a0eb1 fs/dlm/lowcomms.c     (Bob Peterson              2010-11-12 11:15:20 -0600 1555) 		}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1556) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1557) 		spin_lock(&con->writequeue_lock);
5d6898714fe2c fs/dlm/lowcomms.c     (Mike Christie             2013-06-14 04:56:13 -0500 1558) 		writequeue_entry_complete(e, ret);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1559) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1560) 	spin_unlock(&con->writequeue_lock);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1561) 
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1562) 	/* close if we got EOF */
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1563) 	if (test_and_clear_bit(CF_EOF, &con->flags)) {
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1564) 		mutex_unlock(&con->sock_mutex);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1565) 		close_connection(con, false, false, true);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1566) 
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1567) 		/* handling for tcp shutdown */
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1568) 		clear_bit(CF_SHUTDOWN, &con->flags);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1569) 		wake_up(&con->shutdown_wait);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1570) 	} else {
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1571) 		mutex_unlock(&con->sock_mutex);
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1572) 	}
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1573) 
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1574) 	return;
871166f159b36 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:39 -0400 1575) 
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1576) out:
f1f1c1ccf7848 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-24 11:17:59 +0000 1577) 	mutex_unlock(&con->sock_mutex);
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1578) 	return;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1579) 
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1580) out_connect:
f1f1c1ccf7848 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-24 11:17:59 +0000 1581) 	mutex_unlock(&con->sock_mutex);
01da24d3fbed9 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:14 +0000 1582) 	queue_work(send_workqueue, &con->swork);
01da24d3fbed9 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:14 +0000 1583) 	cond_resched();
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1584) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1585) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1586) static void clean_one_writequeue(struct connection *con)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1587) {
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1588) 	struct writequeue_entry *e, *safe;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1589) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1590) 	spin_lock(&con->writequeue_lock);
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1591) 	list_for_each_entry_safe(e, safe, &con->writequeue, list) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1592) 		list_del(&e->list);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1593) 		free_entry(e);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1594) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1595) 	spin_unlock(&con->writequeue_lock);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1596) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1597) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1598) /* Called from recovery when it knows that a node has
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1599)    left the cluster */
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1600) int dlm_lowcomms_close(int nodeid)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1601) {
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1602) 	struct connection *con;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1603) 	struct dlm_node_addr *na;
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1604) 	int idx;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1605) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1606) 	log_print("closing connection to node %d", nodeid);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1607) 	idx = srcu_read_lock(&connections_srcu);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1608) 	con = nodeid2con(nodeid, 0);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1609) 	if (con) {
063c4c99630c0 fs/dlm/lowcomms.c     (Lars Marowsky-Bree        2009-08-11 16:18:23 -0500 1610) 		set_bit(CF_CLOSE, &con->flags);
0d737a8cfd834 fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:21 -0300 1611) 		close_connection(con, true, true, true);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1612) 		clean_one_writequeue(con);
53a5edaa05c10 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:19 -0500 1613) 		if (con->othercon)
53a5edaa05c10 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:19 -0500 1614) 			clean_one_writequeue(con->othercon);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1615) 	}
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1616) 	srcu_read_unlock(&connections_srcu, idx);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1617) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1618) 	spin_lock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1619) 	na = find_node_addr(nodeid);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1620) 	if (na) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1621) 		list_del(&na->list);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1622) 		while (na->addr_count--)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1623) 			kfree(na->addr[na->addr_count]);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1624) 		kfree(na);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1625) 	}
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1626) 	spin_unlock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1627) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1628) 	return 0;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1629) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1630) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1631) /* Receive workqueue function */
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1632) static void process_recv_sockets(struct work_struct *work)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1633) {
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1634) 	struct connection *con = container_of(work, struct connection, rwork);
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1635) 	int err;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1636) 
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1637) 	clear_bit(CF_READ_PENDING, &con->flags);
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1638) 	do {
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1639) 		err = receive_from_sock(con);
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1640) 	} while (!err);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1641) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1642) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1643) static void process_listen_recv_socket(struct work_struct *work)
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1644) {
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1645) 	accept_from_sock(&listen_con);
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1646) }
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1647) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1648) /* Send workqueue function */
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1649) static void process_send_sockets(struct work_struct *work)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1650) {
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1651) 	struct connection *con = container_of(work, struct connection, swork);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1652) 
8a4abb0819769 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:16 +0000 1653) 	clear_bit(CF_WRITE_PENDING, &con->flags);
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400 1654) 
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400 1655) 	if (test_and_clear_bit(CF_RECONNECT, &con->flags))
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400 1656) 		close_connection(con, false, false, true);
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400 1657) 
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400 1658) 	if (con->sock == NULL) { /* not mutex protected so check it inside too */
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400 1659) 		if (test_and_clear_bit(CF_DELAY_CONNECT, &con->flags))
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400 1660) 			msleep(1000);
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1661) 		con->connect_action(con);
18e5651e39a5b fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:37 -0400 1662) 	}
01da24d3fbed9 fs/dlm/lowcomms.c     (Bob Peterson              2017-09-12 08:55:14 +0000 1663) 	if (!list_empty(&con->writequeue))
063c4c99630c0 fs/dlm/lowcomms.c     (Lars Marowsky-Bree        2009-08-11 16:18:23 -0500 1664) 		send_to_sock(con);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1665) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1666) 
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1667) static void work_stop(void)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1668) {
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1669) 	if (recv_workqueue) {
b355516f45070 fs/dlm/lowcomms.c     (David Windsor             2019-04-02 08:37:10 -0400 1670) 		destroy_workqueue(recv_workqueue);
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1671) 		recv_workqueue = NULL;
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1672) 	}
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1673) 
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1674) 	if (send_workqueue) {
b355516f45070 fs/dlm/lowcomms.c     (David Windsor             2019-04-02 08:37:10 -0400 1675) 		destroy_workqueue(send_workqueue);
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1676) 		send_workqueue = NULL;
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1677) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1678) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1679) 
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1680) static int work_start(void)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1681) {
e43f055a95372 fs/dlm/lowcomms.c     (David Teigland            2011-03-10 13:22:34 -0600 1682) 	recv_workqueue = alloc_workqueue("dlm_recv",
e43f055a95372 fs/dlm/lowcomms.c     (David Teigland            2011-03-10 13:22:34 -0600 1683) 					 WQ_UNBOUND | WQ_MEM_RECLAIM, 1);
b9d4105279438 fs/dlm/lowcomms.c     (Namhyung Kim              2010-12-13 13:42:24 -0600 1684) 	if (!recv_workqueue) {
b9d4105279438 fs/dlm/lowcomms.c     (Namhyung Kim              2010-12-13 13:42:24 -0600 1685) 		log_print("can't start dlm_recv");
b9d4105279438 fs/dlm/lowcomms.c     (Namhyung Kim              2010-12-13 13:42:24 -0600 1686) 		return -ENOMEM;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1687) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1688) 
e43f055a95372 fs/dlm/lowcomms.c     (David Teigland            2011-03-10 13:22:34 -0600 1689) 	send_workqueue = alloc_workqueue("dlm_send",
e43f055a95372 fs/dlm/lowcomms.c     (David Teigland            2011-03-10 13:22:34 -0600 1690) 					 WQ_UNBOUND | WQ_MEM_RECLAIM, 1);
b9d4105279438 fs/dlm/lowcomms.c     (Namhyung Kim              2010-12-13 13:42:24 -0600 1691) 	if (!send_workqueue) {
b9d4105279438 fs/dlm/lowcomms.c     (Namhyung Kim              2010-12-13 13:42:24 -0600 1692) 		log_print("can't start dlm_send");
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1693) 		destroy_workqueue(recv_workqueue);
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1694) 		recv_workqueue = NULL;
b9d4105279438 fs/dlm/lowcomms.c     (Namhyung Kim              2010-12-13 13:42:24 -0600 1695) 		return -ENOMEM;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1696) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1697) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1698) 	return 0;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1699) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1700) 
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1701) static void shutdown_conn(struct connection *con)
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1702) {
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1703) 	if (con->shutdown_action)
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1704) 		con->shutdown_action(con);
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1705) }
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1706) 
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1707) void dlm_lowcomms_shutdown(void)
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1708) {
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1709) 	int idx;
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1710) 
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1711) 	/* Set all the flags to prevent any
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1712) 	 * socket activity.
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1713) 	 */
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1714) 	dlm_allow_conn = 0;
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1715) 
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1716) 	if (recv_workqueue)
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1717) 		flush_workqueue(recv_workqueue);
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1718) 	if (send_workqueue)
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1719) 		flush_workqueue(send_workqueue);
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1720) 
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1721) 	dlm_close_sock(&listen_con.sock);
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1722) 
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1723) 	idx = srcu_read_lock(&connections_srcu);
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1724) 	foreach_conn(shutdown_conn);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1725) 	srcu_read_unlock(&connections_srcu, idx);
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1726) }
9d232469bcd77 fs/dlm/lowcomms.c     (Alexander Aring           2021-03-01 17:05:20 -0500 1727) 
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1728) static void _stop_conn(struct connection *con, bool and_other)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1729) {
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1730) 	mutex_lock(&con->sock_mutex);
173a31fe2b23b fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:24 +0000 1731) 	set_bit(CF_CLOSE, &con->flags);
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1732) 	set_bit(CF_READ_PENDING, &con->flags);
8a4abb0819769 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:16 +0000 1733) 	set_bit(CF_WRITE_PENDING, &con->flags);
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000 1734) 	if (con->sock && con->sock->sk) {
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000 1735) 		write_lock_bh(&con->sock->sk->sk_callback_lock);
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1736) 		con->sock->sk->sk_user_data = NULL;
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000 1737) 		write_unlock_bh(&con->sock->sk->sk_callback_lock);
93eaadebe9e1c fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:55 +0000 1738) 	}
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1739) 	if (con->othercon && and_other)
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1740) 		_stop_conn(con->othercon, false);
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1741) 	mutex_unlock(&con->sock_mutex);
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1742) }
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1743) 
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1744) static void stop_conn(struct connection *con)
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1745) {
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1746) 	_stop_conn(con, true);
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1747) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1748) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400 1749) static void connection_release(struct rcu_head *rcu)
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400 1750) {
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400 1751) 	struct connection *con = container_of(rcu, struct connection, rcu);
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400 1752) 
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400 1753) 	kfree(con->rx_buf);
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400 1754) 	kfree(con);
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400 1755) }
4798cbbfbd00c fs/dlm/lowcomms.c     (Alexander Aring           2020-09-24 10:31:26 -0400 1756) 
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1757) static void free_conn(struct connection *con)
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1758) {
0d737a8cfd834 fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2015-08-11 19:22:21 -0300 1759) 	close_connection(con, true, true, true);
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400 1760) 	spin_lock(&connections_lock);
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400 1761) 	hlist_del_rcu(&con->list);
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400 1762) 	spin_unlock(&connections_lock);
948c47e9bcb6a fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:53 -0400 1763) 	if (con->othercon) {
948c47e9bcb6a fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:53 -0400 1764) 		clean_one_writequeue(con->othercon);
5cbec208dc994 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:16 -0500 1765) 		call_srcu(&connections_srcu, &con->othercon->rcu,
5cbec208dc994 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:16 -0500 1766) 			  connection_release);
948c47e9bcb6a fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:53 -0400 1767) 	}
0de984323ac56 fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:52 -0400 1768) 	clean_one_writequeue(con);
5cbec208dc994 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:16 -0500 1769) 	call_srcu(&connections_srcu, &con->rcu, connection_release);
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1770) }
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1771) 
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1772) static void work_flush(void)
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1773) {
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1774) 	int ok;
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1775) 	int i;
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1776) 	struct connection *con;
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1777) 
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1778) 	do {
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1779) 		ok = 1;
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1780) 		foreach_conn(stop_conn);
b355516f45070 fs/dlm/lowcomms.c     (David Windsor             2019-04-02 08:37:10 -0400 1781) 		if (recv_workqueue)
b355516f45070 fs/dlm/lowcomms.c     (David Windsor             2019-04-02 08:37:10 -0400 1782) 			flush_workqueue(recv_workqueue);
b355516f45070 fs/dlm/lowcomms.c     (David Windsor             2019-04-02 08:37:10 -0400 1783) 		if (send_workqueue)
b355516f45070 fs/dlm/lowcomms.c     (David Windsor             2019-04-02 08:37:10 -0400 1784) 			flush_workqueue(send_workqueue);
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1785) 		for (i = 0; i < CONN_HASH_SIZE && ok; i++) {
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400 1786) 			hlist_for_each_entry_rcu(con, &connection_hash[i],
a47666eb763cc fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:49 -0400 1787) 						 list) {
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1788) 				ok &= test_bit(CF_READ_PENDING, &con->flags);
8a4abb0819769 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:16 +0000 1789) 				ok &= test_bit(CF_WRITE_PENDING, &con->flags);
8a4abb0819769 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:16 +0000 1790) 				if (con->othercon) {
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1791) 					ok &= test_bit(CF_READ_PENDING,
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1792) 						       &con->othercon->flags);
8a4abb0819769 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:16 +0000 1793) 					ok &= test_bit(CF_WRITE_PENDING,
8a4abb0819769 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:16 +0000 1794) 						       &con->othercon->flags);
8a4abb0819769 fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 09:01:16 +0000 1795) 				}
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1796) 			}
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1797) 		}
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1798) 	} while (!ok);
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1799) }
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1800) 
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1801) void dlm_lowcomms_stop(void)
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1802) {
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1803) 	int idx;
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1804) 
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1805) 	idx = srcu_read_lock(&connections_srcu);
f0fb83cb9201a fs/dlm/lowcomms.c     (tsutomu.owa@toshiba.co.jp 2017-09-12 08:55:40 +0000 1806) 	work_flush();
3a8db79889ce1 fs/dlm/lowcomms.c     (Marcelo Ricardo Leitner   2016-10-08 10:14:37 -0300 1807) 	foreach_conn(free_conn);
7ae861bbfa0f6 fs/dlm/lowcomms.c     (Alexander Aring           2021-05-21 15:08:35 -0400 1808) 	srcu_read_unlock(&connections_srcu, idx);
1d6e8131cf006 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2007-01-15 14:33:34 +0000 1809) 	work_stop();
043697f030c5c fs/dlm/lowcomms.c     (Alexander Aring           2020-08-27 15:02:50 -0400 1810) 	deinit_local();
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1811) }
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1812) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1813) int dlm_lowcomms_start(void)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1814) {
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1815) 	int error = -EINVAL;
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1816) 	int i;
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1817) 
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1818) 	for (i = 0; i < CONN_HASH_SIZE; i++)
5e9ccc372dc85 fs/dlm/lowcomms.c     (Christine Caulfield       2009-01-28 12:57:40 -0600 1819) 		INIT_HLIST_HEAD(&connection_hash[i]);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1820) 
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1821) 	init_local();
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1822) 	if (!dlm_local_count) {
617e82e10ccf9 fs/dlm/lowcomms.c     (David Teigland            2007-04-26 13:46:49 -0500 1823) 		error = -ENOTCONN;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1824) 		log_print("no local IP address has been set");
513ef596d43cc fs/dlm/lowcomms.c     (David Teigland            2012-03-30 11:46:08 -0500 1825) 		goto fail;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1826) 	}
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1827) 
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1828) 	INIT_WORK(&listen_con.rwork, process_listen_recv_socket);
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1829) 
513ef596d43cc fs/dlm/lowcomms.c     (David Teigland            2012-03-30 11:46:08 -0500 1830) 	error = work_start();
513ef596d43cc fs/dlm/lowcomms.c     (David Teigland            2012-03-30 11:46:08 -0500 1831) 	if (error)
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1832) 		goto fail_local;
513ef596d43cc fs/dlm/lowcomms.c     (David Teigland            2012-03-30 11:46:08 -0500 1833) 
513ef596d43cc fs/dlm/lowcomms.c     (David Teigland            2012-03-30 11:46:08 -0500 1834) 	dlm_allow_conn = 1;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1835) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1836) 	/* Start listening */
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1837) 	if (dlm_config.ci_protocol == 0)
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1838) 		error = tcp_listen_for_all();
6ed7257b46709 fs/dlm/lowcomms.c     (Patrick Caulfield         2007-04-17 15:39:57 +0100 1839) 	else
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1840) 		error = sctp_listen_for_all(&listen_con);
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1841) 	if (error)
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1842) 		goto fail_unlisten;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1843) 
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1844) 	return 0;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1845) 
ac33d07105955 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-12-06 15:10:37 +0000 1846) fail_unlisten:
513ef596d43cc fs/dlm/lowcomms.c     (David Teigland            2012-03-30 11:46:08 -0500 1847) 	dlm_allow_conn = 0;
d11ccd451b655 fs/dlm/lowcomms.c     (Alexander Aring           2020-11-02 20:04:25 -0500 1848) 	dlm_close_sock(&listen_con.sock);
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1849) 	work_stop();
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1850) fail_local:
087f6c68e2ba6 fs/dlm/lowcomms.c     (Alexander Aring           2021-06-02 09:45:15 -0400 1851) 	deinit_local();
513ef596d43cc fs/dlm/lowcomms.c     (David Teigland            2012-03-30 11:46:08 -0500 1852) fail:
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1853) 	return error;
fdda387f73947 fs/dlm/lowcomms-tcp.c (Patrick Caulfield         2006-11-02 11:19:21 -0500 1854) }
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1855) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1856) void dlm_lowcomms_exit(void)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1857) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1858) 	struct dlm_node_addr *na, *safe;
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1859) 
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1860) 	spin_lock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1861) 	list_for_each_entry_safe(na, safe, &dlm_node_addrs, list) {
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1862) 		list_del(&na->list);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1863) 		while (na->addr_count--)
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1864) 			kfree(na->addr[na->addr_count]);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1865) 		kfree(na);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1866) 	}
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1867) 	spin_unlock(&dlm_node_addrs_spin);
36b71a8bfbc92 fs/dlm/lowcomms.c     (David Teigland            2012-07-26 12:44:30 -0500 1868) }