From patchwork Thu May 2 18:59: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: 13652005 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.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 24140664DB for ; Thu, 2 May 2024 19:00:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714676410; cv=none; b=W31cjtu+ZDgCVK1S2yyB5gpQ4ttp+ucQFZ7m8CEOWy0BZxAUXG+5P5ecHp+VdDM0e8FpNe82yB2lDzC89QZ4lzuvtkUidrhz62feW/z0v2/IEjD+1hSFTzKJuoSEAlgUL4SGWNYwQqEsODpN4JalSlHL3CRaRN/FThSqp0tKgdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714676410; c=relaxed/simple; bh=kIH3s5sv5jp1Yhd0hh4rKC/FX7edizNcHKbsGPg23SE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RJPYpJ8SW1MQYsXjdpEWFnk9Q+YV6VM2TA+CpcXrDSYpfR3KcA6XaRtctBbV1nKRB784ch7LvB+M0vmtXGMg2g5c7n05NsWk68kwQ5S0cDspLgi2jKOxRdu6SRpZ+7EVfvuwCzAnWwUZG/T8HI6lsPyUshhTmyUtba1Hpy1+sjQ= 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=W0lZa0D4; arc=none smtp.client-ip=209.85.208.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="W0lZa0D4" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-572babec735so1166460a12.0 for ; Thu, 02 May 2024 12:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1714676406; x=1715281206; 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=7DdC07DBta9RVKmErjlht6S0Wd6hy5Ip/EqYIQTURRQ=; b=W0lZa0D4XWYgDIbC48+1cHLpN/nEMG12b1XF9QYPM9QaPklqN1QgyeV6SeCmTNNhrf KSXEXUUdVhh0WNVd1h7Oo9uBCoohaSfCZ6djyP3EjwyLSmHtIVtpn9nD4BOzdQKwuer1 +3Bl+okHfrGa2cdo+JBepY2wx63hGva1E1qlNHNAiYWgW8Hpid3o4DHO+jozn1b/SM4m sUP87VhQat1qkc1tKaLbIgMneojf2U1Wd0rOg8Atpz9gR7JqbaY740qC2gYsgDO4XqVA /Q3/234dmTalXl59SstDMLwnU6LH3if2MO/E2JOl9bBQASvxLcazZurERPhCMKHP2TSD IbaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714676406; x=1715281206; 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=7DdC07DBta9RVKmErjlht6S0Wd6hy5Ip/EqYIQTURRQ=; b=dSSi9iVuwczeqFFlZ3kUUJrZIKcHdfO/4M3vI5S187m8aV4wkTNEfoQ6vMdN/QauJ+ uYZrO7riXs0nyL8ijLx3bWDUZ14sU0iyJvRhKUEEfYi6X3wfnjxfpgBoe0fa3y4axOut mti1PoN+FG/QwBmSNXqReHGcjJmUNT/J3LsaMifUd5wcXY1q7hBt/kqaRHFHdFxn+m6K Va2Qdp1NAkgmLfMPNdpqmGUFD7OzfxjVPlr2rywLRvrJlabxW9HiW3jKvfJVgngvuVLb fRf/JOd21qlwAPFRq2AnQhLRuFzrx6Q6nB3B8TpBohF9S7o0Sh7Dqba7+x7oMsNyukpk +u2g== X-Gm-Message-State: AOJu0YyZubdP67jGDsm+MmRd1PERjibtuBKjkFpdDUGZ3ywf5ap7zIiw XGdFg04OBobCMPbcM9maycSgTn+yjqYVcSuqlNKuEmjEZ/WeFgTQ4FHlCGZlwKgZChyb+GJTuAF q X-Google-Smtp-Source: AGHT+IEcjQY2/tIeKQ8fN1hHo8EIyYWyrbf6XWFZSBOeMzImHaG0nwWCPiU8TuVFpnVi9vRK/GXxNg== X-Received: by 2002:a17:906:bc52:b0:a58:eb9a:420d with SMTP id s18-20020a170906bc5200b00a58eb9a420dmr2480647ejv.17.1714676406269; Thu, 02 May 2024 12:00:06 -0700 (PDT) Received: from localhost (p200300de373edc00b298a6be282c8242.dip0.t-ipconnect.de. [2003:de:373e:dc00:b298:a6be:282c:8242]) by smtp.gmail.com with UTF8SMTPSA id n25-20020a1709061d1900b00a5906b4e417sm841039ejh.98.2024.05.02.12.00.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 May 2024 12:00:06 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, Martin Wilck Subject: [PATCH 1/3] libmultipath: use bitwise flags for map flushing API Date: Thu, 2 May 2024 20:59:44 +0200 Message-ID: <20240502185946.31192-2-mwilck@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502185946.31192-1-mwilck@suse.com> References: <20240502185946.31192-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rather than passing 3 separate bool variables to _dm_flush_map(), define bitwise flags to modify the function's behavior, and pass these flags to called functions accordingly. This improves the readability of the code, function calls are more expressive. Signed-off-by: Martin Wilck --- libmultipath/devmapper.c | 72 +++++++++++++++++----------------------- libmultipath/devmapper.h | 18 +++++++--- 2 files changed, 43 insertions(+), 47 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 2e7b2c6..a6a9c2b 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -53,9 +53,8 @@ static int dm_cancel_remove_partmaps(const char * mapname); #define __DR_UNUSED__ __attribute__((unused)) #endif -static int dm_remove_partmaps (const char * mapname, int need_sync, - int deferred_remove); -static int do_foreach_partmaps(const char * mapname, +static int dm_remove_partmaps (const char *mapname, int flags); +static int do_foreach_partmaps(const char *mapname, int (*partmap_func)(const char *, void *), void *data); static int _dm_queue_if_no_path(const char *mapname, int enable); @@ -439,9 +438,9 @@ int dm_simplecmd_noflush (int task, const char *name, uint16_t udev_flags) } static int -dm_device_remove (const char *name, int needsync, int deferred_remove) { - return dm_simplecmd(DM_DEVICE_REMOVE, name, 0, needsync, 0, - deferred_remove); +dm_device_remove (const char *name, int flags) { + return dm_simplecmd(DM_DEVICE_REMOVE, name, 0, flags & DMFL_NEED_SYNC, 0, + flags & DMFL_DEFERRED); } static int @@ -1061,8 +1060,7 @@ partmap_in_use(const char *name, void *data) return 0; } -int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, - int need_suspend, int retries) +int _dm_flush_map (const char *mapname, int flags, int retries) { int r; int queue_if_no_path = 0; @@ -1080,10 +1078,10 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, /* If you aren't doing a deferred remove, make sure that no * devices are in use */ - if (!deferred_remove && partmap_in_use(mapname, NULL)) + if (!(flags & DMFL_DEFERRED) && partmap_in_use(mapname, NULL)) return DM_FLUSH_BUSY; - if (need_suspend && + if ((flags & DMFL_SUSPEND) && dm_get_map(mapname, &mapsize, ¶ms) == DMP_OK && strstr(params, "queue_if_no_path")) { if (!_dm_queue_if_no_path(mapname, 0)) @@ -1095,22 +1093,22 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, free(params); params = NULL; - if ((r = dm_remove_partmaps(mapname, need_sync, deferred_remove))) + if ((r = dm_remove_partmaps(mapname, flags))) return r; - if (!deferred_remove && dm_get_opencount(mapname)) { + if (!(flags & DMFL_DEFERRED) && dm_get_opencount(mapname)) { condlog(2, "%s: map in use", mapname); return DM_FLUSH_BUSY; } do { - if (need_suspend && queue_if_no_path != -1) + if ((flags & DMFL_SUSPEND) && queue_if_no_path != -1) dm_simplecmd_flush(DM_DEVICE_SUSPEND, mapname, 0); - r = dm_device_remove(mapname, need_sync, deferred_remove); + r = dm_device_remove(mapname, flags); if (r) { - if (deferred_remove && dm_map_present(mapname)) { + if ((flags & DMFL_DEFERRED) && dm_map_present(mapname)) { condlog(4, "multipath map %s remove deferred", mapname); return DM_FLUSH_DEFERRED; @@ -1124,7 +1122,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, } else { condlog(2, "failed to remove multipath map %s", mapname); - if (need_suspend && queue_if_no_path != -1) { + if ((flags & DMFL_SUSPEND) && queue_if_no_path != -1) { dm_simplecmd_noflush(DM_DEVICE_RESUME, mapname, udev_flags); } @@ -1139,27 +1137,18 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, return DM_FLUSH_FAIL; } +int +dm_flush_map_nopaths(const char *mapname, int deferred_remove __DR_UNUSED__) +{ + int flags = DMFL_NEED_SYNC; + #ifdef LIBDM_API_DEFERRED - -int -dm_flush_map_nopaths(const char * mapname, int deferred_remove) -{ - return _dm_flush_map(mapname, 1, - (deferred_remove == DEFERRED_REMOVE_ON || - deferred_remove == DEFERRED_REMOVE_IN_PROGRESS), - 0, 0); -} - -#else - -int -dm_flush_map_nopaths(const char * mapname, - int deferred_remove __attribute__((unused))) -{ - return _dm_flush_map(mapname, 1, 0, 0, 0); -} - + flags |= ((deferred_remove == DEFERRED_REMOVE_ON || + deferred_remove == DEFERRED_REMOVE_IN_PROGRESS) ? + DMFL_DEFERRED : 0); #endif + return _dm_flush_map(mapname, flags, 0); +} int dm_flush_maps (int retries) { @@ -1528,8 +1517,7 @@ out: } struct remove_data { - int need_sync; - int deferred_remove; + int flags; }; static int @@ -1538,21 +1526,21 @@ remove_partmap(const char *name, void *data) struct remove_data *rd = (struct remove_data *)data; if (dm_get_opencount(name)) { - dm_remove_partmaps(name, rd->need_sync, rd->deferred_remove); - if (rd->deferred_remove && dm_get_opencount(name)) { + dm_remove_partmaps(name, rd->flags); + if ((rd->flags & DMFL_DEFERRED) && dm_get_opencount(name)) { condlog(2, "%s: map in use", name); return DM_FLUSH_BUSY; } } condlog(4, "partition map %s removed", name); - dm_device_remove(name, rd->need_sync, rd->deferred_remove); + dm_device_remove(name, rd->flags); return DM_FLUSH_OK; } static int -dm_remove_partmaps (const char * mapname, int need_sync, int deferred_remove) +dm_remove_partmaps (const char * mapname, int flags) { - struct remove_data rd = { need_sync, deferred_remove }; + struct remove_data rd = { flags }; return do_foreach_partmaps(mapname, remove_partmap, &rd); } diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 93caa2a..bb4a55a 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -58,12 +58,20 @@ enum { }; int partmap_in_use(const char *name, void *data); -int _dm_flush_map (const char *, int, int, int, int); -int dm_flush_map_nopaths(const char * mapname, int deferred_remove); -#define dm_flush_map(mapname) _dm_flush_map(mapname, 1, 0, 0, 0) -#define dm_flush_map_nosync(mapname) _dm_flush_map(mapname, 0, 0, 0, 0) + +enum { + DMFL_NONE = 0, + DMFL_NEED_SYNC = 1 << 0, + DMFL_DEFERRED = 1 << 1, + DMFL_SUSPEND = 1 << 2, +}; + +int _dm_flush_map (const char *mapname, int flags, int retries); +#define dm_flush_map(mapname) _dm_flush_map(mapname, DMFL_NEED_SYNC, 0) +#define dm_flush_map_nosync(mapname) _dm_flush_map(mapname, DMFL_NONE, 0) #define dm_suspend_and_flush_map(mapname, retries) \ - _dm_flush_map(mapname, 1, 0, 1, retries) + _dm_flush_map(mapname, DMFL_NEED_SYNC|DMFL_SUSPEND, retries) +int dm_flush_map_nopaths(const char * mapname, int deferred_remove); int dm_cancel_deferred_remove(struct multipath *mpp); int dm_flush_maps (int retries); int dm_fail_path(const char * mapname, char * path); From patchwork Thu May 2 18:59:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13652006 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 DFF9715FA73 for ; Thu, 2 May 2024 19:00:08 +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=1714676411; cv=none; b=if9XTueBpkz55fOpwPTS//Be+aNvIWSs22exrcuqnTx5RJbHCQJ7QpVfCUkc3fOv7ICs+f6mJAMZxWCycNdpyb3fGMM+HUPuwL69FxNFBF1YeSC2hkjWI1qUi0uDObK4Ual+EBmtLXrgz1KT4Ap4pt7xQ1O+Z9e96Vbjb+3AwDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714676411; c=relaxed/simple; bh=4KJOrg09JRz5+jdoWpKCAdTKZLK862YNzxK06ZopN8k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KZZSsoJHe1i7GCHFxF3KZBXsXKajXLWtPsfKYsviUssa/nfjE6vHhQ55mpdSQVUUcvxLTYHb3YYVmCpcKUf6wg+WXTPaj5vhfwoqDPyrjvpDW1bk4S2/z00m6UYa8XSY8/P6T5pxmfw1SBK1JsQ7G4/YmCwq0JtMu+Y7Py0hEWE= 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=MEBgA+N5; 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="MEBgA+N5" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a595c61553cso274461066b.1 for ; Thu, 02 May 2024 12:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1714676407; x=1715281207; 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=QSj8+GFAHYtdcJJK/ttVbJ3Dza0QpoLbDyzRgd0ohlI=; b=MEBgA+N5IrRUU64QcFh+Zq6bGSLaSFJdi/1f49apDILGZmStIMXWSlXkaVS5HcX9Ej bMkSuxpUJI3DfK44nwp6JIVyQPCcumZNKTwrthP2vw77oR+NQgocYHudmKeVVz8YOfnh Bsw6VNjhHOrY2CSzhJiYfBg8zWpu57mSCR2+qUkWEmTLpHmGdqjOYV/yxt5eLJ1kQrZz TQ6a4okTWOkuuNl9ICtbVtgcLtfTZhDO191NhYIQzeDrWEA128+SNlYfCj5S3YsM2FJ5 v9Z0lNUvvfM1nYL6NT4BKQ0OmUNG+F5413Nhd3WKhyS+KVXfSbjeJdWapGlQB6iTBt9f QbsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714676407; x=1715281207; 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=QSj8+GFAHYtdcJJK/ttVbJ3Dza0QpoLbDyzRgd0ohlI=; b=ZQtVfdzK6weyF2IerZT8ySD0bxCT8SiV7NIbPVLdA8YFYQduNZ9R2IYotWYOGjdifb AGFyOkznZa9TMDSEtJV4CxwqCJvN5ADzR/Deek/l0+15I7490YwfPkmlfJi2UHqcE572 rW8U/9H96p9BDMn6qA0qXTfYqZbAsc3FiMvXIE4mW3/Ym1G1gR5Q+aHqCOxq3p26wtTp rqctR0uVvc8eECHK0Vam0ghfUCJzBHCTA2ifj5trAXMBOoIRvDG98Os+NhtkIip1VPb/ u/LYh9A3eDtBGFJJ7eOXlfVEhnO7aZS3xFFvx8RKidRPLcDUyr5CJPJdmQhEPFrFT8mw W99w== X-Gm-Message-State: AOJu0YwmAtt0zwulYz+fP3edPJOu8F9NqSlcrZfplDd9jIFByY+kVrkq 2DsefQq6YrZMSY4CaaXBNbbedg62p80lafjH55uCB+WxdCdtaWPFoBZrwg/Qbx3HUVN45VXj2XM w X-Google-Smtp-Source: AGHT+IFe5KhpHe9RFyerS7F2J0d0/VgUCr1nWJtzuJX4JS8UH2MjCp62o8jSy87xfalZ6vjns3a68Q== X-Received: by 2002:a17:906:a159:b0:a52:3f01:e11d with SMTP id bu25-20020a170906a15900b00a523f01e11dmr256370ejb.34.1714676407197; Thu, 02 May 2024 12:00:07 -0700 (PDT) Received: from localhost (p200300de373edc00b298a6be282c8242.dip0.t-ipconnect.de. [2003:de:373e:dc00:b298:a6be:282c:8242]) by smtp.gmail.com with UTF8SMTPSA id o12-20020a170906358c00b00a55b17418ebsm830873ejb.89.2024.05.02.12.00.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 May 2024 12:00:07 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, Martin Wilck Subject: [PATCH 2/3] libmultipath: use bitwise flags for dm_simplecmd API Date: Thu, 2 May 2024 20:59:45 +0200 Message-ID: <20240502185946.31192-3-mwilck@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502185946.31192-1-mwilck@suse.com> References: <20240502185946.31192-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Also use bitwise flags for dm_simplecmd() and its relatives. Again, this makes the code more expressive and more readable, while simplifying the function calls. Signed-off-by: Martin Wilck --- libmultipath/devmapper.c | 26 +++++++++++++------------- libmultipath/devmapper.h | 5 +++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index a6a9c2b..08bb3c5 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -386,10 +386,9 @@ libmp_dm_task_create(int task) } static int -dm_simplecmd (int task, const char *name, int no_flush, int need_sync, - uint16_t udev_flags, int deferred_remove __DR_UNUSED__) { +dm_simplecmd (int task, const char *name, int flags, uint16_t udev_flags) { int r = 0; - int udev_wait_flag = ((need_sync || udev_flags) && + int udev_wait_flag = (((flags & DMFL_NEED_SYNC) || udev_flags) && (task == DM_DEVICE_RESUME || task == DM_DEVICE_REMOVE)); uint32_t cookie = 0; @@ -404,11 +403,11 @@ dm_simplecmd (int task, const char *name, int no_flush, int need_sync, dm_task_no_open_count(dmt); dm_task_skip_lockfs(dmt); /* for DM_DEVICE_RESUME */ #ifdef LIBDM_API_FLUSH - if (no_flush) + if (flags & DMFL_NO_FLUSH) dm_task_no_flush(dmt); /* for DM_DEVICE_SUSPEND/RESUME */ #endif #ifdef LIBDM_API_DEFERRED - if (deferred_remove) + if (flags & DMFL_DEFERRED) dm_task_deferred_remove(dmt); #endif if (udev_wait_flag && @@ -429,18 +428,17 @@ out: int dm_simplecmd_flush (int task, const char *name, uint16_t udev_flags) { - return dm_simplecmd(task, name, 0, 1, udev_flags, 0); + return dm_simplecmd(task, name, DMFL_NEED_SYNC, udev_flags); } int dm_simplecmd_noflush (int task, const char *name, uint16_t udev_flags) { - return dm_simplecmd(task, name, 1, 1, udev_flags, 0); + return dm_simplecmd(task, name, DMFL_NO_FLUSH|DMFL_NEED_SYNC, udev_flags); } static int dm_device_remove (const char *name, int flags) { - return dm_simplecmd(DM_DEVICE_REMOVE, name, 0, flags & DMFL_NEED_SYNC, 0, - flags & DMFL_DEFERRED); + return dm_simplecmd(DM_DEVICE_REMOVE, name, flags, 0); } static int @@ -594,8 +592,9 @@ int dm_addmap_reload(struct multipath *mpp, char *params, int flush) params, ADDMAP_RO, 0); } if (r) - r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, !flush, - 1, udev_flags, 0); + r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, + DMFL_NEED_SYNC | (flush ? 0 : DMFL_NO_FLUSH), + udev_flags); if (r) return r; @@ -603,8 +602,9 @@ int dm_addmap_reload(struct multipath *mpp, char *params, int flush) * drop the new table, so doing a second resume will try using * the original table */ if (dm_is_suspended(mpp->alias)) - dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, !flush, 1, - udev_flags, 0); + dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, + DMFL_NEED_SYNC | (flush ? 0 : DMFL_NO_FLUSH), + udev_flags); return 0; } diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index bb4a55a..a242381 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -38,8 +38,8 @@ void skip_libmp_dm_init(void); void libmp_dm_exit(void); void libmp_udev_set_sync_support(int on); struct dm_task *libmp_dm_task_create(int task); -int dm_simplecmd_flush (int, const char *, uint16_t); -int dm_simplecmd_noflush (int, const char *, uint16_t); +int dm_simplecmd_flush (int task, const char *name, uint16_t udev_flags); +int dm_simplecmd_noflush (int task, const char *name, uint16_t udev_flags); int dm_addmap_create (struct multipath *mpp, char *params); int dm_addmap_reload (struct multipath *mpp, char *params, int flush); int dm_map_present (const char *); @@ -64,6 +64,7 @@ enum { DMFL_NEED_SYNC = 1 << 0, DMFL_DEFERRED = 1 << 1, DMFL_SUSPEND = 1 << 2, + DMFL_NO_FLUSH = 1 << 3, }; int _dm_flush_map (const char *mapname, int flags, int retries); From patchwork Thu May 2 18:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13652007 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 C9BEA1635A2 for ; Thu, 2 May 2024 19:00:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714676412; cv=none; b=PBNqa38VZy+PHPSZ0Rhtyron7+89dMgotOdPGqSKGeWFGYpEHJHuTYOITgIMWAXXfTxXzDuIaC0Fol+jExr3zxXpYq/NWJ3cEbF52nYFSkknVxmkaCSQyYAfag0ECbQAPAqUfINfw71gvIMsrviU1l4Dsw5ZXYDAYKvEyu4nzuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714676412; c=relaxed/simple; bh=30dtFGm1hkhKZCekFdmTYbeiLAo+Xk2DVXWo5sniE10=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mVyeYUzFggakYHq9oIT7hGkjTTxl3bos8qJ78aUg/N3IbTDvnaZ0DPGUHUhy20qKZV0ulJ0ccYQeODrCUKxqw4XT4HwU8ag2TBJDFminlw3dEaE2vxi8N/Gkua8Ec49SUzqHOYTP4Kb33gyD2lTRhVMzlzgGeEZKjCl4LBQGKYI= 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=g8mNHc95; arc=none smtp.client-ip=209.85.218.50 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="g8mNHc95" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a58772187d8so1063429266b.3 for ; Thu, 02 May 2024 12:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1714676408; x=1715281208; 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=YcQXJI4rkH47Kd+WCRFf6zni670SxE8JHxCN7gKLILs=; b=g8mNHc95MyGstHqFQrhVqtbRfPV1telUo79eacN4nThicvf2hrEnbdjbXlKHW2GgXc NXXycxDSE6QBm2/WgEtV5ikY2d2yq9zZaPaVa08lZc5t1Uor3r82wL3XPUQrtkWwsebD hqbeKodwVh0yLMvm9gN7FLEw4BVOAoh0HUoYSnVVYXgKFutHNt/4xHbHzSpK7PvnFkQX I5r8MCjhoB9EDBYNrm1CkpmGWTnofCZsUw6ipHH3DsfWkAZ1Z8HXVasmz/LWdfAgUyUE uLpIg7K+ZpBgQ/wgGUPBbDGD0UO85xidTVZHuBtAFXBF5zK1d8pv4MimHSqLmUEP/UdZ zQAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714676408; x=1715281208; 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=YcQXJI4rkH47Kd+WCRFf6zni670SxE8JHxCN7gKLILs=; b=GTHS14x5WcHCnJiPtqisADMUqu07b8TKo0wNqpFYFccc6PNppXyzNJeFoX7FV7H7UU A6f5IAw8MyEo6n71YyMjXUu6JJd1pFLloN7FI1QJV1QfJx5zGeeZfgrHExhfw2vvwYDl XZ/iIh7Soxok0HvnCP6pq9jCuzhvjDU4yK158CeItgP3REqnOFIrDtDL8XQDzZnX/+6G Hb2/9OiqXLVkkPXmAAzMHQi6UN3mEO0GOdi9Y0x0cZ09nsjN2aaH2DRz4lSn1RXRCqXR RkFYQzghtJKtr05J1ep3MayKizgvftwr6Q1a5f/xACxF3xFddHrvsxzoo0Rwm8WE5tcB GdRA== X-Gm-Message-State: AOJu0Yw/gsauVA2VivkPuLILm1AgwlbjLPKENNf1vyMLdxfWeA83tqVN 2lJHyPXmv6Eh+sLeRkOa3J9kgDRPmZzeqJEhWKuRnyPyeLqIMB+zuULCbjaMjSoeNZT7IRWpXBB d X-Google-Smtp-Source: AGHT+IE2O6BBPkaNOc2n/NOvvVR2rM4FDVgXdQ+GsBXrYYgyGH3PcDzsyPqzIAmqWMBH9DD7JiZlow== X-Received: by 2002:a17:906:3748:b0:a58:d7d8:2f48 with SMTP id e8-20020a170906374800b00a58d7d82f48mr263167ejc.72.1714676408320; Thu, 02 May 2024 12:00:08 -0700 (PDT) Received: from localhost (p200300de373edc00b298a6be282c8242.dip0.t-ipconnect.de. [2003:de:373e:dc00:b298:a6be:282c:8242]) by smtp.gmail.com with UTF8SMTPSA id hz18-20020a1709072cf200b00a597bd55982sm358944ejc.130.2024.05.02.12.00.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 May 2024 12:00:08 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev, Martin Wilck Subject: [PATCH 3/3] libmultipath: add argument names to some prototypes Date: Thu, 2 May 2024 20:59:46 +0200 Message-ID: <20240502185946.31192-4-mwilck@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502185946.31192-1-mwilck@suse.com> References: <20240502185946.31192-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/devmapper.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index a242381..19b79c5 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -42,12 +42,12 @@ int dm_simplecmd_flush (int task, const char *name, uint16_t udev_flags); int dm_simplecmd_noflush (int task, const char *name, uint16_t udev_flags); int dm_addmap_create (struct multipath *mpp, char *params); int dm_addmap_reload (struct multipath *mpp, char *params, int flush); -int dm_map_present (const char *); +int dm_map_present (const char *name); int dm_map_present_by_uuid(const char *uuid); -int dm_get_map(const char *, unsigned long long *, char **); -int dm_get_status(const char *, char **); -int dm_type(const char *, char *); -int dm_is_mpath(const char *); +int dm_get_map(const char *name, unsigned long long *size, char **outparams); +int dm_get_status(const char *name, char **outstatus); +int dm_type(const char *name, char *type); +int dm_is_mpath(const char *name); enum { DM_FLUSH_OK = 0,