Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4102121pxu; Mon, 12 Oct 2020 09:30:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPWpexAfgamffnW5/5Lp48QtQ7rWYBsxKdmBjgQkTs1JEU5RiKWDujwVqsC7zhf0QXfDfl X-Received: by 2002:aa7:dc12:: with SMTP id b18mr15077760edu.295.1602520245810; Mon, 12 Oct 2020 09:30:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1602520245; cv=pass; d=google.com; s=arc-20160816; b=LkhiM6fE77MbmWysdZDqyVclo3sfBVRwwRLCbpERM0aklAXbgsZ7HNzXaYqrxYWZUM vT6+Jc1Yv3r7KD11/voyQjweo7y1kp/Oq/hu2EGriN2oIH3/GgFT1waqKKN3Iag6kI+z 3dcRmWutPXmHydiBbftf3MeiV5qwget2pZ9cqs+4W9kcb8Z6/VKRErAeogd3YJBWiXg+ aFfrtBhOB1Skim2YSrw552oqh8oJRsBOpQ1ZUq22rvFnkV6ISy09NoVgIKz/QwB9WRWO 3GPLrEtqEzw7gFdZRB7COKiWzM9BlMnQupKSw+fgbvQpjq1OknNN35b26qPfjHc3hCNK IgRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=izkNFo22iTyrvBM/mJaUvgWkZdJxrF+yvqikQTSQeWU=; b=BWdcKrzsJkuWmes/XLgDtmrKVQ3aEvs/Cb/pb5BQu7iOSoA/lnh/GDuMVXQp3CEBvd yVagNirotcnCluQb05GSENQ/uTFD7vEO+0Lc68VLGU3ZMA95U+ZaosQPtbJqFiPOWqIU L3Xsr7KMnQnemgsshvmnxBL2XLV/8YvH9S9N3by5AWBI8bM0RyWDQZfe6hpH4H9JcKzb pJFBQJ6UTb0CXjYY9cvx1ZkAEyPjKm4fatwXDNNWoLL3bVcQ+l7ke4zrlbzQfKOrhkHy NiZRurcvHnOyipLgDGakPctGg3GbNI1+VTi9yKbcx6QMADb1Th/qdRzcIwz/PdAYMgcu RKGg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@micron.com header.s=selector2 header.b=qQbcrtig; arc=pass (i=1 spf=pass spfdomain=micron.com dmarc=pass fromdomain=micron.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=micron.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si5175140edl.218.2020.10.12.09.30.22; Mon, 12 Oct 2020 09:30:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@micron.com header.s=selector2 header.b=qQbcrtig; arc=pass (i=1 spf=pass spfdomain=micron.com dmarc=pass fromdomain=micron.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=micron.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403954AbgJLQ2z (ORCPT + 99 others); Mon, 12 Oct 2020 12:28:55 -0400 Received: from mail-mw2nam12on2087.outbound.protection.outlook.com ([40.107.244.87]:60032 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2403829AbgJLQ2R (ORCPT ); Mon, 12 Oct 2020 12:28:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bakl4RJn4pCukd9cUcMupbG7ZFAGNYRC7Y50hNv8poGPpr8BQW7CRHRNSuheY0Hd4PpgI6DjY9NMuDWQWVV52eyorAfiFAGyYGu2hso/jiNqUlKvH7/miv6Gd7+R/o6DApKWYh5vc+HdDeK5LoDOGaEmLOYDidR0LfJQuTMk0+BF6686ieRjbTauFmBwma8whIhP1+mM4SyF6e+us14OIS4EuKZRo6fJk6iq69gUQBqZ6YjuWkAqMpTKWn5ikvy0ZUAK9tp3O4Qg6EUqPMJMu6R/KVOZzm0CFrALn0mxLlTQS/4bfVotyfZkKgKWxRkqKHYGY7wHjV1eT5XX6FZnHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=izkNFo22iTyrvBM/mJaUvgWkZdJxrF+yvqikQTSQeWU=; b=Ivlro4/5T0+2h1xsfL4yALaB/yQT7yv/4oSeHFkFItw6WYw3LAF4gozUsCZtx/3Prr12JIv58LsA9akNgcPTNOF1xCg359j/CJS8odQxFxXPpwVLLuqG4QYfQVzGD1VMZRgq117SFwOEoLS5ZAQMqTwev4SUKsyAsdD1rDly49zGGm5jjncJMZ4gtEmkk40gzG1rIIsvVBn+W7ojq10ntuYK8u7YH84J5nk88l5WsgCztsET0wAZPbmjToCuXUnQj3YHYZSPBFTfVelEyuA6XX380BIke1A2kOPjALN2bPGIRB+yuSy9W/FngXqi18asC4KVeQoprnY0dyAGU6vcwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.201.242.130) smtp.rcpttodomain=kvack.org smtp.mailfrom=micron.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=micron.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=micron.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=izkNFo22iTyrvBM/mJaUvgWkZdJxrF+yvqikQTSQeWU=; b=qQbcrtigS7LyoqehgOwY9SZL10lGdEShni6EnLJtPGxRTSVtC+a/pjK9RNr2MHbE5PMNeI+KMIO1N6llH2ws3fVCxZqVh3iqJbE8J9RfDH0UMBWKvAxSlh4Jqf7TjVasXit0xpk3XxR7BkhFSnt3awqDehBxj/590nL9zwtxv28= Received: from SN4PR0201CA0051.namprd02.prod.outlook.com (2603:10b6:803:20::13) by BN7PR08MB4100.namprd08.prod.outlook.com (2603:10b6:406:88::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.22; Mon, 12 Oct 2020 16:28:12 +0000 Received: from SN1NAM01FT015.eop-nam01.prod.protection.outlook.com (2603:10b6:803:20:cafe::7c) by SN4PR0201CA0051.outlook.office365.com (2603:10b6:803:20::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21 via Frontend Transport; Mon, 12 Oct 2020 16:28:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 137.201.242.130) smtp.mailfrom=micron.com; kvack.org; dkim=none (message not signed) header.d=none;kvack.org; dmarc=pass action=none header.from=micron.com; Received-SPF: Pass (protection.outlook.com: domain of micron.com designates 137.201.242.130 as permitted sender) receiver=protection.outlook.com; client-ip=137.201.242.130; helo=mail.micron.com; Received: from mail.micron.com (137.201.242.130) by SN1NAM01FT015.mail.protection.outlook.com (10.152.65.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.3455.23 via Frontend Transport; Mon, 12 Oct 2020 16:28:11 +0000 Received: from micron.com (10.114.5.55) by bowex17c.micron.com (137.201.21.211) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 12 Oct 2020 10:28:07 -0600 From: Nabeel M Mohamed To: , , , , CC: , , , , Nabeel M Mohamed Subject: [PATCH v2 15/22] mpool: add mpool lifecycle management routines Date: Mon, 12 Oct 2020 11:27:29 -0500 Message-ID: <20201012162736.65241-16-nmeeramohide@micron.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20201012162736.65241-1-nmeeramohide@micron.com> References: <20201012162736.65241-1-nmeeramohide@micron.com> MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: bowex17a.micron.com (137.201.21.209) To bowex17c.micron.com (137.201.21.211) X-TM-AS-Product-Ver: SMEX-12.0.0.1782-8.200.1013-24646.005 X-TM-AS-Result: No--9.403300-0.000000-31 X-TM-AS-MatchedID: 700076-702732-121588-700069-703140-700863-701791-700717-7 05063-701475-121367-703750-704978-702727-702501-702542-701073-704401-701029 -703851-700028-704397-702876-703226-704961-700073-700060-701480-703017-7023 95-188019-703213-121336-701105-704673-703967-703027-701275-700864-704502-70 2754-704521-139549-702162-704962-703285-703958-704381-702922-704477-700714- 702688-701750-825159-701478-701343-701342-702415-701586-705244-704714-70319 2-701124-705022-701194-701336-701337-700737-700071-701031-701744-703215-702 298-188199-702898-704959-704053-704559-701432-702444-704574-704475-700876-1 05630-701893-703976-702914-702874-702438-705018-148004-148036-29997-42000-4 2003 X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-MT-Whitelisted: matched X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 99238005-6ec5-44c3-8be4-08d86ecbcff2 X-MS-TrafficTypeDiagnostic: BN7PR08MB4100: X-Microsoft-Antispam-PRVS: X-MS-Exchange-Transport-Forked: True X-EXT-ByPass: 1 X-MT-RULE-Whitelisted: Triggered X-MS-Oob-TLC-OOBClassifiers: OLM:862; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kVXuH4vqmdsCJJMeCtV/7Mupsan7RHTkY9DboltLLrMwobLW3XlZtUY0UBhOu8bdYgMQAlQrJDCUt7JES1RhuoMq2Dxzok35S9tCMuHVW7BzZPI32YvTHeH5S32C4SNPkPrpDi/55rRY2KwxY31OOPuMFfWmsRV83nvzTLZdGpz9qmivcbHUWluoBHr4jcPMIb2vD/SkckV6Z4yPnrc+lfxeBuIX+ScR8/ZKR9tU4rdWqYpHZahKy4tYLt65xyvKo6V6Q8fnMdjNdZaNuTtopnbASkgMaXd47JQ8oHPnVbvX9yNOWoVmsVW0argkxA8D1oGigxgr9VmR/xqz4UkOI4yyNB45ZydAhkFspSIKHfVfWB2dbt3DfOpNrGleE5jrGmoOPASLdFzu+hghOd+Ny5e/PYedrcpcM81B7L/NNsF+9CSh6gmzRpIDdNvZ95CCC0EL6zRE7Nb1papVKyPuLw== X-Forefront-Antispam-Report: CIP:137.201.242.130;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.micron.com;PTR:masquerade.micron.com;CAT:NONE;SFS:(4636009)(376002)(346002)(39860400002)(396003)(136003)(46966005)(426003)(1076003)(356005)(55016002)(316002)(36756003)(30864003)(6666004)(2616005)(110136005)(7696005)(47076004)(336012)(54906003)(107886003)(8676002)(4326008)(86362001)(33310700002)(70206006)(2906002)(26005)(186003)(5660300002)(83380400001)(82740400003)(7636003)(478600001)(6286002)(82310400003)(8936002)(70586007)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: micron.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2020 16:28:11.7521 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99238005-6ec5-44c3-8be4-08d86ecbcff2 X-MS-Exchange-CrossTenant-Id: f38a5ecd-2813-4862-b11b-ac1d563c806f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f38a5ecd-2813-4862-b11b-ac1d563c806f;Ip=[137.201.242.130];Helo=[mail.micron.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM01FT015.eop-nam01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR08MB4100 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds mpool lifecycle management functions: create, activate, deactivate, destroy, rename, add a new media class, fetch properties etc. An mpool is created with a mandatory capacity media class volume. A pool drive (PD) instance is initialized for each media class volume using the attributes pushed from the mpool user library. The metadata manager interfaces are then invoked to activate this mpool and allocate the initial set of metadata containers. The media class attributes, spare percent, mpool configuration etc. are persisted in MDC-0. At mpool activation, the records from MDC-0 containing the mpool properties and metadata for accessing MDC-1 through MDC-N are first loaded into memory, initializing all the necessary in-core structures using the metadata manager and space map interfaces. Then the records from MDC-1 through MDC-N containing the metadata for accessing client mblock and mlog objects are loaded into memory, again initializing all the necessary in-core structures using the metadata manager and space map interfaces. An mpool is destroyed by erasing the superblock on all its constituent media class volumes. Renaming an mpool updates the superblock on all the media class volumes with the new name. Adding a new media class volume to an activated mpool is handled like initializing a volume at mpool create. Co-developed-by: Greg Becker Signed-off-by: Greg Becker Co-developed-by: Pierre Labat Signed-off-by: Pierre Labat Co-developed-by: John Groves Signed-off-by: John Groves Signed-off-by: Nabeel M Mohamed --- drivers/mpool/mp.c | 1086 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1086 insertions(+) create mode 100644 drivers/mpool/mp.c diff --git a/drivers/mpool/mp.c b/drivers/mpool/mp.c new file mode 100644 index 000000000000..6b8c51c23fec --- /dev/null +++ b/drivers/mpool/mp.c @@ -0,0 +1,1086 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2015-2020 Micron Technology, Inc. All rights reserved. + */ + +/* + * Media pool (mpool) manager module. + * + * Defines functions to create and maintain mpools comprising multiple drives + * in multiple media classes used for storing mblocks and mlogs. + */ + +#include +#include +#include + +#include "assert.h" +#include "mpool_printk.h" + +#include "sb.h" +#include "upgrade.h" +#include "mpcore.h" +#include "mp.h" + +/* + * Lock for serializing certain mpool ops where required/desirable; could be per + * mpool in some cases but no meaningful performance benefit for these rare ops; + * also protects mpool_pools and certain mpool_descriptor fields. + */ +static DEFINE_MUTEX(mpool_s_lock); + +int mpool_create(const char *mpname, u32 flags, char **dpaths, struct pd_prop *pd_prop, + struct mpcore_params *params, u64 mlog_cap) +{ + struct omf_sb_descriptor *sbmdc0; + struct mpool_descriptor *mp; + struct pmd_layout *mdc01, *mdc02; + bool active, sbvalid; + u16 sidx; + int err; + + if (!mpname || !*mpname || !dpaths || !pd_prop) + return -EINVAL; + + mdc01 = mdc02 = NULL; + active = sbvalid = false; + + mp = mpool_desc_alloc(); + if (!mp) { + err = -ENOMEM; + mp_pr_err("mpool %s, alloc desc failed", err, mpname); + return err; + } + + sbmdc0 = &(mp->pds_sbmdc0); + strlcpy((char *)mp->pds_name, mpname, sizeof(mp->pds_name)); + mpool_generate_uuid(&mp->pds_poolid); + + if (params) + mp->pds_params = *params; + + mp->pds_pdvcnt = 0; + + mutex_lock(&mpool_s_lock); + + /* + * Allocate the per-mpool workqueue. + * TODO: Make this per-driver + */ + mp->pds_erase_wq = alloc_workqueue("mperasewq", WQ_HIGHPRI, 0); + if (!mp->pds_erase_wq) { + err = -ENOMEM; + mp_pr_err("mpool %s, alloc per-mpool wq failed", err, mpname); + goto errout; + } + + /* + * Set the devices parameters from the ones placed by the discovery + * in pd_prop. + */ + err = mpool_dev_init_all(mp->pds_pdv, 1, dpaths, pd_prop); + if (err) { + mp_pr_err("mpool %s, failed to get device parameters", err, mpname); + goto errout; + } + + mp->pds_pdvcnt = 1; + + mpool_mdc_cap_init(mp, &mp->pds_pdv[0]); + + /* Init new pool drives uuid and mclassp */ + mpool_generate_uuid(&mp->pds_pdv[0].pdi_devid); + + /* + * Init mpool descriptor from new drive info. + * Creates the media classes and place the PDs in them. + * Determine the media class used for the metadata. + */ + err = mpool_desc_init_newpool(mp, flags); + if (err) { + mp_pr_err("mpool %s, desc init from new drive info failed", err, mpname); + goto errout; + } + + /* + * Alloc empty mdc0 and write superblocks to all drives; if + * crash drives with superblocks will not be recognized as mpool + * members because there are not yet any drive state records in mdc0 + */ + sbvalid = true; + err = mpool_dev_sbwrite_newpool(mp, sbmdc0); + if (err) { + mp_pr_err("mpool %s, couldn't write superblocks", err, mpname); + goto errout; + } + + /* Alloc mdc0 mlog layouts and activate mpool with empty mdc0 */ + err = mpool_mdc0_sb2obj(mp, sbmdc0, &mdc01, &mdc02); + if (err) { + mp_pr_err("mpool %s, alloc of MDC0 mlogs failed", err, mpname); + goto errout; + } + + err = pmd_mpool_activate(mp, mdc01, mdc02, 1); + if (err) { + mp_pr_err("mpool %s, activation failed", err, mpname); + goto errout; + } + + active = true; + + /* + * Add the version record (always first record) in MDC0. + * The version record is used only from version 1.0.0.1. + */ + if (omfu_mdcver_cmp2(omfu_mdcver_cur(), ">=", 1, 0, 0, 1)) { + err = pmd_mdc_addrec_version(mp, 0); + if (err) { + mp_pr_err("mpool %s, writing MDC version record in MDC0 failed", + err, mpname); + goto errout; + } + } + + /* + * Add drive state records to mdc0; if crash before complete will + * detect if attempt to open same drive list; it may be possible to + * open the subset of the drive list for which state records were + * written without detection, in which case the other drives can be + * added + */ + err = pmd_prop_mcconfig(mp, &mp->pds_pdv[0], false); + if (err) { + mp_pr_err("mpool %s, add drive state to MDC0 failed", err, mpname); + goto errout; + } + + /* + * Create mdcs so user can create mlog/mblock objects; + * if crash before all the configured mdcs are created, or if create + * fails, will detect in activate and re-try. + * + * mp_cmdcn corresponds to the number of MDCNs used for client + * objects, i.e., [1 - mp_cmdcn] + */ + for (sidx = 1; sidx <= mp->pds_params.mp_mdcnum; sidx++) { + err = pmd_mdc_alloc(mp, mp->pds_params.mp_mdcncap, sidx - 1); + if (err) { + mp_pr_info("mpool %s, only %u MDCs out of %lu MDCs were created", + mpname, sidx - 1, (ulong)mp->pds_params.mp_mdcnum); + /* + * For MDCN creation failure, mask the error and + * continue further with create. + */ + err = 0; + break; + } + } + pmd_update_credit(mp); + + /* + * Attempt root mlog creation only if MDC1 was successfully created. + * If MDC1 doesn't exist, it will be re-created during activate. + */ + if (sidx > 1) { + err = mpool_create_rmlogs(mp, mlog_cap); + if (err) { + mp_pr_info("mpool %s, root mlog creation failed", mpname); + /* + * If root mlog creation fails, mask the error and + * proceed with create. root mlogs will be re-created + * during activate. + */ + err = 0; + } + } + + /* Add mp to the list of all open mpools */ + uuid_to_mpdesc_insert(&mpool_pools, mp); + +errout: + + if (mp->pds_erase_wq) + destroy_workqueue(mp->pds_erase_wq); + + if (active) + pmd_mpool_deactivate(mp); + + if (err && sbvalid) { + struct mpool_dev_info *pd; + int err1; + + /* Erase super blocks on the drives */ + pd = &mp->pds_pdv[0]; + if (mpool_pd_status_get(pd) != PD_STAT_ONLINE) { + err1 = -EIO; + mp_pr_err("%s:%s unavailable or offline, status %d", + err1, mp->pds_name, pd->pdi_name, mpool_pd_status_get(pd)); + } else { + err1 = sb_erase(&pd->pdi_parm); + if (err1) + mp_pr_info("%s: cleanup, sb erase failed on device %s", + mp->pds_name, pd->pdi_name); + } + } + + mpool_desc_free(mp); + + mutex_unlock(&mpool_s_lock); + + return err; +} + +int mpool_activate(u64 dcnt, char **dpaths, struct pd_prop *pd_prop, u64 mlog_cap, + struct mpcore_params *params, u32 flags, struct mpool_descriptor **mpp) +{ + struct omf_sb_descriptor *sbmdc0; + struct mpool_descriptor *mp; + struct pmd_layout *mdc01 = NULL; + struct pmd_layout *mdc02 = NULL; + struct media_class *mcmeta; + u64 mdcmax, mdcnum, mdcncap, mdc0cap; + bool force = ((flags & (1 << MP_FLAGS_FORCE)) != 0); + bool mc_resize[MP_MED_NUMBER] = { }; + bool active; + int dup, doff, err, i; + u8 pdh; + + active = false; + *mpp = NULL; + + if (dcnt > MPOOL_DRIVES_MAX) { + err = -EINVAL; + mp_pr_err("too many drives in input %lu, first drive path %s", + err, (ulong)dcnt, dpaths[0]); + return err; + } + + /* + * Verify no duplicate drive paths + */ + err = check_for_dups(dpaths, dcnt, &dup, &doff); + if (err) { + mp_pr_err("duplicate drive check failed", err); + return err; + } else if (dup) { + err = -EINVAL; + mp_pr_err("duplicate drive path %s", err, (doff == -1) ? "" : dpaths[doff]); + return err; + } + + /* Alloc mpool descriptor and fill in device-indepdendent values */ + mp = mpool_desc_alloc(); + if (!mp) { + err = -ENOMEM; + mp_pr_err("alloc mpool desc failed", err); + return err; + } + + sbmdc0 = &(mp->pds_sbmdc0); + + mp->pds_pdvcnt = 0; + + if (params) + mp->pds_params = *params; + + mutex_lock(&mpool_s_lock); + + mp->pds_workq = alloc_workqueue("mpoolwq", WQ_UNBOUND, 0); + if (!mp->pds_workq) { + err = -ENOMEM; + mp_pr_err("alloc mpoolwq failed, first drive path %s", err, dpaths[0]); + goto errout; + } + + mp->pds_erase_wq = alloc_workqueue("mperasewq", WQ_HIGHPRI, 0); + if (!mp->pds_erase_wq) { + err = -ENOMEM; + mp_pr_err("alloc mperasewq failed, first drive path %s", err, dpaths[0]); + goto errout; + } + + /* Get device parm for all drive paths */ + err = mpool_dev_init_all(mp->pds_pdv, dcnt, dpaths, pd_prop); + if (err) { + mp_pr_err("can't get drive device params, first drive path %s", err, dpaths[0]); + goto errout; + } + + /* Set mp.pdvcnt so dpaths will get closed in cleanup if activate fails. */ + mp->pds_pdvcnt = dcnt; + + /* Init mpool descriptor from superblocks on drives */ + err = mpool_desc_init_sb(mp, sbmdc0, flags, mc_resize); + if (err) { + mp_pr_err("mpool_desc_init_sb failed, first drive path %s", err, dpaths[0]); + goto errout; + } + + mcmeta = &mp->pds_mc[mp->pds_mdparm.md_mclass]; + if (mcmeta->mc_pdmc < 0) { + err = -ENODEV; + mp_pr_err("mpool %s, too many unavailable drives", err, mp->pds_name); + goto errout; + } + + /* Alloc mdc0 mlog layouts from superblock and activate mpool */ + err = mpool_mdc0_sb2obj(mp, sbmdc0, &mdc01, &mdc02); + if (err) { + mp_pr_err("mpool %s, allocation of MDC0 mlogs layouts failed", err, mp->pds_name); + goto errout; + } + + err = pmd_mpool_activate(mp, mdc01, mdc02, 0); + if (err) { + mp_pr_err("mpool %s, activation failed", err, mp->pds_name); + goto errout; + } + + active = true; + + for (pdh = 0; pdh < mp->pds_pdvcnt; pdh++) { + struct mpool_dev_info *pd; + + pd = &mp->pds_pdv[pdh]; + + if (mc_resize[pd->pdi_mclass]) { + err = pmd_prop_mcconfig(mp, pd, false); + if (err) { + mp_pr_err("mpool %s, updating MCCONFIG record for resize failed", + err, mp->pds_name); + goto errout; + } + } + + if (pd->pdi_mclass == MP_MED_CAPACITY) + mpool_mdc_cap_init(mp, pd); + } + + /* Tolerate unavailable drives only if force flag specified */ + for (i = 0; !force && i < MP_MED_NUMBER; i++) { + struct media_class *mc; + + mc = &mp->pds_mc[i]; + if (mc->mc_uacnt) { + err = -ENODEV; + mp_pr_err("mpool %s, unavailable drives present", err, mp->pds_name); + goto errout; + } + } + + /* + * Create mdcs if needed so user can create mlog/mblock objects; + * Only needed if the configured number of mdcs did not get created + * during mpool create due to crash or failure. + */ + mdcmax = mdcncap = mdc0cap = 0; + mdcnum = mp->pds_params.mp_mdcnum; + + pmd_mdc_cap(mp, &mdcmax, &mdcncap, &mdc0cap); + + if (mdc0cap) + mp->pds_params.mp_mdc0cap = mdc0cap; + + if (mdcncap && mdcmax) { + mdcncap = mdcncap / mdcmax; + mp->pds_params.mp_mdcncap = mdcncap; + mp->pds_params.mp_mdcnum = mdcmax; + } + + if (mdcmax < mdcnum) { + mp_pr_info("mpool %s, detected missing MDCs %lu %lu", + mp->pds_name, (ulong)mdcnum, (ulong)mdcmax); + + for (mdcmax++; mdcmax <= mdcnum; mdcmax++) { + + err = pmd_mdc_alloc(mp, mp->pds_params.mp_mdcncap, + mdcmax); + if (!err) + continue; + + /* MDC1 creation failure - non-functional mpool */ + if (mdcmax < 2) { + mp_pr_err("mpool %s, MDC1 can't be created", err, mp->pds_name); + goto errout; + } + + mp_pr_notice("mpool %s, couldn't create %lu MDCs out of %lu MDCs", + mp->pds_name, (ulong)(mdcnum - mdcmax + 1), (ulong)mdcnum); + + /* + * For MDCN (N > 1) creation failure, log a warning, + * mask the error and continue with activate. Mpool + * only needs a minimum of 1 MDC to be functional. + */ + err = 0; + + break; + } + mp->pds_params.mp_mdcnum = mdcmax - 1; + } + + pmd_update_credit(mp); + + /* + * If we reach here, then MDC1 must exist. Now, make sure that the + * root mlogs also exist and if they don't, re-create them. + */ + err = mpool_create_rmlogs(mp, mlog_cap); + if (err) { + /* Root mlogs creation failure - non-functional mpool */ + mp_pr_err("mpool %s, root mlogs creation failed", err, mp->pds_name); + goto errout; + } + + /* Add mp to the list of all activated mpools */ + uuid_to_mpdesc_insert(&mpool_pools, mp); + + /* Start the background thread doing pre-compaction of MDC1/255 */ + pmd_precompact_start(mp); + +errout: + if (err) { + if (mp->pds_workq) + destroy_workqueue(mp->pds_workq); + if (mp->pds_erase_wq) + destroy_workqueue(mp->pds_erase_wq); + + if (active) + pmd_mpool_deactivate(mp); + + mpool_desc_free(mp); + mp = NULL; + } + + mutex_unlock(&mpool_s_lock); + + *mpp = mp; + + if (!err) { + /* + * Start the periodic background job which logs a message + * when an mpool's usable space is close to its limits. + */ + struct smap_usage_work *usagew; + + usagew = &mp->pds_smap_usage_work; + + INIT_DELAYED_WORK(&usagew->smapu_wstruct, smap_log_mpool_usage); + usagew->smapu_mp = mp; + smap_log_mpool_usage(&usagew->smapu_wstruct.work); + } + + return err; +} + +int mpool_deactivate(struct mpool_descriptor *mp) +{ + pmd_precompact_stop(mp); + smap_wait_usage_done(mp); + + mutex_lock(&mpool_s_lock); + destroy_workqueue(mp->pds_workq); + destroy_workqueue(mp->pds_erase_wq); + + pmd_mpool_deactivate(mp); + + mpool_desc_free(mp); + mutex_unlock(&mpool_s_lock); + + return 0; +} + +int mpool_destroy(u64 dcnt, char **dpaths, struct pd_prop *pd_prop, u32 flags) +{ + struct omf_sb_descriptor *sbmdc0; + struct mpool_descriptor *mp; + int dup, doff; + int err, i; + + if (dcnt > MPOOL_DRIVES_MAX) { + err = -EINVAL; + mp_pr_err("first pd %s, too many drives %lu %d", + err, dpaths[0], (ulong)dcnt, MPOOL_DRIVES_MAX); + return err; + } else if (dcnt == 0) { + return -EINVAL; + } + + /* + * Verify no duplicate drive paths + */ + err = check_for_dups(dpaths, dcnt, &dup, &doff); + if (err) { + mp_pr_err("check_for_dups failed, dcnt %lu", err, (ulong)dcnt); + return err; + } else if (dup) { + err = -ENOMEM; + mp_pr_err("duplicate drives found", err); + return err; + } + + sbmdc0 = kzalloc(sizeof(*sbmdc0), GFP_KERNEL); + if (!sbmdc0) { + err = -ENOMEM; + mp_pr_err("alloc sb %zu failed", err, sizeof(*sbmdc0)); + return err; + } + + mp = mpool_desc_alloc(); + if (!mp) { + err = -ENOMEM; + mp_pr_err("alloc mpool desc failed", err); + kfree(sbmdc0); + return err; + } + + mp->pds_pdvcnt = 0; + + mutex_lock(&mpool_s_lock); + + /* Get device parm for all drive paths */ + err = mpool_dev_init_all(mp->pds_pdv, dcnt, dpaths, pd_prop); + if (err) { + mp_pr_err("first pd %s, get device params failed", err, dpaths[0]); + goto errout; + } + + /* Set pdvcnt so dpaths will get closed in cleanup if open fails. */ + mp->pds_pdvcnt = dcnt; + + /* Init mpool descriptor from superblocks on drives */ + err = mpool_desc_init_sb(mp, sbmdc0, flags, NULL); + if (err) { + mp_pr_err("mpool %s, first pd %s, mpool desc init from sb failed", + err, (mp->pds_name == NULL) ? "" : mp->pds_name, dpaths[0]); + goto errout; + } + + /* Erase super blocks on the drives */ + for (i = 0; i < mp->pds_pdvcnt; i++) { + struct mpool_dev_info *pd; + + pd = &mp->pds_pdv[i]; + if (mpool_pd_status_get(pd) != PD_STAT_ONLINE) { + err = -EIO; + mp_pr_err("pd %s unavailable or offline, status %d", + err, pd->pdi_name, mpool_pd_status_get(pd)); + } else { + err = sb_erase(&pd->pdi_parm); + if (err) + mp_pr_err("pd %s, sb erase failed", err, pd->pdi_name); + } + + if (err) + break; + } + +errout: + mpool_desc_free(mp); + + mutex_unlock(&mpool_s_lock); + + kfree(sbmdc0); + + return err; +} + +int mpool_rename(u64 dcnt, char **dpaths, struct pd_prop *pd_prop, + u32 flags, const char *mp_newname) +{ + struct omf_sb_descriptor *sb; + struct mpool_descriptor *mp; + struct mpool_dev_info *pd = NULL; + u16 omf_ver = OMF_SB_DESC_UNDEF; + bool force = ((flags & (1 << MP_FLAGS_FORCE)) != 0); + u8 pdh; + int dup, doff; + int err = 0; + + if (!mp_newname || dcnt == 0) + return -EINVAL; + + if (dcnt > MPOOL_DRIVES_MAX) { + err = -EINVAL; + mp_pr_err("first pd %s, too many drives %lu %d", + err, dpaths[0], (ulong)dcnt, MPOOL_DRIVES_MAX); + return err; + } + + /* + * Verify no duplicate drive paths + */ + err = check_for_dups(dpaths, dcnt, &dup, &doff); + if (err) { + mp_pr_err("check_for_dups failed, dcnt %lu", err, (ulong)dcnt); + return err; + } else if (dup) { + err = -ENOMEM; + mp_pr_err("duplicate drives found", err); + return err; + } + + sb = kzalloc(sizeof(*sb), GFP_KERNEL); + if (!sb) { + err = -ENOMEM; + mp_pr_err("alloc sb %zu failed", err, sizeof(*sb)); + return err; + } + + mp = mpool_desc_alloc(); + if (!mp) { + err = -ENOMEM; + mp_pr_err("alloc mpool desc failed", err); + kfree(sb); + return err; + } + + mp->pds_pdvcnt = 0; + + mutex_lock(&mpool_s_lock); + + /* Get device parm for all drive paths */ + err = mpool_dev_init_all(mp->pds_pdv, dcnt, dpaths, pd_prop); + if (err) { + mp_pr_err("first pd %s, get device params failed", err, dpaths[0]); + goto errout; + } + + /* Set pdvcnt so dpaths will get closed in cleanup if open fails. + */ + mp->pds_pdvcnt = dcnt; + + for (pdh = 0; pdh < mp->pds_pdvcnt; pdh++) { + pd = &mp->pds_pdv[pdh]; + + if (mpool_pd_status_get(pd) != PD_STAT_ONLINE) { + err = -EIO; + mp_pr_err("pd %s unavailable or offline, status %d", + err, pd->pdi_name, mpool_pd_status_get(pd)); + goto errout; + } + + /* + * Read superblock; init and validate pool drive info + * from device parameters stored in the super block. + */ + err = sb_read(&pd->pdi_parm, sb, &omf_ver, force); + if (err) { + mp_pr_err("pd %s, sb read failed", err, pd->pdi_name); + goto errout; + } + + if (omf_ver > OMF_SB_DESC_VER_LAST || + omf_ver < OMF_SB_DESC_VER_LAST) { + err = -EOPNOTSUPP; + mp_pr_err("pd %s, invalid sb version %d %d", + err, pd->pdi_name, omf_ver, OMF_SB_DESC_VER_LAST); + goto errout; + } + + if (!strcmp(mp_newname, sb->osb_name)) + continue; + + strlcpy(sb->osb_name, mp_newname, sizeof(sb->osb_name)); + + err = sb_write_update(&pd->pdi_parm, sb); + if (err) { + mp_pr_err("Failed to rename mpool %s on device %s", + err, mp->pds_name, pd->pdi_name); + goto errout; + } + } + +errout: + mutex_unlock(&mpool_s_lock); + + mpool_desc_free(mp); + kfree(sb); + + return err; +} + +int mpool_drive_add(struct mpool_descriptor *mp, char *dpath, struct pd_prop *pd_prop) +{ + struct mpool_dev_info *pd; + struct mc_smap_parms mcsp; + char *dpathv[1] = { dpath }; + bool erase = false; + bool smap = false; + int err; + + /* + * All device list changes are serialized via mpool_s_lock so + * don't need to acquire mp.pdvlock until ready to update mpool + * descriptor + */ + mutex_lock(&mpool_s_lock); + + if (mp->pds_pdvcnt >= MPOOL_DRIVES_MAX) { + mutex_unlock(&mpool_s_lock); + + mp_pr_warn("%s: pd %s, too many drives %u %d", + mp->pds_name, dpath, mp->pds_pdvcnt, MPOOL_DRIVES_MAX); + return -EINVAL; + } + + /* + * get device parm for dpath; use next slot in mp.pdv which won't + * be visible until we update mp.pdvcnt + */ + pd = &mp->pds_pdv[mp->pds_pdvcnt]; + + /* + * Some leftover may be present due to a previous try to add a PD + * at this position. Clear up. + */ + memset(pd, 0, sizeof(*pd)); + + err = mpool_dev_init_all(pd, 1, dpathv, pd_prop); + if (err) { + mutex_unlock(&mpool_s_lock); + + mp_pr_err("%s: pd %s, getting drive params failed", err, mp->pds_name, dpath); + return err; + } + + /* Confirm drive meets all criteria for adding to this mpool */ + err = mpool_dev_check_new(mp, pd); + if (err) { + mp_pr_err("%s: pd %s, drive doesn't pass criteria", err, mp->pds_name, dpath); + goto errout; + } + + /* + * Check that the drive can be added in a media class. + */ + down_read(&mp->pds_pdvlock); + err = mpool_desc_pdmc_add(mp, mp->pds_pdvcnt, NULL, true); + up_read(&mp->pds_pdvlock); + if (err) { + mp_pr_err("%s: pd %s, can't place in any media class", err, mp->pds_name, dpath); + goto errout; + } + + + mpool_generate_uuid(&pd->pdi_devid); + + /* Write mpool superblock to drive */ + erase = true; + err = mpool_dev_sbwrite(mp, pd, NULL); + if (err) { + mp_pr_err("%s: pd %s, sb write failed", err, mp->pds_name, dpath); + goto errout; + } + + /* Get percent spare */ + down_read(&mp->pds_pdvlock); + err = mc_smap_parms_get(&mp->pds_mc[pd->pdi_mclass], &mp->pds_params, &mcsp); + up_read(&mp->pds_pdvlock); + if (err) + goto errout; + + /* Alloc space map for drive */ + err = smap_drive_init(mp, &mcsp, mp->pds_pdvcnt); + if (err) { + mp_pr_err("%s: pd %s, smap init failed", err, mp->pds_name, dpath); + goto errout; + } + smap = true; + + /* + * Take MDC0 compact lock to prevent race with MDC0 compaction. + * Take it across memory and media update. + */ + PMD_MDC0_COMPACTLOCK(mp); + + /* + * Add drive state record to mdc0; if crash any time prior to adding + * this record the drive will not be recognized as an mpool member + * on next open + */ + err = pmd_prop_mcconfig(mp, pd, false); + if (err) { + PMD_MDC0_COMPACTUNLOCK(mp); + mp_pr_err("%s: pd %s, adding drive state to MDC0 failed", err, mp->pds_name, dpath); + goto errout; + } + + /* Make new drive visible in mpool */ + down_write(&mp->pds_pdvlock); + mp->pds_pdvcnt++; + + /* + * Add the PD in its class. That should NOT fail because we already + * checked that the drive can be added in a media class. + */ + err = mpool_desc_pdmc_add(mp, mp->pds_pdvcnt - 1, NULL, false); + if (err) + mp->pds_pdvcnt--; + + up_write(&mp->pds_pdvlock); + PMD_MDC0_COMPACTUNLOCK(mp); + +errout: + if (err) { + /* + * No pd could have been be added at mp->pds_pdvcnt since we + * dropped pds_pdvlock because mpool_s_lock is held. + */ + if (smap) + smap_drive_free(mp, mp->pds_pdvcnt); + + /* + * Erase the pd super blocks only if the pd doesn't already + * belong to this mpool or another one. + */ + if (erase) + sb_erase(&pd->pdi_parm); + + pd_dev_close(&pd->pdi_parm); + } + + mutex_unlock(&mpool_s_lock); + + return err; +} + +void mpool_mclass_get_cnt(struct mpool_descriptor *mp, u32 *cnt) +{ + int i; + + *cnt = 0; + + down_read(&mp->pds_pdvlock); + for (i = 0; i < MP_MED_NUMBER; i++) { + struct media_class *mc; + + mc = &mp->pds_mc[i]; + if (mc->mc_pdmc >= 0) + (*cnt)++; + } + up_read(&mp->pds_pdvlock); +} + +int mpool_mclass_get(struct mpool_descriptor *mp, u32 *mcxc, struct mpool_mclass_xprops *mcxv) +{ + int i, n; + + if (!mp || !mcxc || !mcxv) + return -EINVAL; + + mutex_lock(&mpool_s_lock); + down_read(&mp->pds_pdvlock); + + for (n = i = 0; i < MP_MED_NUMBER && n < *mcxc; i++) { + struct media_class *mc; + + mc = &mp->pds_mc[i]; + if (mc->mc_pdmc < 0) + continue; + + mcxv->mc_mclass = mc->mc_parms.mcp_classp; + mcxv->mc_devtype = mc->mc_parms.mcp_devtype; + mcxv->mc_spare = mc->mc_sparms.mcsp_spzone; + + mcxv->mc_zonepg = mc->mc_parms.mcp_zonepg; + mcxv->mc_sectorsz = mc->mc_parms.mcp_sectorsz; + mcxv->mc_features = mc->mc_parms.mcp_features; + mcxv->mc_uacnt = mc->mc_uacnt; + smap_mclass_usage(mp, i, &mcxv->mc_usage); + + ++mcxv; + ++n; + } + + up_read(&mp->pds_pdvlock); + mutex_unlock(&mpool_s_lock); + + *mcxc = n; + + return 0; +} + +int mpool_drive_spares(struct mpool_descriptor *mp, enum mp_media_classp mclassp, u8 drive_spares) +{ + struct media_class *mc; + int err; + + if (!mclass_isvalid(mclassp) || drive_spares > 100) { + err = -EINVAL; + mp_pr_err("mpool %s, setting percent %u spare for drives in media class %d failed", + err, mp->pds_name, drive_spares, mclassp); + return err; + } + + /* + * Do not write the spare record or try updating spare if there are + * no PDs in the specified media class. + */ + down_read(&mp->pds_pdvlock); + mc = &mp->pds_mc[mclassp]; + up_read(&mp->pds_pdvlock); + + if (mc->mc_pdmc < 0) { + err = -ENOENT; + goto skip_update; + } + + mutex_lock(&mpool_s_lock); + + /* + * Take mdc0 compact lock to prevent race with mdc0 compaction. + * Also make memory and media update to look atomic to compaction. + */ + PMD_MDC0_COMPACTLOCK(mp); + + /* + * update media class spare record in mdc0; no effect if crash before + * complete + */ + err = pmd_prop_mcspare(mp, mclassp, drive_spares, false); + if (err) { + mp_pr_err("mpool %s, setting spare %u mclass %d failed, could not record in MDC0", + err, mp->pds_name, drive_spares, mclassp); + } else { + /* Update spare zone accounting for media class */ + down_write(&mp->pds_pdvlock); + + err = mc_set_spzone(&mp->pds_mc[mclassp], drive_spares); + if (err) + mp_pr_err("mpool %s, setting spare %u mclass %d failed", + err, mp->pds_name, drive_spares, mclassp); + else + /* + * smap accounting update always succeeds when + * mclassp/zone are valid + */ + smap_drive_spares(mp, mclassp, drive_spares); + + up_write(&mp->pds_pdvlock); + } + + PMD_MDC0_COMPACTUNLOCK(mp); + + mutex_unlock(&mpool_s_lock); + +skip_update: + return err; +} + +void mpool_get_xprops(struct mpool_descriptor *mp, struct mpool_xprops *xprops) +{ + struct media_class *mc; + int mclassp, i; + u16 ftmax; + + mutex_lock(&mpool_s_lock); + down_read(&mp->pds_pdvlock); + + memcpy(xprops->ppx_params.mp_poolid.b, mp->pds_poolid.uuid, MPOOL_UUID_SIZE); + ftmax = 0; + + for (mclassp = 0; mclassp < MP_MED_NUMBER; mclassp++) { + xprops->ppx_pd_mclassv[mclassp] = MP_MED_INVALID; + + mc = &mp->pds_mc[mclassp]; + if (mc->mc_pdmc < 0) { + xprops->ppx_drive_spares[mclassp] = 0; + xprops->ppx_uacnt[mclassp] = 0; + + xprops->ppx_params.mp_mblocksz[mclassp] = 0; + continue; + } + + xprops->ppx_drive_spares[mclassp] = mc->mc_sparms.mcsp_spzone; + xprops->ppx_uacnt[mclassp] = mc->mc_uacnt; + ftmax = max((u16)ftmax, (u16)(xprops->ppx_uacnt[mclassp])); + xprops->ppx_params.mp_mblocksz[mclassp] = + (mc->mc_parms.mcp_zonepg << PAGE_SHIFT) >> 20; + } + + for (i = 0; i < mp->pds_pdvcnt; ++i) { + mc = &mp->pds_mc[mp->pds_pdv[i].pdi_mclass]; + if (mc->mc_pdmc < 0) + continue; + + xprops->ppx_pd_mclassv[i] = mc->mc_parms.mcp_classp; + + strlcpy(xprops->ppx_pd_namev[i], mp->pds_pdv[i].pdi_name, + sizeof(xprops->ppx_pd_namev[i])); + } + + up_read(&mp->pds_pdvlock); + mutex_unlock(&mpool_s_lock); + + xprops->ppx_params.mp_stat = ftmax ? MPOOL_STAT_FAULTED : MPOOL_STAT_OPTIMAL; +} + +int mpool_get_devprops_by_name(struct mpool_descriptor *mp, char *pdname, + struct mpool_devprops *dprop) +{ + int i; + + down_read(&mp->pds_pdvlock); + + for (i = 0; i < mp->pds_pdvcnt; i++) { + if (!strcmp(pdname, mp->pds_pdv[i].pdi_name)) + fill_in_devprops(mp, i, dprop); + } + + up_read(&mp->pds_pdvlock); + + return 0; +} + +void mpool_get_usage(struct mpool_descriptor *mp, enum mp_media_classp mclassp, + struct mpool_usage *usage) +{ + memset(usage, 0, sizeof(*usage)); + + down_read(&mp->pds_pdvlock); + if (mclassp != MP_MED_ALL) { + struct media_class *mc; + + ASSERT(mclassp < MP_MED_NUMBER); + + mc = &mp->pds_mc[mclassp]; + if (mc->mc_pdmc < 0) { + /* Not an error, this media class is empty. */ + up_read(&mp->pds_pdvlock); + return; + } + } + smap_mpool_usage(mp, mclassp, usage); + up_read(&mp->pds_pdvlock); + + if (mclassp == MP_MED_ALL) + pmd_mpool_usage(mp, usage); +} + +int mpool_config_store(struct mpool_descriptor *mp, const struct mpool_config *cfg) +{ + int err; + + if (!mp || !cfg) + return -EINVAL; + + mp->pds_cfg = *cfg; + + err = pmd_prop_mpconfig(mp, cfg, false); + if (err) + mp_pr_err("mpool %s, logging config record failed", err, mp->pds_name); + + return err; +} + +int mpool_config_fetch(struct mpool_descriptor *mp, struct mpool_config *cfg) +{ + if (!mp || !cfg) + return -EINVAL; + + *cfg = mp->pds_cfg; + + return 0; +} -- 2.17.2