From nobody Fri Jan 31 00:17:13 2025 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 5CCD31FBEB2; Mon, 27 Jan 2025 08:58:20 +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=1737968302; cv=none; b=nVK6LrMnDaMwxTwFYNSq7/QCShFOWOUlgthKTbzfLKP/w6+Sg6oKiZ5lBtgtBJ+Py4riFKcWpKT3zHQEeJAM0TxPGAfnRHInzKvJQFRKDkbQsYKAf4b3qQp+7QR8tsg0Gj7fjetxmX2VBCNnlzKHGX3MDO3ubJsvCVPnQWVs4Ms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737968302; c=relaxed/simple; bh=bqK8/2W54ozkCNWlbMzlicFfBQII9J/DaLScdZ9tgXo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=I6icCQH8Z0ViXop2uPZYp4x5zOJgT33eeQI5nQ0kS0INU8O2ikS0dPzQyS759aznqW++Viv+0k2uvoHKQDDWlbtaYH6ISjDqzEHIS+ZjJ+U4s9XDyQRE1CRvQQ+dp2xS+pRaMTTSq3/0Lp0kvDjLUwUredTCN66wnQeur8iftvQ= 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 4YhMkr4bDDz4f3jR6; Mon, 27 Jan 2025 16:57:56 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 6EFF71A14CE; Mon, 27 Jan 2025 16:58:17 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAXe1+mSpdnShB+CA--.53281S8; Mon, 27 Jan 2025 16:58:17 +0800 (CST) From: Yu Kuai To: stable@vger.kernel.org, gregkh@linuxfoundation.org, song@kernel.org, yukuai3@huawei.com Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH 6.12 4/5] md/raid5: implement pers->bitmap_sector() Date: Mon, 27 Jan 2025 16:52:13 +0800 Message-Id: <20250127085214.3197761-5-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250127085214.3197761-1-yukuai1@huaweicloud.com> References: <20250127085214.3197761-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: gCh0CgAXe1+mSpdnShB+CA--.53281S8 X-Coremail-Antispam: 1UD129KBjvJXoWxWry5Kr1xCFWDZw47Ar45trb_yoWrJw4kpa nFvrWagrWYqrnxWwsxJw1kuF4rta93Cw47JFW3WwsYg3W7GrWkZ3W8t3W5Zr1UCrWfJr90 yw15AFW8CF4qgFDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVW8ZV WrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJw CI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjTR_nYFDUUU U X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai commit 9c89f604476cf15c31fbbdb043cff7fbf1dbe0cb upstream. Bitmap is used for the whole array for raid1/raid10, hence IO for the array can be used directly for bitmap. However, bitmap is used for underlying disks for raid5, hence IO for the array can't be used directly for bitmap. Implement pers->bitmap_sector() for raid5 to convert IO ranges from the array to the underlying disks. Signed-off-by: Yu Kuai Link: https://lore.kernel.org/r/20250109015145.158868-5-yukuai1@huaweicloud= .com Signed-off-by: Song Liu --- drivers/md/raid5.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 4482e1b1e4e3..7049960f4357 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -5919,6 +5919,54 @@ static enum reshape_loc get_reshape_loc(struct mddev= *mddev, return LOC_BEHIND_RESHAPE; } =20 +static void raid5_bitmap_sector(struct mddev *mddev, sector_t *offset, + unsigned long *sectors) +{ + struct r5conf *conf =3D mddev->private; + sector_t start =3D *offset; + sector_t end =3D start + *sectors; + sector_t prev_start =3D start; + sector_t prev_end =3D end; + int sectors_per_chunk; + enum reshape_loc loc; + int dd_idx; + + sectors_per_chunk =3D conf->chunk_sectors * + (conf->raid_disks - conf->max_degraded); + start =3D round_down(start, sectors_per_chunk); + end =3D round_up(end, sectors_per_chunk); + + start =3D raid5_compute_sector(conf, start, 0, &dd_idx, NULL); + end =3D raid5_compute_sector(conf, end, 0, &dd_idx, NULL); + + /* + * For LOC_INSIDE_RESHAPE, this IO will wait for reshape to make + * progress, hence it's the same as LOC_BEHIND_RESHAPE. + */ + loc =3D get_reshape_loc(mddev, conf, prev_start); + if (likely(loc !=3D LOC_AHEAD_OF_RESHAPE)) { + *offset =3D start; + *sectors =3D end - start; + return; + } + + sectors_per_chunk =3D conf->prev_chunk_sectors * + (conf->previous_raid_disks - conf->max_degraded); + prev_start =3D round_down(prev_start, sectors_per_chunk); + prev_end =3D round_down(prev_end, sectors_per_chunk); + + prev_start =3D raid5_compute_sector(conf, prev_start, 1, &dd_idx, NULL); + prev_end =3D raid5_compute_sector(conf, prev_end, 1, &dd_idx, NULL); + + /* + * for LOC_AHEAD_OF_RESHAPE, reshape can make progress before this IO + * is handled in make_stripe_request(), we can't know this here hence + * we set bits for both. + */ + *offset =3D min(start, prev_start); + *sectors =3D max(end, prev_end) - *offset; +} + static enum stripe_result make_stripe_request(struct mddev *mddev, struct r5conf *conf, struct stripe_request_ctx *ctx, sector_t logical_sector, struct bio *bi) @@ -8967,6 +9015,7 @@ static struct md_personality raid6_personality =3D .takeover =3D raid6_takeover, .change_consistency_policy =3D raid5_change_consistency_policy, .prepare_suspend =3D raid5_prepare_suspend, + .bitmap_sector =3D raid5_bitmap_sector, }; static struct md_personality raid5_personality =3D { @@ -8992,6 +9041,7 @@ static struct md_personality raid5_personality =3D .takeover =3D raid5_takeover, .change_consistency_policy =3D raid5_change_consistency_policy, .prepare_suspend =3D raid5_prepare_suspend, + .bitmap_sector =3D raid5_bitmap_sector, }; =20 static struct md_personality raid4_personality =3D @@ -9018,6 +9068,7 @@ static struct md_personality raid4_personality =3D .takeover =3D raid4_takeover, .change_consistency_policy =3D raid5_change_consistency_policy, .prepare_suspend =3D raid5_prepare_suspend, + .bitmap_sector =3D raid5_bitmap_sector, }; =20 static int __init raid5_init(void) --=20 2.39.2