qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] exec: fetch the alignment of Linux devdax pmem character dev


From: Joao Martins
Subject: Re: [PATCH] exec: fetch the alignment of Linux devdax pmem character device nodes
Date: Tue, 7 Apr 2020 11:59:10 +0100


On 4/1/20 4:13 AM, Jingqi Liu wrote:
> If the backend file is devdax pmem character device, the alignment
> specified by the option 'align=NUM' in the '-object memory-backend-file'
> needs to match the alignment requirement of the devdax pmem character device.
> 
> This patch fetches the devdax pmem file 'align', so that we can compare
> it with the NUM of 'align=NUM'.
> The NUM needs to be larger than or equal to the devdax pmem file 'align'.
> 
> It also fixes the problem that mmap() returns failure in qemu_ram_mmap()
> when the NUM of 'align=NUM' is less than the devdax pmem file 'align'.
> 
> Cc: Dan Williams <address@hidden>
> Signed-off-by: Jingqi Liu <address@hidden>
> ---
>  exec.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 45 insertions(+), 1 deletion(-)
> 
> diff --git a/exec.c b/exec.c
> index de9d949902..8221abffec 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1736,6 +1736,42 @@ static int64_t get_file_size(int fd)
>      return size;
>  }
>  
> +static int64_t get_file_align(int fd)
> +{
> +    int64_t align = -1;
> +#if defined(__linux__)
> +    struct stat st;
> +
> +    if (fstat(fd, &st) < 0) {
> +        return -errno;
> +    }
> +
> +    /* Special handling for devdax character devices */
> +    if (S_ISCHR(st.st_mode)) {
> +        g_autofree char *subsystem_path = NULL;
> +        g_autofree char *subsystem = NULL;
> +
> +        subsystem_path = g_strdup_printf("/sys/dev/char/%d:%d/subsystem",
> +                                         major(st.st_rdev), 
> minor(st.st_rdev));
> +        subsystem = g_file_read_link(subsystem_path, NULL);
> +
> +        if (subsystem && g_str_has_suffix(subsystem, "/dax")) {
> +            g_autofree char *align_path = NULL;
> +            g_autofree char *align_str = NULL;
> +
> +            align_path = g_strdup_printf("/sys/dev/char/%d:%d/device/align",
> +                                    major(st.st_rdev), minor(st.st_rdev));
> +

Perhaps, you meant instead:

        /sys/dev/char/%d:%d/align

 ?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]