1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

round readahead to multiple of page size in tools

This commit is contained in:
Alasdair Kergon 2007-12-05 19:24:32 +00:00
parent de4ddace2e
commit 9b6135dca4
3 changed files with 21 additions and 3 deletions

View File

@ -952,10 +952,10 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
max_stripe_size = seg->stripe_size;
}
if (read_ahead == DM_READ_AHEAD_AUTO)
if (read_ahead == DM_READ_AHEAD_AUTO) {
read_ahead = max_stripe_size;
else
read_ahead_flags = DM_READ_AHEAD_MINIMUM_FLAG;
}
dm_tree_node_set_read_ahead(dnode, read_ahead, read_ahead_flags);

View File

@ -372,6 +372,7 @@ static int lvchange_readahead(struct cmd_context *cmd,
struct logical_volume *lv)
{
unsigned read_ahead = 0;
unsigned pagesize = (unsigned) lvm_getpagesize() >> SECTOR_SHIFT;
read_ahead = arg_uint_value(cmd, readahead_ARG, 0);
@ -382,6 +383,13 @@ static int lvchange_readahead(struct cmd_context *cmd,
return 0;
}
if (read_ahead != DM_READ_AHEAD_AUTO &&
read_ahead != DM_READ_AHEAD_NONE && read_ahead % pagesize) {
read_ahead = (read_ahead / pagesize) * pagesize;
log_verbose("Rounding down readahead to %u sectors, a multiple "
"of page size %u.", read_ahead, pagesize);
}
if (lv->read_ahead == read_ahead) {
log_error("Read ahead is already %u for \"%s\"",
read_ahead, lv->name);

View File

@ -333,6 +333,7 @@ static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
int argc, char **argv)
{
int contiguous;
unsigned pagesize;
memset(lp, 0, sizeof(*lp));
@ -462,8 +463,17 @@ static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
/*
* Read ahead.
*/
if (arg_count(cmd, readahead_ARG))
if (arg_count(cmd, readahead_ARG)) {
lp->read_ahead = arg_uint_value(cmd, readahead_ARG, 0);
pagesize = lvm_getpagesize() >> SECTOR_SHIFT;
if (lp->read_ahead != DM_READ_AHEAD_AUTO &&
lp->read_ahead != DM_READ_AHEAD_NONE &&
lp->read_ahead % pagesize) {
lp->read_ahead = (lp->read_ahead / pagesize) * pagesize;
log_verbose("Rounding down readahead to %u sectors, a multiple "
"of page size %u.", lp->read_ahead, pagesize);
}
}
/*
* Permissions.