Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 698

kernel-2.6.18-238.el5.src.rpm

From: Milan Broz <mbroz@redhat.com>
Date: Mon, 23 Jun 2008 19:29:57 +0200
Subject: [dm] snapshot: fix chunksize sector conversion
Message-id: 485FDD95.8030200@redhat.com
O-Subject: [RHEL 5.3 PATCH] dm: snapshot: fix chunksize sector conversion (rhbz#443627)
Bugzilla: 443627
RH-Acked-by: Alasdair G Kergon <agk@redhat.com>
RH-Acked-by: John Feeney <jfeeney@redhat.com>
RH-Acked-by: Jeff Moyer <jmoyer@redhat.com>

RHEL5.3 dm: snapshot: fix chunksize sector conversion
Resolves: rhbz#443627

Patch is upstream, commit 924362629bf5645aee5f49f8a0d0d5b193e65997

If a snapshot has a smaller chunksize than the page size the
conversion to pages currently returns 0 instead of 1, causing:
kernel BUG in mempool_resize.

This can happen if physical block device with lvm2 snapshot
created on different architecture is moved to system with
bigger page (reproducer in bugzilla).

Kernel with patch compiled and tested.

diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index 409e08d..feb3ce3 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -128,7 +128,7 @@ struct pstore {
 
 static inline unsigned int sectors_to_pages(unsigned int sectors)
 {
-	return sectors / (PAGE_SIZE >> 9);
+	return DIV_ROUND_UP(sectors, PAGE_SIZE >> 9);
 }
 
 static int alloc_area(struct pstore *ps)