From patchwork Wed Feb 12 17:15:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 3641571 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 975509F334 for ; Wed, 12 Feb 2014 23:19:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 68CB720165 for ; Wed, 12 Feb 2014 23:19:34 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id 1E46F2012D for ; Wed, 12 Feb 2014 23:19:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1CNFk6M003562; Wed, 12 Feb 2014 18:15:47 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1CNFjpG030353 for ; Wed, 12 Feb 2014 18:15:45 -0500 Received: from ask-08.lab.msp.redhat.com (ask-08.lab.msp.redhat.com [10.15.85.8]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1CNFiQ1027591 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 12 Feb 2014 18:15:45 -0500 Received: from ask-08.lab.msp.redhat.com (localhost [127.0.0.1]) by ask-08.lab.msp.redhat.com (8.14.6/8.14.6) with ESMTP id s1CHFJCt013942; Wed, 12 Feb 2014 11:15:19 -0600 Received: (from root@localhost) by ask-08.lab.msp.redhat.com (8.14.6/8.14.6/Submit) id s1CHFIO9013941; Wed, 12 Feb 2014 11:15:18 -0600 From: Benjamin Marzinski To: device-mapper development Date: Wed, 12 Feb 2014 11:15:17 -0600 Message-Id: <1392225317-13898-3-git-send-email-bmarzins@redhat.com> In-Reply-To: <1392225317-13898-1-git-send-email-bmarzins@redhat.com> References: <1392225317-13898-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: Peter Rajnoha , Christophe Varoqui Subject: [dm-devel] [PATCH 2/2] Mark reloads with udev flag X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order for the udev rules to be able to distinguish uevents generated by reloads instead of creates, multipath now tags all the reload resumes with MPATH_UDEV_RELOAD_FLAG, which is defined as the first multipath dm subsystem udev flag. 11-dm-mpath.rules watches for multipath events tag. Signed-off-by: Peter Rajnoha Signed-off-by: Benjamin Marzinski --- kpartx/devmapper.c | 4 ++-- kpartx/devmapper.h | 8 +++++++- kpartx/kpartx.c | 8 ++++---- libmultipath/configure.c | 4 ++-- libmultipath/devmapper.c | 26 ++++++++++++++------------ libmultipath/devmapper.h | 10 ++++++++-- multipathd/cli_handlers.c | 4 ++-- 7 files changed, 39 insertions(+), 25 deletions(-) diff --git a/kpartx/devmapper.c b/kpartx/devmapper.c index 24a43ee..7879a09 100644 --- a/kpartx/devmapper.c +++ b/kpartx/devmapper.c @@ -60,7 +60,7 @@ dm_prereq (char * str, int x, int y, int z) } extern int -dm_simplecmd (int task, const char *name, int no_flush, uint32_t *cookie) { +dm_simplecmd (int task, const char *name, int no_flush, uint32_t *cookie, uint16_t udev_flags) { int r = 0; int udev_wait_flag = (task == DM_DEVICE_RESUME || task == DM_DEVICE_REMOVE); @@ -78,7 +78,7 @@ dm_simplecmd (int task, const char *name, int no_flush, uint32_t *cookie) { if (no_flush) dm_task_no_flush(dmt); - if (udev_wait_flag && !dm_task_set_cookie(dmt, cookie, (udev_sync)? 0 : DM_UDEV_DISABLE_LIBRARY_FALLBACK)) + if (udev_wait_flag && !dm_task_set_cookie(dmt, cookie, ((udev_sync)? 0 : DM_UDEV_DISABLE_LIBRARY_FALLBACK) | udev_flags)) goto out; r = dm_task_run(dmt); diff --git a/kpartx/devmapper.h b/kpartx/devmapper.h index 0edc063..d962e43 100644 --- a/kpartx/devmapper.h +++ b/kpartx/devmapper.h @@ -2,10 +2,16 @@ #define MINOR(dev) ((dev & 0xff) | ((dev >> 12) & 0xfff00)) #define MKDEV(ma,mi) ((mi & 0xff) | (ma << 8) | ((mi & ~0xff) << 12)) +#ifdef DM_SUBSYSTEM_UDEV_FLAG0 +#define MPATH_UDEV_RELOAD_FLAG DM_SUBSYSTEM_UDEV_FLAG0 +#else +#define MPATH_UDEV_RELOAD_FLAG 0 +#endif + extern int udev_sync; int dm_prereq (char *, int, int, int); -int dm_simplecmd (int, const char *, int, uint32_t *); +int dm_simplecmd (int, const char *, int, uint32_t *, uint16_t); int dm_addmap (int, const char *, const char *, const char *, uint64_t, int, const char *, int, mode_t, uid_t, gid_t, uint32_t *); int dm_map_present (char *); diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c index 9a9a5eb..fac98dc 100644 --- a/kpartx/kpartx.c +++ b/kpartx/kpartx.c @@ -440,7 +440,7 @@ main(int argc, char **argv){ continue; if (!dm_simplecmd(DM_DEVICE_REMOVE, partname, - 0, &cookie)) { + 0, &cookie, 0)) { r++; continue; } @@ -498,7 +498,7 @@ main(int argc, char **argv){ } if (op == DM_DEVICE_RELOAD && !dm_simplecmd(DM_DEVICE_RESUME, partname, - 1, &cookie)) { + 1, &cookie, MPATH_UDEV_RELOAD_FLAG)) { fprintf(stderr, "resume failed on %s\n", partname); r++; @@ -560,7 +560,7 @@ main(int argc, char **argv){ if (op == DM_DEVICE_RELOAD) dm_simplecmd(DM_DEVICE_RESUME, partname, 1, - &cookie); + &cookie, MPATH_UDEV_RELOAD_FLAG); dm_devn(partname, &slices[j].major, &slices[j].minor); @@ -593,7 +593,7 @@ main(int argc, char **argv){ continue; if (!dm_simplecmd(DM_DEVICE_REMOVE, - partname, 1, &cookie)) { + partname, 1, &cookie, 0)) { r++; continue; } diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 8c09791..f20a2d6 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -389,13 +389,13 @@ domap (struct multipath * mpp, char * params) case ACT_RELOAD: r = dm_addmap_reload(mpp, params); if (r) - r = dm_simplecmd_noflush(DM_DEVICE_RESUME, mpp->alias); + r = dm_simplecmd_noflush(DM_DEVICE_RESUME, mpp->alias, MPATH_UDEV_RELOAD_FLAG); break; case ACT_RESIZE: r = dm_addmap_reload(mpp, params); if (r) - r = dm_simplecmd_flush(DM_DEVICE_RESUME, mpp->alias, 1); + r = dm_simplecmd_flush(DM_DEVICE_RESUME, mpp->alias, 1, 0); break; case ACT_RENAME: diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 6eb2d96..30e9351 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -105,7 +105,9 @@ dm_lib_prereq (void) { char version[64]; int v[3]; -#ifdef LIBDM_API_COOKIE +#if defined(DM_SUBSYSTEM_UDEV_FLAG0) + int minv[3] = {1, 2, 82}; +#elif defined(LIBDM_API_COOKIE) int minv[3] = {1, 2, 38}; #else int minv[3] = {1, 2, 8}; @@ -202,7 +204,7 @@ dm_prereq (void) } static int -dm_simplecmd (int task, const char *name, int no_flush, int need_sync) { +dm_simplecmd (int task, const char *name, int no_flush, int need_sync, uint16_t udev_flags) { int r = 0; int udev_wait_flag = (need_sync && (task == DM_DEVICE_RESUME || task == DM_DEVICE_REMOVE)); @@ -221,7 +223,7 @@ dm_simplecmd (int task, const char *name, int no_flush, int need_sync) { dm_task_no_flush(dmt); /* for DM_DEVICE_SUSPEND/RESUME */ #endif - if (udev_wait_flag && !dm_task_set_cookie(dmt, &conf->cookie, (conf->daemon)? DM_UDEV_DISABLE_LIBRARY_FALLBACK : 0)) + if (udev_wait_flag && !dm_task_set_cookie(dmt, &conf->cookie, ((conf->daemon)? DM_UDEV_DISABLE_LIBRARY_FALLBACK : 0) | udev_flags)) goto out; r = dm_task_run (dmt); @@ -231,13 +233,13 @@ dm_simplecmd (int task, const char *name, int no_flush, int need_sync) { } extern int -dm_simplecmd_flush (int task, const char *name, int needsync) { - return dm_simplecmd(task, name, 0, needsync); +dm_simplecmd_flush (int task, const char *name, int needsync, uint16_t udev_flags) { + return dm_simplecmd(task, name, 0, needsync, udev_flags); } extern int -dm_simplecmd_noflush (int task, const char *name) { - return dm_simplecmd(task, name, 1, 1); +dm_simplecmd_noflush (int task, const char *name, uint16_t udev_flags) { + return dm_simplecmd(task, name, 1, 1, udev_flags); } extern int @@ -672,7 +674,7 @@ _dm_flush_map (const char * mapname, int need_sync) return 1; } - r = dm_simplecmd_flush(DM_DEVICE_REMOVE, mapname, need_sync); + r = dm_simplecmd_flush(DM_DEVICE_REMOVE, mapname, need_sync, 0); if (r) { condlog(4, "multipath map %s removed", mapname); @@ -705,14 +707,14 @@ dm_suspend_and_flush_map (const char * mapname) if (s) queue_if_no_path = 0; else - s = dm_simplecmd_flush(DM_DEVICE_SUSPEND, mapname, 0); + s = dm_simplecmd_flush(DM_DEVICE_SUSPEND, mapname, 0, 0); if (!dm_flush_map(mapname)) { condlog(4, "multipath map %s removed", mapname); return 0; } condlog(2, "failed to remove multipath map %s", mapname); - dm_simplecmd_noflush(DM_DEVICE_RESUME, mapname); + dm_simplecmd_noflush(DM_DEVICE_RESUME, mapname, 0); if (queue_if_no_path) s = dm_queue_if_no_path((char *)mapname, 1); return 1; @@ -1069,7 +1071,7 @@ dm_remove_partmaps (const char * mapname, int need_sync) condlog(4, "partition map %s removed", names->name); dm_simplecmd_flush(DM_DEVICE_REMOVE, names->name, - need_sync); + need_sync, 0); } next = names->next; @@ -1297,7 +1299,7 @@ int dm_reassign_table(const char *name, char *old, char *new) condlog(3, "%s: failed to reassign targets", name); goto out_reload; } - dm_simplecmd_noflush(DM_DEVICE_RESUME, name); + dm_simplecmd_noflush(DM_DEVICE_RESUME, name, MPATH_UDEV_RELOAD_FLAG); } r = 1; diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 58cd718..6ea816c 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -6,11 +6,17 @@ #define TGT_MPATH "multipath" #define TGT_PART "linear" +#ifdef DM_SUBSYSTEM_UDEV_FLAG0 +#define MPATH_UDEV_RELOAD_FLAG DM_SUBSYSTEM_UDEV_FLAG0 +#else +#define MPATH_UDEV_RELOAD_FLAG 0 +#endif + void dm_init(void); int dm_prereq (void); int dm_drv_version (unsigned int * version, char * str); -int dm_simplecmd_flush (int, const char *, int); -int dm_simplecmd_noflush (int, const char *); +int dm_simplecmd_flush (int, const char *, int, uint16_t); +int dm_simplecmd_noflush (int, const char *, uint16_t); int dm_addmap_create (struct multipath *mpp, char *params); int dm_addmap_reload (struct multipath *mpp, char *params); int dm_map_present (const char *); diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index f7fc522..b086340 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -785,7 +785,7 @@ cli_suspend(void * v, char ** reply, int * len, void * data) { struct vectors * vecs = (struct vectors *)data; char * param = get_keyparam(v, MAP); - int r = dm_simplecmd_noflush(DM_DEVICE_SUSPEND, param); + int r = dm_simplecmd_noflush(DM_DEVICE_SUSPEND, param, 0); param = convert_dev(param, 0); condlog(2, "%s: suspend (operator)", param); @@ -807,7 +807,7 @@ cli_resume(void * v, char ** reply, int * len, void * data) { struct vectors * vecs = (struct vectors *)data; char * param = get_keyparam(v, MAP); - int r = dm_simplecmd_noflush(DM_DEVICE_RESUME, param); + int r = dm_simplecmd_noflush(DM_DEVICE_RESUME, param, 0); param = convert_dev(param, 0); condlog(2, "%s: resume (operator)", param);