1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-04-01 18:50:41 +03:00

hardsect/blksize handling

This commit is contained in:
Alasdair Kergon 2001-09-19 17:46:27 +00:00
parent 633b68b518
commit 76fa6c5cfb
5 changed files with 19 additions and 6 deletions

View File

@ -94,7 +94,7 @@ static int linear_ctr(struct dm_table *t, offset_t b, offset_t l,
lc->delta = (int) start - (int) b;
hardsect_size = get_hardsect_size(lc->rdev);
if (t->hardsect_size > hardsect_size);
if (t->hardsect_size > hardsect_size)
t->hardsect_size = hardsect_size;
*result = lc;

View File

@ -108,6 +108,14 @@ struct dm_table *dm_parse(extract_line_fn line_fn, void *l_private,
e_private);
PARSE_ERROR;
}
/* Ensure sane block size */
if (table->blksize_size < table->hardsect_size) {
err_fn("block size smaller than hardsect size",
e_private);
PARSE_ERROR;
}
}
#undef PARSE_ERROR

View File

@ -131,9 +131,13 @@ struct dm_table *dm_table_create(void)
atomic_set(&t->pending, 0);
init_waitqueue_head(&t->wait);
t->hardsect_size = PAGE_CACHE_SIZE;
/* FIXME: Let this be specified/changed */
t->blksize_size = BLOCK_SIZE;
/* allocate a single nodes worth of targets to
begin with */
t->hardsect_size = PAGE_CACHE_SIZE;
if (alloc_targets(t, KEYS_PER_NODE)) {
kfree(t);
t = 0;

View File

@ -177,8 +177,8 @@ static int dm_blk_close(struct inode *inode, struct file *file)
return 0;
}
#define VOLUME_SIZE(minor) ((_block_size[(minor)] << 10) / \
_hardsect_size[(minor)])
/* In 512-byte units */
#define VOLUME_SIZE(minor) (_block_size[(minor)] >> 1)
static int dm_blk_ioctl(struct inode *inode, struct file *file,
uint command, ulong a)
@ -692,10 +692,10 @@ void __bind(struct mapped_device *md, struct dm_table *t)
md->map = t;
/* In 1024-byte units */
_block_size[minor] = (t->highs[t->num_targets - 1] + 1) >> 1;
/* FIXME: block size depends on the mapping table */
_blksize_size[minor] = BLOCK_SIZE;
_blksize_size[minor] = t->blksize_size;
_hardsect_size[minor] = t->hardsect_size;
register_disk(NULL, md->dev, 1, &dm_blk_dops, _block_size[minor]);
}

View File

@ -174,6 +174,7 @@ struct dm_table {
int counts[MAX_DEPTH]; /* in nodes */
offset_t *index[MAX_DEPTH];
int blksize_size;
int hardsect_size;
int num_targets;
int num_allocated;