file-posix.c (088d67096d753a890abb25e94c57c2e594f3d236) | file-posix.c (038adc2f5850e32019bda06c559d0301be436eae) |
---|---|
1/* 2 * Block driver for RAW files (posix) 3 * 4 * Copyright (c) 2006 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 313 unchanged lines hidden (view full) --- 322 323 return false; 324} 325 326static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp) 327{ 328 BDRVRawState *s = bs->opaque; 329 char *buf; | 1/* 2 * Block driver for RAW files (posix) 3 * 4 * Copyright (c) 2006 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 313 unchanged lines hidden (view full) --- 322 323 return false; 324} 325 326static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp) 327{ 328 BDRVRawState *s = bs->opaque; 329 char *buf; |
330 size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize()); | 330 size_t max_align = MAX(MAX_BLOCKSIZE, qemu_real_host_page_size); |
331 size_t alignments[] = {1, 512, 1024, 2048, 4096}; 332 333 /* For SCSI generic devices the alignment is not really used. 334 With buffered I/O, we don't have any restrictions. */ 335 if (bdrv_is_sg(bs) || !s->needs_alignment) { 336 bs->bl.request_alignment = 1; 337 s->buf_align = 1; 338 return; --- 792 unchanged lines hidden (view full) --- 1131 int ret = sg_get_max_transfer_length(s->fd); 1132 1133 if (ret > 0 && ret <= BDRV_REQUEST_MAX_BYTES) { 1134 bs->bl.max_transfer = pow2floor(ret); 1135 } 1136 1137 ret = sg_get_max_segments(s->fd); 1138 if (ret > 0) { | 331 size_t alignments[] = {1, 512, 1024, 2048, 4096}; 332 333 /* For SCSI generic devices the alignment is not really used. 334 With buffered I/O, we don't have any restrictions. */ 335 if (bdrv_is_sg(bs) || !s->needs_alignment) { 336 bs->bl.request_alignment = 1; 337 s->buf_align = 1; 338 return; --- 792 unchanged lines hidden (view full) --- 1131 int ret = sg_get_max_transfer_length(s->fd); 1132 1133 if (ret > 0 && ret <= BDRV_REQUEST_MAX_BYTES) { 1134 bs->bl.max_transfer = pow2floor(ret); 1135 } 1136 1137 ret = sg_get_max_segments(s->fd); 1138 if (ret > 0) { |
1139 bs->bl.max_transfer = MIN(bs->bl.max_transfer, ret * getpagesize()); | 1139 bs->bl.max_transfer = MIN(bs->bl.max_transfer, 1140 ret * qemu_real_host_page_size); |
1140 } 1141 } 1142 1143 raw_probe_alignment(bs, s->fd, errp); 1144 bs->bl.min_mem_alignment = s->buf_align; | 1141 } 1142 } 1143 1144 raw_probe_alignment(bs, s->fd, errp); 1145 bs->bl.min_mem_alignment = s->buf_align; |
1145 bs->bl.opt_mem_alignment = MAX(s->buf_align, getpagesize()); | 1146 bs->bl.opt_mem_alignment = MAX(s->buf_align, qemu_real_host_page_size); |
1146} 1147 1148static int check_for_dasd(int fd) 1149{ 1150#ifdef BIODASDINFO2 1151 struct dasd_information2_t info = {0}; 1152 1153 return ioctl(fd, BIODASDINFO2, &info); --- 546 unchanged lines hidden (view full) --- 1700 * Returns: 0 on success, -errno on failure. Since this is an optimization, 1701 * caller may ignore failures. 1702 */ 1703static int allocate_first_block(int fd, size_t max_size) 1704{ 1705 size_t write_size = (max_size < MAX_BLOCKSIZE) 1706 ? BDRV_SECTOR_SIZE 1707 : MAX_BLOCKSIZE; | 1147} 1148 1149static int check_for_dasd(int fd) 1150{ 1151#ifdef BIODASDINFO2 1152 struct dasd_information2_t info = {0}; 1153 1154 return ioctl(fd, BIODASDINFO2, &info); --- 546 unchanged lines hidden (view full) --- 1701 * Returns: 0 on success, -errno on failure. Since this is an optimization, 1702 * caller may ignore failures. 1703 */ 1704static int allocate_first_block(int fd, size_t max_size) 1705{ 1706 size_t write_size = (max_size < MAX_BLOCKSIZE) 1707 ? BDRV_SECTOR_SIZE 1708 : MAX_BLOCKSIZE; |
1708 size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize()); | 1709 size_t max_align = MAX(MAX_BLOCKSIZE, qemu_real_host_page_size); |
1709 void *buf; 1710 ssize_t n; 1711 int ret; 1712 1713 buf = qemu_memalign(max_align, write_size); 1714 memset(buf, 0, write_size); 1715 1716 do { --- 2037 unchanged lines hidden --- | 1710 void *buf; 1711 ssize_t n; 1712 int ret; 1713 1714 buf = qemu_memalign(max_align, write_size); 1715 memset(buf, 0, write_size); 1716 1717 do { --- 2037 unchanged lines hidden --- |