qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Sam Li <faithilikerun@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	Hannes Reinecke <hare@suse.de>, Fam Zheng <fam@euphon.net>,
	Kevin Wolf <kwolf@redhat.com>, Eric Blake <eblake@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Hanna Reitz <hreitz@redhat.com>,
	Dmitry Fomichev <dmitry.fomichev@wdc.com>,
	qemu block <qemu-block@nongnu.org>
Subject: Re: [PATCH v7 3/8] file-posix: introduce get_sysfs_long_val for the long sysfs attribute
Date: Tue, 16 Aug 2022 10:55:39 -0700	[thread overview]
Message-ID: <fbdebf32-fc26-4b23-3bc9-aeba0020535f@opensource.wdc.com> (raw)
In-Reply-To: <CAAAx-8+j=HrzhzHDzdE+LWKay6fRkvqugk+1CTb-zAc8ZxpFrg@mail.gmail.com>

On 2022/08/16 10:53, Sam Li wrote:
> Damien Le Moal <damien.lemoal@opensource.wdc.com> 于2022年8月17日周三 01:35写道:
>>
>> On 2022/08/15 23:25, Sam Li wrote:
>>> Use sysfs attribute files to get the long value of zoned device
>>> information.
>>>
>>> Signed-off-by: Sam Li <faithilikerun@gmail.com>
>>> Reviewed-by: Hannes Reinecke <hare@suse.de>
>>> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
>>> ---
>>>  block/file-posix.c | 27 +++++++++++++++++++++++++++
>>>  1 file changed, 27 insertions(+)
>>>
>>> diff --git a/block/file-posix.c b/block/file-posix.c
>>> index c07ac4c697..727389488c 100644
>>> --- a/block/file-posix.c
>>> +++ b/block/file-posix.c
>>> @@ -1258,6 +1258,33 @@ static int get_sysfs_zoned_model(struct stat *st, BlockZoneModel *zoned) {
>>>      return 0;
>>>  }
>>>
>>> +/*
>>> + * Get zoned device information (chunk_sectors, zoned_append_max_bytes,
>>> + * max_open_zones, max_active_zones) through sysfs attribute files.
>>> + */
>>
>> The comment here needs to be more generic since this helper is used in patch 2
>> in hdev_get_max_segments(). So simply something like:
>>
>> /*
>>  * Get a sysfs attribute value as a long integer.
>>  */
>>
>> And since this helper is used in patch 2, this patch needs to go before patch 2
>> (reverse patch 2 and 3 order).
> 
> Can I merge patch2 and patch 3 into one patch? Because in patch 2
> hdev_get_max_segments -> get_sysfs_long_val(-> get_sysfs_str_val)
> while in patch 3 get_sysfs_long_val-> get_sysfs_str_val,
> hdev_get_max_segments is required for qemu setting up I guess so the
> dependency is intertwined here. If we use separate patches, then the
> last patch will modify the first patch's code, which I think is messy.

Indeed. So merge the 2 patches to solve this. Rework the commit message too to
mention the introduction of the get_sysfs_long_val() helper.

> 
>>
>>> +static long get_sysfs_long_val(struct stat *st, const char *attribute) {
>>> +#ifdef CONFIG_LINUX
>>> +    g_autofree char *str = NULL;
>>> +    const char *end;
>>> +    long 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_strtol(str, &end, 10, &val);
>>> +    if (ret == 0 && end && *end == '\n') {
>>> +        ret = val;
>>> +    }
>>> +    return ret;
>>> +#else
>>> +    return -ENOTSUP;
>>> +#endif
>>> +}
>>> +
>>>  static int hdev_get_max_segments(int fd, struct stat *st) {
>>>      int ret;
>>>      if (S_ISCHR(st->st_mode)) {
>>
>>
>> --
>> Damien Le Moal
>> Western Digital Research


-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2022-08-16 17:58 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16  6:25 [PATCH v7 0/8] Add support for zoned device Sam Li
2022-08-16  6:25 ` [PATCH v7 1/8] include: add zoned device structs Sam Li
2022-08-16 17:27   ` Damien Le Moal
2022-08-16  6:25 ` [PATCH v7 2/8] file-posix: introduce get_sysfs_str_val for device zoned model Sam Li
2022-08-16 16:11   ` Sam Li
2022-08-16 17:32   ` Damien Le Moal
2022-08-22 23:05   ` Stefan Hajnoczi
2022-08-23  4:31     ` Sam Li
2022-08-16  6:25 ` [PATCH v7 3/8] file-posix: introduce get_sysfs_long_val for the long sysfs attribute Sam Li
2022-08-16 16:13   ` Sam Li
2022-08-16 17:35   ` Damien Le Moal
2022-08-16 17:53     ` Sam Li
2022-08-16 17:55       ` Damien Le Moal [this message]
2022-08-16  6:25 ` [PATCH v7 4/8] block: add block layer APIs resembling Linux ZonedBlockDevice ioctls Sam Li
2022-08-16 17:50   ` Damien Le Moal
2022-08-26 12:20     ` Sam Li
2022-08-23  0:49   ` Stefan Hajnoczi
2022-08-23  4:12     ` Sam Li
2022-08-23 12:40       ` Stefan Hajnoczi
2022-08-24 23:46       ` Damien Le Moal
2022-08-24 23:53         ` Damien Le Moal
2022-08-16  6:25 ` [PATCH v7 5/8] raw-format: add zone operations to pass through requests Sam Li
2022-08-16  6:25 ` [PATCH v7 6/8] config: add check to block layer Sam Li
2022-08-23  0:54   ` Stefan Hajnoczi
2022-08-23  4:25     ` Sam Li
2022-08-23 12:36       ` Stefan Hajnoczi
2022-08-16  6:25 ` [PATCH v7 7/8] qemu-iotests: test new zone operations Sam Li
2022-08-16  6:25 ` [PATCH v7 8/8] docs/zoned-storage: add zoned device documentation Sam Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fbdebf32-fc26-4b23-3bc9-aeba0020535f@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.com \
    --cc=armbru@redhat.com \
    --cc=dmitry.fomichev@wdc.com \
    --cc=eblake@redhat.com \
    --cc=faithilikerun@gmail.com \
    --cc=fam@euphon.net \
    --cc=hare@suse.de \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).