From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chao Yu Subject: Re: [PATCH 4/5] f2fs-tools: Allow using host-aware devices as regular devices Date: Thu, 21 Mar 2019 16:32:09 +0800 Message-ID: References: <20190318063959.21369-1-damien.lemoal@wdc.com> <20190318063959.21369-5-damien.lemoal@wdc.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1h6t7v-0004Oz-FY for linux-f2fs-devel@lists.sourceforge.net; Thu, 21 Mar 2019 08:32:39 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189] helo=huawei.com) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1h6t7t-00DFA6-OW for linux-f2fs-devel@lists.sourceforge.net; Thu, 21 Mar 2019 08:32:39 +0000 In-Reply-To: <20190318063959.21369-5-damien.lemoal@wdc.com> Content-Language: en-US List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: Damien Le Moal , Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net 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 > --- > 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, > + } 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 { >