aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorWei Yang <richardw.yang@linux.intel.com>2019-10-13 10:11:45 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2019-10-26 15:38:06 +0200
commit038adc2f5850e32019bda06c559d0301be436eae (patch)
tree9eea94c77ab858c6f288121ef1a42796d0b25b9d /block
parent5608956575088554f7612b716916efafae46187c (diff)
downloadqemu-038adc2f5850e32019bda06c559d0301be436eae.zip
qemu-038adc2f5850e32019bda06c559d0301be436eae.tar.gz
qemu-038adc2f5850e32019bda06c559d0301be436eae.tar.bz2
core: replace getpagesize() with qemu_real_host_page_size
There are three page size in qemu: real host page size host page size target page size All of them have dedicate variable to represent. For the last two, we use the same form in the whole qemu project, while for the first one we use two forms: qemu_real_host_page_size and getpagesize(). qemu_real_host_page_size is defined to be a replacement of getpagesize(), so let it serve the role. [Note] Not fully tested for some arch or device. Signed-off-by: Wei Yang <richardw.yang@linux.intel.com> Message-Id: <20191013021145.16011-3-richardw.yang@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/file-posix.c9
-rw-r--r--block/io.c2
-rw-r--r--block/parallels.c2
-rw-r--r--block/qcow2-cache.c2
4 files changed, 8 insertions, 7 deletions
diff --git a/block/file-posix.c b/block/file-posix.c
index 695fcf7..5d1995a 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -327,7 +327,7 @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
{
BDRVRawState *s = bs->opaque;
char *buf;
- size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize());
+ size_t max_align = MAX(MAX_BLOCKSIZE, qemu_real_host_page_size);
size_t alignments[] = {1, 512, 1024, 2048, 4096};
/* For SCSI generic devices the alignment is not really used.
@@ -1136,13 +1136,14 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
ret = sg_get_max_segments(s->fd);
if (ret > 0) {
- bs->bl.max_transfer = MIN(bs->bl.max_transfer, ret * getpagesize());
+ bs->bl.max_transfer = MIN(bs->bl.max_transfer,
+ ret * qemu_real_host_page_size);
}
}
raw_probe_alignment(bs, s->fd, errp);
bs->bl.min_mem_alignment = s->buf_align;
- bs->bl.opt_mem_alignment = MAX(s->buf_align, getpagesize());
+ bs->bl.opt_mem_alignment = MAX(s->buf_align, qemu_real_host_page_size);
}
static int check_for_dasd(int fd)
@@ -1705,7 +1706,7 @@ static int allocate_first_block(int fd, size_t max_size)
size_t write_size = (max_size < MAX_BLOCKSIZE)
? BDRV_SECTOR_SIZE
: MAX_BLOCKSIZE;
- size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize());
+ size_t max_align = MAX(MAX_BLOCKSIZE, qemu_real_host_page_size);
void *buf;
ssize_t n;
int ret;
diff --git a/block/io.c b/block/io.c
index f0b86c1..e46d9e8 100644
--- a/block/io.c
+++ b/block/io.c
@@ -160,7 +160,7 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
bdrv_merge_limits(&bs->bl, &bs->file->bs->bl);
} else {
bs->bl.min_mem_alignment = 512;
- bs->bl.opt_mem_alignment = getpagesize();
+ bs->bl.opt_mem_alignment = qemu_real_host_page_size;
/* Safe default since most protocols use readv()/writev()/etc */
bs->bl.max_iov = IOV_MAX;
diff --git a/block/parallels.c b/block/parallels.c
index 7cd2714..f1dfb03 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -847,7 +847,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
}
}
- s->bat_dirty_block = 4 * getpagesize();
+ s->bat_dirty_block = 4 * qemu_real_host_page_size;
s->bat_dirty_bmap =
bitmap_new(DIV_ROUND_UP(s->header_size, s->bat_dirty_block));
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
index d29b038..7444b9c 100644
--- a/block/qcow2-cache.c
+++ b/block/qcow2-cache.c
@@ -74,7 +74,7 @@ static void qcow2_cache_table_release(Qcow2Cache *c, int i, int num_tables)
/* Using MADV_DONTNEED to discard memory is a Linux-specific feature */
#ifdef CONFIG_LINUX
void *t = qcow2_cache_get_table_addr(c, i);
- int align = getpagesize();
+ int align = qemu_real_host_page_size;
size_t mem_size = (size_t) c->table_size * num_tables;
size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t;
size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align);