From patchwork Mon Jul 4 07:08:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9211727 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 450FF60572 for ; Mon, 4 Jul 2016 07:12:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 313FF28384 for ; Mon, 4 Jul 2016 07:12:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2371628608; Mon, 4 Jul 2016 07:12:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A200028384 for ; Mon, 4 Jul 2016 07:12:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6479WRN009319; Mon, 4 Jul 2016 03:09:32 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u6479A9r017678 for ; Mon, 4 Jul 2016 03:09:10 -0400 Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6479AfK012134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 4 Jul 2016 03:09:10 -0400 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CBB98553D; Mon, 4 Jul 2016 07:09:09 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 52485AC80; Mon, 4 Jul 2016 07:09:05 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 4 Jul 2016 09:08:24 +0200 Message-Id: <1467616126-10036-5-git-send-email-hare@suse.de> In-Reply-To: <1467616126-10036-1-git-send-email-hare@suse.de> References: <1467616126-10036-1-git-send-email-hare@suse.de> X-Greylist: Sender IP whitelisted by DNSRBL, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 04 Jul 2016 07:09:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 04 Jul 2016 07:09:09 +0000 (UTC) for IP:'195.135.220.15' DOMAIN:'mx2.suse.de' HELO:'mx2.suse.de' FROM:'hare@suse.de' RCPT:'' X-RedHat-Spam-Score: -3.188 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 195.135.220.15 mx2.suse.de 195.135.220.15 mx2.suse.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.75 on 10.5.110.28 X-loop: dm-devel@redhat.com Cc: Hannes Reinecke , dm-devel@redhat.com Subject: [dm-devel] [PATCH 04/26] devmapper: explicit config settings X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Virus-Scanned: ClamAV using ClamSMTP Rather than access 'conf' from within the code this patch moves those settings to function arguments. So with this patch we don't need to access 'struct config' anymore. Signed-off-by: Hannes Reinecke --- libmultipath/configure.c | 6 ++++-- libmultipath/devmapper.c | 21 +++++++++++---------- libmultipath/devmapper.h | 4 ++-- multipath/main.c | 2 +- multipathd/main.c | 2 +- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index e49e7ea..a98b1ca 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -633,11 +633,13 @@ domap (struct multipath * mpp, char * params) break; case ACT_RENAME: - r = dm_rename(mpp->alias_old, mpp->alias); + r = dm_rename(mpp->alias_old, mpp->alias, + conf->partition_delim); break; case ACT_FORCERENAME: - r = dm_rename(mpp->alias_old, mpp->alias); + r = dm_rename(mpp->alias_old, mpp->alias, + conf->partition_delim); if (r) r = dm_addmap_reload(mpp, params, 0); break; diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 926d2f5..b50e9e6 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -19,7 +19,6 @@ #include "debug.h" #include "memory.h" #include "devmapper.h" -#include "config.h" #include "sysfs.h" #include "log_pthread.h" @@ -32,6 +31,8 @@ #define UUID_PREFIX "mpath-" #define UUID_PREFIX_LEN 6 +static int dm_conf_verbosity; + #ifdef LIBDM_API_DEFERRED static int dm_cancel_remove_partmaps(const char * mapname); #endif @@ -65,7 +66,7 @@ dm_write_log (int level, const char *file, int line, const char *f, ...) if (level > 6) level = 6; - thres = (conf) ? conf->verbosity : 0; + thres = dm_conf_verbosity; if (thres <= 3 || level > thres) return; @@ -94,9 +95,9 @@ dm_write_log (int level, const char *file, int line, const char *f, ...) } extern void -dm_init(void) { +dm_init(int v) { dm_log_init(&dm_write_log); - dm_log_init_verbose(conf ? conf->verbosity + 3 : 0); + dm_log_init_verbose(v + 3); } static int @@ -1375,21 +1376,21 @@ rename_partmap (const char *name, void *data) for (offset = strlen(rd->old); name[offset] && !(isdigit(name[offset])); offset++); /* do nothing */ snprintf(buff, PARAMS_SIZE, "%s%s%s", rd->new, rd->delim, name + offset); - dm_rename(name, buff); + dm_rename(name, buff, rd->delim); condlog(4, "partition map %s renamed", name); return 0; } int -dm_rename_partmaps (const char * old, char * new) +dm_rename_partmaps (const char * old, char * new, char *delim) { struct rename_data rd; rd.old = old; rd.new = new; - if (conf->partition_delim) - rd.delim = conf->partition_delim; + if (delim) + rd.delim = delim; if (isdigit(new[strlen(new)-1])) rd.delim = "p"; else @@ -1398,13 +1399,13 @@ dm_rename_partmaps (const char * old, char * new) } int -dm_rename (const char * old, char * new) +dm_rename (const char * old, char * new, char *delim) { int r = 0; struct dm_task *dmt; uint32_t cookie; - if (dm_rename_partmaps(old, new)) + if (dm_rename_partmaps(old, new, delim)) return r; if (!(dmt = dm_task_create(DM_DEVICE_RENAME))) diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index b5df369..4bc3b11 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -12,7 +12,7 @@ #define MPATH_UDEV_RELOAD_FLAG 0 #endif -void dm_init(void); +void dm_init(int verbosity); int dm_prereq (void); int dm_drv_version (unsigned int * version, char * str); int dm_simplecmd_flush (int, const char *, uint16_t); @@ -46,7 +46,7 @@ int dm_remove_partmaps (const char * mapname, int need_sync, int deferred_remove); int dm_get_uuid(char *name, char *uuid); int dm_get_info (char * mapname, struct dm_info ** dmi); -int dm_rename (const char * old, char * new); +int dm_rename (const char * old, char * new, char * delim); int dm_reassign(const char * mapname); int dm_reassign_table(const char *name, char *old, char *new); int dm_setgeometry(struct multipath *mpp); diff --git a/multipath/main.c b/multipath/main.c index aadebec..0dbe281 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -583,6 +583,7 @@ main (int argc, char *argv[]) exit(1); } + dm_init(conf->verbosity); if (dm_prereq()) exit(1); dm_drv_version(conf->version, TGT_MPATH); @@ -627,7 +628,6 @@ main (int argc, char *argv[]) condlog(0, "failed to initialize prioritizers"); goto out; } - dm_init(); if (conf->cmd == CMD_VALID_PATH && (!conf->dev || conf->dev_type == DEV_DEVMAP)) { diff --git a/multipathd/main.c b/multipathd/main.c index 3b79aef..8592982 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2111,6 +2111,7 @@ child (void * param) uxsock_timeout = conf->uxsock_timeout; + dm_init(conf->verbosity); dm_drv_version(conf->version, TGT_MPATH); if (init_checkers()) { condlog(0, "failed to initialize checkers"); @@ -2368,7 +2369,6 @@ main (int argc, char *argv[]) int foreground = 0; logsink = 1; - dm_init(); if (getuid() != 0) { fprintf(stderr, "need to be root\n");