From patchwork Thu Nov 7 12:58:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13866433 X-Patchwork-Delegate: yukuai3@huawei.com Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A85B720EA54 for ; Thu, 7 Nov 2024 13:02:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730984537; cv=none; b=RAuX4GYAMjWupswAC6zoo0w2lIo2zicnpbMNJWEyXAbzr7RSazcnDQyRoDcDORv2x8rWDF25yDhHe5Mifzf82XqUnHKM1Oyldsguq/kkkIw1u3Gv+OzxSaIO/4Vog/CR3KeDfHGg9go869fi8Uws/Ad2JECjvY6Q15e20DeDSB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730984537; c=relaxed/simple; bh=FSGOVbCJm0pa10555AIFxB0Mk52SBAGK9fg3pBJ5CpU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DtvKkVn+AWAogBeImkKuOwBETx7EXLAbTdwTUkNbBuy7CAS1In/cmHkWNXQof2JhVWydSXeNpgGdTx6ym9uXdl5sOeU6LUVrcKf8mQjhpwYuWGFPbYj6fFjWmSIgzKNKsfgNDjP5I8odDybMPx9yAoUW5IplHhFF5rcdOyQRSGU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Xkhzq2bbcz4f3m8X for ; Thu, 7 Nov 2024 21:01:59 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 49AF91A058E for ; Thu, 7 Nov 2024 21:02:12 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgCXc4dRuixnj+RyBA--.6466S7; Thu, 07 Nov 2024 21:02:12 +0800 (CST) From: Yu Kuai To: mariusz.tkaczyk@linux.intel.com, linux-raid@vger.kernel.org Cc: yukuai3@huawei.com, yangerkun@huawei.com Subject: [PATCH V2 3/3] mdadm: add support for new lockless bitmap Date: Thu, 7 Nov 2024 20:58:39 +0800 Message-Id: <20241107125839.310633-4-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241107125839.310633-1-yukuai1@huaweicloud.com> References: <20241107125839.310633-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCXc4dRuixnj+RyBA--.6466S7 X-Coremail-Antispam: 1UD129KBjvJXoWxZF43WFW8ZrW8GrWDJry7KFg_yoW5ur1DpF 42vr95Cr13Gw4kWw17ta4kuFZ5Jw1vyFnFkrWkZanIgr1SgrnavF1UGF1UXa4fGw4rJayx Xrn8tw1Uu3yayrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV WxJVW8Jr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx 0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWU JVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa 73UjIFyTuYvjxU2ApnDUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai A new major number 6 is used for the new bitmap. Noted that for the kernel that doesn't support lockless bitmap, create such array will fail: md0: invalid bitmap file superblock: unrecognized superblock version. Signed-off-by: Yu Kuai --- Create.c | 5 ++++- Grow.c | 3 ++- bitmap.h | 1 + mdadm.c | 9 ++++++++- mdadm.h | 1 + 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Create.c b/Create.c index ade677cd..ad9e31a3 100644 --- a/Create.c +++ b/Create.c @@ -541,6 +541,8 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, pr_err("At least 2 nodes are needed for cluster-md\n"); return 1; } + } else if (s->btype == BitmapLockless) { + major_num = BITMAP_MAJOR_LOCKLESS; } memset(&info, 0, sizeof(info)); @@ -1195,7 +1197,8 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, * to stop another mdadm from finding and using those devices. */ - if (s->btype == BitmapInternal || s->btype == BitmapCluster) { + if (s->btype == BitmapInternal || s->btype == BitmapCluster || + s->btype == BitmapLockless) { if (!st->ss->add_internal_bitmap) { pr_err("internal bitmaps not supported with %s metadata\n", st->ss->name); diff --git a/Grow.c b/Grow.c index cc1be6cc..3905f64c 100644 --- a/Grow.c +++ b/Grow.c @@ -383,7 +383,8 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s) free(mdi); } - if (s->btype == BitmapInternal || s->btype == BitmapCluster) { + if (s->btype == BitmapInternal || s->btype == BitmapCluster || + s->btype == BitmapLockless) { int rv; int d; int offset_setable = 0; diff --git a/bitmap.h b/bitmap.h index 7b1f80f2..4b5d2d93 100644 --- a/bitmap.h +++ b/bitmap.h @@ -13,6 +13,7 @@ #define BITMAP_MAJOR_HI 4 #define BITMAP_MAJOR_HOSTENDIAN 3 #define BITMAP_MAJOR_CLUSTERED 5 +#define BITMAP_MAJOR_LOCKLESS 6 #define BITMAP_MINOR 39 diff --git a/mdadm.c b/mdadm.c index 605ccec9..eaffe84d 100644 --- a/mdadm.c +++ b/mdadm.c @@ -56,6 +56,12 @@ static mdadm_status_t set_bitmap_value(struct shape *s, struct context *c, char return MDADM_STATUS_SUCCESS; } + if (strcmp(val, "lockless") == 0) { + s->btype = BitmapLockless; + pr_info("Experimental lockless bitmap, use at your own disk!\n"); + return MDADM_STATUS_SUCCESS; + } + if (strcmp(val, "clustered") == 0) { s->btype = BitmapCluster; /* Set the default number of cluster nodes @@ -1251,7 +1257,8 @@ int main(int argc, char *argv[]) pr_err("--bitmap is required for consistency policy: %s\n", map_num_s(consistency_policies, s.consistency_policy)); exit(2); - } else if ((s.btype == BitmapInternal || s.btype == BitmapCluster) && + } else if ((s.btype == BitmapInternal || s.btype == BitmapCluster || + s.btype == BitmapLockless) && s.consistency_policy != CONSISTENCY_POLICY_BITMAP && s.consistency_policy != CONSISTENCY_POLICY_JOURNAL) { pr_err("--bitmap is not compatible with consistency policy: %s\n", diff --git a/mdadm.h b/mdadm.h index af54a6ab..5e35d78c 100644 --- a/mdadm.h +++ b/mdadm.h @@ -607,6 +607,7 @@ enum bitmap_type { BitmapNone, BitmapInternal, BitmapCluster, + BitmapLockless, BitmapUnknown, };