Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2961072pxj; Mon, 17 May 2021 14:11:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2VC3moXKo9nUv0yKK/ZCtZ9C75AwjiVMmyUqf1g0s7iMvY7stwlEb0CdCAvocogt+zcRJ X-Received: by 2002:a17:906:b1cc:: with SMTP id bv12mr1892926ejb.407.1621285914848; Mon, 17 May 2021 14:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621285914; cv=none; d=google.com; s=arc-20160816; b=km4wDDT/i8bL8QExx7qniY0Tj1WqCGppG4JUj54TiI0yRYS/tg+tq3ZbIJnieCsgsH rW+sDAxEN2+MJO3y4iQeb34UX29JllXRH2iAFuF8qPn7DtDldMFyidh1xwtiSV3q04DN NgSV6ScgM82O/uGgDZRXwH/kbq2GDnqf2NJKoqz013jWVKnccohsrt1PNaJV5PzPiPcN 5015afBxd22cy3c0i4RMw6kR9e01T8DOLIqHinQHWesHSloeGj0dkzgL9cNScV/LpaA4 gfkBk8T/uMHQaE4DDTV21o/BcmYsDDPz26TCsVVhjZvwucSnyOKCZOKHh6h51S+6rPMg dH7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=C9y8Di+ZmGAy+AhvBYJTi6oH+PRqFJVM+Cfkf2HBj8Y=; b=wK8dQgn4jr/LNtKvZGQO+HxQ5eYp/ZBxRdeZeYKB/kZpDsspe4jJHmc93E/9s6dm3r CakQO/BmTH5ww4WiJfyZOWqyBUGPzwOf+MuT55OQTRF8B9p6YJwKeUO1Xx3OWYrl7OXK our93xlSHreomReUggi0HO8oxyHnGOrpSn6SJChmUCy6m4C0N0Pn2tCEHIQrwIstYcRY RqiNIY8lyJyUz5lADqc+5aCy19oNFoBhYcm7sLoGzUDLviwuWOnZzn6FHw08xwgUmGmu xz2pKCXksN8qbBEJkZdAuq5TOuGcfiFC4BFdJhQ68okfIMH4g7xwu4wAVvx60IHuTwS0 sIMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lTVa1tae; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ho39si12585687ejc.563.2021.05.17.14.11.31; Mon, 17 May 2021 14:11:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lTVa1tae; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237956AbhEQOG4 (ORCPT + 99 others); Mon, 17 May 2021 10:06:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:58348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237724AbhEQOGZ (ORCPT ); Mon, 17 May 2021 10:06:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A2F9E6134F; Mon, 17 May 2021 14:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260295; bh=enauJ4tfxKuj7xTzid0znNmpPZsCNml1AHecJf3h3CM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lTVa1taed9h4bpMt4FRRN3A7bF04oXfI3ADw9hBryGL/YrbQEkgK6SCirX+3BEfDb nd5uz6RZASx4/Q04VecwsWwOrg59w0bzr8/HXqPpELH+cXyJ1df7HP7rbHqQgaBfGs gvMy+vj9uWM4RNqHQzpOT/h6wM6CSqrijcgxAB4o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Aring , David Teigland , Sasha Levin Subject: [PATCH 5.12 017/363] fs: dlm: add check if dlm is currently running Date: Mon, 17 May 2021 15:58:03 +0200 Message-Id: <20210517140303.164855833@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Aring [ Upstream commit 517461630d1c25ee4dfc1dee80973a64189d6ccf ] This patch adds checks for dlm config attributes regarding to protocol parameters as it makes only sense to change them when dlm is not running. It also adds a check for valid protocol specifiers and return invalid argument if they are not supported. Signed-off-by: Alexander Aring Signed-off-by: David Teigland Signed-off-by: Sasha Levin --- fs/dlm/config.c | 34 ++++++++++++++++++++++++++++++++-- fs/dlm/lowcomms.c | 2 +- fs/dlm/lowcomms.h | 3 +++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/fs/dlm/config.c b/fs/dlm/config.c index 8439610c266a..88d95d96e36c 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c @@ -164,6 +164,36 @@ static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \ } \ CONFIGFS_ATTR(cluster_, name); +static int dlm_check_protocol_and_dlm_running(unsigned int x) +{ + switch (x) { + case 0: + /* TCP */ + break; + case 1: + /* SCTP */ + break; + default: + return -EINVAL; + } + + if (dlm_allow_conn) + return -EBUSY; + + return 0; +} + +static int dlm_check_zero_and_dlm_running(unsigned int x) +{ + if (!x) + return -EINVAL; + + if (dlm_allow_conn) + return -EBUSY; + + return 0; +} + static int dlm_check_zero(unsigned int x) { if (!x) @@ -180,7 +210,7 @@ static int dlm_check_buffer_size(unsigned int x) return 0; } -CLUSTER_ATTR(tcp_port, dlm_check_zero); +CLUSTER_ATTR(tcp_port, dlm_check_zero_and_dlm_running); CLUSTER_ATTR(buffer_size, dlm_check_buffer_size); CLUSTER_ATTR(rsbtbl_size, dlm_check_zero); CLUSTER_ATTR(recover_timer, dlm_check_zero); @@ -188,7 +218,7 @@ CLUSTER_ATTR(toss_secs, dlm_check_zero); CLUSTER_ATTR(scan_secs, dlm_check_zero); CLUSTER_ATTR(log_debug, NULL); CLUSTER_ATTR(log_info, NULL); -CLUSTER_ATTR(protocol, NULL); +CLUSTER_ATTR(protocol, dlm_check_protocol_and_dlm_running); CLUSTER_ATTR(mark, NULL); CLUSTER_ATTR(timewarn_cs, dlm_check_zero); CLUSTER_ATTR(waitwarn_us, NULL); diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index a4fabcced0f2..0f7fa23cccf0 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c @@ -135,7 +135,7 @@ static DEFINE_SPINLOCK(dlm_node_addrs_spin); static struct listen_connection listen_con; static struct sockaddr_storage *dlm_local_addr[DLM_MAX_ADDR_COUNT]; static int dlm_local_count; -static int dlm_allow_conn; +int dlm_allow_conn; /* Work queues */ static struct workqueue_struct *recv_workqueue; diff --git a/fs/dlm/lowcomms.h b/fs/dlm/lowcomms.h index 790d6703b17e..bcd4dbd1dc98 100644 --- a/fs/dlm/lowcomms.h +++ b/fs/dlm/lowcomms.h @@ -14,6 +14,9 @@ #define LOWCOMMS_MAX_TX_BUFFER_LEN 4096 +/* switch to check if dlm is running */ +extern int dlm_allow_conn; + int dlm_lowcomms_start(void); void dlm_lowcomms_stop(void); void dlm_lowcomms_exit(void); -- 2.30.2