mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 07:00:48 +00:00
[PATCH] dm mirror log: sector size fix
On-disk logs for dm-mirror devices are currently hard-coded to use 512 byte hard-sector-sizes. This patch fixes dm-log so it will work with devices with non-512-byte hard-sector-sizes. To maintain full compatibility, instead of moving the clean-bits bitset to a bitset, and enlarges the disk-header buffer to encompass both the header and the bitset. The I/O routines for the bitset are removed, and the I/O routines for the disk-header now also read/write the bitset. Signed-off-by: Kevin Corry <kevcorry@us.ibm.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
143535396c
commit
702ca6f0be
@ -155,8 +155,6 @@ struct log_c {
|
|||||||
|
|
||||||
struct io_region header_location;
|
struct io_region header_location;
|
||||||
struct log_header *disk_header;
|
struct log_header *disk_header;
|
||||||
|
|
||||||
struct io_region bits_location;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -240,29 +238,6 @@ static inline int write_header(struct log_c *log)
|
|||||||
log->disk_header, &ebits);
|
log->disk_header, &ebits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------
|
|
||||||
* Bits IO
|
|
||||||
*--------------------------------------------------------------*/
|
|
||||||
static int read_bits(struct log_c *log)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
unsigned long ebits;
|
|
||||||
|
|
||||||
r = dm_io_sync_vm(1, &log->bits_location, READ,
|
|
||||||
log->clean_bits, &ebits);
|
|
||||||
if (r)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int write_bits(struct log_c *log)
|
|
||||||
{
|
|
||||||
unsigned long ebits;
|
|
||||||
return dm_io_sync_vm(1, &log->bits_location, WRITE,
|
|
||||||
log->clean_bits, &ebits);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------
|
/*----------------------------------------------------------------
|
||||||
* core log constructor/destructor
|
* core log constructor/destructor
|
||||||
*
|
*
|
||||||
@ -373,9 +348,10 @@ static int disk_ctr(struct dirty_log *log, struct dm_target *ti,
|
|||||||
unsigned int argc, char **argv)
|
unsigned int argc, char **argv)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
size_t size;
|
size_t size, bitset_size;
|
||||||
struct log_c *lc;
|
struct log_c *lc;
|
||||||
struct dm_dev *dev;
|
struct dm_dev *dev;
|
||||||
|
uint32_t *clean_bits;
|
||||||
|
|
||||||
if (argc < 2 || argc > 3) {
|
if (argc < 2 || argc > 3) {
|
||||||
DMWARN("wrong number of arguments to disk mirror log");
|
DMWARN("wrong number of arguments to disk mirror log");
|
||||||
@ -399,23 +375,26 @@ static int disk_ctr(struct dirty_log *log, struct dm_target *ti,
|
|||||||
/* setup the disk header fields */
|
/* setup the disk header fields */
|
||||||
lc->header_location.bdev = lc->log_dev->bdev;
|
lc->header_location.bdev = lc->log_dev->bdev;
|
||||||
lc->header_location.sector = 0;
|
lc->header_location.sector = 0;
|
||||||
lc->header_location.count = 1;
|
|
||||||
|
|
||||||
/*
|
/* Include both the header and the bitset in one buffer. */
|
||||||
* We can't read less than this amount, even though we'll
|
bitset_size = lc->bitset_uint32_count * sizeof(uint32_t);
|
||||||
* not be using most of this space.
|
size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + bitset_size,
|
||||||
*/
|
ti->limits.hardsect_size);
|
||||||
lc->disk_header = vmalloc(1 << SECTOR_SHIFT);
|
lc->header_location.count = size >> SECTOR_SHIFT;
|
||||||
|
|
||||||
|
lc->disk_header = vmalloc(size);
|
||||||
if (!lc->disk_header)
|
if (!lc->disk_header)
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
/* setup the disk bitset fields */
|
/*
|
||||||
lc->bits_location.bdev = lc->log_dev->bdev;
|
* Deallocate the clean_bits buffer that was allocated in core_ctr()
|
||||||
lc->bits_location.sector = LOG_OFFSET;
|
* and point it at the appropriate place in the disk_header buffer.
|
||||||
|
*/
|
||||||
|
clean_bits = lc->clean_bits;
|
||||||
|
lc->clean_bits = (void *)lc->disk_header + (LOG_OFFSET << SECTOR_SHIFT);
|
||||||
|
memcpy(lc->clean_bits, clean_bits, bitset_size);
|
||||||
|
vfree(clean_bits);
|
||||||
|
|
||||||
size = dm_round_up(lc->bitset_uint32_count * sizeof(uint32_t),
|
|
||||||
1 << SECTOR_SHIFT);
|
|
||||||
lc->bits_location.count = size >> SECTOR_SHIFT;
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
@ -429,6 +408,7 @@ static void disk_dtr(struct dirty_log *log)
|
|||||||
struct log_c *lc = (struct log_c *) log->context;
|
struct log_c *lc = (struct log_c *) log->context;
|
||||||
dm_put_device(lc->ti, lc->log_dev);
|
dm_put_device(lc->ti, lc->log_dev);
|
||||||
vfree(lc->disk_header);
|
vfree(lc->disk_header);
|
||||||
|
lc->clean_bits = NULL;
|
||||||
core_dtr(log);
|
core_dtr(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,11 +434,6 @@ static int disk_resume(struct dirty_log *log)
|
|||||||
if (r)
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
/* read the bits */
|
|
||||||
r = read_bits(lc);
|
|
||||||
if (r)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
/* set or clear any new bits */
|
/* set or clear any new bits */
|
||||||
if (lc->sync == NOSYNC)
|
if (lc->sync == NOSYNC)
|
||||||
for (i = lc->header.nr_regions; i < lc->region_count; i++)
|
for (i = lc->header.nr_regions; i < lc->region_count; i++)
|
||||||
@ -473,11 +448,6 @@ static int disk_resume(struct dirty_log *log)
|
|||||||
memcpy(lc->sync_bits, lc->clean_bits, size);
|
memcpy(lc->sync_bits, lc->clean_bits, size);
|
||||||
lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count);
|
lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count);
|
||||||
|
|
||||||
/* write the bits */
|
|
||||||
r = write_bits(lc);
|
|
||||||
if (r)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
/* set the correct number of regions in the header */
|
/* set the correct number of regions in the header */
|
||||||
lc->header.nr_regions = lc->region_count;
|
lc->header.nr_regions = lc->region_count;
|
||||||
|
|
||||||
@ -518,7 +488,7 @@ static int disk_flush(struct dirty_log *log)
|
|||||||
if (!lc->touched)
|
if (!lc->touched)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = write_bits(lc);
|
r = write_header(lc);
|
||||||
if (!r)
|
if (!r)
|
||||||
lc->touched = 0;
|
lc->touched = 0;
|
||||||
|
|
||||||
|
@ -1220,7 +1220,7 @@ static int mirror_status(struct dm_target *ti, status_type_t type,
|
|||||||
|
|
||||||
static struct target_type mirror_target = {
|
static struct target_type mirror_target = {
|
||||||
.name = "mirror",
|
.name = "mirror",
|
||||||
.version = {1, 0, 1},
|
.version = {1, 0, 2},
|
||||||
.module = THIS_MODULE,
|
.module = THIS_MODULE,
|
||||||
.ctr = mirror_ctr,
|
.ctr = mirror_ctr,
|
||||||
.dtr = mirror_dtr,
|
.dtr = mirror_dtr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user