From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5C82B214205; Tue, 8 Apr 2025 11:10:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744110624; cv=none; b=rO2KXAiU39pIzEn+QJv1yjckm4GoEtdyYXvu3Ijhxc6x4ZAbjSruia7DYXbhA/HpNLRA0W9xmiHjFW60Ot+VQNxkq3OUa4bvuh+4UNfoCMfdqE+fdZHzl07aQ5Tn40kUL+pfpzsoClVEy45LDMr1lmvMHOW0/5j4i1Oqrc+GVW8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744110624; c=relaxed/simple; bh=BaV3fvVKNprk34VrtoCZL0yylX5BcyGj8xUfG2aBtw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ei+EFP8VkYeSLl8kkXrRtJKWVi36tiIkLkDsLN4ML+pZnPzZj8k0uVcdQ5v/MJngWsBDYiFQiDXk6Vz5LxA6VpRIMStBUwD9PHFtP5T0fWGYf+iK7bXTQIemK7suBQBlTRxXiwzxjmX1uUX1Ng47NmQ0HZJMBZvwL1UNjrtu6Dk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=M5N+GRNI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="M5N+GRNI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2364C4CEE5; Tue, 8 Apr 2025 11:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744110624; bh=BaV3fvVKNprk34VrtoCZL0yylX5BcyGj8xUfG2aBtw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M5N+GRNI16pdj+2LxUBnvGt3/7SQt1qhClQRKnTtStKIdZK9gMTMZa/W86xahY47e fYyOA1w8qaDytUg8oirxELZEVBRlGnUeLyz0y1TUIlAxUlYBQXA6FEg7io3X+ldEQ5 iVmucrHsloPdWUKuHnGBzrBPn8z7o5JOuHz7+ULU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Su Yue , Heming Zhao , Yu Kuai , Sasha Levin Subject: [PATCH 6.14 134/731] md/md-bitmap: fix wrong bitmap_limit for clustermd when write sb Date: Tue, 8 Apr 2025 12:40:31 +0200 Message-ID: <20250408104917.395423893@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104914.247897328@linuxfoundation.org> References: <20250408104914.247897328@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Su Yue [ Upstream commit 6130825f34d41718c98a9b1504a79a23e379701e ] In clustermd, separate write-intent-bitmaps are used for each cluster node: 0 4k 8k 12k ------------------------------------------------------------------- | idle | md super | bm super [0] + bits | | bm bits[0, contd] | bm super[1] + bits | bm bits[1, contd] | | bm super[2] + bits | bm bits [2, contd] | bm super[3] + bits | | bm bits [3, contd] | | | So in node 1, pg_index in __write_sb_page() could equal to bitmap->storage.file_pages. Then bitmap_limit will be calculated to 0. md_super_write() will be called with 0 size. That means the first 4k sb area of node 1 will never be updated through filemap_write_page(). This bug causes hang of mdadm/clustermd_tests/01r1_Grow_resize. Here use (pg_index % bitmap->storage.file_pages) to make calculation of bitmap_limit correct. Fixes: ab99a87542f1 ("md/md-bitmap: fix writing non bitmap pages") Signed-off-by: Su Yue Reviewed-by: Heming Zhao Link: https://lore.kernel.org/linux-raid/20250303033918.32136-1-glass.su@suse.com Signed-off-by: Yu Kuai Signed-off-by: Sasha Levin --- drivers/md/md-bitmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 23c09d22fcdbc..9ae6cc8e30cbd 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -426,8 +426,8 @@ static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap, struct block_device *bdev; struct mddev *mddev = bitmap->mddev; struct bitmap_storage *store = &bitmap->storage; - unsigned int bitmap_limit = (bitmap->storage.file_pages - pg_index) << - PAGE_SHIFT; + unsigned long num_pages = bitmap->storage.file_pages; + unsigned int bitmap_limit = (num_pages - pg_index % num_pages) << PAGE_SHIFT; loff_t sboff, offset = mddev->bitmap_info.offset; sector_t ps = pg_index * PAGE_SIZE / SECTOR_SIZE; unsigned int size = PAGE_SIZE; @@ -436,7 +436,7 @@ static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap, bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev; /* we compare length (page numbers), not page offset. */ - if ((pg_index - store->sb_index) == store->file_pages - 1) { + if ((pg_index - store->sb_index) == num_pages - 1) { unsigned int last_page_size = store->bytes & (PAGE_SIZE - 1); if (last_page_size == 0) -- 2.39.5