Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2475576pxm; Sun, 27 Feb 2022 22:55:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNAOKtYh51uXXQS5Ct128kfqqnBJQaVGEu6jEuOvZ2YDqI+17wC90jMiSnekYlf/NPPXVC X-Received: by 2002:a17:906:2bc1:b0:6cf:d009:7f6b with SMTP id n1-20020a1709062bc100b006cfd0097f6bmr14025040ejg.17.1646031353600; Sun, 27 Feb 2022 22:55:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646031353; cv=none; d=google.com; s=arc-20160816; b=LhDFmE0UTd5X0U50LAQrgAfmKAUvFINN29Fe5mOFA4j/MYz0uqp5O4OmGmGVTBs7Dd JCOT6wTDSZeXZP6pdg7Q8KEK53cGGaVydC3UrbsBUvKnzP3cl9Bt4/m/6DoTdtmjJ02w TXtMD990GDHWhYKJzIYBfmZMJIP5kiz9sNgNJq++xHyAsp00ELF77RUMps5KH2VjC6LT 6a+grbwYDSxU/+ZD7bvyJBNYKcAWsZaV/NkcexAxXACivVSkarOqSxl92YE+FR0SUgF/ baAoaK8vos3FsVdNhlHbZNdqc+rKiW+Y1yDeBa9G6xseRNMya/2dywTjA2cwwYQmVuK7 ZvaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=oHRzmjmOQRwrczEl5cn+/4pPpiWmRGeE4ByFDiWhXKg=; b=VTFEEv9H7SCCqWj/4bqW7U+S4wLSThksH1gWzZoFXTZOzpVSiZDHY74eDiBtiSurgz 3Fu55/Vg9o6l03hjnM3JieQXALN4ObI8WlpainwhL05aRrvPF0fnENrji2S4jNDMajhX cnLX3vocrLzLou4fgfB/UwEHC561E3M4wuDwfz0FizmRRt+MnC24JJn7Y2a/X+Bh0t4x yyRXbyL80EuAs4uh3qXCgZGWGL4Aug1xrPzBakmWhWUHjqzedNRPTitDbs3wCvevAptH ozZXoTd5uVToKmHbANIUGvNlUZjde3TrJ7TQ5pSVA/DWJZD5xZj6aVQPq2zhaDdCvLQ+ Mmbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HiPvxh3i; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=Q4MTEINa; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss5-20020a170907038500b006b4541eb81asi6071441ejb.744.2022.02.27.22.55.29; Sun, 27 Feb 2022 22:55:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HiPvxh3i; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=Q4MTEINa; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231686AbiB1DAw (ORCPT + 99 others); Sun, 27 Feb 2022 22:00:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231558AbiB1DAw (ORCPT ); Sun, 27 Feb 2022 22:00:52 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3252A3A5CB for ; Sun, 27 Feb 2022 19:00:13 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CD55821107; Mon, 28 Feb 2022 03:00:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1646017211; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oHRzmjmOQRwrczEl5cn+/4pPpiWmRGeE4ByFDiWhXKg=; b=HiPvxh3iwln/l4kLO8LFNiKOJdzLjVWsuqGiVEddWMyZ5TQUE+M4elTHJa6xjG/8WvbVV+ 4HI6BZhj6jaEz9+oDqBbShPJKCSRGYIEY3PqpPD2DnrLG73L1Mwt8UGiJtxQeaab/IJ9mO SM8NjBeysvfcgUwE1ua8B0rTYCFsLxs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1646017211; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oHRzmjmOQRwrczEl5cn+/4pPpiWmRGeE4ByFDiWhXKg=; b=Q4MTEINar/4umDFA+RNdve9eNdrbVL2s049CRk7TgGkKwvwfvNyqzAoBU8jY4L8rWKm59x PnrT9OR5uGHeGaAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9D439139BD; Mon, 28 Feb 2022 03:00:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id tU51Frk6HGIgWwAAMHmgww (envelope-from ); Mon, 28 Feb 2022 03:00:09 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: "Olga Kornievskaia" Cc: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, linux-nfs@vger.kernel.org Subject: Re: [PATCH v10 10/13] sunrpc: add dst_attr attributes to the sysfs xprt directory In-reply-to: <20210608195922.88655-11-olga.kornievskaia@gmail.com> References: <20210608195922.88655-1-olga.kornievskaia@gmail.com>, <20210608195922.88655-11-olga.kornievskaia@gmail.com> Date: Mon, 28 Feb 2022 14:00:03 +1100 Message-id: <164601720393.12951.15824905969343983450@noble.neil.brown.name> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, 09 Jun 2021, Olga Kornievskaia wrote: > From: Olga Kornievskaia > > Allow to query and set the destination's address of a transport. > Setting of the destination address is allowed only for TCP or RDMA > based connections. > > Signed-off-by: Olga Kornievskaia > --- > include/linux/sunrpc/xprt.h | 1 + > net/sunrpc/sysfs.c | 105 ++++++++++++++++++++++++++++++++++++ > net/sunrpc/xprt.c | 4 +- > net/sunrpc/xprtmultipath.c | 2 - > 4 files changed, 109 insertions(+), 3 deletions(-) > .... > +static ssize_t rpc_sysfs_xprt_dstaddr_store(struct kobject *kobj, > + struct kobj_attribute *attr, > + const char *buf, size_t count) > +{ > + struct rpc_xprt *xprt = rpc_sysfs_xprt_kobj_get_xprt(kobj); > + struct sockaddr *saddr; > + char *dst_addr; > + int port; > + struct xprt_addr *saved_addr; > + size_t buf_len; > + > + if (!xprt) > + return 0; > + if (!(xprt->xprt_class->ident == XPRT_TRANSPORT_TCP || > + xprt->xprt_class->ident == XPRT_TRANSPORT_RDMA)) { > + xprt_put(xprt); > + return -EOPNOTSUPP; > + } > + > + if (wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_KILLABLE)) { > + count = -EINTR; > + goto out_put; > + } A bit late to this party, however... This use of wait_on_bit_lock() is not safe. Wake_up events are only generated on XPRT_LOCKED when connect completes (xprt_unlock_connect()) and when xprt_autoclose() runs. Most of the time when a socket is active, this flag is often set and cleared without any wakeup - or without a wakeup which would wake this waiter. There is usually an rpc_wakeup_first_on_queue(). So if this sysfs function is called while XPRT_LOCKED it set, it will block until killed or the connection is closed. xs_enable_swap() has a similar problem, and this has failed in practice. An easy fix would be to add a wake_up_bit() call in xprt_clear_locked() so that we always get that wakeup. I'm not sure that is a good idea though, is this wakeup is almost always unnecessary. For xs_enable_swap() a better solution is to use ->recv_mutex to provide the required exclusion. It isn't clear to me what exclusion this function actually needs, so I cannot suggest an alternate way to provide it. rpc_sysfs_xprt_state_change() has the same problem. NeilBrown