blob: c678204a1b936a179182e3090aec1206f924cea1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# HG changeset patch
# User hirofuchi
# Date 1393586078 -32400
# Node ID 34a08647f2e40d22960d8cb1de718a4391c15f3b
# Parent 93c3b58d3df2ea3f361779dad61240e9381f0bf4
make the requirement of CBLOCKSIZE clear
CBLOCKSIZE must be a power of 2. 1024 or 8192 should be possible, which is not equal to PAGESIZE.
diff --git a/xnbd_common.c b/trunk/xnbd_common.c
--- a/xnbd_common.c
+++ b/xnbd_common.c
@@ -25,6 +25,13 @@
#include "xnbd_common.h"
+/*
+ * CBLOCKSIZE must be a power of 2, because bit operations are used in
+ * mmap_block_region functions. There is an assertion to check this in main()
+ * of xnbd-server.
+ *
+ * 1024 or 8192, which is different from the page size, is also possible, but not well tested.
+ **/
const unsigned int CBLOCKSIZE = 4096;
unsigned int PAGESIZE = 4096;
diff --git a/xnbd_server.c b/trunk/xnbd_server.c
--- a/xnbd_server.c
+++ b/xnbd_server.c
@@ -1060,10 +1060,9 @@
xnbd_initialize(&xnbd);
+ /* must be a power of 2 */
+ g_assert((CBLOCKSIZE & (CBLOCKSIZE - 1)) == 0);
- PAGESIZE = (unsigned int) getpagesize();
- if (CBLOCKSIZE % PAGESIZE != 0)
- warn("CBLOCKSIZE %u PAGESIZE %u", CBLOCKSIZE, PAGESIZE);
if (xnbd.cmd == xnbd_cmd_proxy)
cachestat_initialize(DEFAULT_CACHESTAT_PATH, xnbd.nblocks);
|