qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Hannes Reinecke <hare@suse.de>, Sam Li <faithilikerun@gmail.com>,
	qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>,
	dmitry.fomichev@wdc.com, Stefan Hajnoczi <stefanha@redhat.com>,
	Hanna Reitz <hreitz@redhat.com>,
	qemu-block@nongnu.org, Eric Blake <eblake@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>
Subject: Re: [RFC v4 4/9] file-posix: introduce get_sysfs_str_val for device zoned model.
Date: Tue, 12 Jul 2022 15:35:19 +0900	[thread overview]
Message-ID: <d08f73a1-4d6e-e1bb-21c9-321449e12fd5@opensource.wdc.com> (raw)
In-Reply-To: <1854c78a-a8eb-622e-da62-f074b0f08fee@suse.de>

On 7/12/22 15:17, Hannes Reinecke wrote:
> On 7/12/22 04:13, Sam Li wrote:
>> Signed-off-by: Sam Li <faithilikerun@gmail.com>
>> ---
>>   block/file-posix.c           | 60 ++++++++++++++++++++++++++++++++++++
>>   include/block/block-common.h |  4 +--
>>   2 files changed, 62 insertions(+), 2 deletions(-)
>>
>> diff --git a/block/file-posix.c b/block/file-posix.c
>> index 3161d39ea4..42708012ff 100644
>> --- a/block/file-posix.c
>> +++ b/block/file-posix.c
>> @@ -1279,6 +1279,65 @@ out:
>>   #endif
>>   }
>>   
>> +/*
>> + * Convert the zoned attribute file in sysfs to internal value.
>> + */
>> +static zone_model get_sysfs_str_val(int fd, struct stat *st) {
>> +#ifdef CONFIG_LINUX
>> +    char buf[32];
>> +    char *sysfspath = NULL;
>> +    int ret, offset;
>> +    int sysfd = -1;
>> +
>> +    if (S_ISCHR(st->st_mode)) {
>> +        if (ioctl(fd, SG_GET_SG_TABLESIZE, &ret) == 0) {
>> +            return ret;
>> +        }
>> +        return -ENOTSUP;
>> +    }
>> +
>> +    if (!S_ISBLK(st->st_mode)) {
>> +        return -ENOTSUP;
>> +    }
>> +
>> +    sysfspath = g_strdup_printf("/sys/dev/block/%u:%u/queue/zoned",
>> +                                major(st->st_rdev), minor(st->st_rdev));
>> +    sysfd = open(sysfspath, O_RDONLY);
>> +    if (sysfd == -1) {
>> +        ret = -errno;
>> +        goto out;
>> +    }
>> +    offset = 0;
>> +    do {
>> +        ret = read(sysfd, buf + offset, sizeof(buf) - 1 + offset);
>> +        if (ret > 0) {
>> +            offset += ret;
>> +        }
>> +    } while (ret == -1);
>> +    /* The file is ended with '\n' */
>> +    if (buf[ret - 1] == '\n') {
>> +        buf[ret - 1] = '\0';
>> +    }
>> +
>> +    if (strcmp(buf, "host-managed") == 0) {
>> +        return BLK_Z_HM;
>> +    } else if (strcmp(buf, "host-aware") == 0) {
>> +        return BLK_Z_HA;
>> +    } else {
>> +        return -ENOTSUP;
>> +    }
>> +
>> +out:
>> +    if (sysfd != -1) {
>> +        close(sysfd);
>> +    }
>> +    g_free(sysfspath);
>> +    return ret;
>> +#else
>> +    return -ENOTSUP;
>> +#endif
>> +}
>> +
>>   static int hdev_get_max_segments(int fd, struct stat *st) {
>>       return get_sysfs_long_val(fd, st, "max_segments");
>>   }
>> @@ -1885,6 +1944,7 @@ static int handle_aiocb_zone_mgmt(void *opaque) {
>>       int64_t len = aiocb->aio_nbytes;
>>       zone_op op = aiocb->zone_mgmt.op;
>>   
>> +    zone_model mod;
>>       struct blk_zone_range range;
>>       const char *ioctl_name;
>>       unsigned long ioctl_op;
>> diff --git a/include/block/block-common.h b/include/block/block-common.h
>> index 78cddeeda5..35e00afe8e 100644
>> --- a/include/block/block-common.h
>> +++ b/include/block/block-common.h
>> @@ -56,8 +56,8 @@ typedef enum zone_op {
>>   } zone_op;
>>   
>>   typedef enum zone_model {
>> -    BLK_Z_HM,
>> -    BLK_Z_HA,
>> +    BLK_Z_HM = 0x1,
>> +    BLK_Z_HA = 0x2,
>>   } zone_model;
>>   
>>   typedef enum BlkZoneCondition {
> 
> This hunk is unrelated, please move it into a different patch.

This actually belong to patch 1 where this enum is introduced. No need for
a different patch.

> 
> Cheers,
> 
> Hannes


-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2022-07-12  6:57 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12  2:13 [RFC v4 0/9] Add support for zoned device Sam Li
2022-07-12  2:13 ` [RFC v4 1/9] block: add block layer APIs resembling Linux ZonedBlockDevice ioctls Sam Li
2022-07-12  6:10   ` Hannes Reinecke
2022-07-12  6:17     ` Sam Li
2022-07-12  7:35   ` Damien Le Moal
2022-07-13  0:54     ` Sam Li
2022-07-12 15:49   ` Stefan Hajnoczi
2022-07-12 22:12     ` Damien Le Moal
2022-07-13  6:22       ` Stefan Hajnoczi
2022-07-13  0:51     ` Sam Li
2022-07-13  6:19       ` Stefan Hajnoczi
2022-07-12  2:13 ` [RFC v4 2/9] qemu-io: add zoned block device operations Sam Li
2022-07-12  6:14   ` Hannes Reinecke
2022-07-12  7:44   ` Damien Le Moal
2022-07-27 14:13   ` Stefan Hajnoczi
2022-07-28  1:57     ` Damien Le Moal
2022-07-12  2:13 ` [RFC v4 3/9] file-posix: introduce get_sysfs_long_val for a block queue of sysfs attribute Sam Li
2022-07-12  6:16   ` Hannes Reinecke
2022-07-12  7:37   ` Damien Le Moal
2022-07-12  2:13 ` [RFC v4 4/9] file-posix: introduce get_sysfs_str_val for device zoned model Sam Li
2022-07-12  6:17   ` Hannes Reinecke
2022-07-12  6:35     ` Damien Le Moal [this message]
2022-07-12  7:42   ` Damien Le Moal
2022-07-12  2:13 ` [RFC v4 5/9] qemu-iotests: test new zone operations Sam Li
2022-07-27 14:34   ` Stefan Hajnoczi
2022-07-27 14:59     ` Ming Lei
2022-07-27 15:12       ` Stefan Hajnoczi
2022-07-12  2:13 ` [RFC v4 6/9] raw-format: add " Sam Li
2022-07-27 14:39   ` Stefan Hajnoczi
2022-07-12  2:13 ` [RFC v4 7/9] config: add check to block layer Sam Li
2022-07-27 14:50   ` Stefan Hajnoczi
2022-07-12  2:13 ` [RFC v4 8/9] include: add support for zoned block devices Sam Li
2022-07-27 14:52   ` Stefan Hajnoczi
2022-07-12  2:13 ` [RFC v4 9/9] qapi: add support for zoned host device Sam Li
2022-07-12  7:48   ` Damien Le Moal
2022-07-27 14:53   ` Stefan Hajnoczi
2022-07-12  5:47 ` [RFC v4 0/9] Add support for zoned device Markus Armbruster
2022-07-12  5:59   ` Sam Li
2022-07-18 10:53     ` Markus Armbruster
2022-07-27 14:55 ` Stefan Hajnoczi
2022-07-27 15:06 ` Stefan Hajnoczi
2022-07-27 15:14   ` 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=d08f73a1-4d6e-e1bb-21c9-321449e12fd5@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).