From patchwork Fri Feb 9 23:27:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13551980 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.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 8511237712 for ; Fri, 9 Feb 2024 23:27:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521273; cv=none; b=dQUTheCk0mOz0bpYu478VuYwMfzOIncl9g0pzZmfTCskv+JfK7B4Xg8qgOcH/vLwTkIHVfhRCbFMTV8pUhNY5YbANnGZLAlMI8tzzWugQM4UV47oSU5dGOh21v6eW72CVFU/iLwMX4GXExP++FWXHx4nGgyokv65Tvo7Du08xU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521273; c=relaxed/simple; bh=9JhTyEY7xyHWHgL2v5AU/Txam2omxdPpwVoZQVdz0Xc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rsi8j6vo5APXEeyAXpUPn/YVhq0kNhlzDq6Xp0OA3IEpSeTdt8VqA5mzD6MN5ccWqjPjBVPfEraOrRgkylMfwsTxifHzGtiA1rVgj7e4LfLtaZp313HnMtxU8w2d1ZhSeBUWWdarlUpKjP+UKHJbDKb4TTY5MV32lBVDpUCDG1M= 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=cERT1M/M; arc=none smtp.client-ip=209.85.128.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="cERT1M/M" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-410489e1a63so12138835e9.3 for ; Fri, 09 Feb 2024 15:27:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1707521270; x=1708126070; 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=R3fMdvnxDNyoJn0qP55t3+k8Zw8j30JNS+3y3grOE0s=; b=cERT1M/Mmdl/FBSNP/Sy7JfoDGZHDO2l4hHcb+uozvxRvW4dFr1NR2i7fmqu7hc29Y bCg3BK2TgtifKJ1hjtpF3++uLmCMpxPDkbnnVhndtsOFbErIcESBqesiqtyYLvcGe9MU MMbKDJkDTSKYc5mJgizqVftjaTsbWFV7JgWoYTx2VGmV+WRFqfpmGwOjrhHjtafJLT9k Q2yWmS6y/8+2yKa4/k4Aipw0WEuWZ8jN/leK/MwkKJKBnIdCHZTPRcfQMDjUF9+ATUVt +4y8MYTjKhtOIfpFDc9xNi/ebZBGiHmWM4OdlgGG1iqM8iB9kc6drxa/2Fhl+2BME9Xc 8d1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707521270; x=1708126070; 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=R3fMdvnxDNyoJn0qP55t3+k8Zw8j30JNS+3y3grOE0s=; b=miD8jVq2c07du9KEjIU0Ukah8rbFT8ZzWoeYUtq9BAuajsaB5nfJ1k4t/PbTzkAo9T JG6OmORUt9VYiy5Lfm+NWprC0Mr4tqOAMrGBq1ZbR0MMh2z6HvqS+gaGq+O+08WHyInf 06lLdVkUq8jh0cLW045f2JgrwMwBoGHXvExJIUkrRa93k3aVqtuWbrAvMPbOhzJQWPXg e4+FS7Sv1nBljaID4sXCW3rlgUP5yzEh3eZxfUoLmDRB7rNA8u82hJz7GmWg5TYv+C1q vUtiO5skj5g99Eo4DDxACl+HQZ/MP/2Dv6VzWWDFLUJ/qUx/w6QigeFS0TbYxJxBVHs3 xTqg== X-Gm-Message-State: AOJu0YwEk4h6ZmfGqBi0L8T9DNimMIDzza9Wia600WsD9NBOGczWOTiG D1FK+cIF7Mz7pzVr3dkYa3m/ozjMoq6+QdgtDdw3gYJT2Y55vvpdhZpV/kEHzRc= X-Google-Smtp-Source: AGHT+IEPF2dgG3zjaoxzC24aL27ayKIIT5kgcqPnYqyPSZaxh76L+zQk883QIIuw7hQQREvkyYc83A== X-Received: by 2002:a05:600c:548e:b0:410:676e:9edb with SMTP id iv14-20020a05600c548e00b00410676e9edbmr454387wmb.8.1707521269793; Fri, 09 Feb 2024 15:27:49 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXt9tZr1chphaxyNXtuWhSgm8pP5ojPBIFrIPBP/znnb79YhAAyYmOvxYDFdvwyW+fRNNW5NUEMC/u4rxgdjF3DPolu+09EFU0QDmVt6RWyqhNyC1UNzIWoQdZTnusivtBYv1qI+ogU3Nw4uHXsTsSDjNWN4PHVNnTU6GKzy6O4v/fJH/ZHaWLe Received: from localhost (dslb-002-202-118-224.002.202.pools.vodafone-ip.de. [2.202.118.224]) by smtp.gmail.com with UTF8SMTPSA id fb11-20020a05600c520b00b004109088e59csm4192wmb.31.2024.02.09.15.27.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Feb 2024 15:27:49 -0800 (PST) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, linux-lvm@lists.linux.dev, Zdenek Kabelac , Peter Rajnoha Subject: [PATCH v2 1/7] 11-dm-mpath.rules: use import logic like 13-dm-disk.rules Date: Sat, 10 Feb 2024 00:27:29 +0100 Message-ID: <20240209232735.9791-2-mwilck@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240209232735.9791-1-mwilck@suse.com> References: <20240209232735.9791-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We have to import the properties if either DM_NOSCAN or DM_DISABLE_OTHER_RULES_FLAG is set, because blkid will be skipped in both cases. Also, if DM_UDEV_PRIMARY_SOURCE_FLAG is not set, it makes no sense to try and import the properties. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- multipath/11-dm-mpath.rules.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/multipath/11-dm-mpath.rules.in b/multipath/11-dm-mpath.rules.in index b3117f9..e7be12d 100644 --- a/multipath/11-dm-mpath.rules.in +++ b/multipath/11-dm-mpath.rules.in @@ -79,7 +79,14 @@ ENV{MPATH_DEVICE_READY}!="0", ENV{.MPATH_DEVICE_READY_OLD}=="0", \ # not. If symlinks get lost, systemd may auto-unmount file systems. LABEL="scan_import" -ENV{DM_NOSCAN}!="1", GOTO="import_end" + +# If DM_UDEV_PRIMARY_SOURCE_FLAG is not set, the properties below +# have never been properly set. Don't import them. +ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="import_end" + +# Don't import the properties from db if we will run blkid later. +ENV{DM_NOSCAN}!="1", ENV{DM_DISABLE_OTHER_RULES_FLAG}!="1", GOTO="import_end" + IMPORT{db}="ID_FS_TYPE" IMPORT{db}="ID_FS_USAGE" IMPORT{db}="ID_FS_UUID_ENC" From patchwork Fri Feb 9 23:27:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13551981 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 826CF381BF for ; Fri, 9 Feb 2024 23:27:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521274; cv=none; b=G3Fu0/o4H/maNnlvYjx57lUBO4rDaD0TzCGC09MEPhz2ASoYRB5EQxqCfffmfS4aP7Ed29XkPOLIctbSn14Dp0S2GRpwoENGa5DF6U2BaMsNjs0dyUuAYKilpBpRB/y5bj/kV+YvmCwfVkrf41LiUtj3b07JKL9AzDYSG843Y98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521274; c=relaxed/simple; bh=xWMUkip/o9IM+HB9Pj2gacXg6ZHJiXlP4nEQhjzSL7k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZaMflnW55+gXkTNU73ldv8Up3reyWRqhNJnVu5y+uAr1AZiVsa/A/G1kNXQuPrb0blOxXkTzgOEVVlBz84W23D9zPwq7zkCmYaZ3bUm+fYeal9AHrJBHsVW/oufQ/fNdMtftEUiAH7bpyfHchLUp154N7t9RK7lpHJN6D58OuMs= 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=VJCtcM3J; arc=none smtp.client-ip=209.85.128.42 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="VJCtcM3J" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-410585542b3so11723695e9.2 for ; Fri, 09 Feb 2024 15:27:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1707521271; x=1708126071; 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=dXnlxkG4SsENEEA0l4Ob08V3J/FRJmdSfGWtF8Wxryk=; b=VJCtcM3J4MdSstqZljPFRzr8QtSPMUYBQOL2GShyMT9hZ9MwzJB5tz1PJnrT19+0nO LAsDWHa6kLwqtyHOBCvys9FQ02YbK+pEKw2tt+bT85ULO5gWPQQvMCjOUT/Az3O9X4+N ZSJg9Yfrwm/tfjg2z2g59WaHbAzJf0FyepB2o6k9s5wx3df+mjfbXPzyD8CrUHdmEudY IS/eHnrrszSvVgtwoOE9+hethsbP1cMxrxklqQqiUdPa9o9tcnQBCNoXXRbmIwcA6B7i vvTLOFVZp1IZxlqAR4BQDMkeFmJcy+EyzTdKAQYZ14HFhGbqoZawCXNWFate5PIZeig6 Gx4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707521271; x=1708126071; 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=dXnlxkG4SsENEEA0l4Ob08V3J/FRJmdSfGWtF8Wxryk=; b=IdjeD0La7QBop9r9wfXPjRB0zb8SaSLmkISV9EXUzUDpvrofNquOgxYZFPOEFyGp8j myJoGr6G/Z42kIbR+FFY6d8MgA3W0W2bUydEkmYQFqQcNYn1HIvdDVeup8zZ/6sTBi5V J/Mg0d87chygTz/9gC9qXzt3m2jduA6sSKGEwLfPMwRHWwYrlWFLCCSJVox6h0GGZxcm 1UfBkhyQim/EfvJ6ZdSQjzQmVQkIWm/xvoYWyGCRxJ7348MEjR7C1TW5pvXHuXTCyaW+ fUSxztTpFWFvW0BGU+EqqLhblTUZdlXRAzGjcMEBKX6sMIze3nbcNIeJ6MtGK+FUkXkV k5iQ== X-Gm-Message-State: AOJu0YwcsRk5UXNZbwSsWVTk2T0/jHFP9WBQFdwshxZF8C6kTmmY6fhl w3ZidvwQzDQx3h2kFueIM6pJTSuQ7vUqH3VhINtopKfjkSC85JF8nhZ2VulqDI0= X-Google-Smtp-Source: AGHT+IEnmzt87ASIdMgYS21qhXy6JoN2gZbbHlZF0oPH3oENC5Kjgf5tmpoS/mb30cRpPmrWEOLwHA== X-Received: by 2002:adf:a1db:0:b0:33a:ec79:f923 with SMTP id v27-20020adfa1db000000b0033aec79f923mr274776wrv.54.1707521270890; Fri, 09 Feb 2024 15:27:50 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU+bHZXL9Zjk5PyYHQwUTfbqzkLW+bMRF5jiiTub68Aps2LkNyqPyNPLc3DueujSOJpoFRRdUXRhYx7V2BZXM0w/z06hT9MPgWpnnQhL98lXOGATexwRVBMKvQ1P8+LmdRlPVy5npSCKs1mJb6pRB4cXApjGAzzSzTVMdvRnulLBmvb7LFYMfpY Received: from localhost (dslb-002-202-118-224.002.202.pools.vodafone-ip.de. [2.202.118.224]) by smtp.gmail.com with UTF8SMTPSA id y2-20020a056000108200b0033b5afd7f4dsm370886wrw.91.2024.02.09.15.27.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Feb 2024 15:27:50 -0800 (PST) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, linux-lvm@lists.linux.dev, Zdenek Kabelac , Peter Rajnoha Subject: [PATCH v2 2/7] 11-dm-mpath.rules: don't import DM_UDEV_DISABLE_OTHER_RULES_FLAG Date: Sat, 10 Feb 2024 00:27:30 +0100 Message-ID: <20240209232735.9791-3-mwilck@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240209232735.9791-1-mwilck@suse.com> References: <20240209232735.9791-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DM_UDEV_DISABLE_OTHER_RULES_FLAG is handled by 10-dm.rules, which imports it from db if necessary. There is no need to do this again here. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- multipath/11-dm-mpath.rules.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multipath/11-dm-mpath.rules.in b/multipath/11-dm-mpath.rules.in index e7be12d..fd8d202 100644 --- a/multipath/11-dm-mpath.rules.in +++ b/multipath/11-dm-mpath.rules.in @@ -7,7 +7,7 @@ IMPORT{db}="MPATH_DEVICE_READY" # If this uevent didn't come from dm, don't try to update the # device state -ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG", IMPORT{db}="DM_NOSCAN", GOTO="scan_import" +ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", IMPORT{db}="DM_NOSCAN", GOTO="scan_import" ENV{.MPATH_DEVICE_READY_OLD}="$env{MPATH_DEVICE_READY}" From patchwork Fri Feb 9 23:27:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13551982 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 7B11338DEA for ; Fri, 9 Feb 2024 23:27:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521275; cv=none; b=AzAHA5USlH5GML2RHIihQqQbJF+e8lCdU3507IjcThBtB+a8lGQImLFH4PsoO3U0V9upR4LgyfUz5wm5hNuvS6RYEG5Erz4j29x+wAkWyUo48UzHCL4voIGutXhYw3lPlnv2r0DMKn5/7pop04w+7vnvZuyhwE6OLbwfrVq9dB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521275; c=relaxed/simple; bh=12ieYLFWUCyht5PrtcRMsrvFspnqj0Y1CNTA9Szvkhk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X8ZuFK2RUl8jMKi1uG73jdk9f8o2anguTmD7ws02qzBybPnKAnRQp2ChGDyIOzKyBz4ofZqnR/BGnKAvWKhN4iAMA5/ATjUXxefi5dB3O+LPjlFdh/tBqVQKTRkuKC2gwgtsSlMeFonqtyCuu/YK8snOytbbTFSoHqLYy0Kvwgk= 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=eY+b9Hjs; arc=none smtp.client-ip=209.85.128.42 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="eY+b9Hjs" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-40fd72f7125so12232085e9.1 for ; Fri, 09 Feb 2024 15:27:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1707521272; x=1708126072; 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=z/QHX5dUqpN9GgwHs0h60F5n/zRYHwJWjExBuAqawTw=; b=eY+b9Hjs1mzpSVmsrqOzaRHeMS03SUqSbMw1lmMgQO3PRc9TpcuzFuvsxqcxeah4zg JQbnI2aJxPTQdPajwpYyoqRpt1d8SfvPEG0yBTf3DS7cmm9LDCfmVLymfNBdm7vJYkf/ zKH9c0eJz6HuqFaPQuMS6kIHls8lLkHlFmza7PmnvxGgiFgZhewgK0lNw5tpAorzIbHO KUL5L77M5R0YJNgz9MFVtiTIaC+zpJWWFU2mF0LqyK0jh6EXAajJWVx6W9VscWqWts0s D9Xx65REyd8XsjYdxXxDiHtz1BFd18WpiUVDfL9w43KxUSN5BKVkSk+iWyR7xziG8f44 rdxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707521272; x=1708126072; 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=z/QHX5dUqpN9GgwHs0h60F5n/zRYHwJWjExBuAqawTw=; b=gfvooVktVouRb6CWChbL4cYVZ0JW0oBY5h+gsWPXuteVPSKb358eLdgE2944tZnvse OUJ9S66kUsHKH4Kq8A9fCj/Wq8eP9Zwnv1vPMIChl0fxpBzS00MbPZViJhUNogIgDu0O NinvFIlX0kru3dl8tamirX+Cmrt00iZr86oLS6Ng6AIEnOexFDxoNy7mqnUvkmUYOVF8 8QkTTctpyA17ry1HqZQYNF5ewolGOQ73dQnZndcnVPufGQoDmnj+PJb24mRyq5yZ4jiI u7KtEbrmXOxDrdCi52Mipt+80EpdeRAC4fCZZg0ITKtv2VUAoE1OBKCWao7xwnv65tir x56g== X-Gm-Message-State: AOJu0YysLqEDUHlg7oz08LeKGtxRZLc9F9Tll/MwjPxDC0qKDPuLBo4K BudwC5mzHd3NsUmFE3W2ba1azZR9grNJjADK8sjt3z6wL6/ogzfw9T/VOQ/JgMA= X-Google-Smtp-Source: AGHT+IFIqxrBwKZeiGnlGBs31iTEdbQpOgYsNqvQZfnCZLbOfYt1xfMohSW7luPTaoDzj/CSTdAr/A== X-Received: by 2002:a5d:62c6:0:b0:33b:45e3:d88b with SMTP id o6-20020a5d62c6000000b0033b45e3d88bmr302910wrv.29.1707521271835; Fri, 09 Feb 2024 15:27:51 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXFhBLYHWt4lMU5QYY1kVzx2zZyXX4Iab1UoN4ZebYZn0HBzZhqXPJ4kg+U8NOpZ035NTq73dm8eEl0fNfSVOG9dtSsZXdeE62hFJLUWe9zjFeKDMW2o/fM7MMbqn2/oaCUavt/3OArkwOfxILHZex2KDWbKTIfOA7OIc1uaOAzzEXgYzQ8+zBR Received: from localhost (dslb-002-202-118-224.002.202.pools.vodafone-ip.de. [2.202.118.224]) by smtp.gmail.com with UTF8SMTPSA id ch16-20020a5d5d10000000b0033b58cbf3ebsm381292wrb.26.2024.02.09.15.27.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Feb 2024 15:27:51 -0800 (PST) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, linux-lvm@lists.linux.dev, Zdenek Kabelac , Peter Rajnoha Subject: [PATCH v2 3/7] 11-dm-mpath.rules: handle reloads during coldplug events Date: Sat, 10 Feb 2024 00:27:31 +0100 Message-ID: <20240209232735.9791-4-mwilck@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240209232735.9791-1-mwilck@suse.com> References: <20240209232735.9791-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If a map reload happens while udev is processing rules for a coldplug event, DM_SUSPENDED may be set if the respective test in 10-dm.rules happens while the device is suspened. This will cause the rules for all higher block device layers to be skipped. Record this situation in an udev property. The reload operation will trigger another "change" uevent later, which would normally be treated as a reload, and be ignored without rescanning the device. If a previous "coldplug while suspended" situation is detected, perform a full device rescan instead. Signed-off-by: Martin Wilck --- multipath/11-dm-mpath.rules.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/multipath/11-dm-mpath.rules.in b/multipath/11-dm-mpath.rules.in index fd8d202..54d01a6 100644 --- a/multipath/11-dm-mpath.rules.in +++ b/multipath/11-dm-mpath.rules.in @@ -5,6 +5,11 @@ ENV{DM_UUID}!="mpath-?*", GOTO="mpath_end" IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD" IMPORT{db}="MPATH_DEVICE_READY" +# Coldplug event while device is suspended (e.g. during a reload) +ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}=="1", \ + PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.warning \"Coldplug event for suspended device\"", \ + ENV{DM_COLDPLUG_SUSPENDED}="1", GOTO="scan_import" + # If this uevent didn't come from dm, don't try to update the # device state ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", IMPORT{db}="DM_NOSCAN", GOTO="scan_import" @@ -43,6 +48,16 @@ ENV{DM_ACTION}=="PATH_FAILED", GOTO="mpath_action" ENV{MPATH_DEVICE_READY}="1" LABEL="mpath_action" + +# A previous coldplug event occurred while the device was suspended. +# Activation might have been partially skipped. Activate the device now, +# i.e. disable the MPATH_UNCHANGED logic and set DM_ACTIVATION=1. +IMPORT{db}="DM_COLDPLUG_SUSPENDED" +ENV{DM_COLDPLUG_SUSPENDED}=="1", ENV{DM_SUSPENDED}!="1", \ + ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0", \ + PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.notice \"Forcing activation of previously suspended device\"", \ + GOTO="force_activation" + # DM_SUBSYSTEM_UDEV_FLAG0 is the "RELOAD" flag for multipath subsystem. # Drop the DM_ACTIVATION flag here as mpath reloads tables if any of its # paths are lost/recovered. For any stack above the mpath device, this is not @@ -57,6 +72,8 @@ ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", \ ENV{DM_ACTION}=="PATH_FAILED|PATH_REINSTATED", \ ENV{DM_ACTIVATION}="0", ENV{MPATH_UNCHANGED}="1" +LABEL="force_activation" + # Do not initiate scanning if no path is available, # otherwise there would be a hang or IO error on access. # We'd like to avoid this, especially within udev processing. @@ -99,6 +116,9 @@ IMPORT{db}="ID_PART_GPT_AUTO_ROOT" LABEL="import_end" +# Reset previous DM_COLDPLUG_SUSPENDED if activation happens now +ENV{DM_SUSPENDED}!="1", ENV{DM_ACTIVATION}=="1", ENV{DM_COLDPLUG_SUSPENDED}="" + # Multipath maps should take precedence over their members. ENV{DM_UDEV_LOW_PRIORITY_FLAG}!="1", OPTIONS+="link_priority=50" From patchwork Fri Feb 9 23:27:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13551983 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.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 72C9938FA1 for ; Fri, 9 Feb 2024 23:27:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521276; cv=none; b=S9iMArt+vw7WCNEQT6K/hWWeWvtGT8FhVliu3HgJNC9uxa6uoT51gKBaGC70MyyF8iw+gkz9bXU2Ic2Us5pSdi0ma/wu4aUocP83m2oWwxHOZdyt1dKdvPKsNQmaZt604H2Mh2Qzn4wlAMBVJAEy5IFVW16r4xZIiKZVNzPqmUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521276; c=relaxed/simple; bh=xoZpVfaaiOlvD1NBovtI8+CLaAQXIm45lEJfsGop2TQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=icHSZUM1xTXNWnvGSdPbMIEbPV//iJa2cMnE6dn4Hf9tO1L0k+Q1uezofdwG5zct7rkz1FQlOnZzCLyLxtVLPDcJH9YDcS99SvzcgvSQeu9tA9NuHvBCGv3HQPjKGT3AgvehIIF0vuHRoORaRq2IYtBc93OEX9hEPN9Jjjq3jD4= 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=fh91HjJV; arc=none smtp.client-ip=209.85.221.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="fh91HjJV" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-33b18099411so714953f8f.0 for ; Fri, 09 Feb 2024 15:27:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1707521273; x=1708126073; 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=b6nq1wxtillK0bXwrYEvJV5T8wVUWQuCdStruGZoseA=; b=fh91HjJVHJWVlo0Rto0gxnIaYNoAp6U6vaNIWx/M0Fv/L82QM1eUyNW9luJ5tdJ18E rZhaiDCE+CuufUDe9EnQaBrAWhI3D7EMB7T62+e4yr824gDZ7wGTeWBGEDo1acElLqzZ OajNiq0grRe5eXdCkqw4lLbK3r13vDrFmLjiMKvyAoqF0vdpf3o6F8pl1jaJIFu1+v9m jl5uYmgLKH+aYJUclmieDhs+t5F3W/JGhNrUz1nnws6235RUSJydhvaLqiHjs9q8ny9s n5EKkukhhEJPVzWKOoThQ/56xZlZBStXEOBfE3iu20G7eM3hwc7e0cGSOktSFMYLXaFM z3nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707521273; x=1708126073; 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=b6nq1wxtillK0bXwrYEvJV5T8wVUWQuCdStruGZoseA=; b=D/L5t3k65zBTrQSnX50AWpssGbZArM8ZRPIK2IilWdjUh+5ZwRzjrXQxHfucGvU2gR F55qsvIfAbt6Fm2F9eYAOJk0OFIEFGFwv72WKHQ8oDnCTsHO+w6nXj3340OcEFjN9pRQ qEAhrRotupW2bfpR67cx6bbZ/aj9oNGidG+uqKfNmBpcvAmc11QmqH1YW2vKRglfwVyh 96v0MUgjXh8SfMwHbtLc5fbchjBKtY04r1bfDaXxnSHuuixlBUMCDgzdI9xB4OjTjclo BStiHZ4MvSsO8QmQ8rses22SYPILxnapsibdAfr6HL+uyQpfbYo2ufWQodmlHMss1mVl MvbA== X-Gm-Message-State: AOJu0Yw5WkA/Yc6L5zyar6MROAnPQnz+L+b7BaXyLKGD8bEmq4i/uybo tEclib8+G2dZdm90gOS6/NLaUX3TTRNSzGFBMBtR7Q8e6y2RHKD7/KcWJFPmAt1RehlpLB3ARYS n X-Google-Smtp-Source: AGHT+IHQehVpbnRbdGarzbc6PMpCdXcFUA1qL+AjPdlr8JI3yK3RsxRe3TVeRBhZpJ1YzfnWsSvKDQ== X-Received: by 2002:adf:fd10:0:b0:33b:4f10:f2b8 with SMTP id e16-20020adffd10000000b0033b4f10f2b8mr270814wrr.43.1707521272879; Fri, 09 Feb 2024 15:27:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXx2Rff6D3PZux+R12wPriEs0Dop8/w7PtYlg9yQhM9mhTHMHWjQYUDGReImhuZ40Lpjc+zAkeGOaQLtGuOQCrqq2WCS+tNCp96W7gSQIXokWOPF18apw/y/vSU7KxVVSK4Ew6vPJJAasEI4FQr1WUfJo8vOFjFEFjNIpPB17819vd6LhrYWhro Received: from localhost (dslb-002-202-118-224.002.202.pools.vodafone-ip.de. [2.202.118.224]) by smtp.gmail.com with UTF8SMTPSA id n16-20020a5d67d0000000b0033af26545c8sm378019wrw.50.2024.02.09.15.27.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Feb 2024 15:27:52 -0800 (PST) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, linux-lvm@lists.linux.dev, Zdenek Kabelac , Peter Rajnoha Subject: [PATCH v2 4/7] 11-dm-mpath.rules: don't save DM_UDEV_DISABLE_OTHER_RULES_FLAG_OLD Date: Sat, 10 Feb 2024 00:27:32 +0100 Message-ID: <20240209232735.9791-5-mwilck@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240209232735.9791-1-mwilck@suse.com> References: <20240209232735.9791-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The current rules overwrite DM_UDEV_DISABLE_OTHER_RULES_FLAG and save its value in DM_UDEV_DISABLE_OTHER_RULES_FLAG_OLD if MPATH_DEVICE_READY changes from 1 to 0, and restore DM_UDEV_DISABLE_OTHER_RULES_FLAG from DM_UDEV_DISABLE_OTHER_RULES_FLAG_OLD when MPATH_DEVICE_READY changes back from 0 to 1. This is wrong for multiple reasons. For "spurious" events, 10-dm.rules will read DM_UDEV_DISABLE_OTHER_RULES_FLAG from the udev db and obtain the value saved by 11-dm-mpath.rules rather than it's own saved value, which confuses the logic in 10-dm.rules. 10-dm.rules sets the flag if either DISK_RO==1 or DM_SUSPENDED==1, and never clears it (it can only be cleared by a new genuine libdm event that doesn't have DM_UDEV_DISABLE_OTHER_RULES_FLAG set, while the device is not suspended). lvm commands may set the flag, too, but AFAICS this is only done for certain types of logical volumes, not for multipath maps. If a previously suspended device is resumed, DM_UDEV_DISABLE_OTHER_RULES_FLAG would be cleared, and it would be wrong for 11-dm-mpath.rules to overwrite it with a previuosly saved value. Likewise, if a uevent arrives for a suspended map, and MPATH_DEVICE_READY happens to switch from 0 to 1, it would be wrong to clear DM_UDEV_DISABLE_OTHER_RULES_FLAG by setting it to a previously saved value. We need to set DM_UDEV_DISABLE_OTHER_RULES_FLAG=1 to prevent follow-up rules from attempting I/O on the device. But don't try to save and restore DM_UDEV_DISABLE_OTHER_RULES_FLAG between uevents. Rather, reset DM_UDEV_DISABLE_OTHER_RULES_FLAG to the value we got from 10-dm.rules in a late rule. I chose "z0" for this rule's prefix to make sure it needs to run very late (after 99-systemd.rules, for example) while still allowing some reasonable space after it. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- multipath/11-dm-mpath.rules.in | 19 +++++++++---------- multipath/Makefile | 2 ++ multipath/z0-dm-mpath-late.rules | 4 ++++ 3 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 multipath/z0-dm-mpath-late.rules diff --git a/multipath/11-dm-mpath.rules.in b/multipath/11-dm-mpath.rules.in index 54d01a6..e31107b 100644 --- a/multipath/11-dm-mpath.rules.in +++ b/multipath/11-dm-mpath.rules.in @@ -2,7 +2,6 @@ ACTION!="add|change", GOTO="mpath_end" ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="mpath_end" ENV{DM_UUID}!="mpath-?*", GOTO="mpath_end" -IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD" IMPORT{db}="MPATH_DEVICE_READY" # Coldplug event while device is suspended (e.g. during a reload) @@ -79,16 +78,16 @@ LABEL="force_activation" # We'd like to avoid this, especially within udev processing. ENV{MPATH_DEVICE_READY}=="0", ENV{DM_NOSCAN}="1" -# Also skip all foreign rules if no path is available. -# Remember the original value of DM_DISABLE_OTHER_RULES_FLAG -# and restore it back once we have at least one path available. -ENV{MPATH_DEVICE_READY}=="0", ENV{.MPATH_DEVICE_READY_OLD}=="1", \ - ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}=="", \ - ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}" -ENV{MPATH_DEVICE_READY}=="0", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" +# Skip all foreign rules if no path is available. +# Use DM_UDEV_DISABLE_OTHER_RULES_FLAG to communicate this +# to upper layers. The original value will be restored in a late +# udev rule. +ENV{MPATH_DEVICE_READY}=="0", \ + ENV{.MPATH_SAVE_DISABLE_OTHER_RULES_FLAG}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}", \ + ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" +# If the device comes back online, set DM_ACTIVATION so that +# upper layers do a rescan. ENV{MPATH_DEVICE_READY}!="0", ENV{.MPATH_DEVICE_READY_OLD}=="0", \ - ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}", \ - ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="", \ ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0" # The code to check multipath state ends here. We need to set diff --git a/multipath/Makefile b/multipath/Makefile index f8c1f5e..2f2569c 100644 --- a/multipath/Makefile +++ b/multipath/Makefile @@ -26,6 +26,7 @@ install: $(Q)$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/ $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) $(Q)$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) + $(Q)$(INSTALL_PROGRAM) -m 644 z0-dm-mpath-late.rules $(DESTDIR)$(udevrulesdir) $(Q)$(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)$(udevrulesdir)/56-multipath.rules $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(tmpfilesdir) $(Q)$(INSTALL_PROGRAM) -m 644 tmpfiles.conf $(DESTDIR)$(tmpfilesdir)/multipath.conf @@ -46,6 +47,7 @@ endif uninstall: $(Q)$(RM) $(DESTDIR)$(bindir)/$(EXEC) $(Q)$(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules + $(Q)$(RM) $(DESTDIR)$(udevrulesdir)/z0-dm-mpath-late.rules $(Q)$(RM) $(DESTDIR)$(modulesloaddir)/multipath.conf $(Q)$(RM) $(DESTDIR)$(modulesloaddir)/scsi_dh.conf $(Q)$(RM) $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules diff --git a/multipath/z0-dm-mpath-late.rules b/multipath/z0-dm-mpath-late.rules new file mode 100644 index 0000000..8574b1a --- /dev/null +++ b/multipath/z0-dm-mpath-late.rules @@ -0,0 +1,4 @@ +# If DM_UDEV_DISABLE_OTHER_RULES_FLAG was modified in 11-dm-mpath.rules, +# restore it here, lest a temporary value be saved in the udev db +ACTION=="add|change", ENV{.MPATH_SAVE_DISABLE_OTHER_RULES_FLAG}=="?*", \ + ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{.MPATH_SAVE_DISABLE_OTHER_RULES_FLAG}" From patchwork Fri Feb 9 23:27:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13551984 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 69834381BF for ; Fri, 9 Feb 2024 23:27:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521277; cv=none; b=OcqgVX/T5IAlpI/X5gAm6icwtNWbJZL8vRa/nIVJYud14zlwBCXs62lx5fgSFEi3WNj1PpzeLJGgM+WB3vZJkYDH1UuxqNftG/OmmoPIzh8Zdkrhs0/5NKSORZi2NsMxoBGxw28pdI1WouQwmwFw5tYoRTqoktY2scd5YJ20Bqs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521277; c=relaxed/simple; bh=juVndOSHbLqiMXagx+PpMzzoeOQV4GjA6EAmwBFBbXc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X9js6KmQ9SBm5AaXq1o2AJ0qFXjbcOQiDB76QyZHrgglyRTxFGw5jblM2Y0aY3mECRCQboOl61uvs02f+pcu0dLWkZRk1qDAIfYGZytBla3t0hB5eYNNkCrZHKuVqvEyxPyqxymdggWCMLD0pk+XlryUkjWTYHYfpZA9dx8bTUM= 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=IzNbanUW; arc=none smtp.client-ip=209.85.128.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="IzNbanUW" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4105006bf11so12355825e9.3 for ; Fri, 09 Feb 2024 15:27:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1707521274; x=1708126074; 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=qpHBjGBs5KT8NHv5Xjr68QkEb4nZ9M6hzLeZDP0nDA0=; b=IzNbanUWp+RjndN6cOtyha2QcfEHk/ScxR/u2OQq0H+3iH5LhdXZgp0vBpk+35C3Z1 tABt6PNyOEpLfHH6QVH1E6baJqy2HtF/DZNPUv4bRlz9HIThehnM8HqnQWMUFGCmWIYW M4FLPVDzruEnNStbiULIgtdrJbqUWvyJTy2qg6G9YovVwvpUrisRKP1AeDgfy0Bw0hMc eW4b4tpzdR2qsnOgGRQE1+EuEhivxMN7J89QZoFPB70OQFUn/htvxiBargIaHjhPl9mg dQCdKM7eZ8PvlH09q/zceO63+RpR33QorZWkJ6VhF+7YOYkoDzPLZ5Eskbe2WvC5h9hz h28w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707521274; x=1708126074; 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=qpHBjGBs5KT8NHv5Xjr68QkEb4nZ9M6hzLeZDP0nDA0=; b=mCfUgRcLfE63ztL142p4LiTiAbbXX6MkcB0/kHDF0x9tNXkZ42E2/uUezUqFbhKhMQ Uvlo7V6Dc0sj0dwL8yLxLi00pli1RDTLkFZrDeVRtTcjXpTB8laa1Is57K2IquDgnBW2 dtENhEGPDnf3QdIe5orjoyEQwfQ4BdHeaY66EzTTfQqV3cG6n5+MRgx0dd86dJbyGB5H SCyYkECZPmyPHdpAsMoPYIp/bwN/U5tfaTBNIUeR6k7riXQZ3xD07ADWiEZBhF5m3S4+ 7JSkAKYgoGY6ID4CNthWi+kAjMrthM2n1WHX2vhUl5sCj7XB5i6rYqKg19MrYL/xpRi/ WYMA== X-Gm-Message-State: AOJu0YxOs7WXDPWdtx/PccCko+WdGkgI55V7ZfarsZ+ogx8BU/VGUsOd MZnyIywpo2m0Boiv+KSj40B5zpl0LDqWjJb2QOMKPvp78MgqkJ/ggwsHy867ivg= X-Google-Smtp-Source: AGHT+IEXVvWB7Fou5QV1hjHwzqAZ96DdgCblaPAqhalXH/5a/6EK8Hu1imh5cv6f4vKCDGiI2W3QgA== X-Received: by 2002:a5d:634e:0:b0:33b:3a90:13ea with SMTP id b14-20020a5d634e000000b0033b3a9013eamr389715wrw.4.1707521273818; Fri, 09 Feb 2024 15:27:53 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU5jVEfXZVULwGaIPvPLfF90ab9O67ZmO5/ND/gYfGXGy4JSrxbZYDw2n9YogAwRbTd0g3sWEx4xkPOGG5RiFk+Z5YWa9nCZVKDKI9FIBkxGfsH2LyZo7fBgq3lf/SsQL3yhEI/9Wh2Rf+P8L0bdLY43fNWbQq53XxjOkC45q0HRyCUrOssL2Rz Received: from localhost (dslb-002-202-118-224.002.202.pools.vodafone-ip.de. [2.202.118.224]) by smtp.gmail.com with UTF8SMTPSA id g7-20020a5d5407000000b003392206c808sm369593wrv.105.2024.02.09.15.27.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Feb 2024 15:27:53 -0800 (PST) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, linux-lvm@lists.linux.dev, Zdenek Kabelac , Peter Rajnoha Subject: [PATCH v2 5/7] 11-dm-mpath.rules: clear DM_DISABLE_OTHER_RULES_FLAG for coldplug events Date: Sat, 10 Feb 2024 00:27:33 +0100 Message-ID: <20240209232735.9791-6-mwilck@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240209232735.9791-1-mwilck@suse.com> References: <20240209232735.9791-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For all "spurious" events, which includes coldplug events, DM_DISABLE_OTHER_RULES_FLAG will be read from the udev DB in 10-dm.rules. Thus if a previous event saw the device in suspended state, the flag will be set even if the device has meanwhile resumed. Reset the flag if none of the conditions hold that would cause it to be set in a genuine uevent in 10-dm.rules. It would be cleaner to do this in 10-dm.rules directly, but it cannot be done easily, because the flag can also have an origin inside lvm itself; lvm sets it for various kinds of logical volumes. For generic (non-LVM) dm devices, the flag is only set in 10-dm.rules though, so doing this is safe for multipath. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- multipath/11-dm-mpath.rules.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/multipath/11-dm-mpath.rules.in b/multipath/11-dm-mpath.rules.in index e31107b..8e8741a 100644 --- a/multipath/11-dm-mpath.rules.in +++ b/multipath/11-dm-mpath.rules.in @@ -9,6 +9,13 @@ ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}=="1", \ PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.warning \"Coldplug event for suspended device\"", \ ENV{DM_COLDPLUG_SUSPENDED}="1", GOTO="scan_import" +# Coldplug event. DM_UDEV_DISABLE_OTHER_RULES_FLAG has been restored +# from DB in 10-dm.rules. If the device is not suspended, clear the flag. +# This is safe for multipath where DM_UDEV_DISABLE_OTHER_RULES_FLAG is basically +# equivalent to DM_SUSPENDED==1 || DISK_RO==1 +ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ + ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="", GOTO="scan_import" + # If this uevent didn't come from dm, don't try to update the # device state ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", IMPORT{db}="DM_NOSCAN", GOTO="scan_import" From patchwork Fri Feb 9 23:27:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13551985 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.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 5F03E39846 for ; Fri, 9 Feb 2024 23:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521278; cv=none; b=i4p37xzgCWG1JhjSdoFTtVKBA9/AZWQ+Fe3ZkxbyCBbNFSaofdtX+clScMe+X5LIGc7k01LYUkqXsE+LYgizz7UXOGdacS2ye7+pwPdGoRSnAXFDmgu50si3Fgqca/eYp7KOsItdMLR0+GmKEcG43tALq5Kk3ZdXOyhxRMIYi0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521278; c=relaxed/simple; bh=K/nxda3XSG7QtmtMAv/yQX+YIgqIK2tjc55oSeJFPS0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZupoLs0G2zwKqVrK83JAdV8e3ctrohuc8dzQDAZ88U8run3gLxq2xxUmFDFJUzp6rZ/oAsZmKrVZl2jGKCSQNHduEWAf8SEqGZ0LZiaCNdxRKsZ86wDUzR6vG/iW30I0meHg6OC6vP+fl3DyFJO7tuIB8++OXK4SR369/g1paBo= 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=cQM0EdeV; arc=none smtp.client-ip=209.85.128.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="cQM0EdeV" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4108842369eso2025135e9.3 for ; Fri, 09 Feb 2024 15:27:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1707521275; x=1708126075; 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=u3nB9e2byooXR+GdNIK3rReu3YzHbGIrVFFG/ndgqM4=; b=cQM0EdeV6uHtddvpqAIwELw1trLGZmL+Nzx4/0ZIyXbsPfChc2DYYgbGGapr6yOOJO WwasQgObt75tNTD825UyeIh5VorF/rkxApLowoofBMcRWz3MDyuYxmErtldEDxBQXe/0 TS79zyVUPoDTfI+YRJrZWoHYve9XkAirCu9ZjeyphDSXsYVbXAvYJEXycTlaKNmp9emY bl+/pl+e9K1W9/OxaVmvc3dSuwcwUKzyxmsM+h7Oz7X9YCGbYq7igIXWF4l7w8zzIUYj uCLlbVxGHYly4gH3nWuHNgLk+97In7ivPTk4Ld3YsiHmgyW9kIcAlDsVXinsHUeNwt5F fm+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707521275; x=1708126075; 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=u3nB9e2byooXR+GdNIK3rReu3YzHbGIrVFFG/ndgqM4=; b=NbXNDvN+uQbo7SnqHwzHkvAxUKvR31wPN7z0Wt2QjVhOCFNmg3rpzTaj//HakJlsOd A0SCXndFpdAYLbyUe9XWvhsTmhmoXaFgqfJ06bXXVJ+fl92PaCGP+gTedokqnuPzVCUS YXGAYW2OJmMIrF3jvhmlNGLYVg2Rk59LaBusPoCkt/fIGZ8kh+LaydHyXRMXBRDebndG JHul58j4vaYxZYiES3oWQVglnYm+A0v9xEZGJwqHmxeMV5+P85EUG0viQluKo2KRYF/6 BArLrv0+9Sct7cvrx+8wcVULU2aDksofrIWZ/rKry7865iwnPce+eIAdO08DzWjYFgPT CnIw== X-Gm-Message-State: AOJu0YwX5tQTo4Q5tAKpyA145uBkiQM8PW0YhzwPXalExXVrNsj5ww09 bWKJp4un9P1CDaBXe9g+wGbIkk/JPDYuFmr8LSyOaf4LDO5vVMXqvOZSmWMeuts1eZfnNTaRTaA 7 X-Google-Smtp-Source: AGHT+IEd2LqqzidXq6iai1eeL5UJ8j5iJ1r5CX7aHdlgaHCMUfyjl4kmEdMpnSMHsGSNKwAnikn/VQ== X-Received: by 2002:a05:600c:4f48:b0:410:27e7:f6e with SMTP id m8-20020a05600c4f4800b0041027e70f6emr512079wmq.39.1707521274821; Fri, 09 Feb 2024 15:27:54 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUAf4eJiCF5NLA8r5xXRd1AiC3X51JRSkja9HwF6/W0/ZgrKp2pnhEzkhLYZ26y8iUjvmNfcOUrrplGqUFwvJCjqMKCL6xaZdt8KzCi5PK3QvwyKc0e9/FGhOF7wE5Exaz4nW8qJltSKmt8Vj9kat/3ZZOkWJtJPUeCj0/K74AW4Ygq03mTDa/R Received: from localhost (dslb-002-202-118-224.002.202.pools.vodafone-ip.de. [2.202.118.224]) by smtp.gmail.com with UTF8SMTPSA id v8-20020a5d43c8000000b0033b512b2031sm375375wrr.114.2024.02.09.15.27.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Feb 2024 15:27:54 -0800 (PST) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, linux-lvm@lists.linux.dev, Zdenek Kabelac , Peter Rajnoha Subject: [PATCH v2 6/7] 11-dm-mpath.rules: Don't force activation while device is suspended Date: Sat, 10 Feb 2024 00:27:34 +0100 Message-ID: <20240209232735.9791-7-mwilck@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240209232735.9791-1-mwilck@suse.com> References: <20240209232735.9791-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If paths become available while the device is suspended, don't activate. Another uevent will arrive when the device is resumed. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- multipath/11-dm-mpath.rules.in | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/multipath/11-dm-mpath.rules.in b/multipath/11-dm-mpath.rules.in index 8e8741a..4141833 100644 --- a/multipath/11-dm-mpath.rules.in +++ b/multipath/11-dm-mpath.rules.in @@ -92,10 +92,16 @@ ENV{MPATH_DEVICE_READY}=="0", ENV{DM_NOSCAN}="1" ENV{MPATH_DEVICE_READY}=="0", \ ENV{.MPATH_SAVE_DISABLE_OTHER_RULES_FLAG}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}", \ ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" + # If the device comes back online, set DM_ACTIVATION so that -# upper layers do a rescan. -ENV{MPATH_DEVICE_READY}!="0", ENV{.MPATH_DEVICE_READY_OLD}=="0", \ - ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0" +# upper layers do a rescan. If the device is currently suspended, +# we have to postpone the activation until the next event. +ENV{MPATH_DEVICE_READY}=="0", GOTO="dont_activate" +ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" +ENV{DM_SUSPENDED}==1, ENV{MPATH_DEVICE_READY}="0", GOTO="dont_activate" + +ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0" +LABEL="dont_activate" # The code to check multipath state ends here. We need to set # properties and symlinks regardless whether the map is usable or From patchwork Fri Feb 9 23:27:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13551986 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 8593739AD8 for ; Fri, 9 Feb 2024 23:27:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521280; cv=none; b=jAs2dJNPSZa+4JAqRjgsOTKmQo3wr9LRDrgbjzfT/QN50acVzUcV34Y85Uxw7De+O37vBQ06Tm0PDPboFu2YdGjLHhDROErDcWxD1K1oauQJWPGp5iIeConGK59cVTHq2INyxM0/8AskFOZCTYu0lNtXTqPwDcA4HY+4+j+k0vg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707521280; c=relaxed/simple; bh=XmfUws+oeyOISEqJNNOoqfuX9Z3znjTIsViLY8A4CV0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZwgpMh9FTYJ3bsWFDBK76fU4pOrQv2uFh20zp0vn2jbD69Txk3ROc1uwISt+F1AjX4hwAJTcFohUxXNdxhUrgVJk0B1hUe3+JCZOMrpsz/1JRjpQFVRXKTems5TGXoItUeiTTKSexzVb58COcvqVGx+Maj1k14jRYMUstsgniLo= 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=MZscERst; arc=none smtp.client-ip=209.85.221.48 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="MZscERst" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-33b65b2e43eso735145f8f.1 for ; Fri, 09 Feb 2024 15:27:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1707521276; x=1708126076; 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=sEjWJXUyvIA+QGAomrtyrXXlSTIk0reYqWcesBPAmOE=; b=MZscERstG746/EC6x68aKQKJviZuQo+tnQ9fYymgNZYEcv6cAL9lGfbZmXb01yJtPT CgObe7cYpKguz1iQTVv7MJZo1Rhn/uTShebcsOsHM4wQaojn9OY/2M1SsA1+YgBsMEdW RXEIC2t2peMUgVUhIq2z4gV/mHkpnSpUb2kc29L7lGBdxd8Lv+PUlk0nDIpNvbnvA0dF 9Y7qtT9Nwe9R6Fi3e1F79T1SgoFU7pl2v/oNhLhY8/YTrXLe9QF082LIxXL0NpskNcWY GuMn13AkZvo3UEdTnPk7fAe0y1S8ynIeQ0jpLdS6ufi3fb4IpWvkB4qbKhwfoW9kfluk j3GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707521276; x=1708126076; 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=sEjWJXUyvIA+QGAomrtyrXXlSTIk0reYqWcesBPAmOE=; b=lCl7GrDPu1acw7lMkj/ekmWOPs+919IY7yFKFDVZe3V+RMKwrsWgWq8SiI6Qb2kTnZ q70LoVl+0odS7VT4pGhGvfzKIZE1MKVo9Y1pykAfeZ2p7l3qbDSO3jfIzXDFqPu3p19e DMdd6Nvl+TCFM7Z61fQh6PCHCBEWDKzidTqfl6rLujKAFr420wXlhLe/I75awvMfu3t1 p+SrfGCinrhnl5Vdeznu2xqhzd+eT/H+Z+j5zKrku6UyPrnmiJW88+l+X5PoZfQKFycg 814jH6isgIjLdozflrHmWLeZtHLIG6+hbuSsvu6CXtV1mWH2zvkFDdKWKA5QbNc0j4Ck ML2A== X-Gm-Message-State: AOJu0YyP8q47IDF3NaQX5ZVRKrm5vYtgh2z9i25eRp8EvepgGZuvh1s7 /nrNW89b+oZRwTsDz1RJpKeym67B5ViY206j7QKhbM2aJRW+HmY14EnTsFASWVY= X-Google-Smtp-Source: AGHT+IGSSLxk0L5D7P5puUHUyPvxJd496LTB8d6YAW2DlfpWWlOnfjQ2qdyY6XgY/zJNmZVpdLBONg== X-Received: by 2002:a5d:6d82:0:b0:33a:e526:3a49 with SMTP id l2-20020a5d6d82000000b0033ae5263a49mr349267wrs.23.1707521275947; Fri, 09 Feb 2024 15:27:55 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU5gG2SF6yT8WUL+4vv7+uFebppTrWyIrbkPYcG1Ikb8Eroht6+PTGG50Fo77XTqdcMvlNmYQ4RulqbZG7B0swklZi7I8zivoeAdHOYwiaQzK9qKM8B2VALnjFaNa1HC8bkY7JNCpg8292YaqxlNULkiP2omF9BWweLz145QPPaagaMw2YJDggg Received: from localhost (dslb-002-202-118-224.002.202.pools.vodafone-ip.de. [2.202.118.224]) by smtp.gmail.com with UTF8SMTPSA id y2-20020a056000108200b0033b5afd7f4dsm371009wrw.91.2024.02.09.15.27.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Feb 2024 15:27:55 -0800 (PST) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, linux-lvm@lists.linux.dev, Zdenek Kabelac , Peter Rajnoha Subject: [PATCH v2 7/7] multipath-tools: Makefile.inc: set _FILE_OFFSET_BITS=64 Date: Sat, 10 Feb 2024 00:27:35 +0100 Message-ID: <20240209232735.9791-8-mwilck@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240209232735.9791-1-mwilck@suse.com> References: <20240209232735.9791-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Set _FILE_OFFSET_BITS=64 in order to avoid EOVERFLOW error for getdents() syscalls on some file systems (in particular, ext4) in emultated 32bit environments on 64 bit kernel, e.g. when running in qemu. This error occured in arm/v7 CI runs on Ubuntu runners on GitHub, which can be enabled after applying this change. See e.g. https://sourceware.org/bugzilla/show_bug.cgi?id=23960. This change requires fixes for the unit tests: If -D_FILE_OFFSET_BITS=64 is set, glibc headers replace some functions with their 64bit equivalents. open() is replaced by open64(), etc. cmocka wrappers for these functions must have correct name: defining __wrap_open() has no effect for calls to open64(). Unit tests using the wrongly named wrapper functions will fail in non-obvious ways. Use CPP macros to substitute the correct name for affected functions. Also, the Makefile rule that builds the -Wl,wrap= options must parse the C preprocessor output to generate suitable command line parameters for the linker. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- Makefile.inc | 1 + tests/Makefile | 5 ++++- tests/alias.c | 4 ++-- tests/directio.c | 7 +++--- tests/dmevents.c | 8 +++---- tests/sysfs.c | 57 ++++++++++++++++++++++++------------------------ tests/test-lib.c | 9 +++++--- tests/wrap64.h | 48 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 98 insertions(+), 41 deletions(-) create mode 100644 tests/wrap64.h diff --git a/Makefile.inc b/Makefile.inc index a0e36c4..5668e63 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -100,6 +100,7 @@ WARNFLAGS := -Werror -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implici -Werror=implicit-function-declaration -Werror=format-security \ $(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)\" \ diff --git a/tests/Makefile b/tests/Makefile index 7dac8a8..7dde8bd 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -105,8 +105,11 @@ include $(wildcard $(OBJS:.o=.d)) dep_clean: $(Q)$(RM) $(OBJS:.o=.d) +# Parse the C code for __wrap_xyz() functions and generate linker options from them. +# See comment in wrap64.h %.o.wrap: %.c - @sed -n 's/^.*__wrap_\([a-zA-Z0-9_]*\).*$$/-Wl,--wrap=\1/p' $< | \ + $(Q)$(CC) $(CPPFLAGS) $($*-test_FLAGS) -E $< | \ + sed -n 's/^.*__wrap_\([a-zA-Z0-9_]*\).*$$/-Wl,--wrap=\1/p' | \ sort -u | tr '\n' ' ' >$@ # Pass the original values of CFLAGS etc. to the sub-make, which will include diff --git a/tests/alias.c b/tests/alias.c index c2ae915..95ce994 100644 --- a/tests/alias.c +++ b/tests/alias.c @@ -9,7 +9,7 @@ #include "test-log.h" #include #include - +#include "wrap64.h" #include "globals.c" #include "../libmultipath/alias.c" @@ -71,7 +71,7 @@ int __wrap_rename(const char *old, const char *new) return __set_errno(mock_type(int)); } -int __wrap_mkstemp(char *template) +int WRAP_FUNC(mkstemp)(char *template) { return 10; } diff --git a/tests/directio.c b/tests/directio.c index 5201d21..cbedcc9 100644 --- a/tests/directio.c +++ b/tests/directio.c @@ -24,6 +24,7 @@ #include #include #include +#include "wrap64.h" #include "globals.c" #include "../libmultipath/checkers/directio.c" @@ -66,12 +67,12 @@ int __wrap_ioctl(int fd, ioctl_request_t request, void *argp) #endif } -int __real_fcntl(int fd, int cmd, long arg); +int REAL_FCNTL (int fd, int cmd, long arg); -int __wrap_fcntl(int fd, int cmd, long arg) +int WRAP_FCNTL (int fd, int cmd, long arg) { #ifdef DIO_TEST_DEV - return __real_fcntl(fd, cmd, arg); + return REAL_FCNTL(fd, cmd, arg); #else assert_int_equal(fd, test_fd); assert_int_equal(cmd, F_GETFL); diff --git a/tests/dmevents.c b/tests/dmevents.c index f08e649..540bf0d 100644 --- a/tests/dmevents.c +++ b/tests/dmevents.c @@ -29,7 +29,7 @@ #include #include "structs.h" #include "structs_vec.h" - +#include "wrap64.h" #include "globals.c" /* I have to do this to get at the static variables */ #include "../multipathd/dmevents.c" @@ -207,7 +207,7 @@ static int teardown(void **state) return 0; } -int __wrap_open(const char *pathname, int flags) +int WRAP_FUNC(open)(const char *pathname, int flags) { assert_ptr_equal(pathname, "/dev/mapper/control"); assert_int_equal(flags, O_RDWR); @@ -389,7 +389,7 @@ static void test_init_waiter_bad1(void **state) struct test_data *datap = (struct test_data *)(*state); if (datap == NULL) skip(); - will_return(__wrap_open, -1); + wrap_will_return(WRAP_FUNC(open), -1); assert_int_equal(init_dmevent_waiter(&datap->vecs), -1); assert_ptr_equal(waiter, NULL); } @@ -400,7 +400,7 @@ static void test_init_waiter_good0(void **state) struct test_data *datap = (struct test_data *)(*state); if (datap == NULL) skip(); - will_return(__wrap_open, 2); + wrap_will_return(WRAP_FUNC(open), 2); assert_int_equal(init_dmevent_waiter(&datap->vecs), 0); assert_ptr_not_equal(waiter, NULL); } diff --git a/tests/sysfs.c b/tests/sysfs.c index 6e07efd..fc256d8 100644 --- a/tests/sysfs.c +++ b/tests/sysfs.c @@ -18,6 +18,7 @@ #include "test-log.h" #include "sysfs.h" #include "util.h" +#include "wrap64.h" #define TEST_FD 123 @@ -28,7 +29,7 @@ char *__wrap_udev_device_get_syspath(struct udev_device *ud) return val; } -int __wrap_open(const char *pathname, int flags) +int WRAP_FUNC(open)(const char *pathname, int flags) { int ret; @@ -166,10 +167,10 @@ static void test_sagv_open_fail(void **state) will_return(__wrap_udev_device_get_syspath, "/foo"); expect_condlog(4, "open '/foo/bar'"); - expect_string(__wrap_open, pathname, "/foo/bar"); - expect_value(__wrap_open, flags, O_RDONLY); + expect_string(WRAP_FUNC(open), pathname, "/foo/bar"); + expect_value(WRAP_FUNC(open), flags, O_RDONLY); errno = ENOENT; - will_return(__wrap_open, -1); + wrap_will_return(WRAP_FUNC(open), -1); expect_condlog(3, "__sysfs_attr_get_value: attribute '/foo/bar' cannot be opened"); assert_int_equal(sysfs_attr_get_value((void *)state, "bar", buf, sizeof(buf)), -ENOENT); @@ -181,9 +182,9 @@ static void test_sagv_read_fail(void **state) will_return(__wrap_udev_device_get_syspath, "/foo"); expect_condlog(4, "open '/foo/bar'"); - expect_string(__wrap_open, pathname, "/foo/bar"); - expect_value(__wrap_open, flags, O_RDONLY); - will_return(__wrap_open, TEST_FD); + expect_string(WRAP_FUNC(open), pathname, "/foo/bar"); + expect_value(WRAP_FUNC(open), flags, O_RDONLY); + wrap_will_return(WRAP_FUNC(open), TEST_FD); expect_value(__wrap_read, fd, TEST_FD); expect_value(__wrap_read, count, sizeof(buf)); errno = EISDIR; @@ -196,9 +197,9 @@ static void test_sagv_read_fail(void **state) will_return(__wrap_udev_device_get_syspath, "/foo"); expect_condlog(4, "open '/foo/baz'"); - expect_string(__wrap_open, pathname, "/foo/baz"); - expect_value(__wrap_open, flags, O_RDONLY); - will_return(__wrap_open, TEST_FD); + expect_string(WRAP_FUNC(open), pathname, "/foo/baz"); + expect_value(WRAP_FUNC(open), flags, O_RDONLY); + wrap_will_return(WRAP_FUNC(open), TEST_FD); expect_value(__wrap_read, fd, TEST_FD); expect_value(__wrap_read, count, sizeof(buf)); errno = EPERM; @@ -222,9 +223,9 @@ static void _test_sagv_read(void **state, unsigned int bufsz) memset(buf, '.', sizeof(buf)); will_return(__wrap_udev_device_get_syspath, "/foo"); expect_condlog(4, "open '/foo/bar'"); - expect_string(__wrap_open, pathname, "/foo/bar"); - expect_value(__wrap_open, flags, O_RDONLY); - will_return(__wrap_open, TEST_FD); + expect_string(WRAP_FUNC(open), pathname, "/foo/bar"); + expect_value(WRAP_FUNC(open), flags, O_RDONLY); + wrap_will_return(WRAP_FUNC(open), TEST_FD); expect_value(__wrap_read, fd, TEST_FD); expect_value(__wrap_read, count, bufsz); will_return(__wrap_read, sizeof(input) - 1); @@ -249,9 +250,9 @@ static void _test_sagv_read(void **state, unsigned int bufsz) memset(buf, '.', sizeof(buf)); will_return(__wrap_udev_device_get_syspath, "/foo"); expect_condlog(4, "open '/foo/baz'"); - expect_string(__wrap_open, pathname, "/foo/baz"); - expect_value(__wrap_open, flags, O_RDONLY); - will_return(__wrap_open, TEST_FD); + expect_string(WRAP_FUNC(open), pathname, "/foo/baz"); + expect_value(WRAP_FUNC(open), flags, O_RDONLY); + wrap_will_return(WRAP_FUNC(open), TEST_FD); expect_value(__wrap_read, fd, TEST_FD); expect_value(__wrap_read, count, bufsz); will_return(__wrap_read, sizeof(input) - 1); @@ -300,9 +301,9 @@ static void _test_sagv_read_zeroes(void **state, unsigned int bufsz) memset(buf, '.', sizeof(buf)); will_return(__wrap_udev_device_get_syspath, "/foo"); expect_condlog(4, "open '/foo/bar'"); - expect_string(__wrap_open, pathname, "/foo/bar"); - expect_value(__wrap_open, flags, O_RDONLY); - will_return(__wrap_open, TEST_FD); + expect_string(WRAP_FUNC(open), pathname, "/foo/bar"); + expect_value(WRAP_FUNC(open), flags, O_RDONLY); + wrap_will_return(WRAP_FUNC(open), TEST_FD); expect_value(__wrap_read, fd, TEST_FD); expect_value(__wrap_read, count, bufsz); will_return(__wrap_read, sizeof(input) - 1); @@ -385,10 +386,10 @@ static void test_sasv_open_fail(void **state) will_return(__wrap_udev_device_get_syspath, "/foo"); expect_condlog(4, "open '/foo/bar'"); - expect_string(__wrap_open, pathname, "/foo/bar"); - expect_value(__wrap_open, flags, O_WRONLY); + expect_string(WRAP_FUNC(open), pathname, "/foo/bar"); + expect_value(WRAP_FUNC(open), flags, O_WRONLY); errno = EPERM; - will_return(__wrap_open, -1); + wrap_will_return(WRAP_FUNC(open), -1); expect_condlog(3, "sysfs_attr_set_value: attribute '/foo/bar' cannot be opened"); assert_int_equal(sysfs_attr_set_value((void *)state, "bar", buf, sizeof(buf)), -EPERM); @@ -400,9 +401,9 @@ static void test_sasv_write_fail(void **state) will_return(__wrap_udev_device_get_syspath, "/foo"); expect_condlog(4, "open '/foo/bar'"); - expect_string(__wrap_open, pathname, "/foo/bar"); - expect_value(__wrap_open, flags, O_WRONLY); - will_return(__wrap_open, TEST_FD); + expect_string(WRAP_FUNC(open), pathname, "/foo/bar"); + expect_value(WRAP_FUNC(open), flags, O_WRONLY); + wrap_will_return(WRAP_FUNC(open), TEST_FD); expect_value(__wrap_write, fd, TEST_FD); expect_value(__wrap_write, count, sizeof(buf)); errno = EISDIR; @@ -421,9 +422,9 @@ static void _test_sasv_write(void **state, unsigned int n_written) assert_in_range(n_written, 0, sizeof(buf)); will_return(__wrap_udev_device_get_syspath, "/foo"); expect_condlog(4, "open '/foo/bar'"); - expect_string(__wrap_open, pathname, "/foo/bar"); - expect_value(__wrap_open, flags, O_WRONLY); - will_return(__wrap_open, TEST_FD); + expect_string(WRAP_FUNC(open), pathname, "/foo/bar"); + expect_value(WRAP_FUNC(open), flags, O_WRONLY); + wrap_will_return(WRAP_FUNC(open), TEST_FD); expect_value(__wrap_write, fd, TEST_FD); expect_value(__wrap_write, count, sizeof(buf)); will_return(__wrap_write, n_written); diff --git a/tests/test-lib.c b/tests/test-lib.c index f75ea31..665d438 100644 --- a/tests/test-lib.c +++ b/tests/test-lib.c @@ -16,6 +16,7 @@ #include "propsel.h" #include "unaligned.h" #include "test-lib.h" +#include "wrap64.h" const int default_mask = (DI_SYSFS|DI_BLACKLIST|DI_WWID|DI_CHECKER|DI_PRIO|DI_SERIAL); const char default_devnode[] = "sdxTEST"; @@ -38,16 +39,18 @@ const char default_wwid_1[] = "TEST-WWID-1"; * resolved by the assembler before the linking stage. */ -int __real_open(const char *path, int flags, int mode); + +int REAL_FUNC(open)(const char *path, int flags, int mode); static const char _mocked_filename[] = "mocked_path"; -int __wrap_open(const char *path, int flags, int mode) + +int WRAP_FUNC(open)(const char *path, int flags, int mode) { condlog(4, "%s: %s", __func__, path); if (!strcmp(path, _mocked_filename)) return 111; - return __real_open(path, flags, mode); + return REAL_FUNC(open)(path, flags, mode); } int __wrap_libmp_get_version(int which, unsigned int version[3]) diff --git a/tests/wrap64.h b/tests/wrap64.h new file mode 100644 index 0000000..8c91d27 --- /dev/null +++ b/tests/wrap64.h @@ -0,0 +1,48 @@ +#ifndef _WRAP64_H +#define _WRAP64_H 1 +#include "util.h" + +/* + * Make cmocka work with _FILE_OFFSET_BITS == 64 + * + * If -D_FILE_OFFSET_BITS=64 is set, glibc headers replace some functions with + * their 64bit equivalents. "open()" is replaced by "open64()", etc. cmocka + * wrappers for these functions must have correct name __wrap_open() doesn't + * work if the function called is not open() but open64(). Consequently, unit + * tests using such wrappers will fail. + * Use some CPP trickery to insert the correct name. The Makefile rule that + * creates the .wrap file must parse the C preprocessor output to generate the + * correct -Wl,wrap= option. + */ + +/* Without this indirection, WRAP_FUNC(x) would be expanded to __wrap_WRAP_NAME(x) */ +#define CONCAT2_(x, y) x ## y +#define CONCAT2(x, y) CONCAT2_(x, y) + +#if defined(__GLIBC__) && _FILE_OFFSET_BITS == 64 +#define WRAP_NAME(x) x ## 64 +#else +#define WRAP_NAME(x) x +#endif +#define WRAP_FUNC(x) CONCAT2(__wrap_, WRAP_NAME(x)) +#define REAL_FUNC(x) CONCAT2(__real_, WRAP_NAME(x)) + +/* + * fcntl() needs special treatment; fcntl64() has been introduced in 2.28. + * https://savannah.gnu.org/forum/forum.php?forum_id=9205 + */ +#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 28) +#define WRAP_FCNTL_NAME WRAP_NAME(fcntl) +#else +#define WRAP_FCNTL_NAME fcntl +#endif +#define WRAP_FCNTL CONCAT2(__wrap_, WRAP_FCNTL_NAME) +#define REAL_FCNTL CONCAT2(__real_, WRAP_FCNTL_NAME) + +/* + * will_return() is itself a macro that uses CPP "stringizing". We need a + * macro indirection to make sure the *value* of WRAP_FUNC() is stringized + * (see https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html). + */ +#define wrap_will_return(x, y) will_return(x, y) +#endif