From patchwork Sat Aug 10 02:08:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759334 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 3EBA627452; Sat, 10 Aug 2024 02:12:56 +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=1723255978; cv=none; b=KP/Hd+DcMVv97mTyAxBKHuIcBPPr7Wfg/C5AtVIIfHe7ufPYzsuEJ6UwnLmoZh4xsolXea0Dwj84FdW38uPIQsq1m804goxZxHRoGTFr7eUx/+v9c/OcB2vEtMmzcGnr8Zze4fEyuvUb+cILviZeQHJ67DmyRqLnlHjH+FHIcAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255978; c=relaxed/simple; bh=SR5ipG1SbKiZvkaVsKyWLmS9oRY42Cz5uykzVSnlZl4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V92s0jvI45a07lXwcwwaKTsXiCNKGqG0UR/AJ8/VI1M7WQRmPwl/iz6cmvdGBcQ8c9rVAeTa60d0+QJ968YT55OPxRKvpHbrb+fhh8+foyvyUn31ma82nk2PVcm0f/pU105VyhOhF+jKMqmGb/qiyLjZfxyuz2da9RMItGyU9OM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=none 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=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknl5Zpkz4f3jk1; Sat, 10 Aug 2024 10:12:43 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id E361B1A07B6; Sat, 10 Aug 2024 10:12:52 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S5; Sat, 10 Aug 2024 10:12:52 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 01/26] md/md-bitmap: introduce struct bitmap_operations Date: Sat, 10 Aug 2024 10:08:29 +0800 Message-Id: <20240810020854.797814-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S5 X-Coremail-Antispam: 1UD129KBjvJXoW7CFW5CF4kAF4UuFyUAr17Awb_yoW8trW7pF Z3X34fAw15Jr4UXw1UXayDuFyrX3Z7trZrKrWxCw4ruFyDXF9xGF4rGFWqyw1DWF43AFnx Xw15KryUur18Xr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBl14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkF7I0En4kS14v26r126r1DMx AIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_ Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwI xGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWx JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcV C2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUjX18JUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai The structure is empty for now, and will be used in later patches to merge in bitmap operations, prepare to implement a new lock free bitmap in the fulture. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 8 ++++++++ drivers/md/md-bitmap.h | 4 ++++ drivers/md/md.c | 1 + drivers/md/md.h | 1 + 4 files changed, 14 insertions(+) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 08232d8dc815..d9838fbcc9d7 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -2707,3 +2707,11 @@ const struct attribute_group md_bitmap_group = { .name = "bitmap", .attrs = md_bitmap_attrs, }; + +static struct bitmap_operations bitmap_ops = { +}; + +void mddev_set_bitmap_ops(struct mddev *mddev) +{ + mddev->bitmap_ops = &bitmap_ops; +} diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index bb9eb418780a..992feaf66d47 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -234,7 +234,11 @@ struct bitmap { int cluster_slot; /* Slot offset for clustered env */ }; +struct bitmap_operations { +}; + /* the bitmap API */ +void mddev_set_bitmap_ops(struct mddev *mddev); /* these are used only by md/bitmap */ struct bitmap *md_bitmap_create(struct mddev *mddev, int slot); diff --git a/drivers/md/md.c b/drivers/md/md.c index d3a837506a36..f23138dd96a7 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -772,6 +772,7 @@ int mddev_init(struct mddev *mddev) mddev->resync_min = 0; mddev->resync_max = MaxSector; mddev->level = LEVEL_NONE; + mddev_set_bitmap_ops(mddev); INIT_WORK(&mddev->sync_work, md_start_sync); INIT_WORK(&mddev->del_work, mddev_delayed_delete); diff --git a/drivers/md/md.h b/drivers/md/md.h index a0d6827dced9..e56193f71ab4 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -536,6 +536,7 @@ struct mddev { int sync_checkers; /* # of threads checking writes_pending */ struct bitmap *bitmap; /* the bitmap for the device */ + struct bitmap_operations *bitmap_ops; struct { struct file *file; /* the bitmap file */ loff_t offset; /* offset from superblock of From patchwork Sat Aug 10 02:08:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759336 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 3EB6515AF6; Sat, 10 Aug 2024 02:12:56 +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=1723255979; cv=none; b=QCZ6aanz5MlFYo0FTPd1+WyZSLto5GZpbvJnUVLMqtsLcmtzI8/Kaj6jf9/jm2E/1dTlpn4I7g99dnGCBI1+luPaYGf36TlWIiEwFVtcUWsb2tfFvWbzVC1aknTYuNjLXUwsAsBCZFqi+VP0bj3WL+n2Ur5HN45cS/cEMyumYd4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255979; c=relaxed/simple; bh=eKGwyrAMYPtZUn2NsyA0r0xUoBi2jEpGkrTzT6P3kWs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T4cqL1AShxbicdbnfObzx20nlkNeVu1/D0QM6CNxwgqAF0298naQSrOf5/8hQrxB2OxsI/dYWSpe259sdSbj6PoaIhxeiRILb6hNCMAOi5ECp7i/ysEso0zX3JpZDdIwh4jFcMeAJPaLEb6GqMo/7LQ1cIQuah4tt0wtx/uN9kY= 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.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknf5QvBz4f3jLc; Sat, 10 Aug 2024 10:12:38 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 3EB691A1718; Sat, 10 Aug 2024 10:12:53 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S6; Sat, 10 Aug 2024 10:12:53 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 02/26] md/md-bitmap: merge md_bitmap_create() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:30 +0800 Message-Id: <20240810020854.797814-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S6 X-Coremail-Antispam: 1UD129KBjvJXoWxur47Jw1rKFyrur4Duw4kWFg_yoW5Jw4rpF s7tas8C3y3JrWSgr1UZFWqka4Fqr1vqrZrKryfCw1ruF9rJFnxGF4rWF12y34rGa43JFsx Xw15KryUCr1xXrUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBl14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkF7I0En4kS14v26r126r1DMx AIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_ Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwI xGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWx JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcV C2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUUApnJUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 7 ++++--- drivers/md/md-bitmap.h | 10 +++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index d9838fbcc9d7..d731f7d4bbbb 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1878,7 +1878,7 @@ void md_bitmap_destroy(struct mddev *mddev) * if this returns an error, bitmap_destroy must be called to do clean up * once mddev->bitmap is set */ -struct bitmap *md_bitmap_create(struct mddev *mddev, int slot) +static struct bitmap *bitmap_create(struct mddev *mddev, int slot) { struct bitmap *bitmap; sector_t blocks = mddev->resync_max_sectors; @@ -2029,7 +2029,7 @@ struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot) int rv = 0; struct bitmap *bitmap; - bitmap = md_bitmap_create(mddev, slot); + bitmap = bitmap_create(mddev, slot); if (IS_ERR(bitmap)) { rv = PTR_ERR(bitmap); return ERR_PTR(rv); @@ -2404,7 +2404,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len) } mddev->bitmap_info.offset = offset; - bitmap = md_bitmap_create(mddev, -1); + bitmap = bitmap_create(mddev, -1); if (IS_ERR(bitmap)) { rv = PTR_ERR(bitmap); goto out; @@ -2709,6 +2709,7 @@ const struct attribute_group md_bitmap_group = { }; static struct bitmap_operations bitmap_ops = { + .create = bitmap_create, }; void mddev_set_bitmap_ops(struct mddev *mddev) diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 992feaf66d47..a7cbf0c692fc 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -235,13 +235,21 @@ struct bitmap { }; struct bitmap_operations { + struct bitmap* (*create)(struct mddev *mddev, int slot); }; /* the bitmap API */ void mddev_set_bitmap_ops(struct mddev *mddev); /* these are used only by md/bitmap */ -struct bitmap *md_bitmap_create(struct mddev *mddev, int slot); +static inline struct bitmap *md_bitmap_create(struct mddev *mddev, int slot) +{ + if (!mddev->bitmap_ops->create) + return ERR_PTR(-EOPNOTSUPP); + + return mddev->bitmap_ops->create(mddev, slot); +} + int md_bitmap_load(struct mddev *mddev); void md_bitmap_flush(struct mddev *mddev); void md_bitmap_destroy(struct mddev *mddev); From patchwork Sat Aug 10 02:08:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759335 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 DEA4342A8B; Sat, 10 Aug 2024 02:12:56 +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=1723255979; cv=none; b=Y6nKA3GS8MOvmzXTBGpsRWdj2XlOj15QJXEfVqFy7xwXXsxGF1gGag4G9vjc/871TBvnmwDTBaWFDsX2fb/zR1Slb/dxrhfzEpydfIWm9Q2DOPjw7UqAFI4IAbrxgnQZkiuHoDFf9bY9W+I3GzhaTvumM9sIT2qArlKZkc+brN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255979; c=relaxed/simple; bh=ooiZMn8kzVM9qRH0lDITvlMgCw+H3sH/aBSPrBbzu7w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dWO924NfXfTYB2U6TTMiEcE7XYy+eEyaMBSZ915tNZBxH35v0EnzknYs5cFG/A5ukRKTYHuHpyv00wOqBB3b2wN6BMBPwRJsvByHGAeT8z3iS0u258kKguYzEv03gyC+rBesq+HEu9S3gq2tqDe+hI/jeGZBJDSpzdybDZZevb4= 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.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknm33jLz4f3jk7; Sat, 10 Aug 2024 10:12:44 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 8DBFD1A1382; Sat, 10 Aug 2024 10:12:53 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S7; Sat, 10 Aug 2024 10:12:53 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 03/26] md/md-bitmap: merge md_bitmap_load() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:31 +0800 Message-Id: <20240810020854.797814-4-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S7 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr4rtr1DXF47GrW7uryxGrg_yoW8KF15pF sFqa45Cr43JrWagr1UuFWkua4Yqr1vqr9rtrWxGw1S9F9xXFnxGF4rWF42yw1rGa43JFsx Xw15KFyrCr1xXr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBl14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkF7I0En4kS14v26r126r1DMx AIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_ Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwI xGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWx JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcV C2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbTUDJUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 6 +++--- drivers/md/md-bitmap.h | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index d731f7d4bbbb..9a9f0fe3ebd0 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1965,7 +1965,7 @@ static struct bitmap *bitmap_create(struct mddev *mddev, int slot) return ERR_PTR(err); } -int md_bitmap_load(struct mddev *mddev) +static int bitmap_load(struct mddev *mddev) { int err = 0; sector_t start = 0; @@ -2021,7 +2021,6 @@ int md_bitmap_load(struct mddev *mddev) out: return err; } -EXPORT_SYMBOL_GPL(md_bitmap_load); /* caller need to free returned bitmap with md_bitmap_free() */ struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot) @@ -2411,7 +2410,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len) } mddev->bitmap = bitmap; - rv = md_bitmap_load(mddev); + rv = bitmap_load(mddev); if (rv) { mddev->bitmap_info.offset = 0; md_bitmap_destroy(mddev); @@ -2710,6 +2709,7 @@ const struct attribute_group md_bitmap_group = { static struct bitmap_operations bitmap_ops = { .create = bitmap_create, + .load = bitmap_load, }; void mddev_set_bitmap_ops(struct mddev *mddev) diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index a7cbf0c692fc..de7fbe5903dd 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -236,6 +236,7 @@ struct bitmap { struct bitmap_operations { struct bitmap* (*create)(struct mddev *mddev, int slot); + int (*load)(struct mddev *mddev); }; /* the bitmap API */ @@ -250,7 +251,14 @@ static inline struct bitmap *md_bitmap_create(struct mddev *mddev, int slot) return mddev->bitmap_ops->create(mddev, slot); } -int md_bitmap_load(struct mddev *mddev); +static inline int md_bitmap_load(struct mddev *mddev) +{ + if (!mddev->bitmap_ops->load) + return -EOPNOTSUPP; + + return mddev->bitmap_ops->load(mddev); +} + void md_bitmap_flush(struct mddev *mddev); void md_bitmap_destroy(struct mddev *mddev); From patchwork Sat Aug 10 02:08:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759340 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 DE9FD18E20; Sat, 10 Aug 2024 02:12:56 +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=1723255980; cv=none; b=pxaqxbgrBgQz8V+GsACdvfDqzEBJpj7jnsUqCLFJ3VoyGEAGjHk9yn/G8YfjUO6imfPEKgnPiMSl1mLnONj7oZ2EMY8+Jw7Z+zrp2xWJrLwEDz34O4P8UFz+r9C+vfwXVFoCJIckbqY3T7GnbuZ+6sZGpxtF3bXskZGNCimDOIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255980; c=relaxed/simple; bh=Ub/xMJwEu+Nf5291AZMXWWXELeyrO/nsn3k8t0xpd5A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Nbh6+axE5ITavjswSiX1aZokPPczYrbvHfafVNh6iMRTA1ElaYPEmg8+57Vj5S+ctWSGUOnorAOLEV6Nrhm2gId3ROxzMgwJDZFpvJrfgr1AXgfxXvWQm/ErbQijGoMrvQ3X6VAhvWd866KRnI/aUirsYpPF7bsOWwWUISGku0Y= 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.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknm601pz4f3jk0; Sat, 10 Aug 2024 10:12:44 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id F0B0C1A0359; Sat, 10 Aug 2024 10:12:53 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S8; Sat, 10 Aug 2024 10:12:53 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 04/26] md/md-bitmap: merge md_bitmap_destroy() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:32 +0800 Message-Id: <20240810020854.797814-5-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S8 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr47GF4DCryfuw1rtrWrZrb_yoW5Jr1rpa nrta45Cr43JrW3Wr1UZFWq9a4FvF1ktr9rtryxGw1rCF9xJFnxGF4rWF1jyw1rGa43AFsI v3W5tryrWr18XF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBK14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr 1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkF7I0En4kS14v26r126r 1DMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_ Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x 0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8 JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIx AIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbx9NDUUUUU= = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 7 ++++--- drivers/md/md-bitmap.h | 10 +++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 9a9f0fe3ebd0..8aaf0491bf5d 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1852,7 +1852,7 @@ void md_bitmap_wait_behind_writes(struct mddev *mddev) } } -void md_bitmap_destroy(struct mddev *mddev) +static void bitmap_destroy(struct mddev *mddev) { struct bitmap *bitmap = mddev->bitmap; @@ -2366,7 +2366,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len) goto out; } - md_bitmap_destroy(mddev); + bitmap_destroy(mddev); mddev->bitmap_info.offset = 0; if (mddev->bitmap_info.file) { struct file *f = mddev->bitmap_info.file; @@ -2413,7 +2413,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len) rv = bitmap_load(mddev); if (rv) { mddev->bitmap_info.offset = 0; - md_bitmap_destroy(mddev); + bitmap_destroy(mddev); goto out; } } @@ -2710,6 +2710,7 @@ const struct attribute_group md_bitmap_group = { static struct bitmap_operations bitmap_ops = { .create = bitmap_create, .load = bitmap_load, + .destroy = bitmap_destroy, }; void mddev_set_bitmap_ops(struct mddev *mddev) diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index de7fbe5903dd..46db4d8199d8 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -237,6 +237,7 @@ struct bitmap { struct bitmap_operations { struct bitmap* (*create)(struct mddev *mddev, int slot); int (*load)(struct mddev *mddev); + void (*destroy)(struct mddev *mddev); }; /* the bitmap API */ @@ -259,8 +260,15 @@ static inline int md_bitmap_load(struct mddev *mddev) return mddev->bitmap_ops->load(mddev); } +static inline void md_bitmap_destroy(struct mddev *mddev) +{ + if (!mddev->bitmap_ops->destroy) + return; + + mddev->bitmap_ops->destroy(mddev); +} + void md_bitmap_flush(struct mddev *mddev); -void md_bitmap_destroy(struct mddev *mddev); void md_bitmap_print_sb(struct bitmap *bitmap); void md_bitmap_update_sb(struct bitmap *bitmap); From patchwork Sat Aug 10 02:08:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759337 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 2D1E4433A0; Sat, 10 Aug 2024 02:12:56 +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=1723255979; cv=none; b=qlkcjZ/rLMewIGAK8T5CpF+o9FX+zMGAhB+OGPV++lCmzvhj0I3pHkBPrnAznGlENedzbGf8BJb5XaaY/p+t+6xuKzqqHuKrfNLlKXgu5Srpv5l7ol1Ca4VDkWsfoiNcnE7zOrU9Ylv3dsw8AmcIX3Ob+aSbfmQ+FQCfLA9geFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255979; c=relaxed/simple; bh=XuzieE8hEXTvl4iETklpJsh4ejMMZBLqiyTNyaxkPp0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iSbHJIWpIWn5LS4gtXiQzVdEEvUHyH2cdswcpm6ELBQ5yKm7TeTSoKEztiBG9YMP5J9f0GNwW0huuN+OycPv30kiHKVGmB/7NbNkk+QDs4zwh3Va1CfDk6pe2bIs3N3M7I2KpwH+8Rhoy1REVEOWj88ldfj3rMY+XUNQ9tk4gnQ= 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 4Wgkng5rxFz4f3jLc; Sat, 10 Aug 2024 10:12:39 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 4B41A1A058E; Sat, 10 Aug 2024 10:12:54 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S9; Sat, 10 Aug 2024 10:12:54 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 05/26] md/md-bitmap: merge md_bitmap_flush() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:33 +0800 Message-Id: <20240810020854.797814-6-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S9 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr45Cr4rAr1Uuw4rJw4DXFb_yoW8Cw1rpF srt3W5Cw43tFW3Ww1UZFyDCa4FvF1ktrZrKFyfCw1rCF9xXFnxGF4rWa4jyw1rGF13JFsI vw15tr1UWr18XFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPUUUUU = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 3 ++- drivers/md/md-bitmap.h | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 8aaf0491bf5d..33bcae5594e2 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1776,7 +1776,7 @@ void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long /* * flush out any pending updates */ -void md_bitmap_flush(struct mddev *mddev) +static void bitmap_flush(struct mddev *mddev) { struct bitmap *bitmap = mddev->bitmap; long sleep; @@ -2711,6 +2711,7 @@ static struct bitmap_operations bitmap_ops = { .create = bitmap_create, .load = bitmap_load, .destroy = bitmap_destroy, + .flush = bitmap_flush, }; void mddev_set_bitmap_ops(struct mddev *mddev) diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 46db4d8199d8..749351db04d3 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -238,6 +238,7 @@ struct bitmap_operations { struct bitmap* (*create)(struct mddev *mddev, int slot); int (*load)(struct mddev *mddev); void (*destroy)(struct mddev *mddev); + void (*flush)(struct mddev *mddev); }; /* the bitmap API */ @@ -268,7 +269,13 @@ static inline void md_bitmap_destroy(struct mddev *mddev) mddev->bitmap_ops->destroy(mddev); } -void md_bitmap_flush(struct mddev *mddev); +static inline void md_bitmap_flush(struct mddev *mddev) +{ + if (!mddev->bitmap_ops->flush) + return; + + mddev->bitmap_ops->flush(mddev); +} void md_bitmap_print_sb(struct bitmap *bitmap); void md_bitmap_update_sb(struct bitmap *bitmap); From patchwork Sat Aug 10 02:08:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759347 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 88AAC140E22; Sat, 10 Aug 2024 02:13:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255984; cv=none; b=hS2q+4i9gKlWHdjsofrgF8L57s16JFtMO4u0tQzrqTj9rQxdn3p2mey8Hn6gbHGq9n0xRm7s6yz98YGRPyYvQxTTuXD+6B2WpXfdrm9yWkRFkSFv37gSbCn20pd/MVfPM0+Li+2U66LYTNpdgIo8daMikjNoKofn2BtuKjiEh4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255984; c=relaxed/simple; bh=kfyzLf4j4zTDCXEueW1t7qzELjN1/EPMb3+fZXgAFsw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KmktVlu/73QAlwsVn2uDF8A8u3yFkxkirojQ/AedmDApV5LeDYw1PHrzmsrI4SGV3jdRaUj3XvewoJpOcdv8tdmq4kCpizx0bBvoYKtoPviXfsQ0qg5cEdEF3o7ZXmIgoBWzBM43VziQvsoUWu7REIe7FGGlLom9LCtpc5HQB1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=none smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Wgknj0RCcz4f3jQv; Sat, 10 Aug 2024 10:12:41 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 8D2801A018D; Sat, 10 Aug 2024 10:12:54 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S10; Sat, 10 Aug 2024 10:12:54 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 06/26] md/md-bitmap: don't expose md_bitmap_print_sb() Date: Sat, 10 Aug 2024 10:08:34 +0800 Message-Id: <20240810020854.797814-7-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S10 X-Coremail-Antispam: 1UD129KBjvJXoW7WF18Aw1rWryxJFy5JF43KFg_yoW8WF17pr Z8Gwn8CrW5JF43X3W7Zry09FyrJw4Dtr9rKFyfC34ruFy7XFnxGr48K3Wqywn5Gr13JFsx Xwn8tryUGr18Xa7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPUUUUU = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai md_bitmap_print_sb() is only used inside md-bitmap.c, hence make it static, and also rename it to bitmap_print_sb(). Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 4 ++-- drivers/md/md-bitmap.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 33bcae5594e2..0ff733756043 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -513,7 +513,7 @@ void md_bitmap_update_sb(struct bitmap *bitmap) EXPORT_SYMBOL(md_bitmap_update_sb); /* print out the bitmap file superblock */ -void md_bitmap_print_sb(struct bitmap *bitmap) +static void bitmap_print_sb(struct bitmap *bitmap) { bitmap_super_t *sb; @@ -760,7 +760,7 @@ static int md_bitmap_read_sb(struct bitmap *bitmap) bitmap->mddev->bitmap_info.space > sectors_reserved) bitmap->mddev->bitmap_info.space = sectors_reserved; } else { - md_bitmap_print_sb(bitmap); + bitmap_print_sb(bitmap); if (bitmap->cluster_slot < 0) md_cluster_stop(bitmap->mddev); } diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 749351db04d3..935c5dc45b89 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -277,7 +277,6 @@ static inline void md_bitmap_flush(struct mddev *mddev) mddev->bitmap_ops->flush(mddev); } -void md_bitmap_print_sb(struct bitmap *bitmap); void md_bitmap_update_sb(struct bitmap *bitmap); void md_bitmap_status(struct seq_file *seq, struct bitmap *bitmap); From patchwork Sat Aug 10 02:08:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759350 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 471A914373D; Sat, 10 Aug 2024 02:13:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255985; cv=none; b=QJc+XlQ5eTVxE59qW78qvaDPAZ8zUimT3iSLk3GX6CmXJ00nS/IqsYARdyPkZeC5lowByDqxRMJ3uqsiK+zgt1WWWAZOUzCThpPuxLUXUbCYb7yjUBTVtjerdBGMhrtBw1fVDkHoxkTuY/QkJMfK7pTQJ12PnNCRrzGE8oMo8mY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255985; c=relaxed/simple; bh=RkS2tL3IdufzwkTCHDNb/QKY4/MXX1wFU7D2kHTxEns=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F0WjJ5RGGSWWhY1w5yfhldtFnOf+avuq3xzYx7HbjSPKfBhYltFyacUUGQNQ4pTevpovHbrVSKwBOcMyEel5a8Xk+IYWSZ7O2kLyZtzdGw5pUYzSxfZVhgAIS4603lcUQbgECie4/YXYEBpCyri7vd9gbzyfOCYGACvhWNOMDZA= 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.56 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.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Wgknj2w85z4f3jRF; Sat, 10 Aug 2024 10:12:41 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id E1FD01A0359; Sat, 10 Aug 2024 10:12:54 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S11; Sat, 10 Aug 2024 10:12:54 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 07/26] md/md-bitmap: merge md_bitmap_update_sb() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:35 +0800 Message-Id: <20240810020854.797814-8-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S11 X-Coremail-Antispam: 1UD129KBjvJXoW3XrWDtr1rKr1ftF1kJF47urg_yoW7Xw1xpa yUK3Z8Gr43JayfXr1UAFyv9Fy5Aw4ktr9rKFWxCa1ruF9Iqrn3GF4rGF1Dtw15Gr13JFsx Xw45JF4UGF4xXF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8Jw CI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUYcTQUUUU U X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 15 ++++++++------- drivers/md/md-bitmap.h | 11 ++++++++++- drivers/md/md-cluster.c | 3 ++- drivers/md/md.c | 4 ++-- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 0ff733756043..b34f13aa2697 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -472,7 +472,7 @@ static void md_bitmap_wait_writes(struct bitmap *bitmap) /* update the event counter and sync the superblock to disk */ -void md_bitmap_update_sb(struct bitmap *bitmap) +static void bitmap_update_sb(struct bitmap *bitmap) { bitmap_super_t *sb; @@ -510,7 +510,6 @@ void md_bitmap_update_sb(struct bitmap *bitmap) write_sb_page(bitmap, bitmap->storage.sb_index, bitmap->storage.sb_page, 1); } -EXPORT_SYMBOL(md_bitmap_update_sb); /* print out the bitmap file superblock */ static void bitmap_print_sb(struct bitmap *bitmap) @@ -893,7 +892,7 @@ static void md_bitmap_file_unmap(struct bitmap_storage *store) static void md_bitmap_file_kick(struct bitmap *bitmap) { if (!test_and_set_bit(BITMAP_STALE, &bitmap->flags)) { - md_bitmap_update_sb(bitmap); + bitmap_update_sb(bitmap); if (bitmap->storage.file) { pr_warn("%s: kicking failed bitmap file %pD4 from array!\n", @@ -1796,7 +1795,7 @@ static void bitmap_flush(struct mddev *mddev) md_bitmap_daemon_work(mddev); if (mddev->bitmap_info.external) md_super_wait(mddev); - md_bitmap_update_sb(bitmap); + bitmap_update_sb(bitmap); } /* @@ -2014,7 +2013,7 @@ static int bitmap_load(struct mddev *mddev) mddev_set_timeout(mddev, mddev->bitmap_info.daemon_sleep, true); md_wakeup_thread(mddev->thread); - md_bitmap_update_sb(bitmap); + bitmap_update_sb(bitmap); if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags)) err = -EIO; @@ -2075,7 +2074,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, } if (clear_bits) { - md_bitmap_update_sb(bitmap); + bitmap_update_sb(bitmap); /* BITMAP_PAGE_PENDING is set, but bitmap_unplug needs * BITMAP_PAGE_DIRTY or _NEEDWRITE to write ... */ for (i = 0; i < bitmap->storage.file_pages; i++) @@ -2568,7 +2567,7 @@ backlog_store(struct mddev *mddev, const char *buf, size_t len) mddev_create_serial_pool(mddev, rdev); } if (old_mwb != backlog) - md_bitmap_update_sb(mddev->bitmap); + bitmap_update_sb(mddev->bitmap); mddev_unlock_and_resume(mddev); return len; @@ -2712,6 +2711,8 @@ static struct bitmap_operations bitmap_ops = { .load = bitmap_load, .destroy = bitmap_destroy, .flush = bitmap_flush, + + .update_sb = bitmap_update_sb, }; void mddev_set_bitmap_ops(struct mddev *mddev) diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 935c5dc45b89..29c217630ae5 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -239,6 +239,8 @@ struct bitmap_operations { int (*load)(struct mddev *mddev); void (*destroy)(struct mddev *mddev); void (*flush)(struct mddev *mddev); + + void (*update_sb)(struct bitmap *bitmap); }; /* the bitmap API */ @@ -277,7 +279,14 @@ static inline void md_bitmap_flush(struct mddev *mddev) mddev->bitmap_ops->flush(mddev); } -void md_bitmap_update_sb(struct bitmap *bitmap); +static inline void md_bitmap_update_sb(struct mddev *mddev) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->update_sb) + return; + + mddev->bitmap_ops->update_sb(mddev->bitmap); +} + void md_bitmap_status(struct seq_file *seq, struct bitmap *bitmap); int md_bitmap_setallbits(struct bitmap *bitmap); diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c index 1d0db62f0351..79e67393fee0 100644 --- a/drivers/md/md-cluster.c +++ b/drivers/md/md-cluster.c @@ -1244,7 +1244,8 @@ static int cluster_check_sync_size(struct mddev *mddev) bm_lockres->flags |= DLM_LKF_NOQUEUE; rv = dlm_lock_sync(bm_lockres, DLM_LOCK_PW); if (!rv) - md_bitmap_update_sb(bitmap); + mddev->bitmap_ops->update_sb(bitmap); + lockres_free(bm_lockres); sb = kmap_atomic(bitmap->storage.sb_page); diff --git a/drivers/md/md.c b/drivers/md/md.c index f23138dd96a7..e749e24e12de 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -2821,7 +2821,7 @@ void md_update_sb(struct mddev *mddev, int force_change) mddev_add_trace_msg(mddev, "md md_update_sb"); rewrite: - md_bitmap_update_sb(mddev->bitmap); + md_bitmap_update_sb(mddev); rdev_for_each(rdev, mddev) { if (rdev->sb_loaded != 1) continue; /* no noise on spare devices */ @@ -9966,7 +9966,7 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev) if (ret) pr_info("md-cluster: resize failed\n"); else - md_bitmap_update_sb(mddev->bitmap); + md_bitmap_update_sb(mddev); } /* Check for change of roles in the active devices */ From patchwork Sat Aug 10 02:08:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759351 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 469B614373A; Sat, 10 Aug 2024 02:13:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255985; cv=none; b=qlMUYyfwThDiGrCo0l2lK32NZ7T+pdkAm3CqoT5n6ICcEprqjqBlPbK0XfmKdTAGTud5s4GtVaDTN5pMlaK9eh97ewEfjY2lxJ74hlcruoA6ac5TEADljdlrh1v9z69hxim6in4+uxf+2TKWkBgP5k3fLzx7v0r6TGEXvgV2/iw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255985; c=relaxed/simple; bh=zfiglKccvzzgA0/fEWZcwMg3ZBLAuwYhbnLVJSyk+Ic=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kz2gA0swddXC6PcDAfR7cK9oLiIs5EMs9UjsPUOoD4MsYOlHcw5ZvlPTZvJgosM8+4jVzCIcolAAzFBYB6+kZreYxRZV+N2D08OtfQFFVdTdhUjfuXv6es9v9mXh8UOvX5nS+86lpJ0y75OTii7HC2pDntWPWQPpsBc4CgOwQeQ= 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.56 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 dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Wgknj5CcQz4f3jdK; Sat, 10 Aug 2024 10:12:41 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 3CF881A0568; Sat, 10 Aug 2024 10:12:55 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S12; Sat, 10 Aug 2024 10:12:55 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 08/26] md/md-bitmap: merge md_bitmap_status() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:36 +0800 Message-Id: <20240810020854.797814-9-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S12 X-Coremail-Antispam: 1UD129KBjvJXoWxGF17Gr1DWFWfAF18CFy8Zrb_yoW5XF4Upa y7J3W5CrW5JFWfX3W7AFyq9a45X3Wktr9rKr97C3yruFy7XFnxWF4rGa4Utw1rGF1fJFsx Z3Z8KryUGr18XFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8Jw CI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUYcTQUUUU U X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 3 ++- drivers/md/md-bitmap.h | 11 +++++++++-- drivers/md/md.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index b34f13aa2697..9a21123a3b8b 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -2092,7 +2092,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot); -void md_bitmap_status(struct seq_file *seq, struct bitmap *bitmap) +static void bitmap_status(struct seq_file *seq, struct bitmap *bitmap) { unsigned long chunk_kb; struct bitmap_counts *counts; @@ -2711,6 +2711,7 @@ static struct bitmap_operations bitmap_ops = { .load = bitmap_load, .destroy = bitmap_destroy, .flush = bitmap_flush, + .status = bitmap_status, .update_sb = bitmap_update_sb, }; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 29c217630ae5..c60b6a9f6163 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -239,6 +239,7 @@ struct bitmap_operations { int (*load)(struct mddev *mddev); void (*destroy)(struct mddev *mddev); void (*flush)(struct mddev *mddev); + void (*status)(struct seq_file *seq, struct bitmap *bitmap); void (*update_sb)(struct bitmap *bitmap); }; @@ -279,6 +280,14 @@ static inline void md_bitmap_flush(struct mddev *mddev) mddev->bitmap_ops->flush(mddev); } +static inline void md_bitmap_status(struct seq_file *seq, struct mddev *mddev) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->status) + return; + + mddev->bitmap_ops->status(seq, mddev->bitmap); +} + static inline void md_bitmap_update_sb(struct mddev *mddev) { if (!mddev->bitmap || !mddev->bitmap_ops->update_sb) @@ -287,8 +296,6 @@ static inline void md_bitmap_update_sb(struct mddev *mddev) mddev->bitmap_ops->update_sb(mddev->bitmap); } -void md_bitmap_status(struct seq_file *seq, struct bitmap *bitmap); - int md_bitmap_setallbits(struct bitmap *bitmap); void md_bitmap_write_all(struct bitmap *bitmap); diff --git a/drivers/md/md.c b/drivers/md/md.c index e749e24e12de..033ea06f6abe 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8454,7 +8454,7 @@ static int md_seq_show(struct seq_file *seq, void *v) } else seq_printf(seq, "\n "); - md_bitmap_status(seq, mddev->bitmap); + md_bitmap_status(seq, mddev); seq_printf(seq, "\n"); } From patchwork Sat Aug 10 02:08:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759338 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 AC42C768FC; Sat, 10 Aug 2024 02:12:58 +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=1723255980; cv=none; b=t/yyYoZRsQxeqEw/Zix3UUxucSjzskhUBuzlxEtbBHls9Uv4gg7hR63aWg5aTSNzSKCJ8ptk5PD1oAcHxyp81S59Af6rt6yEds3MVK/fSy+B5ZI6cCKOk1cwIxaR32VDftw++lF+JU9hUz1uGv2SexXVvZFlt+qKPZFxXyZC2Nw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255980; c=relaxed/simple; bh=EPAN+eNjEibMqCHz2sVTaGwU1MF1ALOpXhYvKQo4nfA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JaqLWcgc/GCYU/gLYoEi8TiqfVOgFd2A4dyDkDmA3Qd3JIuSbYdkAjcpXZM+yrtJKPe1sVViMETyrAr20SDhDSYqQDSlj5MckgYK59pOX+w1ew5hONzSjxl3zjPDRT9mLdOvhaulZ4mkKTiJWaHqc+zxHmierEN/DqjDR/QQ440= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=none 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=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknp3nHgz4f3jk0; Sat, 10 Aug 2024 10:12:46 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 99BCF1A07B6; Sat, 10 Aug 2024 10:12:55 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S13; Sat, 10 Aug 2024 10:12:55 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 09/26] md/md-bitmap: remove md_bitmap_setallbits() Date: Sat, 10 Aug 2024 10:08:37 +0800 Message-Id: <20240810020854.797814-10-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S13 X-Coremail-Antispam: 1UD129KBjvdXoW7Jr1ftF15WF45uw1xXr1DWrg_yoW3Grb_Za 1ktryxWryUCF9YyF17Xr1Svry2qw1DWa1kuFWIqrWfZF13Aa4rGr40kr1DtrW8GFyDCa43 KryUXr48Gr4Y9jkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbD8FF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2 IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28E F7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr 1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkF7I0En4kS14v26r126r 1DMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_ Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x 0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWx JVW8Jr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPUUUUU = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai md_bitmap_setallbits() is not used, hence can be removed. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index c60b6a9f6163..3fd2e5a7ba9c 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -296,7 +296,6 @@ static inline void md_bitmap_update_sb(struct mddev *mddev) mddev->bitmap_ops->update_sb(mddev->bitmap); } -int md_bitmap_setallbits(struct bitmap *bitmap); void md_bitmap_write_all(struct bitmap *bitmap); void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e); From patchwork Sat Aug 10 02:08:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759339 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 D8F37130AF6; Sat, 10 Aug 2024 02:12:58 +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=1723255980; cv=none; b=Wc5NqJ6rCml7W+5vzPy7aOQGjTaSFYurVqSAW6jtpOI1aEn3MnxPdMX5Tx23z84m1xyuSHtqscXH8DySYZPIHUCRFEyy0ZuIXmeksykllwGTSJkR3j/X0uSefIBVQLj+1UB1CB/VhOsWc6VmN/fu+I33HKMxKwTriTwYPqMMnxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255980; c=relaxed/simple; bh=3GoKVzYachsSHL4Lugg1lCn/HUX3KP9ILTUz99MjpN0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fbdH693/I/wjOXcY9fzivN+4tx1z4xLYSWK8zTgjR1CBiYixm+ZzlUBBta2H2WZi5M14lx1NRIt3xQsv5o9cg9XGs1KD6zR/LZSM2IOEkWKHACgqSoSye4+Tp+/UEjpoHKutzfg+lMgdp03XpIZI2mBlfsGeSM8n8r2oobH+kq0= 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.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknp675Jz4f3jkL; Sat, 10 Aug 2024 10:12:46 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id E90961A11D6; Sat, 10 Aug 2024 10:12:55 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S14; Sat, 10 Aug 2024 10:12:55 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 10/26] md/md-bitmap: merge bitmap_write_all() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:38 +0800 Message-Id: <20240810020854.797814-11-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S14 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr45Cr4xZw1rtrWrKrWfKrg_yoW5JFW3pa y7Ka45u3y5JFW7X3W7AFyDuFyYv3Wktr9rtrWfC34ruFyUAFnxWF4rWa4Utwn5GrW3JFsx Zw45try8Gr48XF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJw CI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUYcTQUUUU U X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 3 ++- drivers/md/md-bitmap.h | 9 ++++++++- drivers/md/md.c | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 9a21123a3b8b..aab7bb5418f7 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1225,7 +1225,7 @@ static int md_bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) return ret; } -void md_bitmap_write_all(struct bitmap *bitmap) +static void bitmap_write_all(struct bitmap *bitmap) { /* We don't actually write all bitmap blocks here, * just flag them as needing to be written @@ -2712,6 +2712,7 @@ static struct bitmap_operations bitmap_ops = { .destroy = bitmap_destroy, .flush = bitmap_flush, .status = bitmap_status, + .write_all = bitmap_write_all, .update_sb = bitmap_update_sb, }; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 3fd2e5a7ba9c..9df0c1d5f7ee 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -240,6 +240,7 @@ struct bitmap_operations { void (*destroy)(struct mddev *mddev); void (*flush)(struct mddev *mddev); void (*status)(struct seq_file *seq, struct bitmap *bitmap); + void (*write_all)(struct bitmap *bitmap); void (*update_sb)(struct bitmap *bitmap); }; @@ -296,7 +297,13 @@ static inline void md_bitmap_update_sb(struct mddev *mddev) mddev->bitmap_ops->update_sb(mddev->bitmap); } -void md_bitmap_write_all(struct bitmap *bitmap); +static inline void md_bitmap_write_all(struct mddev *mddev) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->write_all) + return; + + mddev->bitmap_ops->write_all(mddev->bitmap); +} void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e); diff --git a/drivers/md/md.c b/drivers/md/md.c index 033ea06f6abe..2260540dd458 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -9507,7 +9507,7 @@ static void md_start_sync(struct work_struct *ws) * stored on all devices. So make sure all bitmap pages get written. */ if (spares) - md_bitmap_write_all(mddev->bitmap); + md_bitmap_write_all(mddev); name = test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) ? "reshape" : "resync"; From patchwork Sat Aug 10 02:08: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: 13759341 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 797A513C8EE; Sat, 10 Aug 2024 02:13:00 +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=1723255982; cv=none; b=eBoJP9r/KJ9UN0eqBah1ur3iHb69iTd7Y4Cd1ayu0VSf8mJ6mo16l5hM++5cCCOU4m2r0wCYhxLBqaZet7wE7xhRT2311dBfP8tiz7fba+sTxB3zsAgJZg0M/hFF+4Jf5NbveRH2+mCFXXv7uibLJbtdGgvZeTHbCydaoG3BQbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255982; c=relaxed/simple; bh=4sdSxi6ze98VBI5UDN6ZqHskrfxynjBOCOUgdM+3QBE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ok7coPwkAjvT8Oj/coB7wVwJfwCWlVHQdbI9p5Wb6ahMpDwwHNuyAhqHkLFY2vlhut7/9Dd5E1CoAyG/6JYuqMRIm7TiZtqdcteOdmTXvdAOYZaBjZ8cI0a4mATF9Sr4fB3VeU+KYjYRJk5iPJespumYm1T0ursnaTJx2IZEnVo= 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.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknq120Bz4f3jM1; Sat, 10 Aug 2024 10:12:47 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 465311A0359; Sat, 10 Aug 2024 10:12:56 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S15; Sat, 10 Aug 2024 10:12:56 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 11/26] md/md-bitmap: merge md_bitmap_dirty_bits() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:39 +0800 Message-Id: <20240810020854.797814-12-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S15 X-Coremail-Antispam: 1UD129KBjvJXoWxZF4fAFyUGr48WryxGF1DGFg_yoW5XFyDpF WfK345CrW5Ja12qw17ZryDua4Yyw1ktrZrKFWxJ345uFyUXFnxWF4rGa4Utw1kGrWfJFZx Z345tryUWr40qaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJw CI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUYcTQUUUU U X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 4 +++- drivers/md/md-bitmap.h | 10 +++++++++- drivers/md/md.c | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index aab7bb5418f7..b85ae1bf2b7d 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1755,7 +1755,8 @@ static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, in } /* dirty the memory and file bits for bitmap chunks "s" to "e" */ -void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e) +static void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, + unsigned long e) { unsigned long chunk; @@ -2713,6 +2714,7 @@ static struct bitmap_operations bitmap_ops = { .flush = bitmap_flush, .status = bitmap_status, .write_all = bitmap_write_all, + .dirty_bits = bitmap_dirty_bits, .update_sb = bitmap_update_sb, }; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 9df0c1d5f7ee..b708a25bd6f4 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -241,6 +241,7 @@ struct bitmap_operations { void (*flush)(struct mddev *mddev); void (*status)(struct seq_file *seq, struct bitmap *bitmap); void (*write_all)(struct bitmap *bitmap); + void (*dirty_bits)(struct bitmap *bitmap, unsigned long s, unsigned long e); void (*update_sb)(struct bitmap *bitmap); }; @@ -305,7 +306,14 @@ static inline void md_bitmap_write_all(struct mddev *mddev) mddev->bitmap_ops->write_all(mddev->bitmap); } -void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e); +static inline void md_bitmap_dirty_bits(struct mddev *mddev, unsigned long s, + unsigned long e) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->dirty_bits) + return; + + mddev->bitmap_ops->dirty_bits(mddev->bitmap, s, e); +} /* these are exported */ int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset, diff --git a/drivers/md/md.c b/drivers/md/md.c index 2260540dd458..841539a0be1b 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -4688,7 +4688,7 @@ bitmap_store(struct mddev *mddev, const char *buf, size_t len) if (buf == end) break; } if (*end && !isspace(*end)) break; - md_bitmap_dirty_bits(mddev->bitmap, chunk, end_chunk); + md_bitmap_dirty_bits(mddev, chunk, end_chunk); buf = skip_spaces(end); } md_bitmap_unplug(mddev->bitmap); /* flush the bits to disk */ From patchwork Sat Aug 10 02:08:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759353 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 4C702149C5E; Sat, 10 Aug 2024 02:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255987; cv=none; b=CFJpQUC2LYVaKiUUJhVSUrijEpIvFH7gQYSJAh0iOc49lNnCw+WZvRHxS1f+VG2mBnHdwDGnAQHe6X+BcgagydIPiL/0AKLnP8nDuZgLYMiRzD3z1qNgPAIQskb8lhzAixwTkuA5rXPW2WK8GekC2n1L7C/T1+w6k1ABkML4YBU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255987; c=relaxed/simple; bh=8KGMMYBD4oCErK23FW+dRM+iocQ2l5lpj113vR/GwRg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QslHAphOtlAHAZ7ds1QKbzKUdT3snNIMCcVFktY7RGTKh6ldO9at7IjbnTnSCwlOuRrcpB0HvE6aOJafpYrCub95rul3kl6ctK++lTdkJ0scUZRqOqlwnPJ+T881LVffFISra8z+q4aw/XUEKHR5uklDeNp+NWmCFx3U611ld7I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=none smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Wgknl0lYtz4f3jdV; Sat, 10 Aug 2024 10:12:43 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 979DA1A018D; Sat, 10 Aug 2024 10:12:56 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S16; Sat, 10 Aug 2024 10:12:56 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 12/26] md/md-bitmap: merge md_bitmap_startwrite() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:40 +0800 Message-Id: <20240810020854.797814-13-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S16 X-Coremail-Antispam: 1UD129KBjvJXoWxur43JrW7CFWUCFW7AF1UKFg_yoWrKF47pF 4UGFya93y5ta13Xw1UCFyDuFyFy3WktrZrtrWfX3s8uFyjqFnxWF48WFyjqw1DCFy3AFZx Zwn8trWUGr42qFDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJw CI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUYcTQUUUU U X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 6 ++++-- drivers/md/md-bitmap.h | 15 +++++++++++++-- drivers/md/raid1.c | 3 ++- drivers/md/raid10.c | 2 +- drivers/md/raid5.c | 5 ++--- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index b85ae1bf2b7d..75e87073e3bc 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1460,7 +1460,8 @@ __acquires(bitmap->lock) &(bitmap->bp[page].map[pageoff]); } -int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, int behind) +static int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, + unsigned long sectors, int behind) { if (!bitmap) return 0; @@ -1522,7 +1523,6 @@ int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long s } return 0; } -EXPORT_SYMBOL(md_bitmap_startwrite); void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, int success, int behind) @@ -2716,6 +2716,8 @@ static struct bitmap_operations bitmap_ops = { .write_all = bitmap_write_all, .dirty_bits = bitmap_dirty_bits, + .startwrite = bitmap_startwrite, + .update_sb = bitmap_update_sb, }; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index b708a25bd6f4..166cc2a44909 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -243,6 +243,9 @@ struct bitmap_operations { void (*write_all)(struct bitmap *bitmap); void (*dirty_bits)(struct bitmap *bitmap, unsigned long s, unsigned long e); + int (*startwrite)(struct bitmap *bitmap, sector_t offset, + unsigned long sectors, int behind); + void (*update_sb)(struct bitmap *bitmap); }; @@ -316,8 +319,16 @@ static inline void md_bitmap_dirty_bits(struct mddev *mddev, unsigned long s, } /* these are exported */ -int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset, - unsigned long sectors, int behind); +static inline int md_bitmap_startwrite(struct mddev *mddev, sector_t offset, + unsigned long sectors, int behind) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->startwrite) + return -EOPNOTSUPP; + + return mddev->bitmap_ops->startwrite(mddev->bitmap, offset, sectors, + behind); +} + void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, int success, int behind); int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int degraded); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 7acfe7c9dc8d..16e741bde382 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1617,7 +1617,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, alloc_behind_master_bio(r1_bio, bio); } - md_bitmap_startwrite(bitmap, r1_bio->sector, r1_bio->sectors, + md_bitmap_startwrite(mddev, r1_bio->sector, + r1_bio->sectors, test_bit(R1BIO_BehindIO, &r1_bio->state)); first_clone = 0; } diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 2a9c4ee982e0..34948fef1339 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1492,7 +1492,7 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, md_account_bio(mddev, &bio); r10_bio->master_bio = bio; atomic_set(&r10_bio->remaining, 1); - md_bitmap_startwrite(mddev->bitmap, r10_bio->sector, r10_bio->sectors, 0); + md_bitmap_startwrite(mddev, r10_bio->sector, r10_bio->sectors, 0); for (i = 0; i < conf->copies; i++) { if (r10_bio->devs[i].bio) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index c14cf2410365..127e4b4c6c20 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -3563,7 +3563,7 @@ static void __add_stripe_bio(struct stripe_head *sh, struct bio *bi, */ set_bit(STRIPE_BITMAP_PENDING, &sh->state); spin_unlock_irq(&sh->stripe_lock); - md_bitmap_startwrite(conf->mddev->bitmap, sh->sector, + md_bitmap_startwrite(conf->mddev, sh->sector, RAID5_STRIPE_SECTORS(conf), 0); spin_lock_irq(&sh->stripe_lock); clear_bit(STRIPE_BITMAP_PENDING, &sh->state); @@ -5791,8 +5791,7 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi) for (d = 0; d < conf->raid_disks - conf->max_degraded; d++) - md_bitmap_startwrite(mddev->bitmap, - sh->sector, + md_bitmap_startwrite(mddev, sh->sector, RAID5_STRIPE_SECTORS(conf), 0); sh->bm_seq = conf->seq_flush + 1; From patchwork Sat Aug 10 02:08:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759342 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 BF3FD13CFB9; Sat, 10 Aug 2024 02:13:00 +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=1723255982; cv=none; b=eXr3OamDztMYDBiLze9ZOTkeuYY6RSsC4DZlqPKOe4KxN5PhjaR76NGLIbvn1kHZZWqIY6vDlusKQYehjiyyhLXo1w7csHsomxH0BO+xj5qZtb/FFerSHYPy0E+oYo5gNjsruCEFjB7FtfrZVkoPezwE3GUoNUqXkcxgF4S3aEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255982; c=relaxed/simple; bh=lNo99pSAZdtkSebDL8Wq6jBs0LkdHcTUK07tuvqHdpA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e4ei/QAXs/ohi4Gu00f+p/nMGl23wlNNw5brZyulBUKJhOEBOHKnnpSY6u8b6cSYdzpQcbJWvawW7Y6RKUs8y5j2wPzWryoDn9aBWoI0svKB53tzcJLA3JQ58kX9/I9bR5CzvgSX3L5bb+tB8TVgxU9Uc8aaVwG6C1z5kq2ivwU= 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.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknq6KQVz4f3jkP; Sat, 10 Aug 2024 10:12:47 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 079251A018D; Sat, 10 Aug 2024 10:12:57 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S17; Sat, 10 Aug 2024 10:12:56 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 13/26] md/md-bitmap: merge md_bitmap_endwrite() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:41 +0800 Message-Id: <20240810020854.797814-14-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S17 X-Coremail-Antispam: 1UD129KBjvJXoW3JFWkCw1kuFyfCrW8ur4kZwb_yoW7tr4kpa yUJrySk3y5tFZxZw1UAFyDuFyFv34kKrZrtrWfW3s8ua4jgF90gF48WFW0qw1DCF1ayFWa vw15trWUGrWjqFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJw CI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUYcTQUUUU U X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 6 +++--- drivers/md/md-bitmap.h | 15 +++++++++++++-- drivers/md/raid1.c | 3 +-- drivers/md/raid10.c | 3 +-- drivers/md/raid5-cache.c | 2 +- drivers/md/raid5.c | 6 +++--- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 75e87073e3bc..d726e571406d 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1524,8 +1524,8 @@ static int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, return 0; } -void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset, - unsigned long sectors, int success, int behind) +static void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, + unsigned long sectors, int success, int behind) { if (!bitmap) return; @@ -1575,7 +1575,6 @@ void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset, sectors = 0; } } -EXPORT_SYMBOL(md_bitmap_endwrite); static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int degraded) @@ -2717,6 +2716,7 @@ static struct bitmap_operations bitmap_ops = { .dirty_bits = bitmap_dirty_bits, .startwrite = bitmap_startwrite, + .endwrite = bitmap_endwrite, .update_sb = bitmap_update_sb, }; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 166cc2a44909..3a8be496d9b2 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -245,6 +245,8 @@ struct bitmap_operations { int (*startwrite)(struct bitmap *bitmap, sector_t offset, unsigned long sectors, int behind); + void (*endwrite)(struct bitmap *bitmap, sector_t offset, + unsigned long sectors, int success, int behind); void (*update_sb)(struct bitmap *bitmap); }; @@ -329,8 +331,17 @@ static inline int md_bitmap_startwrite(struct mddev *mddev, sector_t offset, behind); } -void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset, - unsigned long sectors, int success, int behind); +static inline void md_bitmap_endwrite(struct mddev *mddev, sector_t offset, + unsigned long sectors, int success, + int behind) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->endwrite) + return; + + mddev->bitmap_ops->endwrite(mddev->bitmap, offset, sectors, success, + behind); +} + int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int degraded); void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted); void md_bitmap_close_sync(struct bitmap *bitmap); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 16e741bde382..670ed59d3453 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -418,8 +418,7 @@ static void close_write(struct r1bio *r1_bio) r1_bio->behind_master_bio = NULL; } /* clear the bitmap if all writes complete successfully */ - md_bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector, - r1_bio->sectors, + md_bitmap_endwrite(r1_bio->mddev, r1_bio->sector, r1_bio->sectors, !test_bit(R1BIO_Degraded, &r1_bio->state), test_bit(R1BIO_BehindIO, &r1_bio->state)); md_write_end(r1_bio->mddev); diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 34948fef1339..2876686a9bf2 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -427,8 +427,7 @@ static void raid10_end_read_request(struct bio *bio) static void close_write(struct r10bio *r10_bio) { /* clear the bitmap if all writes complete successfully */ - md_bitmap_endwrite(r10_bio->mddev->bitmap, r10_bio->sector, - r10_bio->sectors, + md_bitmap_endwrite(r10_bio->mddev, r10_bio->sector, r10_bio->sectors, !test_bit(R10BIO_Degraded, &r10_bio->state), 0); md_write_end(r10_bio->mddev); diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c index 874874fe4fa1..1b007276371c 100644 --- a/drivers/md/raid5-cache.c +++ b/drivers/md/raid5-cache.c @@ -313,7 +313,7 @@ void r5c_handle_cached_data_endio(struct r5conf *conf, if (sh->dev[i].written) { set_bit(R5_UPTODATE, &sh->dev[i].flags); r5c_return_dev_pending_writes(conf, &sh->dev[i]); - md_bitmap_endwrite(conf->mddev->bitmap, sh->sector, + md_bitmap_endwrite(conf->mddev, sh->sector, RAID5_STRIPE_SECTORS(conf), !test_bit(STRIPE_DEGRADED, &sh->state), 0); diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 127e4b4c6c20..2e54115da719 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -3663,7 +3663,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh, bi = nextbi; } if (bitmap_end) - md_bitmap_endwrite(conf->mddev->bitmap, sh->sector, + md_bitmap_endwrite(conf->mddev, sh->sector, RAID5_STRIPE_SECTORS(conf), 0, 0); bitmap_end = 0; /* and fail all 'written' */ @@ -3709,7 +3709,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh, } } if (bitmap_end) - md_bitmap_endwrite(conf->mddev->bitmap, sh->sector, + md_bitmap_endwrite(conf->mddev, sh->sector, RAID5_STRIPE_SECTORS(conf), 0, 0); /* If we were in the middle of a write the parity block might * still be locked - so just clear all R5_LOCKED flags @@ -4059,7 +4059,7 @@ static void handle_stripe_clean_event(struct r5conf *conf, bio_endio(wbi); wbi = wbi2; } - md_bitmap_endwrite(conf->mddev->bitmap, sh->sector, + md_bitmap_endwrite(conf->mddev, sh->sector, RAID5_STRIPE_SECTORS(conf), !test_bit(STRIPE_DEGRADED, &sh->state), 0); From patchwork Sat Aug 10 02:08:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759354 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 6332614A0AA; Sat, 10 Aug 2024 02:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255987; cv=none; b=CnrdWZYu+YENZpZi2yXgjfSxIqFWKwwixJ8rJEHWBtDaz4zYey4vFquWPNml16qOplx+o4EdpoDQTnKl26UHAZCiad8wvsvDwqf8GliylFMdgC1f+EZfDFKkLGticFkGTE9Uy1xymBTUc4qv9fNr3kuGAUjYn0F7xI9bByPYbBU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255987; c=relaxed/simple; bh=JWUJ+/sdpbN5vmS9PwBk/EOLMtVQyw8njMOOh6kT50M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JtLvnI1IoaQgkuVEI/VK9BF20x0mbC1t5aN1N0eBQfiKRfswATLyqLm0RpDe7BUzWE1CmTZ1D0FX0DK2TT8tGlR02NSk8KM8omZwR/WDqNKaqs1KVG86lR+O+2FBw0Oma+Ws4aPXJotLtPlfVofYHPMdjV1GaTdm04uSN4s5SmU= 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.56 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.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Wgknl5Xtdz4f3jrp; Sat, 10 Aug 2024 10:12:43 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 476101A0359; Sat, 10 Aug 2024 10:12:57 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S18; Sat, 10 Aug 2024 10:12:57 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 14/26] md/md-bitmap: merge md_bitmap_start_sync() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:42 +0800 Message-Id: <20240810020854.797814-15-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S18 X-Coremail-Antispam: 1UD129KBjvJXoW3JrW3GF18JF1xCFy7uF48WFg_yoWxuF1kpa 1DJFy3K3y5Way5Xa4UCryDuF1Fyas7trZrtryfWwn8uFykGFnrXF40gFyjq3WUGFy3tFZ0 vwn0yF45CryaqFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 10 +++++----- drivers/md/md-bitmap.h | 13 ++++++++++++- drivers/md/raid1.c | 4 ++-- drivers/md/raid10.c | 6 +++--- drivers/md/raid5.c | 4 ++-- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index d726e571406d..b20b6585fc44 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1604,8 +1604,8 @@ static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t return rv; } -int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, - int degraded) +static int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, + sector_t *blocks, int degraded) { /* bitmap_start_sync must always report on multiples of whole * pages, otherwise resync (which is very PAGE_SIZE based) will @@ -1626,7 +1626,6 @@ int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *block } return rv; } -EXPORT_SYMBOL(md_bitmap_start_sync); void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted) { @@ -1720,7 +1719,7 @@ void md_bitmap_sync_with_cluster(struct mddev *mddev, WARN((blocks > new_lo) && old_lo, "alignment is not correct for lo\n"); for (sector = old_hi; sector < new_hi; ) { - md_bitmap_start_sync(bitmap, sector, &blocks, 0); + bitmap_start_sync(bitmap, sector, &blocks, 0); sector += blocks; } WARN((blocks > new_hi) && old_hi, "alignment is not correct for hi\n"); @@ -1988,7 +1987,7 @@ static int bitmap_load(struct mddev *mddev) */ while (sector < mddev->resync_max_sectors) { sector_t blocks; - md_bitmap_start_sync(bitmap, sector, &blocks, 0); + bitmap_start_sync(bitmap, sector, &blocks, 0); sector += blocks; } md_bitmap_close_sync(bitmap); @@ -2717,6 +2716,7 @@ static struct bitmap_operations bitmap_ops = { .startwrite = bitmap_startwrite, .endwrite = bitmap_endwrite, + .start_sync = bitmap_start_sync, .update_sb = bitmap_update_sb, }; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 3a8be496d9b2..118141b6caeb 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -247,6 +247,8 @@ struct bitmap_operations { unsigned long sectors, int behind); void (*endwrite)(struct bitmap *bitmap, sector_t offset, unsigned long sectors, int success, int behind); + int (*start_sync)(struct bitmap *bitmap, sector_t offset, + sector_t *blocks, int degraded); void (*update_sb)(struct bitmap *bitmap); }; @@ -342,7 +344,16 @@ static inline void md_bitmap_endwrite(struct mddev *mddev, sector_t offset, behind); } -int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int degraded); +static inline int md_bitmap_start_sync(struct mddev *mddev, sector_t offset, + sector_t *blocks, int degraded) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->start_sync) + return -EOPNOTSUPP; + + return mddev->bitmap_ops->start_sync(mddev->bitmap, offset, blocks, + degraded); +} + void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted); void md_bitmap_close_sync(struct bitmap *bitmap); void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 670ed59d3453..e86cf05f9870 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2807,7 +2807,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr, /* before building a request, check if we can skip these blocks.. * This call the bitmap_start_sync doesn't actually record anything */ - if (!md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) && + if (!md_bitmap_start_sync(mddev, sector_nr, &sync_blocks, 1) && !conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { /* We can skip this block, and probably several more */ *skipped = 1; @@ -2982,7 +2982,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr, if (len == 0) break; if (sync_blocks == 0) { - if (!md_bitmap_start_sync(mddev->bitmap, sector_nr, + if (!md_bitmap_start_sync(mddev, sector_nr, &sync_blocks, still_degraded) && !conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 2876686a9bf2..20c0ccf28ef5 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3319,7 +3319,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, * we only need to recover the block if it is set in * the bitmap */ - must_sync = md_bitmap_start_sync(mddev->bitmap, sect, + must_sync = md_bitmap_start_sync(mddev, sect, &sync_blocks, 1); if (sync_blocks < max_sync) max_sync = sync_blocks; @@ -3363,7 +3363,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, } } - must_sync = md_bitmap_start_sync(mddev->bitmap, sect, + must_sync = md_bitmap_start_sync(mddev, sect, &sync_blocks, still_degraded); any_working = 0; @@ -3541,7 +3541,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, mddev_is_clustered(mddev) && (sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high)); - if (!md_bitmap_start_sync(mddev->bitmap, sector_nr, + if (!md_bitmap_start_sync(mddev, sector_nr, &sync_blocks, mddev->degraded) && !conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 2e54115da719..a2688987a2d0 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -6530,7 +6530,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n } if (!test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery) && !conf->fullsync && - !md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) && + !md_bitmap_start_sync(mddev, sector_nr, &sync_blocks, 1) && sync_blocks >= RAID5_STRIPE_SECTORS(conf)) { /* we can skip this block, and probably more */ do_div(sync_blocks, RAID5_STRIPE_SECTORS(conf)); @@ -6561,7 +6561,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n still_degraded = 1; } - md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, still_degraded); + md_bitmap_start_sync(mddev, sector_nr, &sync_blocks, still_degraded); set_bit(STRIPE_SYNC_REQUESTED, &sh->state); set_bit(STRIPE_HANDLE, &sh->state); From patchwork Sat Aug 10 02:08:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759346 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 12C2113D537; Sat, 10 Aug 2024 02:13:00 +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=1723255984; cv=none; b=IsyFE0sWF5plRQIYYb4+cO6QXZBDlgD/qwIoRO9Rkc91sjvmujAOybsfoK9TuaEJFkVURz6Vd/clV9ZKJyS0o7vdXVDujw3mPFI+As2RrtNUvokNxkDRqGpzfPRaFuW9HmO/etwU735tn/UA8NA8bCN9oRZp90Lg3RX5mabWmD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255984; c=relaxed/simple; bh=tDCd78oqtNMe3t9kch1dy9Ak9MX/TYUzcriY75aB3xk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lwz/U9rtCO0/HNvt9JfmrVGYNZBm6AQ17kqNaUbv6XrjMzDf3Gx9iqcObUPiqq1dzZisvFkGMcP3aDq2abmWY87FBtOkEpM2LK4+UaU1iXj3W01IY1kKqJqxPn5z3fhMn7Op6nBV83ctTlOnj9iw2EhnXKsmSJVnJW3z3fL2N2U= 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 4Wgknr3Rm1z4f3jkK; Sat, 10 Aug 2024 10:12:48 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 9758B1A058E; Sat, 10 Aug 2024 10:12:57 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S19; Sat, 10 Aug 2024 10:12:57 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 15/26] md/md-bitmap: merge md_bitmap_end_sync() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:43 +0800 Message-Id: <20240810020854.797814-16-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S19 X-Coremail-Antispam: 1UD129KBjvJXoWxtF4UWFy5Wry8JFW5Gr4fuFg_yoWxGr4fp3 yDtFy3G3y5WFW3X3WUA3yDCFyFy3s7tr9rtFyfW3s3uFykGFnxGF48GFyjq3WqkFyfAFs0 vwn0yrW5CF1UXFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 15 ++++++--------- drivers/md/md-bitmap.h | 14 +++++++++++++- drivers/md/raid1.c | 4 ++-- drivers/md/raid10.c | 5 ++--- drivers/md/raid5.c | 2 +- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index b20b6585fc44..d0163533da14 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1627,15 +1627,12 @@ static int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, return rv; } -void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted) +static void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, + sector_t *blocks, int aborted) { bitmap_counter_t *bmc; unsigned long flags; - if (bitmap == NULL) { - *blocks = 1024; - return; - } spin_lock_irqsave(&bitmap->counts.lock, flags); bmc = md_bitmap_get_counter(&bitmap->counts, offset, blocks, 0); if (bmc == NULL) @@ -1656,7 +1653,6 @@ void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks unlock: spin_unlock_irqrestore(&bitmap->counts.lock, flags); } -EXPORT_SYMBOL(md_bitmap_end_sync); void md_bitmap_close_sync(struct bitmap *bitmap) { @@ -1669,7 +1665,7 @@ void md_bitmap_close_sync(struct bitmap *bitmap) if (!bitmap) return; while (sector < bitmap->mddev->resync_max_sectors) { - md_bitmap_end_sync(bitmap, sector, &blocks, 0); + bitmap_end_sync(bitmap, sector, &blocks, 0); sector += blocks; } } @@ -1697,7 +1693,7 @@ void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force) sector &= ~((1ULL << bitmap->counts.chunkshift) - 1); s = 0; while (s < sector && s < bitmap->mddev->resync_max_sectors) { - md_bitmap_end_sync(bitmap, s, &blocks, 0); + bitmap_end_sync(bitmap, s, &blocks, 0); s += blocks; } bitmap->last_end_sync = jiffies; @@ -1713,7 +1709,7 @@ void md_bitmap_sync_with_cluster(struct mddev *mddev, sector_t sector, blocks = 0; for (sector = old_lo; sector < new_lo; ) { - md_bitmap_end_sync(bitmap, sector, &blocks, 0); + bitmap_end_sync(bitmap, sector, &blocks, 0); sector += blocks; } WARN((blocks > new_lo) && old_lo, "alignment is not correct for lo\n"); @@ -2717,6 +2713,7 @@ static struct bitmap_operations bitmap_ops = { .startwrite = bitmap_startwrite, .endwrite = bitmap_endwrite, .start_sync = bitmap_start_sync, + .end_sync = bitmap_end_sync, .update_sb = bitmap_update_sb, }; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 118141b6caeb..58c114246a2d 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -249,6 +249,8 @@ struct bitmap_operations { unsigned long sectors, int success, int behind); int (*start_sync)(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int degraded); + void (*end_sync)(struct bitmap *bitmap, sector_t offset, + sector_t *blocks, int aborted); void (*update_sb)(struct bitmap *bitmap); }; @@ -354,7 +356,17 @@ static inline int md_bitmap_start_sync(struct mddev *mddev, sector_t offset, degraded); } -void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted); +static inline void md_bitmap_end_sync(struct mddev *mddev, sector_t offset, + sector_t *blocks, int aborted) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->end_sync) { + *blocks = 1024; + return; + } + + mddev->bitmap_ops->end_sync(mddev->bitmap, offset, blocks, aborted); +} + void md_bitmap_close_sync(struct bitmap *bitmap); void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force); void md_bitmap_sync_with_cluster(struct mddev *mddev, diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index e86cf05f9870..cf787ead3d0d 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2036,7 +2036,7 @@ static void abort_sync_write(struct mddev *mddev, struct r1bio *r1_bio) /* make sure these bits don't get cleared. */ do { - md_bitmap_end_sync(mddev->bitmap, s, &sync_blocks, 1); + md_bitmap_end_sync(mddev, s, &sync_blocks, 1); s += sync_blocks; sectors_to_go -= sync_blocks; } while (sectors_to_go > 0); @@ -2782,7 +2782,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr, * We can find the current addess in mddev->curr_resync */ if (mddev->curr_resync < max_sector) /* aborted */ - md_bitmap_end_sync(mddev->bitmap, mddev->curr_resync, + md_bitmap_end_sync(mddev, mddev->curr_resync, &sync_blocks, 1); else /* completed sync */ conf->fullsync = 0; diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 20c0ccf28ef5..3746692f5f1c 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3191,13 +3191,12 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, if (mddev->curr_resync < max_sector) { /* aborted */ if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) - md_bitmap_end_sync(mddev->bitmap, mddev->curr_resync, + md_bitmap_end_sync(mddev, mddev->curr_resync, &sync_blocks, 1); else for (i = 0; i < conf->geo.raid_disks; i++) { sector_t sect = raid10_find_virt(conf, mddev->curr_resync, i); - md_bitmap_end_sync(mddev->bitmap, sect, - &sync_blocks, 1); + md_bitmap_end_sync(mddev, sect, &sync_blocks, 1); } } else { /* completed sync */ diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index a2688987a2d0..c566fcc6fd46 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -6497,7 +6497,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n } if (mddev->curr_resync < max_sector) /* aborted */ - md_bitmap_end_sync(mddev->bitmap, mddev->curr_resync, + md_bitmap_end_sync(mddev, mddev->curr_resync, &sync_blocks, 1); else /* completed sync */ conf->fullsync = 0; From patchwork Sat Aug 10 02:08:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759355 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 6D60B14A0B5; Sat, 10 Aug 2024 02:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255988; cv=none; b=cp8nDztq6mezzHljoWMAM7ildm3qibxIhbD++ZB4lPDuDl5syRCQbU2Z4+OTSdvhwXbPpE49ESKaBJxbX+jGO34FgVTrT4RMgi7qQhWP2JwKH2HEJkuhmukRiT/dB2baq/o3Vu+qofVKxxibfygevS1jB8hRZYCPQClEFbYbyds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255988; c=relaxed/simple; bh=85UhZxktp/puF1w3TBxQjXWLFJnQgLthqCk8//atkdI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ieaqm8K8eSFyAuL7yhVBQCzLCabbLO1T1E7S7t6XMaO08t1q8Q44j/Xr52WzjpaIIRfJkj2wStgdmOe8ILH4rNTNVhbhgjoGFWqgxbscJUM95Ur/ysfWqGIafvqeUPZrUMdbJu5QpV1KrJFtUZx78D7Cvb1v4CXVpvm0dYDEPeU= 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.56 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.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Wgknm3ZgCz4f3jJ4; Sat, 10 Aug 2024 10:12:44 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 05AC61A1745; Sat, 10 Aug 2024 10:12:58 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S20; Sat, 10 Aug 2024 10:12:57 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 16/26] md/md-bitmap: merge md_bitmap_close_sync() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:44 +0800 Message-Id: <20240810020854.797814-17-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S20 X-Coremail-Antispam: 1UD129KBjvJXoWxurW3XFy3CFWDWFWxuw1fCrg_yoWrCw1Dpa yDJry3C345WFW3X345A3yDu3WFyas7tr9rKryfG3s3uFykXF9xJF4rGa4jq3WqgF13JFZ0 vws8trW5CF15XFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 9 ++++----- drivers/md/md-bitmap.h | 10 +++++++++- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 2 +- drivers/md/raid5.c | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index d0163533da14..100551868484 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1654,7 +1654,7 @@ static void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, spin_unlock_irqrestore(&bitmap->counts.lock, flags); } -void md_bitmap_close_sync(struct bitmap *bitmap) +static void bitmap_close_sync(struct bitmap *bitmap) { /* Sync has finished, and any bitmap chunks that weren't synced * properly have been aborted. It remains to us to clear the @@ -1662,14 +1662,12 @@ void md_bitmap_close_sync(struct bitmap *bitmap) */ sector_t sector = 0; sector_t blocks; - if (!bitmap) - return; + while (sector < bitmap->mddev->resync_max_sectors) { bitmap_end_sync(bitmap, sector, &blocks, 0); sector += blocks; } } -EXPORT_SYMBOL(md_bitmap_close_sync); void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force) { @@ -1986,7 +1984,7 @@ static int bitmap_load(struct mddev *mddev) bitmap_start_sync(bitmap, sector, &blocks, 0); sector += blocks; } - md_bitmap_close_sync(bitmap); + bitmap_close_sync(bitmap); if (mddev->degraded == 0 || bitmap->events_cleared == mddev->events) @@ -2714,6 +2712,7 @@ static struct bitmap_operations bitmap_ops = { .endwrite = bitmap_endwrite, .start_sync = bitmap_start_sync, .end_sync = bitmap_end_sync, + .close_sync = bitmap_close_sync, .update_sb = bitmap_update_sb, }; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 58c114246a2d..56ede16ce5fe 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -251,6 +251,7 @@ struct bitmap_operations { sector_t *blocks, int degraded); void (*end_sync)(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted); + void (*close_sync)(struct bitmap *bitmap); void (*update_sb)(struct bitmap *bitmap); }; @@ -367,7 +368,14 @@ static inline void md_bitmap_end_sync(struct mddev *mddev, sector_t offset, mddev->bitmap_ops->end_sync(mddev->bitmap, offset, blocks, aborted); } -void md_bitmap_close_sync(struct bitmap *bitmap); +static inline void md_bitmap_close_sync(struct mddev *mddev) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->close_sync) + return; + + mddev->bitmap_ops->close_sync(mddev->bitmap); +} + void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force); void md_bitmap_sync_with_cluster(struct mddev *mddev, sector_t old_lo, sector_t old_hi, diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index cf787ead3d0d..8f5beba4184c 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2787,7 +2787,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr, else /* completed sync */ conf->fullsync = 0; - md_bitmap_close_sync(mddev->bitmap); + md_bitmap_close_sync(mddev); close_sync(conf); if (mddev_is_clustered(mddev)) { diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 3746692f5f1c..19035e9950f1 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3216,7 +3216,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, } conf->fullsync = 0; } - md_bitmap_close_sync(mddev->bitmap); + md_bitmap_close_sync(mddev); close_sync(conf); *skipped = 1; return sectors_skipped; diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index c566fcc6fd46..06f8a4a55b2b 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -6501,7 +6501,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n &sync_blocks, 1); else /* completed sync */ conf->fullsync = 0; - md_bitmap_close_sync(mddev->bitmap); + md_bitmap_close_sync(mddev); return 0; } From patchwork Sat Aug 10 02:08:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759343 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 492A813D62A; Sat, 10 Aug 2024 02:13:01 +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=1723255983; cv=none; b=RiiRyDmDhs7jmRn2e5sEKOX82/D7kQ3G0IvPPOWO7elaTctKxMQ6ad7hJDotPbJ0YY7ZiAxtS8ONkmV97v5BM3wGqBPJAMs6E/oc4rcXik6QbU5n2iDpsVpsF6PKdhIVaWooNp5leEbpAVwBqJb/HvpnTwwxua1oIcKZMrmPDa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255983; c=relaxed/simple; bh=bQNaMQmHAUF6WPw1dSnt9QTvbt9vHp3n+0DyGR5TaK8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rGVIklsJ9QRXyeJo81MLxw6u8NfXgrkVIbB5VUggaXiGhzc4eLXSm8diWGaC8AefzzGiqB2PPFLzhbidjofRDAzzlDUEmYfFpmieR58eXWUaQ3LksgFA8Z6bIt4ufiRAWkwz1YcpoVa6Ib6VoZqJgil3zKIZaj9ywg4uM4PWgIA= 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 4Wgknl6QBFz4f3jHy; Sat, 10 Aug 2024 10:12:43 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 5E7421A058E; Sat, 10 Aug 2024 10:12:58 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S21; Sat, 10 Aug 2024 10:12:58 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 17/26] md/md-bitmap: mrege md_bitmap_cond_end_sync() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:45 +0800 Message-Id: <20240810020854.797814-18-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S21 X-Coremail-Antispam: 1UD129KBjvJXoWxur47tryrXFyDAFykAr4kCrg_yoWrZr4rpa yDtFy3C345WFW3Xa4UA3yDuFyFyas7tFZrKFyxW34fuFyDXFnxGF4rGa4jq3WDKF13JFZ0 qw45Kr45Cr1kWF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 7 +++---- drivers/md/md-bitmap.h | 11 ++++++++++- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 2 +- drivers/md/raid5.c | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 100551868484..3c09de471634 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1669,13 +1669,12 @@ static void bitmap_close_sync(struct bitmap *bitmap) } } -void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force) +static void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, + bool force) { sector_t s = 0; sector_t blocks; - if (!bitmap) - return; if (sector == 0) { bitmap->last_end_sync = jiffies; return; @@ -1697,7 +1696,6 @@ void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force) bitmap->last_end_sync = jiffies; sysfs_notify_dirent_safe(bitmap->mddev->sysfs_completed); } -EXPORT_SYMBOL(md_bitmap_cond_end_sync); void md_bitmap_sync_with_cluster(struct mddev *mddev, sector_t old_lo, sector_t old_hi, @@ -2713,6 +2711,7 @@ static struct bitmap_operations bitmap_ops = { .start_sync = bitmap_start_sync, .end_sync = bitmap_end_sync, .close_sync = bitmap_close_sync, + .cond_end_sync = bitmap_cond_end_sync, .update_sb = bitmap_update_sb, }; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 56ede16ce5fe..71c3610dca7b 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -252,6 +252,7 @@ struct bitmap_operations { void (*end_sync)(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted); void (*close_sync)(struct bitmap *bitmap); + void (*cond_end_sync)(struct bitmap *bitmap, sector_t sector, bool force); void (*update_sb)(struct bitmap *bitmap); }; @@ -376,7 +377,15 @@ static inline void md_bitmap_close_sync(struct mddev *mddev) mddev->bitmap_ops->close_sync(mddev->bitmap); } -void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force); +static inline void md_bitmap_cond_end_sync(struct mddev *mddev, sector_t sector, + bool force) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->cond_end_sync) + return; + + mddev->bitmap_ops->cond_end_sync(mddev->bitmap, sector, force); +} + void md_bitmap_sync_with_cluster(struct mddev *mddev, sector_t old_lo, sector_t old_hi, sector_t new_lo, sector_t new_hi); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 8f5beba4184c..c8cd6036441b 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2825,7 +2825,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr, * sector_nr + two times RESYNC_SECTORS */ - md_bitmap_cond_end_sync(mddev->bitmap, sector_nr, + md_bitmap_cond_end_sync(mddev, sector_nr, mddev_is_clustered(mddev) && (sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high)); diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 19035e9950f1..1ea9b4117b08 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3536,7 +3536,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, * safety reason, which ensures curr_resync_completed is * updated in bitmap_cond_end_sync. */ - md_bitmap_cond_end_sync(mddev->bitmap, sector_nr, + md_bitmap_cond_end_sync(mddev, sector_nr, mddev_is_clustered(mddev) && (sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high)); diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 06f8a4a55b2b..8f0de56c0b23 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -6539,7 +6539,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n return sync_blocks * RAID5_STRIPE_SECTORS(conf); } - md_bitmap_cond_end_sync(mddev->bitmap, sector_nr, false); + md_bitmap_cond_end_sync(mddev, sector_nr, false); sh = raid5_get_active_stripe(conf, NULL, sector_nr, R5_GAS_NOBLOCK); From patchwork Sat Aug 10 02:08:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759345 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 9E54413D8B0; Sat, 10 Aug 2024 02:13:01 +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=1723255983; cv=none; b=eMn2jD/5Y+MK7b74M5ffe3LnvB8VqoWmFfUJnoBDRedKz+K68f9ei3NycxQ1RWQ5IDAw9Ggjmp0R4dUhVfzGWx5CVQt5QWC4YGywNhzVqH9LGkWiLrUDSkcx6ERuvOsDoY9+00XNEShKlZdDkKn1/LvdVnc6P6KYCVQee9GVQ7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255983; c=relaxed/simple; bh=gtCoLl16b57j359Qvp2Gr6UuGv5YQ8u3l67VlSQ4J90=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nvlB+rTpz+6nI90k/l4in2J5Qv+hQclaEUt0lShP6I5UXM371f0p+P9BrsOl5wkV9y+MPlwfJUC603epIxqJKwz7Zx6cpk1gPWkmUQDE3ZtrlJltf5BS2KZ7rfVAsWTxIDXtbVFLvVHBXNu+BWeuza9UMEPDI2gjgZmckOIqTnA= 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.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknm1l1vz4f3jJ1; Sat, 10 Aug 2024 10:12:44 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id B33CF1A1737; Sat, 10 Aug 2024 10:12:58 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S22; Sat, 10 Aug 2024 10:12:58 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 18/26] md/md-bitmap: merge bitmap_sync_with_cluster() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:46 +0800 Message-Id: <20240810020854.797814-19-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S22 X-Coremail-Antispam: 1UD129KBjvJXoWxurW3XFyrJr4xZryDZr15twb_yoW5AF1rpr WUKa43Gry3JFZIq3WUZryDuFyFv34kJr9rtryxW34rCFyDJrnxGF4rG3ZFqw4DGF4fJFs0 vw15KF45ur18XF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 9 ++++----- drivers/md/md-bitmap.h | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 3c09de471634..8828175ad442 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1697,11 +1697,10 @@ static void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, sysfs_notify_dirent_safe(bitmap->mddev->sysfs_completed); } -void md_bitmap_sync_with_cluster(struct mddev *mddev, - sector_t old_lo, sector_t old_hi, - sector_t new_lo, sector_t new_hi) +static void bitmap_sync_with_cluster(struct bitmap *bitmap, + sector_t old_lo, sector_t old_hi, + sector_t new_lo, sector_t new_hi) { - struct bitmap *bitmap = mddev->bitmap; sector_t sector, blocks = 0; for (sector = old_lo; sector < new_lo; ) { @@ -1716,7 +1715,6 @@ void md_bitmap_sync_with_cluster(struct mddev *mddev, } WARN((blocks > new_hi) && old_hi, "alignment is not correct for hi\n"); } -EXPORT_SYMBOL(md_bitmap_sync_with_cluster); static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed) { @@ -2714,6 +2712,7 @@ static struct bitmap_operations bitmap_ops = { .cond_end_sync = bitmap_cond_end_sync, .update_sb = bitmap_update_sb, + .sync_with_cluster = bitmap_sync_with_cluster, }; void mddev_set_bitmap_ops(struct mddev *mddev) diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 71c3610dca7b..5a77b6d8358b 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -255,6 +255,9 @@ struct bitmap_operations { void (*cond_end_sync)(struct bitmap *bitmap, sector_t sector, bool force); void (*update_sb)(struct bitmap *bitmap); + void (*sync_with_cluster)(struct bitmap *bitmap, + sector_t old_lo, sector_t old_hi, + sector_t new_lo, sector_t new_hi); }; /* the bitmap API */ @@ -386,9 +389,16 @@ static inline void md_bitmap_cond_end_sync(struct mddev *mddev, sector_t sector, mddev->bitmap_ops->cond_end_sync(mddev->bitmap, sector, force); } -void md_bitmap_sync_with_cluster(struct mddev *mddev, - sector_t old_lo, sector_t old_hi, - sector_t new_lo, sector_t new_hi); +static inline void md_bitmap_sync_with_cluster(struct mddev *mddev, + sector_t old_lo, sector_t old_hi, + sector_t new_lo, sector_t new_hi) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->sync_with_cluster) + return; + + mddev->bitmap_ops->sync_with_cluster(mddev->bitmap, old_lo, old_hi, + new_lo, new_hi); +} void md_bitmap_unplug(struct bitmap *bitmap); void md_bitmap_unplug_async(struct bitmap *bitmap); From patchwork Sat Aug 10 02:08:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759357 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 3EB7914B942; Sat, 10 Aug 2024 02:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255988; cv=none; b=Xx8PaEBBaDSjTlRtW/hTIGti+Rb11Q2Y/H/G/4IJ54X+KqYBgm++RzmUZYHuXxIEvu9EEUzGztfZa3DfVu/J56TwizTLwqv0LDXqyUTlo5BrbShChatv7ujRTOwZUDu1PyETmM+Yik3tlHrGV2VTAQbYyGzVu0X1mEDhuHVtUY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255988; c=relaxed/simple; bh=XmTlWSY9JEvzY71VPDRjCfrFkCWCvam1DQ0Vrwpazu4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uV7zLVJ+Wn2rcAEV7EWr0YVgjd6b7vg342WUtW0GPS7wnAFRcvXCZefqTM7ZJ8oysBP9j5Wzv5X3iwip6He3rb8KOFNy7SXb6BPBfkZospURX2utSDICejoyyPn1PQx3qfqJW927lOOF4xJfdSfEBoimigfST/q2N/QbveIiC5A= 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.56 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.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Wgknn41BRz4f3jJ4; Sat, 10 Aug 2024 10:12:45 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 1399D1A0359; Sat, 10 Aug 2024 10:12:59 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S23; Sat, 10 Aug 2024 10:12:58 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 19/26] md/md-bitmap: merge md_bitmap_resize() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:47 +0800 Message-Id: <20240810020854.797814-20-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S23 X-Coremail-Antispam: 1UD129KBjvJXoW3GF1xKr43Gr1fXr4DCFyUJrb_yoWxKry5pa yUtF9xC345GFW3Wa1UZFykuF1Fv34ktr9rtryxC34ruFy7XFnxCF4rWFyjq3WUKa45JFs8 Xan8JrW5CF1kXF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/dm-raid.c | 2 +- drivers/md/md-bitmap.c | 11 +++++++---- drivers/md/md-bitmap.h | 13 +++++++++++-- drivers/md/md-cluster.c | 4 ++-- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 8 ++++---- drivers/md/raid5.c | 2 +- 7 files changed, 27 insertions(+), 15 deletions(-) diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index 0c3323e0adb2..6342775c79dd 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -4066,7 +4066,7 @@ static int raid_preresume(struct dm_target *ti) mddev->bitmap_info.chunksize != to_bytes(rs->requested_bitmap_chunk_sectors)))) { int chunksize = to_bytes(rs->requested_bitmap_chunk_sectors) ?: mddev->bitmap_info.chunksize; - r = md_bitmap_resize(mddev->bitmap, mddev->dev_sectors, chunksize, 0); + r = md_bitmap_resize(mddev, mddev->dev_sectors, chunksize, 0); if (r) DMERR("Failed to resize bitmap"); } diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 8828175ad442..ed43139b52f4 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -32,6 +32,9 @@ #include "md.h" #include "md-bitmap.h" +static int bitmap_resize(struct bitmap *bitmap, sector_t blocks, + int chunksize, int init); + static inline char *bmname(struct bitmap *bitmap) { return bitmap->mddev ? mdname(bitmap->mddev) : "mdX"; @@ -1936,7 +1939,7 @@ static struct bitmap *bitmap_create(struct mddev *mddev, int slot) goto error; bitmap->daemon_lastrun = jiffies; - err = md_bitmap_resize(bitmap, blocks, mddev->bitmap_info.chunksize, 1); + err = bitmap_resize(bitmap, blocks, mddev->bitmap_info.chunksize, 1); if (err) goto error; @@ -2108,8 +2111,8 @@ static void bitmap_status(struct seq_file *seq, struct bitmap *bitmap) seq_printf(seq, "\n"); } -int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks, - int chunksize, int init) +static int bitmap_resize(struct bitmap *bitmap, sector_t blocks, + int chunksize, int init) { /* If chunk_size is 0, choose an appropriate chunk size. * Then possibly allocate new storage space. @@ -2314,7 +2317,6 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks, err: return ret; } -EXPORT_SYMBOL_GPL(md_bitmap_resize); static ssize_t location_show(struct mddev *mddev, char *page) @@ -2712,6 +2714,7 @@ static struct bitmap_operations bitmap_ops = { .cond_end_sync = bitmap_cond_end_sync, .update_sb = bitmap_update_sb, + .resize = bitmap_resize, .sync_with_cluster = bitmap_sync_with_cluster, }; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 5a77b6d8358b..37edf8626a60 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -255,6 +255,8 @@ struct bitmap_operations { void (*cond_end_sync)(struct bitmap *bitmap, sector_t sector, bool force); void (*update_sb)(struct bitmap *bitmap); + int (*resize)(struct bitmap *bitmap, sector_t blocks, int chunksize, + int init); void (*sync_with_cluster)(struct bitmap *bitmap, sector_t old_lo, sector_t old_hi, sector_t new_lo, sector_t new_hi); @@ -389,6 +391,15 @@ static inline void md_bitmap_cond_end_sync(struct mddev *mddev, sector_t sector, mddev->bitmap_ops->cond_end_sync(mddev->bitmap, sector, force); } +static inline int md_bitmap_resize(struct mddev *mddev, sector_t blocks, + int chunksize, int init) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->resize) + return -EOPNOTSUPP; + + return mddev->bitmap_ops->resize(mddev->bitmap, blocks, chunksize, init); +} + static inline void md_bitmap_sync_with_cluster(struct mddev *mddev, sector_t old_lo, sector_t old_hi, sector_t new_lo, sector_t new_hi) @@ -404,8 +415,6 @@ void md_bitmap_unplug(struct bitmap *bitmap); void md_bitmap_unplug_async(struct bitmap *bitmap); void md_bitmap_daemon_work(struct mddev *mddev); -int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks, - int chunksize, int init); struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot); int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *lo, sector_t *hi, bool clear_bits); diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c index 79e67393fee0..d843ea190e7b 100644 --- a/drivers/md/md-cluster.c +++ b/drivers/md/md-cluster.c @@ -628,8 +628,8 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg) break; case BITMAP_RESIZE: if (le64_to_cpu(msg->high) != mddev->pers->size(mddev, 0, 0)) - ret = md_bitmap_resize(mddev->bitmap, - le64_to_cpu(msg->high), 0, 0); + ret = md_bitmap_resize(mddev, le64_to_cpu(msg->high), 0, + 0); break; default: ret = -1; diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index c8cd6036441b..fef69fce586c 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -3311,7 +3311,7 @@ static int raid1_resize(struct mddev *mddev, sector_t sectors) mddev->array_sectors > newsize) return -EINVAL; if (mddev->bitmap) { - int ret = md_bitmap_resize(mddev->bitmap, newsize, 0, 0); + int ret = md_bitmap_resize(mddev, newsize, 0, 0); if (ret) return ret; } diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 1ea9b4117b08..a8a14cda8446 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -4201,7 +4201,7 @@ static int raid10_resize(struct mddev *mddev, sector_t sectors) mddev->array_sectors > size) return -EINVAL; if (mddev->bitmap) { - int ret = md_bitmap_resize(mddev->bitmap, size, 0, 0); + int ret = md_bitmap_resize(mddev, size, 0, 0); if (ret) return ret; } @@ -4470,7 +4470,7 @@ static int raid10_start_reshape(struct mddev *mddev) newsize = raid10_size(mddev, 0, conf->geo.raid_disks); if (!mddev_is_clustered(mddev)) { - ret = md_bitmap_resize(mddev->bitmap, newsize, 0, 0); + ret = md_bitmap_resize(mddev, newsize, 0, 0); if (ret) goto abort; else @@ -4492,13 +4492,13 @@ static int raid10_start_reshape(struct mddev *mddev) MD_FEATURE_RESHAPE_ACTIVE)) || (oldsize == newsize)) goto out; - ret = md_bitmap_resize(mddev->bitmap, newsize, 0, 0); + ret = md_bitmap_resize(mddev, newsize, 0, 0); if (ret) goto abort; ret = md_cluster_ops->resize_bitmaps(mddev, newsize, oldsize); if (ret) { - md_bitmap_resize(mddev->bitmap, oldsize, 0, 0); + md_bitmap_resize(mddev, oldsize, 0, 0); goto abort; } } diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 8f0de56c0b23..8b1e2157a798 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -8320,7 +8320,7 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors) mddev->array_sectors > newsize) return -EINVAL; if (mddev->bitmap) { - int ret = md_bitmap_resize(mddev->bitmap, sectors, 0, 0); + int ret = md_bitmap_resize(mddev, sectors, 0, 0); if (ret) return ret; } From patchwork Sat Aug 10 02:08:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759356 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 069B6130499; Sat, 10 Aug 2024 02:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255988; cv=none; b=SIJ9R+bIXZAcRxx/xfBkwA5cZyNeDdKKj9g2pI5Gv3EFBibPyMb7/IjfyFx/T7ewpyOiu1fJhagYOi3Jzo1Pqm7QfodxCcokP5Poz2wlHkLBN2TTmzP2dlPJfAI5JKSYCmVI7lLXSAaouPcWnWz3oo9gJsvJsxFM2YECeUK+G4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255988; c=relaxed/simple; bh=GF/k2FBC297lPmJcv4z2avEr2mmu+H5jGLUps8CdbY4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hXJdzrhi91ESbHCmmBy3bO1fZvUnW8gAJ7J1xkYyH2QOQX00sdmRsOXWYGNNy3F4LOAvxwzwudPUnH0bqJMj3eQK0Exv3SuMGVNIQLoemCBKNmhIb4lxyLRg0uoqk/0Z1KlRRSbpDx079hdZTqBTmQODvIxsQG4roBkPP2Cvl+A= 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.56 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.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Wgknn5lbFz4f3jrs; Sat, 10 Aug 2024 10:12:45 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 51D891A174A; Sat, 10 Aug 2024 10:12:59 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S24; Sat, 10 Aug 2024 10:12:59 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 20/26] md/md-bitmap: merge get_bitmap_from_slot() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:48 +0800 Message-Id: <20240810020854.797814-21-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S24 X-Coremail-Antispam: 1UD129KBjvJXoWxZFWUur1DAw1DAw48JryDAwb_yoWrGw1rpF 4Uta43CrWrJrWagr1UuFyDAa45tw1ktr9rKryfGw4fuF9xWF98GF4rG3W8t34YkF15JFsI qw4YkrWUur1rXr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Also rename it to md_bitmap_get_from_slot(). Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 6 +++--- drivers/md/md-bitmap.h | 11 ++++++++++- drivers/md/md-cluster.c | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index ed43139b52f4..f6c0334708ee 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -2014,7 +2014,7 @@ static int bitmap_load(struct mddev *mddev) } /* caller need to free returned bitmap with md_bitmap_free() */ -struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot) +static struct bitmap *bitmap_get_from_slot(struct mddev *mddev, int slot) { int rv = 0; struct bitmap *bitmap; @@ -2033,7 +2033,6 @@ struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot) return bitmap; } -EXPORT_SYMBOL(get_bitmap_from_slot); /* Loads the bitmap associated with slot and copies the resync information * to our bitmap @@ -2046,7 +2045,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, struct bitmap_counts *counts; struct bitmap *bitmap; - bitmap = get_bitmap_from_slot(mddev, slot); + bitmap = bitmap_get_from_slot(mddev, slot); if (IS_ERR(bitmap)) { pr_err("%s can't get bitmap from slot %d\n", __func__, slot); return -1; @@ -2716,6 +2715,7 @@ static struct bitmap_operations bitmap_ops = { .update_sb = bitmap_update_sb, .resize = bitmap_resize, .sync_with_cluster = bitmap_sync_with_cluster, + .get_from_slot = bitmap_get_from_slot, }; void mddev_set_bitmap_ops(struct mddev *mddev) diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 37edf8626a60..199fb961b11f 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -260,6 +260,7 @@ struct bitmap_operations { void (*sync_with_cluster)(struct bitmap *bitmap, sector_t old_lo, sector_t old_hi, sector_t new_lo, sector_t new_hi); + struct bitmap* (*get_from_slot)(struct mddev *mddev, int slot); }; /* the bitmap API */ @@ -411,11 +412,19 @@ static inline void md_bitmap_sync_with_cluster(struct mddev *mddev, new_lo, new_hi); } +static inline struct bitmap *md_bitmap_get_from_slot(struct mddev *mddev, + int slot) +{ + if (!mddev->bitmap_ops->get_from_slot) + return ERR_PTR(-EOPNOTSUPP); + + return mddev->bitmap_ops->get_from_slot(mddev, slot); +} + void md_bitmap_unplug(struct bitmap *bitmap); void md_bitmap_unplug_async(struct bitmap *bitmap); void md_bitmap_daemon_work(struct mddev *mddev); -struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot); int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *lo, sector_t *hi, bool clear_bits); void md_bitmap_free(struct bitmap *bitmap); diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c index d843ea190e7b..d608535fc06a 100644 --- a/drivers/md/md-cluster.c +++ b/drivers/md/md-cluster.c @@ -1162,7 +1162,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz if (i == md_cluster_ops->slot_number(mddev)) continue; - bitmap = get_bitmap_from_slot(mddev, i); + bitmap = md_bitmap_get_from_slot(mddev, i); if (IS_ERR(bitmap)) { pr_err("can't get bitmap from slot %d\n", i); bitmap = NULL; @@ -1224,7 +1224,7 @@ static int cluster_check_sync_size(struct mddev *mddev) if (i == current_slot) continue; - bitmap = get_bitmap_from_slot(mddev, i); + bitmap = md_bitmap_get_from_slot(mddev, i); if (IS_ERR(bitmap)) { pr_err("can't get bitmap from slot %d\n", i); return -1; From patchwork Sat Aug 10 02:08:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759360 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 435BB14D715; Sat, 10 Aug 2024 02:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255990; cv=none; b=DzHew3uvmU5xh0Je7VPmXyzQHBWXzQSuq3tSlPsOnu8HgqlhDOgp21UjERnqZ4id5qiYoFL1hTtUO9GXZJyw4O8TTLf1CEJjMFkwkoliHiXr866V5NIixMyx+ZOpBoxOZ/Fl5zXcIWu9jjWZq8T+GEVXqY1+Ufiv8EUdH7Ru3dk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255990; c=relaxed/simple; bh=aQ3S0oPGZfpRLApuclwyt0A5xu9fFRSZCcGxPQI+wR0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pcI5uqxaS1yS9ryMtcLcVXcsNfpaG7frFnCa9TiSkmJOaWMqL/ibZhzGlOvpcNXB/mBZexkAKJ5lZqXJM0btMxZwOgPeeZESsfpjt+EyE+nxkoV04cmoKvyjVZqe8PNdFO/FC+5ccksi6TfoXD8hl/Y9/26ksIqCpShOXBBMh9A= 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.56 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.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Wgknp11j2z4f3jrt; Sat, 10 Aug 2024 10:12:46 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id A26961A13AA; Sat, 10 Aug 2024 10:12:59 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S25; Sat, 10 Aug 2024 10:12:59 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 21/26] md/md-bitmap: merge md_bitmap_copy_from_slot() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:49 +0800 Message-Id: <20240810020854.797814-22-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S25 X-Coremail-Antispam: 1UD129KBjvJXoWxCr1xAF43WF47JFyxJFWxXrb_yoW5Ww4xpF 4UtasxG3y5JFWaq3WUZFyDua45tr1ktrZrKryxGw1ruFy3WF98GF1rG3W8t34rKF1rJFsI q3W5KrWrCr1FqF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 7 +++---- drivers/md/md-bitmap.h | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index f6c0334708ee..199bd6757543 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -2037,8 +2037,8 @@ static struct bitmap *bitmap_get_from_slot(struct mddev *mddev, int slot) /* Loads the bitmap associated with slot and copies the resync information * to our bitmap */ -int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, - sector_t *low, sector_t *high, bool clear_bits) +static int bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *low, + sector_t *high, bool clear_bits) { int rv = 0, i, j; sector_t block, lo = 0, hi = 0; @@ -2080,8 +2080,6 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, return rv; } -EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot); - static void bitmap_status(struct seq_file *seq, struct bitmap *bitmap) { @@ -2716,6 +2714,7 @@ static struct bitmap_operations bitmap_ops = { .resize = bitmap_resize, .sync_with_cluster = bitmap_sync_with_cluster, .get_from_slot = bitmap_get_from_slot, + .copy_from_slot = bitmap_copy_from_slot, }; void mddev_set_bitmap_ops(struct mddev *mddev) diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 199fb961b11f..acd868e2ef5e 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -261,6 +261,8 @@ struct bitmap_operations { sector_t old_lo, sector_t old_hi, sector_t new_lo, sector_t new_hi); struct bitmap* (*get_from_slot)(struct mddev *mddev, int slot); + int (*copy_from_slot)(struct mddev *mddev, int slot, + sector_t *lo, sector_t *hi, bool clear_bits); }; /* the bitmap API */ @@ -421,12 +423,20 @@ static inline struct bitmap *md_bitmap_get_from_slot(struct mddev *mddev, return mddev->bitmap_ops->get_from_slot(mddev, slot); } +static inline int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, + sector_t *lo, sector_t *hi, + bool clear_bits) +{ + if (!mddev->bitmap_ops->copy_from_slot) + return -EOPNOTSUPP; + + return mddev->bitmap_ops->copy_from_slot(mddev, slot, lo, hi, clear_bits); +} + void md_bitmap_unplug(struct bitmap *bitmap); void md_bitmap_unplug_async(struct bitmap *bitmap); void md_bitmap_daemon_work(struct mddev *mddev); -int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, - sector_t *lo, sector_t *hi, bool clear_bits); void md_bitmap_free(struct bitmap *bitmap); void md_bitmap_wait_behind_writes(struct mddev *mddev); From patchwork Sat Aug 10 02:08:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759348 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 C45851411E7; Sat, 10 Aug 2024 02:13:02 +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=1723255984; cv=none; b=BfCzkPxXSROBGWv85YLLzC+zhhma0NwrK11d4cRqRplY5WpKXPLHxTGjwBWswwJbe+6e/uT0GXIEVn8yZva89loBwhWj17mFpB0p+6ukgQ3cwiNstehBGv9M365kGU+QiHUnXBqLBC9Xk/luVcIAjLAB/lfgsev0KE737GT+k1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255984; c=relaxed/simple; bh=ytQ+ZCjobUKkClI9y2VOTywlyx2dRMYTWhjAPVSakDA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZIiMlkv7MO9zqf8apr60BrOsOMaSsUvNN+/WzcyyOfkIWPrPrT2L8uMiIQ+7+iiNatLmFsAPpRnviqFZApo+Z1IN0wjV6FtbGX7+Mfx7HSKB/c8Voo8Y4A5j04vR5uqeLhdpKZGlx/hSeQBnU4PVcrgqh0X5XkNzcLOh+yq9jGw= 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.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknt67Gbz4f3jk0; Sat, 10 Aug 2024 10:12:50 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 025161A13AA; Sat, 10 Aug 2024 10:13:00 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S26; Sat, 10 Aug 2024 10:12:59 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 22/26] md/md-bitmap: merge md_bitmap_free() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:50 +0800 Message-Id: <20240810020854.797814-23-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S26 X-Coremail-Antispam: 1UD129KBjvJXoW3Jw4kuFy7AF1kAFW3Gw1xZrb_yoW7GF45pF 4Ut3W5GrW5JFWaqr1UArWq9a4Yyw1ktr9rKryxAw1ruF9xXFnxGF48GFy8K345CFy5JFsx Xw15KFs5ur4UXrUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 17 +++++++---------- drivers/md/md-bitmap.h | 10 +++++++++- drivers/md/md-cluster.c | 10 +++++----- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 199bd6757543..99c496a32e94 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1790,10 +1790,7 @@ static void bitmap_flush(struct mddev *mddev) bitmap_update_sb(bitmap); } -/* - * free memory that was allocated - */ -void md_bitmap_free(struct bitmap *bitmap) +static void __bitmap_free(struct bitmap *bitmap) { unsigned long k, pages; struct bitmap_page *bp; @@ -1827,7 +1824,6 @@ void md_bitmap_free(struct bitmap *bitmap) kfree(bp); kfree(bitmap); } -EXPORT_SYMBOL(md_bitmap_free); void md_bitmap_wait_behind_writes(struct mddev *mddev) { @@ -1861,7 +1857,7 @@ static void bitmap_destroy(struct mddev *mddev) mutex_unlock(&mddev->bitmap_info.mutex); mddev_set_timeout(mddev, MAX_SCHEDULE_TIMEOUT, true); - md_bitmap_free(bitmap); + __bitmap_free(bitmap); } /* @@ -1952,7 +1948,7 @@ static struct bitmap *bitmap_create(struct mddev *mddev, int slot) return bitmap; error: - md_bitmap_free(bitmap); + __bitmap_free(bitmap); return ERR_PTR(err); } @@ -2013,7 +2009,7 @@ static int bitmap_load(struct mddev *mddev) return err; } -/* caller need to free returned bitmap with md_bitmap_free() */ +/* caller need to free returned bitmap with __bitmap_free() */ static struct bitmap *bitmap_get_from_slot(struct mddev *mddev, int slot) { int rv = 0; @@ -2027,7 +2023,7 @@ static struct bitmap *bitmap_get_from_slot(struct mddev *mddev, int slot) rv = md_bitmap_init_from_disk(bitmap, 0); if (rv) { - md_bitmap_free(bitmap); + __bitmap_free(bitmap); return ERR_PTR(rv); } @@ -2076,7 +2072,7 @@ static int bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *low, md_bitmap_unplug(mddev->bitmap); *low = lo; *high = hi; - md_bitmap_free(bitmap); + __bitmap_free(bitmap); return rv; } @@ -2715,6 +2711,7 @@ static struct bitmap_operations bitmap_ops = { .sync_with_cluster = bitmap_sync_with_cluster, .get_from_slot = bitmap_get_from_slot, .copy_from_slot = bitmap_copy_from_slot, + .free = __bitmap_free, }; void mddev_set_bitmap_ops(struct mddev *mddev) diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index acd868e2ef5e..b5836e5ff1e3 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -263,6 +263,7 @@ struct bitmap_operations { struct bitmap* (*get_from_slot)(struct mddev *mddev, int slot); int (*copy_from_slot)(struct mddev *mddev, int slot, sector_t *lo, sector_t *hi, bool clear_bits); + void (*free)(struct bitmap *bitmap); }; /* the bitmap API */ @@ -433,11 +434,18 @@ static inline int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, return mddev->bitmap_ops->copy_from_slot(mddev, slot, lo, hi, clear_bits); } +static inline void md_bitmap_free(struct mddev *mddev, struct bitmap *bitmap) +{ + if (!mddev->bitmap_ops->free) + return; + + return mddev->bitmap_ops->free(bitmap); +} + void md_bitmap_unplug(struct bitmap *bitmap); void md_bitmap_unplug_async(struct bitmap *bitmap); void md_bitmap_daemon_work(struct mddev *mddev); -void md_bitmap_free(struct bitmap *bitmap); void md_bitmap_wait_behind_writes(struct mddev *mddev); static inline bool md_bitmap_enabled(struct bitmap *bitmap) diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c index d608535fc06a..9e3c579703f6 100644 --- a/drivers/md/md-cluster.c +++ b/drivers/md/md-cluster.c @@ -1192,12 +1192,12 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz * can't resize bitmap */ goto out; - md_bitmap_free(bitmap); + md_bitmap_free(mddev, bitmap); } return 0; out: - md_bitmap_free(bitmap); + md_bitmap_free(mddev, bitmap); update_bitmap_size(mddev, oldsize); return -1; } @@ -1238,7 +1238,7 @@ static int cluster_check_sync_size(struct mddev *mddev) bm_lockres = lockres_init(mddev, str, NULL, 1); if (!bm_lockres) { pr_err("md-cluster: Cannot initialize %s\n", str); - md_bitmap_free(bitmap); + md_bitmap_free(mddev, bitmap); return -1; } bm_lockres->flags |= DLM_LKF_NOQUEUE; @@ -1253,11 +1253,11 @@ static int cluster_check_sync_size(struct mddev *mddev) sync_size = sb->sync_size; else if (sync_size != sb->sync_size) { kunmap_atomic(sb); - md_bitmap_free(bitmap); + md_bitmap_free(mddev, bitmap); return -1; } kunmap_atomic(sb); - md_bitmap_free(bitmap); + md_bitmap_free(mddev, bitmap); } return (my_sync_size == sync_size) ? 0 : -1; From patchwork Sat Aug 10 02:08:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759349 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 0153614265F; Sat, 10 Aug 2024 02:13:02 +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=1723255985; cv=none; b=NQ7UoPjFuPNOtcoxzp+Ws3UNxSgXK/CIJlOKVVVZy7KRRmZGcP5QOhmX4GnL4pSkpXu/GBx71D4HIMqiISkZS5nxq4ZznmYJsDvqD3UbHjpS0xljBSOMddWuyJ8m2sPdiOhvsnm7IBbinWtMEpaG+ikS+x6JxxSlJoxUwK7mTsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255985; c=relaxed/simple; bh=0c7LxUUaBa7OPsP91Q71xnibTX2ZAre8LY2EEVElqcE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=er3qBl7y4/SesznberfnhYGff9O4/3OfUuTSvGX/NVVr9yIyBM+Gsrgu55qsCmarXM6aTAsXzUlck6wO0F6nzk4kxDyqZ74qJt0LP9j4SMOMV1T4JfMGu2NONoKD9jwhJWmVsp+h0axXdtgJvxBbxM/quCXOdnQRBXEFgweGcdM= 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.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknv1VrXz4f3jk1; Sat, 10 Aug 2024 10:12:51 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 569631A018D; Sat, 10 Aug 2024 10:13:00 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S27; Sat, 10 Aug 2024 10:13:00 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 23/26] md/md-bitmap: merge md_bitmap_wait_behind_writes() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:51 +0800 Message-Id: <20240810020854.797814-24-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S27 X-Coremail-Antispam: 1UD129KBjvJXoWxur4xCw1UCr17Xw15Ar47Jwb_yoW5Zw43pF WDt3Z0kr15tFW3Xw4UAFWkAF1Fyr1ktr9rtryfGwn5uF1DJrnxKF4FgF1Utw15Ary3JFs8 Zan5tryrCr18XF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 11 +++++------ drivers/md/md-bitmap.h | 11 +++++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 99c496a32e94..87e192d172fb 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1825,14 +1825,12 @@ static void __bitmap_free(struct bitmap *bitmap) kfree(bitmap); } -void md_bitmap_wait_behind_writes(struct mddev *mddev) +static void bitmap_wait_behind_writes(struct bitmap *bitmap) { - struct bitmap *bitmap = mddev->bitmap; - /* wait for behind writes to complete */ - if (bitmap && atomic_read(&bitmap->behind_writes) > 0) { + if (atomic_read(&bitmap->behind_writes) > 0) { pr_debug("md:%s: behind writes in progress - waiting to stop.\n", - mdname(mddev)); + mdname(bitmap->mddev)); /* need to kick something here to make sure I/O goes? */ wait_event(bitmap->behind_wait, atomic_read(&bitmap->behind_writes) == 0); @@ -1846,7 +1844,7 @@ static void bitmap_destroy(struct mddev *mddev) if (!bitmap) /* there was no bitmap */ return; - md_bitmap_wait_behind_writes(mddev); + bitmap_wait_behind_writes(bitmap); if (!mddev->serialize_policy) mddev_destroy_serial_pool(mddev, NULL); @@ -2705,6 +2703,7 @@ static struct bitmap_operations bitmap_ops = { .end_sync = bitmap_end_sync, .close_sync = bitmap_close_sync, .cond_end_sync = bitmap_cond_end_sync, + .wait_behind_writes = bitmap_wait_behind_writes, .update_sb = bitmap_update_sb, .resize = bitmap_resize, diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index b5836e5ff1e3..090d4f11f3cd 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -253,6 +253,7 @@ struct bitmap_operations { sector_t *blocks, int aborted); void (*close_sync)(struct bitmap *bitmap); void (*cond_end_sync)(struct bitmap *bitmap, sector_t sector, bool force); + void (*wait_behind_writes)(struct bitmap *bitmap); void (*update_sb)(struct bitmap *bitmap); int (*resize)(struct bitmap *bitmap, sector_t blocks, int chunksize, @@ -395,6 +396,14 @@ static inline void md_bitmap_cond_end_sync(struct mddev *mddev, sector_t sector, mddev->bitmap_ops->cond_end_sync(mddev->bitmap, sector, force); } +static inline void md_bitmap_wait_behind_writes(struct mddev *mddev) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->wait_behind_writes) + return; + + mddev->bitmap_ops->wait_behind_writes(mddev->bitmap); +} + static inline int md_bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize, int init) { @@ -446,8 +455,6 @@ void md_bitmap_unplug(struct bitmap *bitmap); void md_bitmap_unplug_async(struct bitmap *bitmap); void md_bitmap_daemon_work(struct mddev *mddev); -void md_bitmap_wait_behind_writes(struct mddev *mddev); - static inline bool md_bitmap_enabled(struct bitmap *bitmap) { return bitmap && bitmap->storage.filemap && From patchwork Sat Aug 10 02:08:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759358 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 42EF314D6FF; Sat, 10 Aug 2024 02:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255989; cv=none; b=p7kelPw+kvfvjeOlqF3q/fmmYjrk5nuIzSeayrZCY9ALghSYHrgJjYb68yAmYCNjQlZoIqE4TEQwI7IxJXZmcKBqUAyonv+C3sIju0NJOusXQ6UnKS2GDywA9ysYqZPLhNgSxWLLiErmrFxpSpn9wsMwIUvi38wSeKXBuXD6fX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255989; c=relaxed/simple; bh=vfc/XbQZGRMG87KPcwul/B3aFqvLo45/3cCQfUcgCF0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oBZgsOtx3Li+PwLbZO/l33UrgmowmMYP4MiG9e4SN+f0CZJpRv70YHY3/kRuocFkY3jSx2auGih351c77ym24YhgOgig4pgscxY1t9LfXNROir60e+fhA1cSU1CWXst0qq4sGcrUstBfPExEHoqJEMB/V5UNStz25YxcJwsWl8w= 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.56 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.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Wgknq1GQxz4f3jrp; Sat, 10 Aug 2024 10:12:47 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id A8DFF1A159B; Sat, 10 Aug 2024 10:13:00 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S28; Sat, 10 Aug 2024 10:13:00 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 24/26] md/md-bitmap: merge md_bitmap_daemon_work() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:52 +0800 Message-Id: <20240810020854.797814-25-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S28 X-Coremail-Antispam: 1UD129KBjvJXoWxur4xGF48JFyUuw1UAr1xuFg_yoW5tr47pa y5t3Z8Cr45JFW3W3W7ArWDZF1Fqr1ktr9rtryfG34rCFy5JrnxWFWrGFyUt3Z5Jr1xAFs8 Za15Jry8Gr1UWFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 19 +++++++------------ drivers/md/md-bitmap.h | 10 +++++++++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 87e192d172fb..4f3ea6e51572 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1292,9 +1292,9 @@ static void mddev_set_timeout(struct mddev *mddev, unsigned long timeout, * bitmap daemon -- periodically wakes up to clean bits and flush pages * out to disk */ -void md_bitmap_daemon_work(struct mddev *mddev) +static void bitmap_daemon_work(struct bitmap *bitmap) { - struct bitmap *bitmap; + struct mddev *mddev = bitmap->mddev; unsigned long j; unsigned long nextpage; sector_t blocks; @@ -1304,13 +1304,8 @@ void md_bitmap_daemon_work(struct mddev *mddev) * bitmap_destroy. */ mutex_lock(&mddev->bitmap_info.mutex); - bitmap = mddev->bitmap; - if (bitmap == NULL) { - mutex_unlock(&mddev->bitmap_info.mutex); - return; - } - if (time_before(jiffies, bitmap->daemon_lastrun - + mddev->bitmap_info.daemon_sleep)) + if (time_before(jiffies, bitmap->daemon_lastrun + + mddev->bitmap_info.daemon_sleep)) goto done; bitmap->daemon_lastrun = jiffies; @@ -1780,11 +1775,11 @@ static void bitmap_flush(struct mddev *mddev) */ sleep = mddev->bitmap_info.daemon_sleep * 2; bitmap->daemon_lastrun -= sleep; - md_bitmap_daemon_work(mddev); + bitmap_daemon_work(bitmap); bitmap->daemon_lastrun -= sleep; - md_bitmap_daemon_work(mddev); + bitmap_daemon_work(bitmap); bitmap->daemon_lastrun -= sleep; - md_bitmap_daemon_work(mddev); + bitmap_daemon_work(bitmap); if (mddev->bitmap_info.external) md_super_wait(mddev); bitmap_update_sb(bitmap); diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 090d4f11f3cd..f67e030139cd 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -254,6 +254,7 @@ struct bitmap_operations { void (*close_sync)(struct bitmap *bitmap); void (*cond_end_sync)(struct bitmap *bitmap, sector_t sector, bool force); void (*wait_behind_writes)(struct bitmap *bitmap); + void (*daemon_work)(struct bitmap *bitmap); void (*update_sb)(struct bitmap *bitmap); int (*resize)(struct bitmap *bitmap, sector_t blocks, int chunksize, @@ -404,6 +405,14 @@ static inline void md_bitmap_wait_behind_writes(struct mddev *mddev) mddev->bitmap_ops->wait_behind_writes(mddev->bitmap); } +static inline void md_bitmap_daemon_work(struct mddev *mddev) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->daemon_work) + return; + + mddev->bitmap_ops->daemon_work(mddev->bitmap); +} + static inline int md_bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize, int init) { @@ -453,7 +462,6 @@ static inline void md_bitmap_free(struct mddev *mddev, struct bitmap *bitmap) void md_bitmap_unplug(struct bitmap *bitmap); void md_bitmap_unplug_async(struct bitmap *bitmap); -void md_bitmap_daemon_work(struct mddev *mddev); static inline bool md_bitmap_enabled(struct bitmap *bitmap) { From patchwork Sat Aug 10 02:08:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759359 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 42F6714D714; Sat, 10 Aug 2024 02:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255989; cv=none; b=oWLAd32326qw7ha+NtFnGHuf5cpcKhHPAEUWkbzYFV71g4dv/qil5f5VBxii0/hThk5i37/z9ecsCfxSZYVxdTO2QaNTEnTKdj7pPaNj8kBGNk40Wq6nwSUqDv/yCVqN0Ng3YQQun5vs4xpCYH+kooHGTAHAMTSpyiI4JBwMFic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255989; c=relaxed/simple; bh=l5Bz3tr9NCdwvggLxieDHElxo/QNBgZqBT4V6Jg3sfg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fG9Q4IJOx5AcpoFyxaz4B4kQZXB+OQSc/ucN2vCFAitbUg1VsFamWUvzpSiv5Q8ErWYXwrGTH3GHrWtmP+13J/C4oeWNDsdoB7drqMteiaZ+IGCBG+/Zz36UheCLjBTNl3L8gKnJu96s16tBmLEGR2wLahPjCha4OsxcMny8D+8= 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.56 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 dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Wgknq44JDz4f3jrq; Sat, 10 Aug 2024 10:12:47 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 14DA51A0568; Sat, 10 Aug 2024 10:13:01 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S29; Sat, 10 Aug 2024 10:13:00 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 25/26] md/md-bitmap: merge md_bitmap_unplug() and md_bitmap_unplug_async() Date: Sat, 10 Aug 2024 10:08:53 +0800 Message-Id: <20240810020854.797814-26-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S29 X-Coremail-Antispam: 1UD129KBjvJXoW3JFy7Xw1DGF4fCryUJr15CFg_yoW7WFWUpr 90q3s8CF45JFW3Xw1jyry2vF1Fv3Wvqr9rtry8Cw4ruFy3XF9xGF48GFWUtw1DCrnxCFs8 Zw15tr95GF4rWF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai Add a new paramater "bool sync" for md_bitmap_unplug(), and remove the exported md_bitmap_unplug_async(). Hence bitmap_operations only need one op to cover them. Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 23 +++++++++++++++-------- drivers/md/md-bitmap.h | 3 +-- drivers/md/md.c | 2 +- drivers/md/raid1-10.c | 5 +---- drivers/md/raid5.c | 2 +- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 4f3ea6e51572..b08476746350 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1030,7 +1030,7 @@ static int md_bitmap_file_test_bit(struct bitmap *bitmap, sector_t block) /* this gets called when the md device is ready to unplug its underlying * (slave) device queues -- before we let any writes go down, we need to * sync the dirty pages of the bitmap file to disk */ -void md_bitmap_unplug(struct bitmap *bitmap) +static void bitmap_unplug(struct bitmap *bitmap) { unsigned long i; int dirty, need_write; @@ -1062,7 +1062,6 @@ void md_bitmap_unplug(struct bitmap *bitmap) if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags)) md_bitmap_file_kick(bitmap); } -EXPORT_SYMBOL(md_bitmap_unplug); struct bitmap_unplug_work { struct work_struct work; @@ -1075,11 +1074,11 @@ static void md_bitmap_unplug_fn(struct work_struct *work) struct bitmap_unplug_work *unplug_work = container_of(work, struct bitmap_unplug_work, work); - md_bitmap_unplug(unplug_work->bitmap); + bitmap_unplug(unplug_work->bitmap); complete(unplug_work->done); } -void md_bitmap_unplug_async(struct bitmap *bitmap) +static void bitmap_unplug_async(struct bitmap *bitmap) { DECLARE_COMPLETION_ONSTACK(done); struct bitmap_unplug_work unplug_work; @@ -1091,7 +1090,15 @@ void md_bitmap_unplug_async(struct bitmap *bitmap) queue_work(md_bitmap_wq, &unplug_work.work); wait_for_completion(&done); } -EXPORT_SYMBOL(md_bitmap_unplug_async); + +void md_bitmap_unplug(struct bitmap *bitmap, bool sync) +{ + if (sync) + bitmap_unplug(bitmap); + else + bitmap_unplug_async(bitmap); +} +EXPORT_SYMBOL(md_bitmap_unplug); static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed); @@ -2060,9 +2067,9 @@ static int bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *low, for (i = 0; i < bitmap->storage.file_pages; i++) if (test_page_attr(bitmap, i, BITMAP_PAGE_PENDING)) set_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE); - md_bitmap_unplug(bitmap); + bitmap_unplug(bitmap); } - md_bitmap_unplug(mddev->bitmap); + bitmap_unplug(mddev->bitmap); *low = lo; *high = hi; __bitmap_free(bitmap); @@ -2296,7 +2303,7 @@ static int bitmap_resize(struct bitmap *bitmap, sector_t blocks, spin_unlock_irq(&bitmap->counts.lock); if (!init) { - md_bitmap_unplug(bitmap); + bitmap_unplug(bitmap); bitmap->mddev->pers->quiesce(bitmap->mddev, 0); } ret = 0; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index f67e030139cd..054e85c4a704 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -460,8 +460,7 @@ static inline void md_bitmap_free(struct mddev *mddev, struct bitmap *bitmap) return mddev->bitmap_ops->free(bitmap); } -void md_bitmap_unplug(struct bitmap *bitmap); -void md_bitmap_unplug_async(struct bitmap *bitmap); +void md_bitmap_unplug(struct bitmap *bitmap, bool sync); static inline bool md_bitmap_enabled(struct bitmap *bitmap) { diff --git a/drivers/md/md.c b/drivers/md/md.c index 841539a0be1b..2e6270c47317 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -4691,7 +4691,7 @@ bitmap_store(struct mddev *mddev, const char *buf, size_t len) md_bitmap_dirty_bits(mddev, chunk, end_chunk); buf = skip_spaces(end); } - md_bitmap_unplug(mddev->bitmap); /* flush the bits to disk */ + md_bitmap_unplug(mddev->bitmap, true); /* flush the bits to disk */ out: mddev_unlock(mddev); return len; diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c index 2ea1710a3b70..e8410d0cc96f 100644 --- a/drivers/md/raid1-10.c +++ b/drivers/md/raid1-10.c @@ -168,10 +168,7 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio, */ static inline void raid1_prepare_flush_writes(struct bitmap *bitmap) { - if (current->bio_list) - md_bitmap_unplug_async(bitmap); - else - md_bitmap_unplug(bitmap); + md_bitmap_unplug(bitmap, current->bio_list == NULL); } /* diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 8b1e2157a798..99332649bac3 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -6766,7 +6766,7 @@ static void raid5d(struct md_thread *thread) /* Now is a good time to flush some bitmap updates */ conf->seq_flush++; spin_unlock_irq(&conf->device_lock); - md_bitmap_unplug(mddev->bitmap); + md_bitmap_unplug(mddev->bitmap, true); spin_lock_irq(&conf->device_lock); conf->seq_write = conf->seq_flush; activate_bit_delay(conf, conf->temp_inactive_list); From patchwork Sat Aug 10 02:08:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13759352 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 20F4A1459FC; Sat, 10 Aug 2024 02:13:04 +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=1723255986; cv=none; b=IKHoliUvkllVx8dctAlx4/FatPz668Ug7vxBGPGaKEOJE9V59mb66BEhBWl6ZpSYkiRISQezAdFt+/iTNpMra3X4W5R5Nj7f5JxCKU/1DTfEtBSl9e0rL/NQNEJFeXAwEo7DPj1KKp5sQjNaa1y0LDt42ogULbozs7loRu5MzYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723255986; c=relaxed/simple; bh=C22l+sN+EahvZitAw6Nos0NBz1atzmQNuIhYxDl+K3U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PYRcKDU4OhPYZjGa3EzZZYxLgxxCmev5YH25xImhZ9p4+L4RvlWjAQzEUeBEYUYHwPeDQcJMfBE1HxmPR/Rfr/8gBl3ClXnhh99nAhS67CwrwwjBL/2L/If16GFSRDiEZKPqH9CoI9/ai/LHMjEPz6bEci4leY2vK28HJAqgwT0= 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.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Wgknw1cM8z4f3jk0; Sat, 10 Aug 2024 10:12:52 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 5A32B1A15A6; Sat, 10 Aug 2024 10:13:01 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHL4WizLZmErwLBQ--.1937S30; Sat, 10 Aug 2024 10:13:01 +0800 (CST) From: Yu Kuai To: song@kernel.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC -next 26/26] md/md-bitmap: merge bitmap_unplug() into bitmap_operations Date: Sat, 10 Aug 2024 10:08:54 +0800 Message-Id: <20240810020854.797814-27-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240810020854.797814-1-yukuai1@huaweicloud.com> References: <20240810020854.797814-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: gCh0CgAHL4WizLZmErwLBQ--.1937S30 X-Coremail-Antispam: 1UD129KBjvJXoW3Gr18tr1rur1fGryxWFyUZFb_yoW3Jw4Up3 yUta45CF45JFW3Xw1DArZruF1Fq3WktF9rtryfCwn5uF17Xr9xGF4rGFyUtw1DAr13JFs8 Aw45trykGF1UXF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai Signed-off-by: Yu Kuai --- drivers/md/md-bitmap.c | 16 ++++++++-------- drivers/md/md-bitmap.h | 11 +++++++++-- drivers/md/md.c | 2 +- drivers/md/raid1-10.c | 4 ++-- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 4 ++-- drivers/md/raid5.c | 2 +- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index b08476746350..449556124d0e 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1030,7 +1030,7 @@ static int md_bitmap_file_test_bit(struct bitmap *bitmap, sector_t block) /* this gets called when the md device is ready to unplug its underlying * (slave) device queues -- before we let any writes go down, we need to * sync the dirty pages of the bitmap file to disk */ -static void bitmap_unplug(struct bitmap *bitmap) +static void __bitmap_unplug(struct bitmap *bitmap) { unsigned long i; int dirty, need_write; @@ -1074,7 +1074,7 @@ static void md_bitmap_unplug_fn(struct work_struct *work) struct bitmap_unplug_work *unplug_work = container_of(work, struct bitmap_unplug_work, work); - bitmap_unplug(unplug_work->bitmap); + __bitmap_unplug(unplug_work->bitmap); complete(unplug_work->done); } @@ -1091,14 +1091,13 @@ static void bitmap_unplug_async(struct bitmap *bitmap) wait_for_completion(&done); } -void md_bitmap_unplug(struct bitmap *bitmap, bool sync) +static void bitmap_unplug(struct bitmap *bitmap, bool sync) { if (sync) - bitmap_unplug(bitmap); + __bitmap_unplug(bitmap); else bitmap_unplug_async(bitmap); } -EXPORT_SYMBOL(md_bitmap_unplug); static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed); @@ -2067,9 +2066,9 @@ static int bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *low, for (i = 0; i < bitmap->storage.file_pages; i++) if (test_page_attr(bitmap, i, BITMAP_PAGE_PENDING)) set_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE); - bitmap_unplug(bitmap); + __bitmap_unplug(bitmap); } - bitmap_unplug(mddev->bitmap); + __bitmap_unplug(mddev->bitmap); *low = lo; *high = hi; __bitmap_free(bitmap); @@ -2303,7 +2302,7 @@ static int bitmap_resize(struct bitmap *bitmap, sector_t blocks, spin_unlock_irq(&bitmap->counts.lock); if (!init) { - bitmap_unplug(bitmap); + __bitmap_unplug(bitmap); bitmap->mddev->pers->quiesce(bitmap->mddev, 0); } ret = 0; @@ -2706,6 +2705,7 @@ static struct bitmap_operations bitmap_ops = { .close_sync = bitmap_close_sync, .cond_end_sync = bitmap_cond_end_sync, .wait_behind_writes = bitmap_wait_behind_writes, + .unplug = bitmap_unplug, .update_sb = bitmap_update_sb, .resize = bitmap_resize, diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 054e85c4a704..9e9e328d675c 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -255,6 +255,7 @@ struct bitmap_operations { void (*cond_end_sync)(struct bitmap *bitmap, sector_t sector, bool force); void (*wait_behind_writes)(struct bitmap *bitmap); void (*daemon_work)(struct bitmap *bitmap); + void (*unplug)(struct bitmap *bitmap, bool sync); void (*update_sb)(struct bitmap *bitmap); int (*resize)(struct bitmap *bitmap, sector_t blocks, int chunksize, @@ -413,6 +414,14 @@ static inline void md_bitmap_daemon_work(struct mddev *mddev) mddev->bitmap_ops->daemon_work(mddev->bitmap); } +static inline void md_bitmap_unplug(struct mddev *mddev, bool sync) +{ + if (!mddev->bitmap && !mddev->bitmap_ops->unplug) + return; + + mddev->bitmap_ops->unplug(mddev->bitmap, sync); +} + static inline int md_bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize, int init) { @@ -460,8 +469,6 @@ static inline void md_bitmap_free(struct mddev *mddev, struct bitmap *bitmap) return mddev->bitmap_ops->free(bitmap); } -void md_bitmap_unplug(struct bitmap *bitmap, bool sync); - static inline bool md_bitmap_enabled(struct bitmap *bitmap) { return bitmap && bitmap->storage.filemap && diff --git a/drivers/md/md.c b/drivers/md/md.c index 2e6270c47317..8610b6fec263 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -4691,7 +4691,7 @@ bitmap_store(struct mddev *mddev, const char *buf, size_t len) md_bitmap_dirty_bits(mddev, chunk, end_chunk); buf = skip_spaces(end); } - md_bitmap_unplug(mddev->bitmap, true); /* flush the bits to disk */ + md_bitmap_unplug(mddev, true); /* flush the bits to disk */ out: mddev_unlock(mddev); return len; diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c index e8410d0cc96f..45b30f08f3a5 100644 --- a/drivers/md/raid1-10.c +++ b/drivers/md/raid1-10.c @@ -166,9 +166,9 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio, * while current io submission must wait for bitmap io to be done. In order to * avoid such deadlock, submit bitmap io asynchronously. */ -static inline void raid1_prepare_flush_writes(struct bitmap *bitmap) +static inline void raid1_prepare_flush_writes(struct mddev *mddev) { - md_bitmap_unplug(bitmap, current->bio_list == NULL); + md_bitmap_unplug(mddev, current->bio_list == NULL); } /* diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index fef69fce586c..4e8dd032a453 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -893,7 +893,7 @@ static void wake_up_barrier(struct r1conf *conf) static void flush_bio_list(struct r1conf *conf, struct bio *bio) { /* flush any pending bitmap writes to disk before proceeding w/ I/O */ - raid1_prepare_flush_writes(conf->mddev->bitmap); + raid1_prepare_flush_writes(conf->mddev); wake_up_barrier(conf); while (bio) { /* submit pending writes */ diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index a8a14cda8446..13f61e07d513 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -883,7 +883,7 @@ static void flush_pending_writes(struct r10conf *conf) __set_current_state(TASK_RUNNING); blk_start_plug(&plug); - raid1_prepare_flush_writes(conf->mddev->bitmap); + raid1_prepare_flush_writes(conf->mddev); wake_up(&conf->wait_barrier); while (bio) { /* submit pending writes */ @@ -1099,7 +1099,7 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule) /* we aren't scheduling, so we can do the write-out directly. */ bio = bio_list_get(&plug->pending); - raid1_prepare_flush_writes(mddev->bitmap); + raid1_prepare_flush_writes(mddev); wake_up_barrier(conf); while (bio) { /* submit pending writes */ diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 99332649bac3..0bb3608dd3c8 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -6766,7 +6766,7 @@ static void raid5d(struct md_thread *thread) /* Now is a good time to flush some bitmap updates */ conf->seq_flush++; spin_unlock_irq(&conf->device_lock); - md_bitmap_unplug(mddev->bitmap, true); + md_bitmap_unplug(mddev, true); spin_lock_irq(&conf->device_lock); conf->seq_write = conf->seq_flush; activate_bit_delay(conf, conf->temp_inactive_list);