From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mail19.linbit.com (LINBIT Mail Daemon) with ESMTP id 33D90420419 for ; Sat, 13 Jun 2020 11:58:11 +0200 (CEST) Received: by mail-wm1-f68.google.com with SMTP id o8so538462wmh.4 for ; Sat, 13 Jun 2020 02:58:11 -0700 (PDT) Received: from soda.linbit (62-99-137-214.static.upcbusiness.at. [62.99.137.214]) by smtp.gmail.com with ESMTPSA id k12sm14328836wrn.42.2020.06.13.02.58.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 13 Jun 2020 02:58:10 -0700 (PDT) Resent-Message-ID: <20200613095808.GM4222@soda.linbit> Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) by mail19.linbit.com (LINBIT Mail Daemon) with ESMTP id 739EF42041F for ; Thu, 21 May 2020 01:10:04 +0200 (CEST) Received: by mail-qt1-f195.google.com with SMTP id v4so4076418qte.3 for ; Wed, 20 May 2020 16:10:04 -0700 (PDT) From: Marcelo Ricardo Leitner To: Christoph Hellwig Message-ID: <20200520231001.GU2491@localhost.localdomain> References: <20200520195509.2215098-1-hch@lst.de> <20200520195509.2215098-32-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200520195509.2215098-32-hch@lst.de> Cc: Eric Dumazet , linux-nvme@lists.infradead.org, linux-sctp@vger.kernel.org, target-devel@vger.kernel.org, linux-afs@lists.infradead.org, drbd-dev@lists.linbit.com, linux-cifs@vger.kernel.org, rds-devel@oss.oracle.com, linux-rdma@vger.kernel.org, cluster-devel@redhat.com, Alexey Kuznetsov , Jakub Kicinski , ceph-devel@vger.kernel.org, linux-nfs@vger.kernel.org, Neil Horman , Hideaki YOSHIFUJI , netdev@vger.kernel.org, Vlad Yasevich , linux-kernel@vger.kernel.org, Jon Maloy , Ying Xue , "David S. Miller" , ocfs2-devel@oss.oracle.com Subject: Re: [Drbd-dev] [PATCH 31/33] sctp: add sctp_sock_set_nodelay List-Id: "*Coordination* of development, patches, contributions -- *Questions* \(even to developers\) go to drbd-user, please." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Sat, 13 Jun 2020 10:14:17 -0000 On Wed, May 20, 2020 at 09:55:07PM +0200, Christoph Hellwig wrote: > Add a helper to directly set the SCTP_NODELAY sockopt from kernel space > without going through a fake uaccess. > > Signed-off-by: Christoph Hellwig > --- > fs/dlm/lowcomms.c | 10 ++-------- > include/net/sctp/sctp.h | 7 +++++++ > 2 files changed, 9 insertions(+), 8 deletions(-) > > diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c > index 69333728d871b..9f1c3cdc9d653 100644 > --- a/fs/dlm/lowcomms.c > +++ b/fs/dlm/lowcomms.c > @@ -914,7 +914,6 @@ static int sctp_bind_addrs(struct connection *con, uint16_t port) > static void sctp_connect_to_sock(struct connection *con) > { > struct sockaddr_storage daddr; > - int one = 1; > int result; > int addr_len; > struct socket *sock; > @@ -961,8 +960,7 @@ static void sctp_connect_to_sock(struct connection *con) > log_print("connecting to %d", con->nodeid); > > /* Turn off Nagle's algorithm */ > - kernel_setsockopt(sock, SOL_SCTP, SCTP_NODELAY, (char *)&one, > - sizeof(one)); > + sctp_sock_set_nodelay(sock->sk); > > /* > * Make sock->ops->connect() function return in specified time, > @@ -1176,7 +1174,6 @@ static int sctp_listen_for_all(void) > struct socket *sock = NULL; > int result = -EINVAL; > struct connection *con = nodeid2con(0, GFP_NOFS); > - int one = 1; > > if (!con) > return -ENOMEM; > @@ -1191,10 +1188,7 @@ static int sctp_listen_for_all(void) > } > > sock_set_rcvbuf(sock->sk, NEEDED_RMEM); > - result = kernel_setsockopt(sock, SOL_SCTP, SCTP_NODELAY, (char *)&one, > - sizeof(one)); > - if (result < 0) > - log_print("Could not set SCTP NODELAY error %d\n", result); > + sctp_sock_set_nodelay(sock->sk); > > write_lock_bh(&sock->sk->sk_callback_lock); > /* Init con struct */ > diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h > index 3ab5c6bbb90bd..f8bcb75bb0448 100644 > --- a/include/net/sctp/sctp.h > +++ b/include/net/sctp/sctp.h > @@ -615,4 +615,11 @@ static inline bool sctp_newsk_ready(const struct sock *sk) > return sock_flag(sk, SOCK_DEAD) || sk->sk_socket; > } > > +static inline void sctp_sock_set_nodelay(struct sock *sk) > +{ > + lock_sock(sk); > + sctp_sk(sk)->nodelay = true; > + release_sock(sk); > +} > + The duplication with sctp_setsockopt_nodelay() is quite silly/bad. Also, why have the 'true' hardcoded? It's what dlm uses, yes, but the API could be a bit more complete than that. Like for the other patch, this one could build on David's patch, do the ternary check before calling sctp_setsockopt_nodelay and then move sctp_setsockopt_nodelay to the header, or something like that.