All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@wdc.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <yuchao0@huawei.com>,
	linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH 4/5] f2fs-tools: Allow using host-aware devices as regular devices
Date: Mon, 18 Mar 2019 15:39:58 +0900	[thread overview]
Message-ID: <20190318063959.21369-5-damien.lemoal@wdc.com> (raw)
In-Reply-To: <20190318063959.21369-1-damien.lemoal@wdc.com>

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;
+			} 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 {
-- 
2.20.1

  parent reply	other threads:[~2019-03-18  6:40 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 ` Damien Le Moal [this message]
2019-03-21  8:32   ` [PATCH 4/5] f2fs-tools: Allow using host-aware devices as regular devices Chao Yu
2019-03-21  9:29     ` Damien Le Moal
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=20190318063959.21369-5-damien.lemoal@wdc.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.