From patchwork Tue Dec 27 05:50:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinga Tanska X-Patchwork-Id: 13082288 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 12C93C10F1B for ; Tue, 27 Dec 2022 12:49:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231154AbiL0MtA (ORCPT ); Tue, 27 Dec 2022 07:49:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbiL0Ms6 (ORCPT ); Tue, 27 Dec 2022 07:48:58 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28501F12 for ; Tue, 27 Dec 2022 04:48:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672145338; x=1703681338; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UsKT/OHMZPqJwYAz/zuqaIMFUZy+jMgSbUj/4Cwmuq0=; b=b3LKLXu4i8jDl7zDEei6ZbLlcrDVCOTYp3AT7H4LXp8fdTxGegv+NX2c qUh+CNa5U4RNmMbshlpl+0hCmcx4llfxbi9+Hq510eM/JHiOEAOlCiK/g itBWTcX2SDDwXFP1bXU91eHBU1M2boox0e7AJVIdj4WTVXfNIkJ/L55zB nhm3TLPlAX/tzLsIgWJ8+41mTNppJYi63jhUMibpNFfSIJ5J35irr0t58 eZakN30aRSN2c/qfY4lw3PVXh7ItJDkg1Us4at4AqSJv8MdfhpfqY9n5q XAw+4LQwWDrxSzKRk9+Gl7htdJ29/ZxwGTNFlgseOZdtt7aeeYe/Y2VrJ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="385117688" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="385117688" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 04:48:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="646415738" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="646415738" Received: from unknown (HELO localhost.igk.intel.com) ([10.102.92.203]) by orsmga007.jf.intel.com with ESMTP; 27 Dec 2022 04:48:56 -0800 From: Kinga Tanska To: linux-raid@vger.kernel.org Cc: jes@trained-monkey.org, colyli@suse.de, xni@redhat.com Subject: [PATCH v3 1/3] Manage: do not check array state when drive is removed Date: Tue, 27 Dec 2022 06:50:42 +0100 Message-Id: <20221227055044.18168-2-kinga.tanska@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20221227055044.18168-1-kinga.tanska@intel.com> References: <20221227055044.18168-1-kinga.tanska@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org Array state doesn't need to be checked when drive is removed, but until now clean state was required. Result of the is_remove_safe() function will be independent from array state. Signed-off-by: Kinga Tanska --- Manage.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Manage.c b/Manage.c index b1d0e630..157a2b98 100644 --- a/Manage.c +++ b/Manage.c @@ -1322,8 +1322,7 @@ bool is_remove_safe(mdu_array_info_t *array, const int fd, char *devname, const sysfs_free(mdi); bool is_enough = enough(array->level, array->raid_disks, - array->layout, (array->state & 1), - avail); + array->layout, 1, avail); free(avail); return is_enough; From patchwork Tue Dec 27 05:50:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinga Tanska X-Patchwork-Id: 13082289 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 EE490C4332F for ; Tue, 27 Dec 2022 12:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231220AbiL0MtD (ORCPT ); Tue, 27 Dec 2022 07:49:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbiL0MtB (ORCPT ); Tue, 27 Dec 2022 07:49:01 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84404F12 for ; Tue, 27 Dec 2022 04:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672145340; x=1703681340; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CU2CIKL5Xx2Ryfk8LM4TxaA7RoJ+WxH0vPwC6D+cbJ0=; b=WXBgLpVIVTph9K6d8sq34nBQ99XPVeN+aJ7AUIo3CHm1Yavrcnm+CRJR j79JPIrzi/ViJs0LY915p7lOS+anttWexZDwJMOLrwBPbEcIL7+jbarmP hKvWMqU7bjZ267iNt+BeF1OYYMSm/XSw1abTQj1K1CBbTzkvGyLAg3ov+ JMnfpvUEYhVhu6VH01aYutBko1cfFGhWjo62XkYbcEpMyDwhwmM4uCo6k 2sM9lwPjwJEvc++8TkeBSJ5AkrBtnX0GJsTMWX8Hvzi7K6UgALTatGRgs VBlZbIzOKV1DKuzkTSc9vq/A4S39deSaew2GAmmGsv9/Jl6gnww/G0d+3 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="385117695" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="385117695" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 04:49:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="646415743" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="646415743" Received: from unknown (HELO localhost.igk.intel.com) ([10.102.92.203]) by orsmga007.jf.intel.com with ESMTP; 27 Dec 2022 04:48:59 -0800 From: Kinga Tanska To: linux-raid@vger.kernel.org Cc: jes@trained-monkey.org, colyli@suse.de, xni@redhat.com Subject: [PATCH v3 2/3] incremental, manage: do not verify if remove is safe Date: Tue, 27 Dec 2022 06:50:43 +0100 Message-Id: <20221227055044.18168-3-kinga.tanska@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20221227055044.18168-1-kinga.tanska@intel.com> References: <20221227055044.18168-1-kinga.tanska@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org Function is_remove_safe() was introduced to verify if removing member device won't cause failed state of the array. This verification should be used only with set-faulty command. Add special mode indicating that Incremental removal was executed. If this mode is used do not execute is_remove_safe() routine. Signed-off-by: Kinga Tanska --- Incremental.c | 2 +- Manage.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Incremental.c b/Incremental.c index 5a5f4c4c..bccfdeb9 100644 --- a/Incremental.c +++ b/Incremental.c @@ -1744,7 +1744,7 @@ int IncrementalRemove(char *devname, char *id_path, int verbose) memset(&devlist, 0, sizeof(devlist)); devlist.devname = devname; - devlist.disposition = 'f'; + devlist.disposition = 'I'; /* for a container, we must fail each member array */ if (ent->metadata_version && strncmp(ent->metadata_version, "external:", 9) == 0) { diff --git a/Manage.c b/Manage.c index 157a2b98..48b479a7 100644 --- a/Manage.c +++ b/Manage.c @@ -1495,8 +1495,9 @@ int Manage_subdevs(char *devname, int fd, /* Assume this is a kernel-internal name like 'sda1' */ int found = 0; char dname[55]; - if (dv->disposition != 'r' && dv->disposition != 'f') { - pr_err("%s only meaningful with -r or -f, not -%c\n", + if (dv->disposition != 'r' && dv->disposition != 'f' && + dv->disposition != 'I') { + pr_err("%s only meaningful with -r, -f or -I, not -%c\n", dv->devname, dv->disposition); goto abort; } @@ -1648,7 +1649,7 @@ int Manage_subdevs(char *devname, int fd, close(sysfd); goto abort; } - + case 'I': /* incremental fail */ if ((sysfd >= 0 && write(sysfd, "faulty", 6) != 6) || (sysfd < 0 && ioctl(fd, SET_DISK_FAULTY, rdev))) { From patchwork Tue Dec 27 05:50:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinga Tanska X-Patchwork-Id: 13082290 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 9E6BEC4332F for ; Tue, 27 Dec 2022 12:49:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231335AbiL0MtH (ORCPT ); Tue, 27 Dec 2022 07:49:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbiL0MtE (ORCPT ); Tue, 27 Dec 2022 07:49:04 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57AF0F28 for ; Tue, 27 Dec 2022 04:49:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672145343; x=1703681343; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bXEx8eIQTkuFlX6pWtU783H2skdgHa3KrqRNILO2O7I=; b=fI4VI4mP/75ZO0/V72DqrbzTgUYc02WFrFPsk5xmn1HFRhQxAvcGw0RY co48JAeChpPgVB3mmYQjnQzkQUomAKYABKzn8xOoD9gqpAuK6PraydRrp gu1aGO29vOtco1K2CIK+RTt5eDV5UvkLT7PyOog9iukmrvbF5DMu+MjHf CXn1z63zgkEJYXYsi6dq5PMjP0QrcsCrLjXzT2yKztyMIIvIjIz1gupOG BkLQv6sZSgp3oMbatkpI0oGtkMQR0HcA75iPGUN2ydGKOj6aqTPTveK1k gckiWE3/db2RliyDS9+80ZfWHiiLPjPxreHyOtjEaF9XD64whn4ynl296 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="385117701" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="385117701" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 04:49:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="646415746" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="646415746" Received: from unknown (HELO localhost.igk.intel.com) ([10.102.92.203]) by orsmga007.jf.intel.com with ESMTP; 27 Dec 2022 04:49:01 -0800 From: Kinga Tanska To: linux-raid@vger.kernel.org Cc: jes@trained-monkey.org, colyli@suse.de, xni@redhat.com Subject: [PATCH v3 3/3] manage: move comment with function description Date: Tue, 27 Dec 2022 06:50:44 +0100 Message-Id: <20221227055044.18168-4-kinga.tanska@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20221227055044.18168-1-kinga.tanska@intel.com> References: <20221227055044.18168-1-kinga.tanska@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org Move the function description from the function body to outside to obey kernel coding style. Signed-off-by: Kinga Tanska Acked-by: Paul Menzel --- Manage.c | 72 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/Manage.c b/Manage.c index 48b479a7..eee25fd8 100644 --- a/Manage.c +++ b/Manage.c @@ -1328,38 +1328,54 @@ bool is_remove_safe(mdu_array_info_t *array, const int fd, char *devname, const return is_enough; } +/** + * Manage_subdevs() - Execute operation depending on devmode. + * + * @devname: name of the device. + * @fd: file descriptor. + * @devlist: list of sub-devices to manage. + * @verbose: verbose level. + * @test: test flag. + * @update: type of update. + * @force: force flag. + * + * This function executes operation defined by devmode + * for each dev from devlist. + * Devmode can be: + * 'a' - add the device + * 'S' - add the device as a spare - don't try re-add + * 'j' - add the device as a journal device + * 'A' - re-add the device + * 'r' - remove the device: HOT_REMOVE_DISK + * device can be 'faulty' or 'detached' in which case all + * matching devices are removed. + * 'f' - set the device faulty SET_DISK_FAULTY + * device can be 'detached' in which case any device that + * is inaccessible will be marked faulty. + * 'I' - remove device by using incremental fail + * which is executed when device is removed surprisingly. + * 'R' - mark this device as wanting replacement. + * 'W' - this device is added if necessary and activated as + * a replacement for a previous 'R' device. + * ----- + * 'w' - 'W' will be changed to 'w' when it is paired with + * a 'R' device. If a 'W' is found while walking the list + * it must be unpaired, and is an error. + * 'M' - this is created by a 'missing' target. It is a slight + * variant on 'A' + * 'F' - Another variant of 'A', where the device was faulty + * so must be removed from the array first. + * 'c' - confirm the device as found (for clustered environments) + * + * For 'f' and 'r', the device can also be a kernel-internal + * name such as 'sdb'. + * + * Return: 0 on success, otherwise 1 or 2. + */ int Manage_subdevs(char *devname, int fd, struct mddev_dev *devlist, int verbose, int test, char *update, int force) { - /* Do something to each dev. - * devmode can be - * 'a' - add the device - * 'S' - add the device as a spare - don't try re-add - * 'j' - add the device as a journal device - * 'A' - re-add the device - * 'r' - remove the device: HOT_REMOVE_DISK - * device can be 'faulty' or 'detached' in which case all - * matching devices are removed. - * 'f' - set the device faulty SET_DISK_FAULTY - * device can be 'detached' in which case any device that - * is inaccessible will be marked faulty. - * 'R' - mark this device as wanting replacement. - * 'W' - this device is added if necessary and activated as - * a replacement for a previous 'R' device. - * ----- - * 'w' - 'W' will be changed to 'w' when it is paired with - * a 'R' device. If a 'W' is found while walking the list - * it must be unpaired, and is an error. - * 'M' - this is created by a 'missing' target. It is a slight - * variant on 'A' - * 'F' - Another variant of 'A', where the device was faulty - * so must be removed from the array first. - * 'c' - confirm the device as found (for clustered environments) - * - * For 'f' and 'r', the device can also be a kernel-internal - * name such as 'sdb'. - */ mdu_array_info_t array; unsigned long long array_size; struct mddev_dev *dv;