Damien Zammit, le dim. 26 déc. 2021 22:38:57 +1100, a ecrit:
> This ensures memory pages are allocated before written to.
Applied, thanks!
> ---
> rumpdisk/block-rump.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/rumpdisk/block-rump.c b/rumpdisk/block-rump.c
> index 7a4a167e..fe97bf85 100644
> --- a/rumpdisk/block-rump.c
> +++ b/rumpdisk/block-rump.c
> @@ -284,10 +284,18 @@ rumpdisk_device_write (void *d, mach_port_t reply_port,
> {
> struct block_data *bd = d;
> ssize_t written;
> + volatile uint8_t dummy_read;
> + int pagesize = sysconf (_SC_PAGE_SIZE);
> + int npages = (count + pagesize - 1) / pagesize;
> + int i;
>
> if ((bd->mode & D_WRITE) == 0)
> return D_INVALID_OPERATION;
>
> + /* Fault-in the memory pages by reading a single byte of each */
> + for (i = 0; i < npages; i++)
> + dummy_read = ((volatile uint8_t *)data)[i * pagesize];
> +
> written = rump_sys_pwrite (bd->rump_fd, (const void *)data, (size_t)count,
> (off_t)bn * bd->block_size);
> vm_deallocate (mach_task_self (), (vm_address_t) data, count);
>
> @@ -313,6 +321,7 @@ rumpdisk_device_read (void *d, mach_port_t reply_port,
> vm_address_t buf;
> int pagesize = sysconf (_SC_PAGE_SIZE);
> int npages = (count + pagesize - 1) / pagesize;
> + int i;
> ssize_t err;
> kern_return_t ret;
>
> @@ -327,8 +336,9 @@ rumpdisk_device_read (void *d, mach_port_t reply_port,
> if (ret != KERN_SUCCESS)
> return ENOMEM;
>
> - /* Ensure physical allocation. */
> - memset (buf, 0, npages * pagesize);
> + /* Ensure physical allocation by writing a single byte of each */
> + for (i = 0; i < npages; i++)
> + ((uint8_t *)buf)[i * pagesize] = 0;
>
> err = rump_sys_pread (bd->rump_fd, (void *)buf, (size_t)count, (off_t)bn *
> bd->block_size);
> if (err < 0)
> --
> 2.33.1
>
>
--
Samuel
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This email was infected under the terms of the GNU General Public License.