From patchwork Wed Apr 17 18:46:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13633756 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B23CB847B for ; Wed, 17 Apr 2024 18:46:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379620; cv=none; b=U6Y0oHfF6X0xdqhGmynoHB7NSWc8WZSfeuBp6TtK5P4KVNLCzOTcbrDlztxQSvbIE82bCl1h9V7SFG/7kAgSo27nmp+sPKbSXGQir71qwCkUz/hL/WyW1FxrN5S9FScPc7kD3MIGwF++GD+dVpQG81s34BchvVqVxHlUHzjb4eI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379620; c=relaxed/simple; bh=s9dyK21a7pWs+n6tABOXXWZb6Odu9ksSkFib26+qHgI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KBwTxtRORVKt9tSfrjK/DI1g0lJfGzolgA5YUf/KgmeiPZV6TpbQ1rldr2e8/HlFv1rSbLfDYjKl2w5QO0NvKTU8G2/lMMPePxvDm407xOW9quzfLn3OQOhFVuPJQ9/s6SvHWc1hWat+aXZ06soc/pMQKwaUwFeHvp+0aw32soc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=WbFFXmLf; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="WbFFXmLf" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a52aa665747so459001066b.2 for ; Wed, 17 Apr 2024 11:46:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1713379616; x=1713984416; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JfrczQHfKohV7iNu1KOXTKLy5m7zYzOKvS0wp3qYKgw=; b=WbFFXmLfZOLXLc9iOANEyYtgJfJtyzLxnAxqyiroRPIxHOLlOII8imCCGzL9AekT3S neGO8v4zZN1vfq230UPsVnsqkPEDo+pLL61or6JVB5ILpjS9MkNsfGSlu8FHIh74Bvlo RGKrcxU+GYh2VdK1UmGrqqFcYh2tETCkRu5hR4VOqVZ2yYJxDnpaCzXufJhoC7jTleW3 WqhmJzS5FDcrcc3e/xN9TR0r7JboSmbwZj26NkWWGqH30LZt8rtVF/JmIpamD6Qr1hKQ 0ZqQ3Zaf8BsQ3/2Pz8Cnpk1g1JT4JqsK2y0UMbBh/w3yT1b1VMGDswoEM2FEoRbhhJyM GqTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713379616; x=1713984416; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JfrczQHfKohV7iNu1KOXTKLy5m7zYzOKvS0wp3qYKgw=; b=TdoYhT/OlE+jmj4EowviAkAdULggGs74alwplF7VtNh38Ac9gyBGktKZSAGsWAqpZ0 vECssbAc55TogqCK8w5Hsryd8eq1ycPeeICJnJtB2zR5UBng+wN3cFjai2Hu1NwBx68K F4mk6UFUM74YmDUDhUWhX5279h+G/7V+9BmqjEG7Z5hDWXDrWK+HT8wp67D29m34U+27 UQV+S9OoqWC/kxy7BxQ1297wjzrRUKOVkrxa8aMxF/oCeTk7ZepGRjeznW8iG30Y3FD/ uA9pAzKC3veyqHbv9GxBbc7MVsKQXcqK4sDtWd9NY8fI461bd6jrXmiM3C5MRinh+F41 8DQQ== X-Gm-Message-State: AOJu0Yz5W0MaaDCXU0Y16ld9sypl5zDJGENnKn//YHeqSPdLigM0h9gb 4RQ6B8r9mFbU5B7DM3dyXZFZcJ+u2udufmVHhQ+aQBs0bqkWjv7naQYlyuvRgSg= X-Google-Smtp-Source: AGHT+IE9+Ljs4As2t4B5X1m64th49dTXa0foQL7TmjEjFPsZlXWFmHRBM9FaOYuYe19avixJX36oCQ== X-Received: by 2002:a17:906:b4b:b0:a52:6b5f:fc67 with SMTP id v11-20020a1709060b4b00b00a526b5ffc67mr197044ejg.61.1713379615893; Wed, 17 Apr 2024 11:46:55 -0700 (PDT) Received: from localhost (dslb-090-186-231-154.090.186.pools.vodafone-ip.de. [90.186.231.154]) by smtp.gmail.com with UTF8SMTPSA id wk11-20020a170907054b00b00a525a18f748sm5217630ejb.165.2024.04.17.11.46.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Apr 2024 11:46:54 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, Etienne AUJAMES Subject: [PATCH 1/8] multipath-tools: add TGTDIR option Date: Wed, 17 Apr 2024 20:46:37 +0200 Message-ID: <20240417184644.6193-2-mwilck@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417184644.6193-1-mwilck@suse.com> References: <20240417184644.6193-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 TGTDIR is a convenience option for developers for building multipath-tools such that compiled-in paths of the plugins, config files, etc. match an installation under some optional path. See README.md for instructions and examples. Signed-off-by: Martin Wilck --- .github/actions/spelling/expect.txt | 2 ++ Makefile.inc | 8 +++---- README.md | 33 +++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 5906403..fc9f22f 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -167,6 +167,7 @@ retrigger rhabarber rootprefix rootprefixdir +rpmbuild rport rtpi sas @@ -200,6 +201,7 @@ tcp TESTDEPS testname tgill +TGTDIR TIDS tmo tpg diff --git a/Makefile.inc b/Makefile.inc index 5668e63..81b86cd 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -101,9 +101,9 @@ WARNFLAGS := -Werror -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implici $(WNOCLOBBERED) -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) $(W_URCU_TYPE_LIMITS) CPPFLAGS := $(FORTIFY_OPT) $(CPPFLAGS) $(D_URCU_VERSION) \ -D_FILE_OFFSET_BITS=64 \ - -DBIN_DIR=\"$(bindir)\" -DMULTIPATH_DIR=\"$(plugindir)\" \ - -DRUNTIME_DIR=\"$(runtimedir)\" -DCONFIG_DIR=\"$(configdir)\" \ - -DDEFAULT_CONFIGFILE=\"$(configfile)\" -DSTATE_DIR=\"$(statedir)\" \ + -DBIN_DIR=\"$(bindir)\" -DMULTIPATH_DIR=\"$(TGTDIR)$(plugindir)\" \ + -DRUNTIME_DIR=\"$(runtimedir)\" -DCONFIG_DIR=\"$(TGTDIR)$(configdir)\" \ + -DDEFAULT_CONFIGFILE=\"$(TGTDIR)$(configfile)\" -DSTATE_DIR=\"$(TGTDIR)$(statedir)\" \ -DEXTRAVERSION=\"$(EXTRAVERSION)\" -MMD -MP CFLAGS := -std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe BIN_CFLAGS := -fPIE -DPIE @@ -149,4 +149,4 @@ NV_VERSION_SCRIPT = $(DEVLIB:%.so=%-nv.version) %: %.in @echo creating $@ - $(Q)sed 's:@CONFIGFILE@:'$(configfile)':g;s:@CONFIGDIR@:'$(configdir)':g;s:@STATE_DIR@:'$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g;s/@MODPROBE_UNIT@/'$(MODPROBE_UNIT)'/g;s:@BINDIR@:'$(bindir)':g' $< >$@ + $(Q)sed 's:@CONFIGFILE@:'$(TGTDIR)$(configfile)':g;s:@CONFIGDIR@:'$(TGTDIR)$(configdir)':g;s:@STATE_DIR@:'$(TGTDIR)$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g;s/@MODPROBE_UNIT@/'$(MODPROBE_UNIT)'/g;s:@BINDIR@:'$(bindir)':g' $< >$@ diff --git a/README.md b/README.md index d4f35f5..7207b14 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,39 @@ sufficient control. See `Makefile.inc` for even more fine-grained control. On such distributions, override `unitdir` and `libudevdir` to use systemd's `rootprefix`: `make libudevdir=/lib/udev unitdir=/lib/systemd/system` +### prefix, DESTDIR and TGTDIR + +`prefix` and related variables are included in compiled-in paths like +`plugindir` and are used by `make install`. Using `prefix` is useful if +multipath-tools is built locally on the same host where it's supposed to be +installed. + +By convention, the `DESTDIR` variable is prepended to all paths by `make +install`, but not to any compiled-in paths. +It is useful if the software is built on one system (build host) but intended +to be run on another system (installation host). This is typically used in build +systems like *rpmbuild* to set a root directory for all the installed +files. + +On the contrary, the `TGTDIR` variable is used for compiled-in paths only, and +ignored by `make install`. It is useful for running multipath-tools in a separate +subdirectory in the installation host, mostly for testing / development +purposes. + +For example, + + make prefix=/opt DESTDIR=/build TGTDIR=/test install + +will install plugins into `/build/opt/lib64/multipath` on the build +host. On the installation host, the plugins will be expected to be found under +`/test/opt/lib64/multipath`. If the developer runs + + rsync -a $BUILD_HOST:$DESTDIR/ $INSTALL_HOST:$TGTDIR/ + +and adds `$TGTDIR/lib64` to `LD_LIBRARY_PATH` on the installation host, the +multipath binaries installed under `$TGTDIR` will find their plugins and +configuration files in the expected compiled-in paths. + ### Compiler Options Use `OPTFLAGS` to change optimization-related compiler options; From patchwork Wed Apr 17 18:46:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13633757 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 908CE14A96 for ; Wed, 17 Apr 2024 18:46:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379620; cv=none; b=k6sCSsOWh93TpzXF/5D3z6nivc/5NWpKEX1+yxhtorn1n5v92xpBkbWArDxga3vrduQU+NOAed7ysNHnWYJPZFeuVY9j30u89uGPAo83sxkcanqksNg4KPi6J011iSCj1TRIFhFmuUYcrBazG2cJ8PzgkG8Qgk2f4QwUe+MKTdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379620; c=relaxed/simple; bh=TpEX0GK1rQQ/Xpklw3SopwVXaYIqxOhb7DH2DJKMsCY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XliLlXt/JyRh+xWQL3uZEqdTctvfDCbuvf/us3JryuE4T6OmM8wxZxVS7Kzj2svSZN3HBgfecgmVkgjnRPAn/eGHi66KmX2PR51DpqxmkPCeFjUxhLOL0NlQiPh15p1Mflnz6hsDPo4hYN+Bv/A8Ijlb26hXfK/XpCllL87DWbE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=bV0dqyZ0; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="bV0dqyZ0" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a51beae2f13so693239966b.1 for ; Wed, 17 Apr 2024 11:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1713379617; x=1713984417; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lSEbmtP17uf1+bU90SODFrwuyJTQShZqEa2GOWESEX0=; b=bV0dqyZ090ubeL8QtAZGoerVds56raU1UyuzgF7CbMatAifJBPtigbGD2R5yAZPzdn wmpZVDFfne+zCFMLDi3lD5y1ba2Us6CuWKBD1mQYJm64UGU3ZDioSLpa0dtSAeVlsKoS 5mn/y2fku+HzQojBYOm1M3+bdwbTSXFn9T1mI6q7NJishgupbHZx+tBX/S1NPYJh4UD+ bBUFv5wTQfF7cRrl+LtjA8asmf59AabH7rgVP3ryQzyaAfzdzZJfUzyxFvs4BDV1ldfJ ftgAmjx1OmIpdT05JXMk3nr42+PRdBsryRGF66eHT/4KygY61l1oYUFI9ET5hazXL24V Lggw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713379617; x=1713984417; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lSEbmtP17uf1+bU90SODFrwuyJTQShZqEa2GOWESEX0=; b=ZqrhhqWwTgCqzrfTgiY9lxcl9gr2rEmwg6c7PKE/q8bw9xPpjvQw+WF5l0r7d4Wcfr XjCPXLTLC9PCRR5Ys3okzuMXd1wUKFdaEb7ToMzf0WTss+7doRD+IQ4zwbjmWkwFW9U1 kVRaMfBTGzzVGDuw5HqHewi89YjOYAGaXV/3RtkaBNzxfMAwr58fSrxsCcPino4ugKxU 0kpQVnk94VCgojo0NN1ih/7FP5ZITixI0FGp3zVn6NDFTrqEwQTM1JJmkzluOdg1ocJo ClTqLpM3+NxGotMm1sNrke/L84Mgea1TjW0pajaA52AcAVDZC7SDC0XhTYGpNn2N1z3t VgtQ== X-Gm-Message-State: AOJu0YwhcCAbcKgY5byU9Ea/9h7I9MwXo1Lqa94TXVDN/Ch1Znt5XA1Z oEHsZZOB5IwhiSQOXr90dDEiwf4kNCP7YvNMfD++doXiwRqCGssDMLEB4HCtGPI= X-Google-Smtp-Source: AGHT+IF8YGJ8FHkPm+sOzRRZDx9VM3w5Ej7TIxYCEaAu7OcNkcTakixSqmBQPKFJT6JKYvMuGwIWvQ== X-Received: by 2002:a17:906:11d2:b0:a55:653b:3981 with SMTP id o18-20020a17090611d200b00a55653b3981mr201621eja.50.1713379616874; Wed, 17 Apr 2024 11:46:56 -0700 (PDT) Received: from localhost (dslb-090-186-231-154.090.186.pools.vodafone-ip.de. [90.186.231.154]) by smtp.gmail.com with UTF8SMTPSA id q5-20020a170906360500b00a51da296f66sm8357746ejb.41.2024.04.17.11.46.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Apr 2024 11:46:56 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, Etienne AUJAMES Subject: [PATCH 2/8] libmultipath: move get_udev_for_mpp to sysfs.c Date: Wed, 17 Apr 2024 20:46:38 +0200 Message-ID: <20240417184644.6193-3-mwilck@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417184644.6193-1-mwilck@suse.com> References: <20240417184644.6193-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 No functional changes, just code movement. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 20 -------------------- libmultipath/sysfs.c | 19 +++++++++++++++++++ libmultipath/sysfs.h | 4 ++++ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 4ecf6ba..89ac03d 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -453,26 +453,6 @@ pgcmp (struct multipath * mpp, struct multipath * cmpp) return r; } -static struct udev_device * -get_udev_for_mpp(const struct multipath *mpp) -{ - dev_t devnum; - struct udev_device *udd; - - if (!mpp || !has_dm_info(mpp)) { - condlog(1, "%s called with empty mpp", __func__); - return NULL; - } - - devnum = makedev(mpp->dmi.major, mpp->dmi.minor); - udd = udev_device_new_from_devnum(udev, 'b', devnum); - if (!udd) { - condlog(1, "failed to get udev device for %s", mpp->alias); - return NULL; - } - return udd; -} - void trigger_partitions_udev_change(struct udev_device *dev, const char *action, int len) { diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c index 328951e..afe9de9 100644 --- a/libmultipath/sysfs.c +++ b/libmultipath/sysfs.c @@ -339,3 +339,22 @@ bool sysfs_is_multipathed(struct path *pp, bool set_wwid) return found; } + +struct udev_device *get_udev_for_mpp(const struct multipath *mpp) +{ + dev_t devnum; + struct udev_device *udd; + + if (!mpp || !has_dm_info(mpp)) { + condlog(1, "%s called with empty mpp", __func__); + return NULL; + } + + devnum = makedev(mpp->dmi.major, mpp->dmi.minor); + udd = udev_device_new_from_devnum(udev, 'b', devnum); + if (!udd) { + condlog(1, "failed to get udev device for %s", mpp->alias); + return NULL; + } + return udd; +} diff --git a/libmultipath/sysfs.h b/libmultipath/sysfs.h index 2db86bd..3be3f66 100644 --- a/libmultipath/sysfs.h +++ b/libmultipath/sysfs.h @@ -39,4 +39,8 @@ do { \ int sysfs_get_size (struct path *pp, unsigned long long * size); int sysfs_check_holders(char * check_devt, char * new_devt); bool sysfs_is_multipathed(struct path *pp, bool set_wwid); + +struct multipath; +struct udev_device *get_udev_for_mpp(const struct multipath *mpp); + #endif From patchwork Wed Apr 17 18:46:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13633758 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7370D171A1 for ; Wed, 17 Apr 2024 18:46:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379621; cv=none; b=dMTB5pH9c5OPCR8Th1HQAZhRbrWmuETcEm+0+A3ooYJmm4cpyzibP2+oxlt9JBVX4Y0xv9pQl9kLd17T+66rQlb8TPsXhwKZ+wo9XAZ1FlSB9lP8Y3by3D+T/2hKQ4oF4dXIYlw1k5riokJo3QdiN1G+ynNnNPrBRNdcxUw6NzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379621; c=relaxed/simple; bh=IsP5IV+jUQFxbgWNWPmpLEVlqwWF7aCK6IkgNOwRwis=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B5JEDNmZZZFNOJ1/sGGlFl0U254l1/gV06NwxavWQQnzQH77IcYZPbXhOBliWEhR0cPDLS27EJR6Gyy7vtMZ9PcwHaHKAcDLWlKypMvJPFLBDzNsasJ/qW5Hwj4N7fXKSYassgKAvnC6TCFqTtZ1w7c27JcZP/3i8HPvjAxgU0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=CKTL//7R; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="CKTL//7R" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a524ecaf215so580354566b.2 for ; Wed, 17 Apr 2024 11:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1713379618; x=1713984418; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JpYhjYm5FDWPMTBd0ATasJ02QXsCYM7X2shAUnSlddc=; b=CKTL//7RU03zukgAa1pWc+LWj37V/1TEcO29S+8iOW/WpIy6XSE+Ud8S3ZMOBxXFMy Rpgmknk7qUTSNWr6istBeeBzS0ugL+qoVqb3hyqxlln6sER+A+JuBf2/9QpIbQPstezS 8697wNP+93Qut+pIWmcEF7dlWRQkSeyMUrKQ4g62XL/EYqKMqLvdoQ8jZ9yt4h+AnMGe IKjvgHrXLXyUfDMujOgaFUuYupzzOVREgCzveWcQwyLjxXLy+k1NGzPKmo0jhbA2qprj vCQLf9IJQREAlKHl0Nhtp2zRACs82zDT8yL/tSJro+MCDNL62w+q2ORP+rJZ/lpAsCdr 4XrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713379618; x=1713984418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JpYhjYm5FDWPMTBd0ATasJ02QXsCYM7X2shAUnSlddc=; b=qkfWKDHVBnaUJolztlLmwgybGJlhaDa4wmrWsbn1KNth/94ONd0LfskbSyixRaDHyB QI9GBh8kI74Vu0WmAv/lVoW4WJGb7BG22cAQ9017zMQ17XWKgFW16BCnKXHLh923zO+Z 2PyyyeZUD4csVB8CR5FAjgVC7HbOBtNPmHsZWg9xUUT/J8MYMpiHXvak/JsQ/B77EGZx PqdALpnKGwCGlKxD7+3YSD2k1mE/CyP4jLjv2ecjeDt6V2ZlQAnhOeXGBphh/jg76XnX HWAdgqizf21JY4gMOrVWLKrGauuydF8DowgfgBCEfTEfR5VSwogsegT31zIs45eaywaJ TwNQ== X-Gm-Message-State: AOJu0YydntJqaG+wif1cb9R6p6C561DhqCVFW+mewkkb7kaV5Mc6ZZac Om2HCaROmnQll4zzdOgoxcrRcb8Og9LOFEBEh6KKQ1mrqcg6gmyjJW+l6SzrNqw= X-Google-Smtp-Source: AGHT+IHuFZabrMcTmZJTrQcb8bd5TvkeQUXfj5FlVhmlCBkFVFRpGl1QQVyEyBLsUHAFgtUfEJO5RQ== X-Received: by 2002:a17:906:4151:b0:a52:c873:a66 with SMTP id l17-20020a170906415100b00a52c8730a66mr249758ejk.34.1713379617824; Wed, 17 Apr 2024 11:46:57 -0700 (PDT) Received: from localhost (dslb-090-186-231-154.090.186.pools.vodafone-ip.de. [90.186.231.154]) by smtp.gmail.com with UTF8SMTPSA id f18-20020a170906391200b00a5546604a5asm2235209eje.104.2024.04.17.11.46.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Apr 2024 11:46:57 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, Etienne AUJAMES Subject: [PATCH 3/8] libmultipath: add mp_find_path_by_devt() Date: Wed, 17 Apr 2024 20:46:39 +0200 Message-ID: <20240417184644.6193-4-mwilck@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417184644.6193-1-mwilck@suse.com> References: <20240417184644.6193-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A helper function that searches a struct multipath by dev_t, and works whether or not mpp->paths is currently available. Signed-off-by: Martin Wilck --- libmultipath/structs.c | 19 +++++++++++++++++++ libmultipath/structs.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/libmultipath/structs.c b/libmultipath/structs.c index 74e31a1..e248fb5 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -526,6 +526,25 @@ find_path_by_devt (const struct _vector *pathvec, const char * dev_t) return NULL; } +struct path *mp_find_path_by_devt(const struct multipath *mpp, const char *devt) +{ + struct path *pp; + struct pathgroup *pgp; + unsigned int i, j; + + pp = find_path_by_devt(mpp->paths, devt); + if (pp) + return pp; + + vector_foreach_slot (mpp->pg, pgp, i){ + vector_foreach_slot (pgp->paths, pp, j){ + if (!strcmp(pp->dev_t, devt)) + return pp; + } + } + return NULL; +} + static int do_pathcount(const struct multipath *mpp, const int *states, unsigned int nr_states) { diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 734905e..a25eb9d 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -568,6 +568,9 @@ struct path * find_path_by_devt (const struct _vector *pathvec, const char *devt struct path * find_path_by_dev (const struct _vector *pathvec, const char *dev); struct path * first_path (const struct multipath *mpp); +struct path *mp_find_path_by_devt(const struct multipath *mpp, const char *devt); + + int pathcount (const struct multipath *, int); int count_active_paths(const struct multipath *); int count_active_pending_paths(const struct multipath *); From patchwork Wed Apr 17 18:46:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13633759 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EB60171A5 for ; Wed, 17 Apr 2024 18:47:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379622; cv=none; b=VUJM11vCER8jV6Kr+HGRaY32TvSWhGxHxX/mpYuo4TwXPGsKafmhjZyjtzaRBs6xk156q1ENLCI1LQxu0bEV2masyUOrbbE+H8HbVQPuBNQFcHv1IfYkFyuxpNDV3kIR5esBze+ZYHNzsczTO2sgZHYFU243sv6Kkbq//JzU0yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379622; c=relaxed/simple; bh=SO0DtHDuegnhT+Y8X0OaIOd3Q0R7Ey+XxiapKg6hVrM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZhrZp1BoLx7mdq4W1sMmO2JMckEqT46R5lpCXZMQvxDHMco6cLNUtGJDQmmrOQT8ny+AqkXsTpxuwSXRkmPnmCT6DRtHGJrjx0L59gXTWQ79E9WxMX4UYyNRiT2Pq015xIApKHNutfV5ZplfYejZlxFzsedXg6sjDNyxQ+0RxJg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=CVIgSZeL; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="CVIgSZeL" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a5200202c1bso791101666b.0 for ; Wed, 17 Apr 2024 11:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1713379619; x=1713984419; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=srxyZAGyXYvn2b4ezfzCvudChQrNSnEsfsA8PnCNW9E=; b=CVIgSZeLe4AcPDRjF+OTHG5Pfr5980BcasgGJSSdQCjKqyEQK3pHBcf6Iaxrbr+JyU sq0WEdBg5tCZdmrZYnV1qODFI3Mt367W+9wimuJA39TtKxWAp30EgD5IOHigvY2Zyl96 nxHMFz0IXM+5F/drBqNeOOsQmjr+GTMadW5/Xc/I8WFLeuA5AstaBcYyvFDX6UMuzDWh /xL3xOujj0PF9ToAuDeQHOYzm6V806DdwlUlPRVdj83rv/q2OZO36Kfil7keUR5NUI6y IbMvjnvl90h56JwUa1Sg1qVairyr+N9lJNHV6UE+6PQWBwoxd3+btB82IjKApNxnjQ4C 4n/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713379619; x=1713984419; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=srxyZAGyXYvn2b4ezfzCvudChQrNSnEsfsA8PnCNW9E=; b=Yrmn975erP5ZkcUUTGhdnKPVnmFMocYdgyEKHYXTjTc8ou7pG6NZV9M8w8OOYiGMUX zW5P/OhdkwTAlqti6VEmm936+CZ5d5oFgsNOdLAAYR1IMb60Ix+wshZ/nLWs5M/z7FNQ GKRjThAYBplS6YMd541X2zGJKixQT0azS/8cYPTYMzr5jSM1FEHeODFYHxWk7AcbiXnJ XZXMaNcYrhDQB1Gt2FcDZ9XiO/XEW9IvMb7Na0GGvpReZrpSmgAv7IJU57nvDOQtvtUQ UeC1+i8HtZNplZvyN4lMYZXpwmaxuZhvDZgKhfo5eAoackSPg5w9h+VI3KV04Zx1ivh3 miGA== X-Gm-Message-State: AOJu0Yx9zZQX8B6ZBouSeyiujGHOo5U4meGCEkno/CbAB0HkdN6nNpNJ nOo/c9QSefMgDCAiV7iB2pQiG4dmoRCJhHut2P4NZL2d018MkB99Udd5dLJ0iIQ= X-Google-Smtp-Source: AGHT+IGuBeDkJxq3l/2p84b0q63zgETiPHBsrnMh9NuxlHR8gaYxrBzj4DyfI1gTH8e3euTThTFhdA== X-Received: by 2002:a17:906:32d2:b0:a51:d611:cd5e with SMTP id k18-20020a17090632d200b00a51d611cd5emr245150ejk.57.1713379618889; Wed, 17 Apr 2024 11:46:58 -0700 (PDT) Received: from localhost (dslb-090-186-231-154.090.186.pools.vodafone-ip.de. [90.186.231.154]) by smtp.gmail.com with UTF8SMTPSA id ji16-20020a170907981000b00a5244a80cfcsm6408791ejc.91.2024.04.17.11.46.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Apr 2024 11:46:58 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, Etienne AUJAMES Subject: [PATCH 4/8] Revert "libmultipath: fix max_sectors_kb on adding path" Date: Wed, 17 Apr 2024 20:46:40 +0200 Message-ID: <20240417184644.6193-5-mwilck@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417184644.6193-1-mwilck@suse.com> References: <20240417184644.6193-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This reverts commit bbb77f318ee483292f50a7782aecaecc7e60f727. --- libmultipath/configure.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 89ac03d..13602f3 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -575,12 +575,11 @@ sysfs_set_max_sectors_kb(struct multipath *mpp, int is_reload) ssize_t len; int i, j, ret, err = 0; struct udev_device *udd; - int max_sectors_kb = mpp->max_sectors_kb; + int max_sectors_kb; - /* by default, do not initialize max_sectors_kb on the device */ - if (max_sectors_kb == MAX_SECTORS_KB_UNDEF && !is_reload) + if (mpp->max_sectors_kb == MAX_SECTORS_KB_UNDEF) return 0; - /* on reload, re-apply the user tuning on all the path devices */ + max_sectors_kb = mpp->max_sectors_kb; if (is_reload) { if (!has_dm_info(mpp) && dm_get_info(mpp->alias, &mpp->dmi) != 0) { From patchwork Wed Apr 17 18:46:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13633760 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8328814A96 for ; Wed, 17 Apr 2024 18:47:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379623; cv=none; b=tP9P+xmftkR5J20g5NjSzaRQQ3LSWPawvsw0KYLCvC4GnxR3sUxgyDqF7iB0gM6eGlAHfSddYqIHvd7R1qIjoGBbWWHT19+BR/2R4ZJd/VXw2Mb8i2hzucFIw762Zj5bcBiDk4iPHWAvftS2+vBSk/01iX10/mjVEpSmLFToINM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379623; c=relaxed/simple; bh=Oqb6UXlQRZ4MkuGarXB8tFvIBVigD0yxdWr9Y+YlEXY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AxR6YN5nkMjK+gZzBx/+R+TIUZk+BQcgr+O6iRouigUEYwz9H8VgwEYl4MAM/nGYBAQuz9NmAuPZcbmYXmBP/rwwsqIgslVo827JOW6JgeaFOEUfWrlIGE9sagjuSw6kAmBc79kNvtz956bfMdi/9QejH9eqG8oGyyHPrKbSMnA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Ig7JooY4; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Ig7JooY4" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a55692e09c9so10977366b.0 for ; Wed, 17 Apr 2024 11:47:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1713379620; x=1713984420; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v2eBvjLt81/TLit0FrLrg/nOi5eX+QqzSNRXc3RJe4Q=; b=Ig7JooY4cJCH/N3XdkC+MFCZOCEjSEFwl1gR4dzPaPe06TJA4M/rT9d8W7HMmfLRGP HUIhmQ+zEGqoaJorUrmmzbfia58Bbpl5TKFz/HQB5ZwgHs83/Wu3FRVpbzI1quR4pi7W nC8QxNbikhq94Irs/JSYEuRSkJfknZzqNo7ND9znDTh9MDvAr0mPahBuEdnhN5alfSTN WEUoirf8OeQKaRYBS1MyDqOZOO3o/ycL+5K/eRrIPqCIFj1+5Fw9nLO0Mdh7s6AylIne siUKTn4pzVVHdvv4XKCeoTXHWEKJHI2wMCw492riThTsTCzzTYUSZUcIsxHAdMowD8J2 AVog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713379620; x=1713984420; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v2eBvjLt81/TLit0FrLrg/nOi5eX+QqzSNRXc3RJe4Q=; b=G2u+8OmIrzrI8TFK7Jw4AN2BIgTErRdgQU99k0ZFuynarBNoG3+PhZBBGFfrBD293V C6+57/RfeBT5DCEkPG65rn6SRqPk+/n1u9lsypPrgbPVH5KaTESymjU0hjKgSslS24RP PKhG/269bDqaLbWndqjyBYToImz4sDNOumB4YTwKPHXK1LzmU62sObUPB00dQNI3zSA+ AQ3moFIGFlxFUcUP0rivyHZjIq9YTD5YASUWUNNPpiOWYkJSNB2avmS8xzjkgxR+lfJv WOrFGIiyoHSfN57NoTLRkwjVHTa+cjVWHhiiBlkq/USRybNoGuzlTxT/85kStWKFjn4T +5Hw== X-Gm-Message-State: AOJu0YwDbSWjn2nz4cAapCllVVKIRdGXmbn3haJJejlPp24BCzyMxy70 /LW+CdvFwWXzS0HV+sczbZtgIO4cFztaIhUO9LFZN9bNcCb5FO9Xveeupa1A7lqoSzom3lqByez e X-Google-Smtp-Source: AGHT+IF0fK8CWpl1QmRrwSE87eY22aDD4vo6Whtldb5h1i9oCoXaq3TgeixWZpbXNBps/9zOqt/JLQ== X-Received: by 2002:a50:d598:0:b0:570:5e97:c023 with SMTP id v24-20020a50d598000000b005705e97c023mr344017edi.33.1713379619805; Wed, 17 Apr 2024 11:46:59 -0700 (PDT) Received: from localhost (dslb-090-186-231-154.090.186.pools.vodafone-ip.de. [90.186.231.154]) by smtp.gmail.com with UTF8SMTPSA id d6-20020aa7c1c6000000b005704049eaecsm2455519edp.1.2024.04.17.11.46.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Apr 2024 11:46:59 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, Etienne AUJAMES Subject: [PATCH 5/8] libmultipath: Only set max_sectors_kb on map creation Date: Wed, 17 Apr 2024 20:46:41 +0200 Message-ID: <20240417184644.6193-6-mwilck@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417184644.6193-1-mwilck@suse.com> References: <20240417184644.6193-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Changing max_sectors_kb on a live map is dangerous. When I/O occurs while the max_sectors_kb value of a map is larger than that of any of its paths, I/O errors like this may result: blk_insert_cloned_request: over max size limit. (127 > 126) This situation must be strictly avoided. The kernel makes sure that the map's limits match those of the paths when the map is created. But setting max_sectors_kb on path devices before reloading is dangerous, even if we read the value from the map's max_sectors_kb beforehand. The reason for this is that the sysfs value max_sectors_kb is the kernel's max_sectors divided by 2, and user space has no way to figure out if the kernel-internal value is odd or even. Thus by writing back the value just read to max_sectors_kb, one might actually decrease the kernel value by one. The only safe way to set max_sectors_kb on a live map would be to suspend it, flushing all outstanding IO, then the path max_sectors_kb, reload, and resume. Since commit 8fd4868 ("libmultipath: don't set max_sectors_kb on reloads"), we don't set the configured max_sectors_kb any more. But as shown above, this is not safe. So really only set max_sectors_kb when creating a map. Users who have stacked block devices on top of multipath, as described in the commit message of 8fd4868 must make sure that the max_sectors_kb setting is correct when the multipath map is first created. Decreasing the map's max_sectors_kb value (without touching the paths) should actually be possible in this situation, because stacked block devices are usually bio-based, and bio-based IO (in contrast to request-based) can be split if the lower-level device has can't handle the size of the I/O. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 13602f3..8cbb2a8 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -566,46 +566,18 @@ trigger_paths_udev_change(struct multipath *mpp, bool is_mpath) mpp->needs_paths_uevent = 0; } -static int -sysfs_set_max_sectors_kb(struct multipath *mpp, int is_reload) +static int sysfs_set_max_sectors_kb(struct multipath *mpp) { struct pathgroup * pgp; struct path *pp; char buff[11]; ssize_t len; int i, j, ret, err = 0; - struct udev_device *udd; - int max_sectors_kb; if (mpp->max_sectors_kb == MAX_SECTORS_KB_UNDEF) return 0; - max_sectors_kb = mpp->max_sectors_kb; - if (is_reload) { - if (!has_dm_info(mpp) && - dm_get_info(mpp->alias, &mpp->dmi) != 0) { - condlog(1, "failed to get dm info for %s", mpp->alias); - return 1; - } - udd = get_udev_for_mpp(mpp); - if (!udd) { - condlog(1, "failed to get udev device to set max_sectors_kb for %s", mpp->alias); - return 1; - } - ret = sysfs_attr_get_value(udd, "queue/max_sectors_kb", buff, - sizeof(buff)); - udev_device_unref(udd); - if (!sysfs_attr_value_ok(ret, sizeof(buff))) { - condlog(1, "failed to get current max_sectors_kb from %s", mpp->alias); - return 1; - } - if (sscanf(buff, "%u\n", &max_sectors_kb) != 1) { - condlog(1, "can't parse current max_sectors_kb from %s", - mpp->alias); - return 1; - } - } - snprintf(buff, 11, "%d", max_sectors_kb); - len = strlen(buff); + + len = snprintf(buff, sizeof(buff), "%d", mpp->max_sectors_kb); vector_foreach_slot (mpp->pg, pgp, i) { vector_foreach_slot(pgp->paths, pp, j) { @@ -923,7 +895,7 @@ int domap(struct multipath *mpp, char *params, int is_daemon) return DOMAP_RETRY; } - sysfs_set_max_sectors_kb(mpp, 0); + sysfs_set_max_sectors_kb(mpp); if (is_daemon && mpp->ghost_delay > 0 && count_active_paths(mpp) && pathcount(mpp, PATH_UP) == 0) mpp->ghost_delay_tick = mpp->ghost_delay; @@ -934,7 +906,6 @@ int domap(struct multipath *mpp, char *params, int is_daemon) case ACT_RELOAD: case ACT_RELOAD_RENAME: - sysfs_set_max_sectors_kb(mpp, 1); if (mpp->ghost_delay_tick > 0 && pathcount(mpp, PATH_UP)) mpp->ghost_delay_tick = 0; r = dm_addmap_reload(mpp, params, 0); @@ -942,7 +913,6 @@ int domap(struct multipath *mpp, char *params, int is_daemon) case ACT_RESIZE: case ACT_RESIZE_RENAME: - sysfs_set_max_sectors_kb(mpp, 1); if (mpp->ghost_delay_tick > 0 && pathcount(mpp, PATH_UP)) mpp->ghost_delay_tick = 0; r = dm_addmap_reload(mpp, params, 1); From patchwork Wed Apr 17 18:46:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13633761 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85303171A1 for ; Wed, 17 Apr 2024 18:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379624; cv=none; b=pL2DBcp2rOTdDZ5z15Z4KeZG0vCVmN/xGJe/6TiUkDcg2pH+2MbMPZHPuFFpRNLxg9hrGSn8d3Ev81Qf3fgjNCWn+SDUS2Xyl+pH4YRDQvCG0Q5FNtRxFipXfO0cutLpomPrF+bLs2cS2pID89gaGUl9YKe95WMU86uMf55mQ3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379624; c=relaxed/simple; bh=GxIkLGK4meWOas6k6Sxou561sZWWC4YMx/J8RDiA8vc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OljRoQNP6D2GyFH1L+dkoN+Aquj+6On6lYpg0AYn0NPqb0dkcqrDaxjMIP1N05v0YYdWCpHtzASyxpQ87LRamHVZI5f71/87tpmBqWihxPo4qzV9SEyWJzRz4cRCNINwtrzta9LFVN6+EirpQP//F3o50URRMums8gXbEndlPXk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=fRb/uZZ4; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="fRb/uZZ4" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a53f131d9deso447019166b.3 for ; Wed, 17 Apr 2024 11:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1713379621; x=1713984421; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XOakQ0jXP3vq9GfDKq8+6tKevaMvcHeP6fQ6zmIuZjI=; b=fRb/uZZ4cnFCjKOkT7gDsMp6m668f5eArEzgtbto5VENOVBxtoUksBAgexQvZh7mm/ vyTd01NVHf1F8k/OBKDlygYQxixzJkGFjymspyiVNURZI7kO2WacwpknXd3kR4rGzw8o JJ2GNDMqAb3A0Kpr4JUT84d4doaEwdUUt1GzSlDAoRQOzUU68q2FPa/IDWZVUghScrBL cXAqyPQTTBtMf2kadtbj1p8rIIWY++lty/7TyVDrvCeVetdfXTNRThNUdiR8Uy10EHw5 bme2y5CIlMC5IHyGhmGw2a3qJihS1wYX/rF7/+aqjwz6dn9iWHLVr5bM3tq/Gq0+EMjC LSpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713379621; x=1713984421; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XOakQ0jXP3vq9GfDKq8+6tKevaMvcHeP6fQ6zmIuZjI=; b=R2VyHp+PsJNoMsZE6yclrOWPSGwRAObc5gueMxfgMwk/b4N+C1M9HOZENqFc/guAiD tJn8xr3GlGYh3pd32Vx46BRjBIuOrmTIycUUVc7q4b/M4IACjcwaz4VvAAogufxgKiy9 nZGxy9Z+vUsIxUUmcUdDkbdqtASmMWJj3yzQD5geiwViVKBxNQq1pL29+aNLjIs+ElQY rRB1GjuD8JrAhnVn3xoYwCWkj1y+qo1pwSLlq/32H5I1EbA4Qo4bXYCXBNHTbzl9HPVD 69oaNi97oHcS3JY9qLRxdk0uK+a5GfS358ryX4BoHBvKMoX1MpkzZPVqcz47pbrKs7cL uazQ== X-Gm-Message-State: AOJu0YyXiiLTqGbNRa44Dh1eIO+U3un9YxAHLzL7IVAnlOKiXLTBy7KO j10fOVfTUl8JFhzjRO/7RYxmTz8cqWcRUY9TxP+gZP78FH29Dx04btxdifHbWqo= X-Google-Smtp-Source: AGHT+IFLqit+ZLAT1uTp8llBkLukni+no3b72YMnIFsYOn5zkWGPhwfnPG3EOY4IYfGq/G34FqrHMg== X-Received: by 2002:a17:906:c9c6:b0:a55:65e6:ce9f with SMTP id hk6-20020a170906c9c600b00a5565e6ce9fmr232716ejb.20.1713379620879; Wed, 17 Apr 2024 11:47:00 -0700 (PDT) Received: from localhost (dslb-090-186-231-154.090.186.pools.vodafone-ip.de. [90.186.231.154]) by smtp.gmail.com with UTF8SMTPSA id hs40-20020a1709073ea800b00a473362062fsm8390425ejc.220.2024.04.17.11.47.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Apr 2024 11:47:00 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, Etienne AUJAMES Subject: [PATCH 6/8] libmultipath: set max_sectors_kb in adopt_paths() Date: Wed, 17 Apr 2024 20:46:42 +0200 Message-ID: <20240417184644.6193-7-mwilck@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417184644.6193-1-mwilck@suse.com> References: <20240417184644.6193-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 As explained in the previous commit, setting max_sectors_kb for paths that are members of a live map is dangerous. But as long as a path is not a member of a map, setting max_sectors_kb poses no risk. Set the parameter in adopt_paths(), for paths that aren't members of the map yet. In order to determine whether or not a path is currently member of the map, adopt_paths() needs to passed the current member list. If (and only if) it's called from coalesce_paths(), the passed struct multipath does not represent the current state of the map; adopt_paths() must therefore get a new argument current_mpp that represents the kernel state. We must still call sysfs_set_max_sectors_kb() from domap() in the ACT_CREATE case, because when adopt_paths is called from coalesce_paths() for a map that doesn't exist yet, mpp->max_sectors_kb is not set. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 2 +- libmultipath/structs_vec.c | 62 ++++++++++++++++++++++++++++++++++---- libmultipath/structs_vec.h | 6 ++-- multipathd/main.c | 6 ++-- tests/Makefile | 2 +- tests/test-lib.c | 9 +++++- 6 files changed, 73 insertions(+), 14 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 8cbb2a8..b5c701f 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -1105,7 +1105,7 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid, /* * at this point, we know we really got a new mp */ - mpp = add_map_with_path(vecs, pp1, 0); + mpp = add_map_with_path(vecs, pp1, 0, cmpp); if (!mpp) { orphan_path(pp1, "failed to create multipath device"); continue; diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 0fc608c..c0c5cc9 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -242,7 +242,38 @@ static bool update_pathvec_from_dm(vector pathvec, struct multipath *mpp, return must_reload; } -int adopt_paths(vector pathvec, struct multipath *mpp) +static bool set_path_max_sectors_kb(const struct path *pp, int max_sectors_kb) +{ + char buf[11]; + ssize_t len; + int ret, current; + bool rc = false; + + if (max_sectors_kb == MAX_SECTORS_KB_UNDEF) + return rc; + + if (sysfs_attr_get_value(pp->udev, "queue/max_sectors_kb", buf, sizeof(buf)) <= 0 + || sscanf(buf, "%d\n", ¤t) != 1) + current = MAX_SECTORS_KB_UNDEF; + if (current == max_sectors_kb) + return rc; + + len = snprintf(buf, sizeof(buf), "%d", max_sectors_kb); + ret = sysfs_attr_set_value(pp->udev, "queue/max_sectors_kb", buf, len); + if (ret != len) + log_sysfs_attr_set_value(3, ret, + "failed setting max_sectors_kb on %s", + pp->dev); + else { + condlog(3, "%s: set max_sectors_kb to %d for %s", __func__, + max_sectors_kb, pp->dev); + rc = true; + } + return rc; +} + +int adopt_paths(vector pathvec, struct multipath *mpp, + const struct multipath *current_mpp) { int i, ret; struct path * pp; @@ -285,9 +316,28 @@ int adopt_paths(vector pathvec, struct multipath *mpp) continue; } - if (!find_path_by_devt(mpp->paths, pp->dev_t) && - store_path(mpp->paths, pp)) - goto err; + if (!find_path_by_devt(mpp->paths, pp->dev_t)) { + + if (store_path(mpp->paths, pp)) + goto err; + /* + * Setting max_sectors_kb on live paths is dangerous. + * But we can do it here on a path that isn't yet part + * of the map. If this value is lower than the current + * max_sectors_kb and the map is reloaded, the map's + * max_sectors_kb will be safely adjusted by the kernel. + * + * We must make sure that the path is not part of the + * map yet. Normally we can check this in mpp->paths. + * But if adopt_paths is called from coalesce_paths, + * we need to check the separate struct multipath that + * has been obtained from map_discovery(). + */ + if (!current_mpp || + !mp_find_path_by_devt(current_mpp, pp->dev_t)) + mpp->need_reload = mpp->need_reload || + set_path_max_sectors_kb(pp, mpp->max_sectors_kb); + } pp->mpp = mpp; condlog(3, "%s: ownership set to %s", @@ -693,7 +743,7 @@ find_existing_alias (struct multipath * mpp, } struct multipath *add_map_with_path(struct vectors *vecs, struct path *pp, - int add_vec) + int add_vec, const struct multipath *current_mpp) { struct multipath * mpp; struct config *conf = NULL; @@ -721,7 +771,7 @@ struct multipath *add_map_with_path(struct vectors *vecs, struct path *pp, goto out; mpp->size = pp->size; - if (adopt_paths(vecs->pathvec, mpp) || pp->mpp != mpp || + if (adopt_paths(vecs->pathvec, mpp, current_mpp) || pp->mpp != mpp || find_slot(mpp->paths, pp) == -1) goto out; diff --git a/libmultipath/structs_vec.h b/libmultipath/structs_vec.h index 3253f1b..dbc4305 100644 --- a/libmultipath/structs_vec.h +++ b/libmultipath/structs_vec.h @@ -13,7 +13,8 @@ struct vectors { void set_no_path_retry(struct multipath *mpp); -int adopt_paths (vector pathvec, struct multipath * mpp); +int adopt_paths (vector pathvec, struct multipath *mpp, + const struct multipath *current_mpp); void orphan_path (struct path * pp, const char *reason); void set_path_removed(struct path *pp); @@ -28,7 +29,8 @@ void remove_maps (struct vectors * vecs); void sync_map_state (struct multipath *); struct multipath * add_map_with_path (struct vectors * vecs, - struct path * pp, int add_vec); + struct path * pp, int add_vec, + const struct multipath *current_mpp); void update_queue_mode_del_path(struct multipath *mpp); void update_queue_mode_add_path(struct multipath *mpp); int update_multipath_table (struct multipath *mpp, vector pathvec, int flags); diff --git a/multipathd/main.c b/multipathd/main.c index dd17d5c..d8518a9 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -636,7 +636,7 @@ update_map (struct multipath *mpp, struct vectors *vecs, int new_map) retry: condlog(4, "%s: updating new map", mpp->alias); - if (adopt_paths(vecs->pathvec, mpp)) { + if (adopt_paths(vecs->pathvec, mpp, NULL)) { condlog(0, "%s: failed to adopt paths for new map update", mpp->alias); retries = -1; @@ -1231,7 +1231,7 @@ rescan: if (mpp) { condlog(4,"%s: adopting all paths for path %s", mpp->alias, pp->dev); - if (adopt_paths(vecs->pathvec, mpp) || pp->mpp != mpp || + if (adopt_paths(vecs->pathvec, mpp, NULL) || pp->mpp != mpp || find_slot(mpp->paths, pp) == -1) goto fail; /* leave path added to pathvec */ @@ -1245,7 +1245,7 @@ rescan: return 0; } condlog(4,"%s: creating new map", pp->dev); - if ((mpp = add_map_with_path(vecs, pp, 1))) { + if ((mpp = add_map_with_path(vecs, pp, 1, NULL))) { mpp->action = ACT_CREATE; /* * We don't depend on ACT_CREATE, as domap will diff --git a/tests/Makefile b/tests/Makefile index d1d52dd..4005204 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -45,7 +45,7 @@ dmevents-test_OBJDEPS = $(multipathdir)/devmapper.o dmevents-test_LIBDEPS = -lpthread -ldevmapper -lurcu hwtable-test_TESTDEPS := test-lib.o hwtable-test_OBJDEPS := $(multipathdir)/discovery.o $(multipathdir)/blacklist.o \ - $(multipathdir)/structs.o $(multipathdir)/propsel.o + $(multipathdir)/structs_vec.o $(multipathdir)/structs.o $(multipathdir)/propsel.o hwtable-test_LIBDEPS := -ludev -lpthread -ldl blacklist-test_TESTDEPS := test-log.o blacklist-test_LIBDEPS := -ludev diff --git a/tests/test-lib.c b/tests/test-lib.c index cdb2780..88f35e9 100644 --- a/tests/test-lib.c +++ b/tests/test-lib.c @@ -152,6 +152,13 @@ int __wrap_sysfs_get_size(struct path *pp, unsigned long long *sz) return 0; } +int __wrap_sysfs_attr_set_value(struct udev_device *dev, const char *attr_name, + const char * value, size_t value_len) +{ + condlog(5, "%s: %s", __func__, value); + return value_len; +} + void *__wrap_udev_device_get_parent_with_subsystem_devtype( struct udev_device *ud, const char *subsys, char *type) { @@ -400,7 +407,7 @@ struct multipath *__mock_multipath(struct vectors *vecs, struct path *pp) /* pathinfo() call in adopt_paths */ mock_pathinfo(DI_CHECKER|DI_PRIO, &mop); - mp = add_map_with_path(vecs, pp, 1); + mp = add_map_with_path(vecs, pp, 1, NULL); assert_ptr_not_equal(mp, NULL); /* TBD: mock setup_map() ... */ From patchwork Wed Apr 17 18:46:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13633762 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42E83171A5 for ; Wed, 17 Apr 2024 18:47:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379625; cv=none; b=XVIkmfq2WSLMPp7ogXlUk+oxEvz+vU9xqPsBNphd3BnNfues2JPjOTqQIeO/ozrmCVNRl6mrt75uM1d6fq122qKuyxqG40IjGphRHpcCgX3kAd2N22FZpWYBCuy8skr6X7X8gcJnpbvJK86hIyHTBVHaTg+PAIomJ3gYA6V3thg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379625; c=relaxed/simple; bh=GEVoW9l0QWlS9CJZmo8jucAAKc3FzD0818F6EK1zmv8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JL4IrG488eNp73jQQFUkGaJaxCg4kJXDOeYg2SjiBoamN+EbtvjmCxSlz95emA10dRkm3S/jiBpj7FNwPI8P9CwXdrazoMVBHkVU1WxRFsn/E3KehPbcUy1891JA2n5O6AwngmcnxzhQ198NPC/IG5YUWqzznd0ChecDGjW/gUQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=BBBDYuk3; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="BBBDYuk3" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a52223e004dso669207066b.2 for ; Wed, 17 Apr 2024 11:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1713379621; x=1713984421; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6X1ban8PiuleLsxaXXPlo+IWgAWCA3j5fink/sWFBp0=; b=BBBDYuk3iqinidaExc/xPEllXsdzCuRpMk994Hin7QINDHAiCyF0X6ujHn6PRFpQOp 9xHMTN7i9XfUChsjcxVBj9QUZ3yT98JhHbZYoVZV53tp2UjRDCFp0y6emBmF2Ua3Ygmb FaUWqrJ7VQdAS6b5QlmyppO+TMdk+o3kWN0Xo5SF/MQGCLjs5OO99qhOTnNyGemS1Tlp CetMCgDK3BOXPuRDKxueehStrNAq5b/kTHIJzu+JxSoockpq89gCQ3+Bjnm65SPJB09k XlptugpVzqzJw6OAGlumVV97XzS3bi+s7yW2KxvNWOiOroUb2scbN2/yBZ6fNrrgEO/s wGzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713379621; x=1713984421; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6X1ban8PiuleLsxaXXPlo+IWgAWCA3j5fink/sWFBp0=; b=kPpckB0iy1XgAx9h838Bcfb4wlINwCDddzcpTXYPzcT+CUugKeYlaRcsFGPPgbw6pX ucEUZLqUTVVp5UbkgSnEm2wHgRD+OR5pb//61/C1d6py7Tt/i3R5kJy4JSsGQdui+0Ua P7UDSkWJ/q8uI6G1ynYgv0jYNxJQ6UpC73Vj2Oj/Zm+W5Nf7OG67xOwqqJRh84204uid HJ+WrlsMba3YEk5YXeQvkTAuNLqQi7tXNXGA06hQ8QjvZiYpqBJRLRTN9Z5G/litg3EA ekR0WCq40SjE2eW0PgegxF5Bz5d01EWmgWPHXUX9rdwBGTVsEAU5seQt0ewkVbtbM+hL 38VA== X-Gm-Message-State: AOJu0YxtCcA7oHhasc8vmIvRNTFdVKCS0Z5LboWRUKEU6UiUSizurAC0 N9NqWpiAyk+mKBlOd0NEFNrdb4rjirhmk5DKzqsFCe4evZIQigIWDr0JVSyHjww= X-Google-Smtp-Source: AGHT+IHBHVm5IRSD8ytHxNIYgn+rxz6t4sx2bPLbIIx7y06OqjwI6/JFLg/3cee+9OhU/u0LtW0x2A== X-Received: by 2002:a17:906:b094:b0:a52:6eb7:7654 with SMTP id x20-20020a170906b09400b00a526eb77654mr234371ejy.46.1713379621748; Wed, 17 Apr 2024 11:47:01 -0700 (PDT) Received: from localhost (dslb-090-186-231-154.090.186.pools.vodafone-ip.de. [90.186.231.154]) by smtp.gmail.com with UTF8SMTPSA id x13-20020a170906b08d00b00a51d073da7esm8369083ejy.82.2024.04.17.11.47.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Apr 2024 11:47:01 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, Etienne AUJAMES Subject: [PATCH 7/8] libmultipath: add wildcard %k for printing max_sectors_kb Date: Wed, 17 Apr 2024 20:46:43 +0200 Message-ID: <20240417184644.6193-8-mwilck@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417184644.6193-1-mwilck@suse.com> References: <20240417184644.6193-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Martin Wilck --- libmultipath/print.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/libmultipath/print.c b/libmultipath/print.c index 360308d..efd5a16 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -32,6 +32,7 @@ #include "util.h" #include "foreign.h" #include "strbuf.h" +#include "sysfs.h" #define PRINT_PATH_LONG "%w %i %d %D %p %t %T %s %o" #define PRINT_PATH_INDENT "%i %d %D %t %T %o" @@ -431,6 +432,27 @@ snprint_multipath_vpd_data(struct strbuf *buff, return append_strbuf_str(buff, "[undef]"); } +static void cleanup_udev_device(struct udev_device **udd) +{ + if (*udd) + udev_device_unref(*udd); +} + +static int +snprint_multipath_max_sectors_kb(struct strbuf *buff, const struct multipath *mpp) +{ + char buf[11]; + int max_sectors_kb; + struct udev_device *udd __attribute__((cleanup(cleanup_udev_device))) + = get_udev_for_mpp(mpp); + + if (!udd || + sysfs_attr_get_value(udd, "queue/max_sectors_kb", buf, sizeof(buf)) <= 0 || + sscanf(buf, "%d\n", &max_sectors_kb) != 1) + return print_strbuf(buff, "n/a"); + return print_strbuf(buff, "%d", max_sectors_kb); +} + /* * path info printing functions */ @@ -790,6 +812,20 @@ snprint_alua_tpg(struct strbuf *buff, const struct path * pp) return print_strbuf(buff, "0x%04x", pp->tpg_id); } +static int +snprint_path_max_sectors_kb(struct strbuf *buff, const struct path *pp) +{ + char buf[11]; + int max_sectors_kb; + + if (!pp->udev || + sysfs_attr_get_value(pp->udev, "queue/max_sectors_kb", + buf, sizeof(buf)) <= 0 || + sscanf(buf, "%d\n", &max_sectors_kb) != 1) + return print_strbuf(buff, "n/a"); + return print_strbuf(buff, "%d", max_sectors_kb); +} + static const struct multipath_data mpd[] = { {'n', "name", snprint_name}, {'w', "uuid", snprint_multipath_uuid}, @@ -815,6 +851,7 @@ static const struct multipath_data mpd[] = { {'e', "rev", snprint_multipath_rev}, {'G', "foreign", snprint_multipath_foreign}, {'g', "vpd page data", snprint_multipath_vpd_data}, + {'k', "max_sectors_kb",snprint_multipath_max_sectors_kb}, }; static const struct path_data pd[] = { @@ -845,6 +882,7 @@ static const struct path_data pd[] = { {'I', "init_st", snprint_initialized}, {'L', "LUN hex", snprint_path_lunhex}, {'A', "TPG", snprint_alua_tpg}, + {'k', "max_sectors_kb",snprint_path_max_sectors_kb}, }; static const struct pathgroup_data pgd[] = { From patchwork Wed Apr 17 18:46:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13633763 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F3D114287 for ; Wed, 17 Apr 2024 18:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379626; cv=none; b=Y7rXtgTF+biMNTrDWX49eYduA+kdHZDQzh0KXuTfJF3ewahRckgOdx82uFSWMNRpDqSFjeAxfV/cP3sTHV3F+HQxIeAUFBpVVURbR621YJ5p2D2TIstCONA2oET1P1Nihx+CgVn7Vx9lBgcJH6VSgfOIlzeBIVRpx5vUSLL+Fx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713379626; c=relaxed/simple; bh=t8JuubzvwyRy9JUN1J5J8KG6h63BLDPZF1WeblTqHU4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aOjoaII351szlpg0oYx19dSIvrRHtJekbGk7ld1yDiudUbKzuGC+kWeC1WuTMADcVJ6erjZZcP81zWc5dBg5wktmAhWonGuDeN3bXvXinlHV6d3cM2MGcrgSH42NumvKCHu1z64QUyahPQpow/L/1ApAVbj2nhis03tiIR1W0y8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=c9/b+F9Z; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="c9/b+F9Z" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a53f131d9deso447022666b.3 for ; Wed, 17 Apr 2024 11:47:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1713379623; x=1713984423; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j25/ezTrgvO75oD7NPmOABy85ds+9Ko5ey38VCKJdw4=; b=c9/b+F9Z4GKkvmILAVxwLG2Ftdh9k4smfTaq7+dzg64xLvREZ+B4Qw6PWHp0P/bwNm QXdA9Sz5D1ueTAfJ41oScLxm9jNlpjfDbtJnlnXhNuoVNoOGyH4Ls5t9UJ5GOy8awb0J LtsxA5TMHxbRPQui3wSCgEGyMcF/OWuZ5Gs/xPVOKlHZL15p6yp10jY6ucVz7k2wfVJY 6yD0aX+wnjabeQGH+0O0F5Wf1eKjgHSw0p4eX5QNIQhWMksgob85LQ/+sgn1NKGduuqX DJUydCJiujxDWf2OAMY5eveUJfqQixvLUrL5H1M7NInsgAijBLhFHWP0j3G2xpbTcxiO ux/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713379623; x=1713984423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j25/ezTrgvO75oD7NPmOABy85ds+9Ko5ey38VCKJdw4=; b=DdHcy3ZaFAkr3OoH1HVyC+Qjtj8fqJWbFY0dObOhouzc9o7KIHMappBWaJ+1J75gZm Lq4VC5lGilo6cpM7C21ZBDK+RvJGxejd4zjPRscIeth4jAdqx5wYXR6UXcU4IBiFmIRI vjcRVTXipYgoobwKyFs6glBw6rUInznKDU9YrLJLPSyNUHpf0uaeJ2InzLevS/63Aa2W 8ecj5rQylYsDxFlHp5JWtnHODvGMvyF5cE3oeiFrzsZCzO3g8562YP/n8LFlRk7nHx+Y JpxdHKlPM3nGH8GBkaYhF9WC6gLSmm2JE0ACDAdPkRwmEDQ1PqRcO9HbpaR1/pANaT9c BzTQ== X-Gm-Message-State: AOJu0YyAsSMNpl/i3idUPY/wWLn/yLKETUzpjwg5MA/3fdAFrqXeGITy LWcLwK2TgD4hs4Epr1xPduX0slPJtrAnoxaHVWCrH7JquPM2sQuYuVFMAZtVm8DP6fBLw1gTkpA 4 X-Google-Smtp-Source: AGHT+IH0LOkRzMbTkPAEfJre0iuh097+U9hyvPxW8ZEBTLOpYw4SK7mrCLjZGX9aZdlccMUO3FQbxw== X-Received: by 2002:a17:906:851:b0:a55:6606:bbf7 with SMTP id f17-20020a170906085100b00a556606bbf7mr211138ejd.35.1713379623023; Wed, 17 Apr 2024 11:47:03 -0700 (PDT) Received: from localhost (dslb-090-186-231-154.090.186.pools.vodafone-ip.de. [90.186.231.154]) by smtp.gmail.com with UTF8SMTPSA id qb42-20020a1709077eaa00b00a5216df5d25sm8381387ejc.3.2024.04.17.11.47.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Apr 2024 11:47:02 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, Etienne AUJAMES Subject: [PATCH 8/8] multipath.conf(5): update documentation for max_sectors_kb Date: Wed, 17 Apr 2024 20:46:44 +0200 Message-ID: <20240417184644.6193-9-mwilck@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417184644.6193-1-mwilck@suse.com> References: <20240417184644.6193-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Martin Wilck --- multipath/multipath.conf.5.in | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/multipath/multipath.conf.5.in b/multipath/multipath.conf.5.in index c788c18..b29a75f 100644 --- a/multipath/multipath.conf.5.in +++ b/multipath/multipath.conf.5.in @@ -1311,11 +1311,36 @@ The default is: \fB0\fR . .TP .B max_sectors_kb -Sets the max_sectors_kb device parameter on all path devices and the multipath -device to the specified value. +Sets the \fImax_sectors_kb\fR device parameter on some path devices and the multipath +device to the specified value. \fImax_sectors_kb\fR is the largest I/O size, in units +of 1024 bytes, that the kernel allows for a single I/O request. For hardware devices +like SCSI disks, this value is limited by the capabilities of the hardware. +It is crucial that the value of a multipath map is never higher than the minimum value of +of all its path devices. This is ensured by the kernel when a multipath map +is loaded, but manipulating the values of a map or either of its paths while the +map is live can cause race conditions and I/O errors. Therefore this value is only +enforced by multipathd when a multipath map is first created, or when a path device +is added to a map. In both cases, race conditions are avoided by the kernel. .RS -.TP -The default is: in \fB/sys/block//queue/max_sectors_kb\fR +.PP +Setting \fImax_sectors_kb\fR does not guarantee that all path devices will have this +value set. It is not an error if the value of a path device is higher than that of +the containing multipath map. It is also not an error if the actual limit of a map is +lower than the value in \fI@CONFIGFILE@\fR. This can happen if the hardware limits of one +or more path devices are lower than the configured value. +.PP +Normally the kernel and its device drivers take care of the maximum +I/O size, and administrators do not need to bother about \fImax_sectors_kb\fR. +But some hardware devices may report incorrect I/O size limits, or other components +in the environment (e.g. the fabric) may impose constraints that the kernel cannot +detect. In such cases setting \fImax_sectors_kb\fR makes sense. It should be set when +maps are first created, and not be changed thereafter. +If the setting \fBmust\fR be changed for a live map, set the +value in \fI@CONFIGFILE@\fR, run \fBmultipathd reconfigure\fR, and use +\fBmultipathd del path \fR and \fBmultipathd add path \fR to +delete and re-add the same path device. +.LP +The default is: \fBundefined\fR. .RE . .