All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Chao Yu <yuchao0@huawei.com>, Jaegeuk Kim <jaegeuk@kernel.org>,
	"linux-f2fs-devel@lists.sourceforge.net"
	<linux-f2fs-devel@lists.sourceforge.net>
Subject: Re: [PATCH 4/5] f2fs-tools: Allow using host-aware devices as regular devices
Date: Thu, 21 Mar 2019 09:29:17 +0000	[thread overview]
Message-ID: <BYAPR04MB581680081781D788BC646807E7420@BYAPR04MB5816.namprd04.prod.outlook.com> (raw)
In-Reply-To: a2201b9a-9fa0-a01f-d44f-03120f3d4d8f@huawei.com

On 2019/03/21 17:32, Chao Yu wrote:
> On 2019/3/18 14:39, Damien Le Moal wrote:
>> Host-aware zoned block devices can accept random writes anywhere and so
>> do not require to be handled under F2FS_ZONED_HM mode. Allow host aware
>> disks to be treated as regular devices if c.zoned_mode is false, that
>> is, if the -m option is not specified in mkfs.f2fs.
>>
>> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
>> ---
>>  lib/libf2fs.c | 43 ++++++++++++++++++++++++++++++-------------
>>  1 file changed, 30 insertions(+), 13 deletions(-)
>>
>> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
>> index 5ca1bb0..214c921 100644
>> --- a/lib/libf2fs.c
>> +++ b/lib/libf2fs.c
>> @@ -933,9 +933,21 @@ int get_device_info(int i)
>>  	}
>>  
>>  	if (dev->zoned_model != F2FS_ZONED_NONE) {
>> -		if (dev->zoned_model == F2FS_ZONED_HM)
>> +		if (dev->zoned_model == F2FS_ZONED_HM) {
>>  			c.zoned_model = F2FS_ZONED_HM;
>> +		} else {
>> +			/* F2FS_ZONED_HA */
>> +			if (c.zoned_mode) {
>> +				c.zoned_model = F2FS_ZONED_HM;
> 
> May I ask why we change the model from F2FS_ZONED_HA to F2FS_ZONED_HM?
> 
> Thanks,

There is some confusion I think in the code between disk zoned model and f2fs
zoned mode. Currently, F2FS_ZONED_HA is not tested anywhere to drive the check
against c.zoned_mode. Before this patch, the code was:

	if (dev->zoned_model != F2FS_ZONED_NONE) {
		if (dev->zoned_model == F2FS_ZONED_HM)
			c.zoned_model = F2FS_ZONED_HM;

So only HM disks end up setting "c.zoned_model = F2FS_ZONED_HM" which requires
c.zoned_mode to be set. For an F2FS_ZONED_HA disk, c.zoned_model stays as NONE
and c.zone_blocks is set, regardless of c.zoned_mode setting. The end result is
that the HA disk will be used as a regular disk when -m is not specified on mkfs
command line, and as a zoned disk when -m is specified. However, many areas of
the code check for c.zoned_model == F2FS_ZONED_HM, and that is always false for
HA disks.

The idea here is to allow a cleaner control over HA disk use: either use them as
regular disks and ignore that they are zoned, or use them in the same manner as
HM disks, ignoring the fact that HA disks can accept random writes. Anything in
between these 2 modes does not really make sense.

Now, rereading the code and explaining all this, I realize that the commit
message is actually not correct at all and misleading to the intent of the
patch. I will revisit it and check again this patch. We could actually drop it
for now and I can resend later.

In any case, I am sending a v2 for this series.

Thanks for your review !


> 
>> +			} else {
>> +				MSG(0, "Info: treating host-aware zoned block "
>> +				    "device as regular device\n");
>> +				dev->zoned_model = F2FS_ZONED_NONE;
>> +			}
>> +		}
>> +	}
>>  
>> +	if (c.zoned_model == F2FS_ZONED_HM) {
>>  		if (f2fs_get_zone_blocks(i)) {
>>  			MSG(0, "\tError: Failed to get number of blocks per zone\n");
>>  			free(stat_buf);
>> @@ -1071,6 +1083,7 @@ int get_device_info(int i)
>>  
>>  int f2fs_get_device_info(void)
>>  {
>> +	bool zoned = false;
>>  	int i;
>>  
>>  	for (i = 0; i < c.ndevs; i++)
>> @@ -1089,22 +1102,26 @@ int f2fs_get_device_info(void)
>>  		return -1;
>>  	}
>>  
>> +	/* For zoned devices, the zones sizes must be equal */
>>  	for (i = 0; i < c.ndevs; i++) {
>> -		if (c.devices[i].zoned_model != F2FS_ZONED_NONE) {
>> -			if (c.zone_blocks &&
>> -				c.zone_blocks != c.devices[i].zone_blocks) {
>> -				MSG(0, "\tError: not support different zone sizes!!!\n");
>> -				return -1;
>> -			}
>> -			c.zone_blocks = c.devices[i].zone_blocks;
>> +		if (c.devices[i].zoned_model != F2FS_ZONED_HM)
>> +			continue;
>> +
>> +		zoned = true;
>> +
>> +		if (c.zone_blocks &&
>> +		    c.zone_blocks != c.devices[i].zone_blocks) {
>> +			MSG(0, "\tError: zones of different size are not supported\n");
>> +			return -1;
>>  		}
>> +		c.zone_blocks = c.devices[i].zone_blocks;
>>  	}
>>  
>> -	/*
>> -	 * Align sections to the device zone size
>> -	 * and align F2FS zones to the device zones.
>> -	 */
>> -	if (c.zone_blocks) {
>> +	if (zoned) {
>> +		/*
>> +		 * Align sections to the device zone size
>> +		 * and align F2FS zones to the device zones.
>> +		 */
>>  		c.segs_per_sec = c.zone_blocks / DEFAULT_BLOCKS_PER_SEGMENT;
>>  		c.secs_per_zone = 1;
>>  	} else {
>>
> 


-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2019-03-21  9:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-18  6:39 [PATCH 0/5] Zoned block device support improvments Damien Le Moal
2019-03-18  6:39 ` [PATCH 1/5] f2fs-tools: Fix various compilation warnings Damien Le Moal
2019-03-21  6:29   ` Chao Yu
2019-03-18  6:39 ` [PATCH 2/5] f2fs-tools: Add f2fs_io to .gitignore Damien Le Moal
2019-03-21  6:29   ` Chao Yu
2019-03-18  6:39 ` [PATCH 3/5] f2fs-tools: Improve zoned model check Damien Le Moal
2019-03-21  6:32   ` Chao Yu
2019-03-26 18:24   ` Jaegeuk Kim
2019-03-26 22:58     ` Damien Le Moal
2019-03-18  6:39 ` [PATCH 4/5] f2fs-tools: Allow using host-aware devices as regular devices Damien Le Moal
2019-03-21  8:32   ` Chao Yu
2019-03-21  9:29     ` Damien Le Moal [this message]
2019-03-21 12:27       ` Chao Yu
2019-03-18  6:39 ` [PATCH 5/5] f2fs-tools: Fix multi-device format with zoned devices Damien Le Moal
2019-03-21  8:41   ` Chao Yu
2019-03-21  9:30     ` Damien Le Moal

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=BYAPR04MB581680081781D788BC646807E7420@BYAPR04MB5816.namprd04.prod.outlook.com \
    --to=damien.lemoal@wdc.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=yuchao0@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.