[sheepdog] [PATCH 3/4] collie: don't round_up vdi size & read/write
Liu Yuan
namei.unix at gmail.com
Wed May 22 10:36:06 CEST 2013
Openstack Glance doesn't assume the size will be rounded up. We don't need block
uint constraint, it is no harm to support random read/write on the sheepdog vdi
on the byte granularity.
With removing the sector constraint, we'll get a better file-like abstraction to
store arbitrary length objects.
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
collie/vdi.c | 12 +-----------
sheep/plain_store.c | 4 ++++
2 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/collie/vdi.c b/collie/vdi.c
index ccc4e04..7dea4f3 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -523,7 +523,7 @@ int do_vdi_create(const char *vdiname, int64_t vdi_size,
hdr.vdi.base_vdi_id = base_vid;
hdr.vdi.snapid = snapshot ? 1 : 0;
- hdr.vdi.vdi_size = round_up(vdi_size, 512);
+ hdr.vdi.vdi_size = vdi_size;
hdr.vdi.copies = nr_copies;
ret = collie_exec_req(sdhost, sdport, &hdr, buf);
@@ -1187,10 +1187,6 @@ static int vdi_read(int argc, char **argv)
ret = parse_option_size(argv[optind++], &offset);
if (ret < 0)
return EXIT_USAGE;
- if (offset % 512 != 0) {
- fprintf(stderr, "Read offset must be block-aligned\n");
- return EXIT_USAGE;
- }
if (argv[optind]) {
ret = parse_option_size(argv[optind++], &total);
if (ret < 0)
@@ -1214,7 +1210,6 @@ static int vdi_read(int argc, char **argv)
}
total = min(total, inode->vdi_size - offset);
- total = round_up(total, 512);
idx = offset / SD_DATA_OBJ_SIZE;
offset %= SD_DATA_OBJ_SIZE;
while (done < total) {
@@ -1270,10 +1265,6 @@ static int vdi_write(int argc, char **argv)
ret = parse_option_size(argv[optind++], &offset);
if (ret < 0)
return EXIT_USAGE;
- if (offset % 512 != 0) {
- fprintf(stderr, "Write offset must be block-aligned\n");
- return EXIT_USAGE;
- }
if (argv[optind]) {
ret = parse_option_size(argv[optind++], &total);
if (ret < 0)
@@ -1295,7 +1286,6 @@ static int vdi_write(int argc, char **argv)
}
total = min(total, inode->vdi_size - offset);
- total = round_up(total, 512);
idx = offset / SD_DATA_OBJ_SIZE;
offset %= SD_DATA_OBJ_SIZE;
while (done < total) {
diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index 846d9b2..843a894 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -371,6 +371,10 @@ int default_create_and_write(uint64_t oid, const struct siocb *iocb)
/* Drop the O_DIRRECT for create operation for simplicity */
flags &= ~O_DIRECT;
+ if (flags_direct(flags) && !is_aligned(iocb))
+ /* Drop the O_DIRRECT for create operation for simplicity */
+ flags &= ~O_DIRECT;
+
if (uatomic_is_true(&sys->use_journal) &&
journal_write_store(oid, iocb->buf, iocb->length,
iocb->offset, true)
--
1.7.9.5
More information about the sheepdog
mailing list