[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 1/2] file-posix: probe discard alignment on Linux block de
From: |
Eric Blake |
Subject: |
Re: [PATCH v3 1/2] file-posix: probe discard alignment on Linux block devices |
Date: |
Thu, 17 Apr 2025 11:27:36 -0500 |
User-agent: |
NeoMutt/20250404 |
On Mon, Apr 14, 2025 at 04:12:13PM -0400, Stefan Hajnoczi wrote:
> Populate the pdiscard_alignment block limit so the block layer is able
> align discard requests correctly.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> block/file-posix.c | 67 +++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 66 insertions(+), 1 deletion(-)
>
> +static int get_sysfs_u32_val(struct stat *st, const char *attribute,
> + uint32_t *u32)
> +{
> + g_autofree char *str = NULL;
> + const char *end;
> + unsigned int val;
> + int ret;
> +
> + ret = get_sysfs_str_val(st, attribute, &str);
> + if (ret < 0) {
> + return ret;
> + }
> +
> + /* The file is ended with '\n', pass 'end' to accept that. */
> + ret = qemu_strtoui(str, &end, 10, &val);
> + if (ret == 0 && end && *end == '\0') {
This doesn't match the comment. If we expect the file contents to end
in \n, then this should be checking *end == '\n', not '\0'.
> + *u32 = val;
> + }
> + return ret;
> +}
> #endif
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization: qemu.org | libguestfs.org