From patchwork Thu Aug 18 07:20:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinga Tanska X-Patchwork-Id: 12947205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D5C4C25B0E for ; Thu, 18 Aug 2022 14:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244837AbiHROUx (ORCPT ); Thu, 18 Aug 2022 10:20:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343508AbiHROUv (ORCPT ); Thu, 18 Aug 2022 10:20:51 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32887AFAF7 for ; Thu, 18 Aug 2022 07:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660832451; x=1692368451; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J8q/EG3e+YZD+2ViwIvgzZnFSxL2L20MLea6+q65R8w=; b=DrN67HWT3QdL9DdnL5JB6P01qZfRM2WePaesYBcP1Z5iuHCQT1/CdUej 6Edmuyj//rUVZE4vCSLD8hJzUsU08s07lf9AzH1i5HYr7Fe8U30iWUCaq SLglX+Zb10/+bQfHahjilKkz0AOVBrQ2qgkWFysrZ5jAPeH0gQt6u7wsX lZ0wqqmK8UPCt5fQN4xENLZrGvzNdAmk7w6VxDljQBTtgEisLHt1ht1zj 92y/APB2zQ14KPkTbl7JEHxKpL/dHnjS6JCqRDYmyokUn+F5boPk6HOgI 6ab3OZqQuCNN2hJc9oOFF1rEW4V9v9Hn5mZoCjZWLbQ5mDNFS0ww3/AXv g==; X-IronPort-AV: E=McAfee;i="6500,9779,10443"; a="356757969" X-IronPort-AV: E=Sophos;i="5.93,246,1654585200"; d="scan'208";a="356757969" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2022 07:20:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,246,1654585200"; d="scan'208";a="636840649" Received: from unknown (HELO unbrick.amr.corp.intel.com) ([10.102.92.203]) by orsmga008.jf.intel.com with ESMTP; 18 Aug 2022 07:20:27 -0700 From: Kinga Tanska To: linux-raid@vger.kernel.org Cc: jes@trained-monkey.org, colyli@suse.de Subject: [PATCH v3 1/2] Assemble: check if device is container before scheduling force-clean update Date: Thu, 18 Aug 2022 09:20:40 +0200 Message-Id: <20220818072041.13586-2-kinga.tanska@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220818072041.13586-1-kinga.tanska@intel.com> References: <20220818072041.13586-1-kinga.tanska@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org Up to now using assemble with force flag making each array as clean. Force-clean should not be done for the container. This commit add check if device is different than container before cleaning. Signed-off-by: Kinga Tanska --- Assemble.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Assemble.c b/Assemble.c index 704b8293..f31372db 100644 --- a/Assemble.c +++ b/Assemble.c @@ -1813,10 +1813,9 @@ try_again: } #endif } - if (c->force && !clean && + if (c->force && !clean && content->array.level != LEVEL_CONTAINER && !enough(content->array.level, content->array.raid_disks, - content->array.layout, clean, - avail)) { + content->array.layout, clean, avail)) { change += st->ss->update_super(st, content, "force-array", devices[chosen_drive].devname, c->verbose, 0, NULL); From patchwork Thu Aug 18 07:20:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinga Tanska X-Patchwork-Id: 12947206 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F4D5C00140 for ; Thu, 18 Aug 2022 14:20:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245360AbiHROUz (ORCPT ); Thu, 18 Aug 2022 10:20:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343560AbiHROUx (ORCPT ); Thu, 18 Aug 2022 10:20:53 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0930CAFAF7 for ; Thu, 18 Aug 2022 07:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660832452; x=1692368452; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=F35PxKee0nkDAmiYOMThE9NZRtva0CXTFB/DBHyELac=; b=kuzCOlbRrZC5rDfzNKxAbThSXX04F0JQS/ravi49byNsg/5ysFnXlNGE OW9XKeiHFXRRI4PkZDMfi/tLA2LHaN7/s41sR1KCL1c0L/GJpucJH34He 4ScUL7vCQSODHlfWWyRy6N2183/u9MpAjNQ0WtAwgpPXWhVPixxYP4iKM 9MZjgBJzhAt7pOHdc5NZsG4c06ia4d2TbW/JWFa7VipsscLMeAwAEZubs sn3NT5diDXcQ98YEdXqXCeONAgYWxpyk+8WGC1uAdtWwrgH8/F/JsW0Ky 7al8GlHhCsi8IGUerGgOXdTdU2kWxrVdbHMwraCOD+VOYPSfuU3lmh4KQ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10443"; a="356757972" X-IronPort-AV: E=Sophos;i="5.93,246,1654585200"; d="scan'208";a="356757972" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2022 07:20:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,246,1654585200"; d="scan'208";a="636840657" Received: from unknown (HELO unbrick.amr.corp.intel.com) ([10.102.92.203]) by orsmga008.jf.intel.com with ESMTP; 18 Aug 2022 07:20:29 -0700 From: Kinga Tanska To: linux-raid@vger.kernel.org Cc: jes@trained-monkey.org, colyli@suse.de Subject: [PATCH v3 2/2] mdadm: replace container level checking with inline Date: Thu, 18 Aug 2022 09:20:41 +0200 Message-Id: <20220818072041.13586-3-kinga.tanska@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220818072041.13586-1-kinga.tanska@intel.com> References: <20220818072041.13586-1-kinga.tanska@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org To unify all containers checks in code, is_container() function is added and propagated. Signed-off-by: Kinga Tanska --- Assemble.c | 5 ++--- Create.c | 6 +++--- Grow.c | 6 +++--- Incremental.c | 4 ++-- mdadm.h | 14 ++++++++++++++ super-ddf.c | 6 +++--- super-intel.c | 4 ++-- super0.c | 2 +- super1.c | 2 +- sysfs.c | 2 +- 10 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Assemble.c b/Assemble.c index f31372db..27324939 100644 --- a/Assemble.c +++ b/Assemble.c @@ -1123,7 +1123,7 @@ static int start_array(int mdfd, i/2, mddev); } - if (content->array.level == LEVEL_CONTAINER) { + if (is_container(content->array.level)) { sysfs_rules_apply(mddev, content); if (c->verbose >= 0) { pr_err("Container %s has been assembled with %d drive%s", @@ -1553,8 +1553,7 @@ try_again: */ trustworthy = LOCAL; - if (name[0] == 0 && - content->array.level == LEVEL_CONTAINER) { + if (!name[0] && is_container(content->array.level)) { name = content->text_version; trustworthy = METADATA; } diff --git a/Create.c b/Create.c index 0ff1922d..6edc4ad3 100644 --- a/Create.c +++ b/Create.c @@ -472,7 +472,7 @@ int Create(struct supertype *st, char *mddev, st->minor_version >= 1) /* metadata at front */ warn |= check_partitions(fd, dname, 0, 0); - else if (s->level == 1 || s->level == LEVEL_CONTAINER || + else if (s->level == 1 || is_container(s->level) || (s->level == 0 && s->raiddisks == 1)) /* partitions could be meaningful */ warn |= check_partitions(fd, dname, freesize*2, s->size*2); @@ -982,7 +982,7 @@ int Create(struct supertype *st, char *mddev, * again returns container info. */ st->ss->getinfo_super(st, &info_new, NULL); - if (st->ss->external && s->level != LEVEL_CONTAINER && + if (st->ss->external && !is_container(s->level) && !same_uuid(info_new.uuid, info.uuid, 0)) { map_update(&map, fd2devnm(mdfd), info_new.text_version, @@ -1025,7 +1025,7 @@ int Create(struct supertype *st, char *mddev, map_unlock(&map); free(infos); - if (s->level == LEVEL_CONTAINER) { + if (is_container(s->level)) { /* No need to start. But we should signal udev to * create links */ sysfs_uevent(&info, "change"); diff --git a/Grow.c b/Grow.c index 9c6fc95e..391c4212 100644 --- a/Grow.c +++ b/Grow.c @@ -2156,7 +2156,7 @@ size_change_error: devname, s->size); } changed = 1; - } else if (array.level != LEVEL_CONTAINER) { + } else if (!is_container(array.level)) { s->size = get_component_size(fd)/2; if (s->size == 0) s->size = array.size; @@ -2212,7 +2212,7 @@ size_change_error: info.component_size = s->size*2; info.new_level = s->level; info.new_chunk = s->chunk * 1024; - if (info.array.level == LEVEL_CONTAINER) { + if (is_container(info.array.level)) { info.delta_disks = UnSet; info.array.raid_disks = s->raiddisks; } else if (s->raiddisks) @@ -2325,7 +2325,7 @@ size_change_error: printf("layout for %s set to %d\n", devname, array.layout); } - } else if (array.level == LEVEL_CONTAINER) { + } else if (is_container(array.level)) { /* This change is to be applied to every array in the * container. This is only needed when the metadata imposes * restraints of the various arrays in the container. diff --git a/Incremental.c b/Incremental.c index a57fc323..077d4eea 100644 --- a/Incremental.c +++ b/Incremental.c @@ -244,7 +244,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c, c->autof = ci->autof; name_to_use = info.name; - if (name_to_use[0] == 0 && info.array.level == LEVEL_CONTAINER) { + if (name_to_use && is_container(info.array.level)) { name_to_use = info.text_version; trustworthy = METADATA; } @@ -472,7 +472,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c, /* 7/ Is there enough devices to possibly start the array? */ /* 7a/ if not, finish with success. */ - if (info.array.level == LEVEL_CONTAINER) { + if (is_container(info.array.level)) { char devnm[32]; /* Try to assemble within the container */ sysfs_uevent(sra, "change"); diff --git a/mdadm.h b/mdadm.h index c7268a71..72abfc50 100644 --- a/mdadm.h +++ b/mdadm.h @@ -1885,3 +1885,17 @@ enum r0layout { * This is true for native and DDF, IMSM allows 16. */ #define MD_NAME_MAX 32 + +/** + * is_container() - check if @level is &LEVEL_CONTAINER + * @level: level value + * + * return: + * 1 if level is equal to &LEVEL_CONTAINER, 0 otherwise. + */ +static inline int is_container(const int level) +{ + if (level == LEVEL_CONTAINER) + return 1; + return 0; +} \ No newline at end of file diff --git a/super-ddf.c b/super-ddf.c index 3f304cdc..bd366da2 100644 --- a/super-ddf.c +++ b/super-ddf.c @@ -3345,7 +3345,7 @@ static int validate_geometry_ddf(struct supertype *st, if (level == LEVEL_NONE) level = LEVEL_CONTAINER; - if (level == LEVEL_CONTAINER) { + if (is_container(level)) { /* Must be a fresh device to add to a container */ return validate_geometry_ddf_container(st, level, layout, raiddisks, *chunk, @@ -3460,7 +3460,7 @@ validate_geometry_ddf_container(struct supertype *st, int fd; unsigned long long ldsize; - if (level != LEVEL_CONTAINER) + if (!is_container(level)) return 0; if (!dev) return 1; @@ -3498,7 +3498,7 @@ static int validate_geometry_ddf_bvd(struct supertype *st, struct dl *dl; unsigned long long maxsize; /* ddf/bvd supports lots of things, but not containers */ - if (level == LEVEL_CONTAINER) { + if (is_container(level)) { if (verbose) pr_err("DDF cannot create a container within an container\n"); return 0; diff --git a/super-intel.c b/super-intel.c index d5fad102..7376a2e9 100644 --- a/super-intel.c +++ b/super-intel.c @@ -6661,7 +6661,7 @@ static int validate_geometry_imsm_container(struct supertype *st, int level, struct intel_super *super = NULL; int rv = 0; - if (level != LEVEL_CONTAINER) + if (!is_container(level)) return 0; if (!dev) return 1; @@ -7580,7 +7580,7 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, * if given unused devices create a container * if given given devices in a container create a member volume */ - if (level == LEVEL_CONTAINER) + if (is_container(level)) /* Must be a fresh device to add to a container */ return validate_geometry_imsm_container(st, level, raiddisks, data_offset, dev, diff --git a/super0.c b/super0.c index b79b97a9..87a4b374 100644 --- a/super0.c +++ b/super0.c @@ -1273,7 +1273,7 @@ static int validate_geometry0(struct supertype *st, int level, if (get_linux_version() < 3001000) tbmax = 2; - if (level == LEVEL_CONTAINER) { + if (is_container(level)) { if (verbose) pr_err("0.90 metadata does not support containers\n"); return 0; diff --git a/super1.c b/super1.c index a12a5bc8..d3a48478 100644 --- a/super1.c +++ b/super1.c @@ -2800,7 +2800,7 @@ static int validate_geometry1(struct supertype *st, int level, unsigned long long overhead; int fd; - if (level == LEVEL_CONTAINER) { + if (is_container(level)) { if (verbose) pr_err("1.x metadata does not support containers\n"); return 0; diff --git a/sysfs.c b/sysfs.c index 2995713d..054842c2 100644 --- a/sysfs.c +++ b/sysfs.c @@ -762,7 +762,7 @@ int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int resume) rv = sysfs_set_num(sra, sd, "offset", sd->data_offset); rv |= sysfs_set_num(sra, sd, "size", (sd->component_size+1) / 2); - if (sra->array.level != LEVEL_CONTAINER) { + if (!is_container(sra->array.level)) { if (sra->consistency_policy == CONSISTENCY_POLICY_PPL) { rv |= sysfs_set_num(sra, sd, "ppl_sector", sd->ppl_sector); rv |= sysfs_set_num(sra, sd, "ppl_size", sd->ppl_size);