mkfs.f2fs: check options for zoned block devices

Trim must not be disabled with zoned mode.
For host-managed zoned block devices, the zoned mode is mandatory.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 3fda98c..6fd2f2a 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -150,6 +150,20 @@
 	if (f2fs_get_device_info() < 0)
 		return -1;
 
+	/*
+	 * Some options are mandatory for host-managed
+	 * zoned block devices.
+	 */
+	if (c.zoned_model == F2FS_ZONED_HM && !c.zoned_mode) {
+		MSG(0, "\tError: zoned block device feature is required\n");
+		return -1;
+	}
+
+	if (c.zoned_mode && !c.trim) {
+		MSG(0, "\tError: Trim is required for zoned block devices\n");
+		return -1;
+	}
+
 	if (f2fs_format_device() < 0)
 		return -1;