mkfs.f2fs: ZBC device support
PATCH 1/1 mkfs.f2fs: ZBC device support
This patch adds "-m" option to configure ZBC device.
This is to support host-managed SMR device and configure some major features and on-disk layout in f2fs.
Signed-off-by Jaegeuk Kim <[email protected]>
--- include/f2fs_fs.h | 35 +++ lib/Makefile.am | 2 +- lib/libf2fs.c | 17 ++ lib/zbc.c | 647 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/zbc.h | 361 +++++++++++++++++++++++++++ mkfs/f2fs_format.c | 4 +- mkfs/f2fs_format_main.c | 9 +- 7 files changed, 1069 insertions(+), 6 deletions(-) create mode 100644 lib/zbc.c create mode 100644 lib/zbc.h
include/f2fs_fs.h +35 -0
@@ -229,6 +229,32 @@ enum f2fs_config_func { SLOAD, }; +enum zbc_sk { +ZBC_E_ILLEGAL_REQUEST =0x5 , +ZBC_E_DATA_PROTECT =0x7 , +ZBC_E_ABORTED_COMMAND =0xB , +}; + +/** +* Additional sense code/Additional sense code qualifier. +*/ +enum zbc_asc_ascq { +ZBC_E_INVALID_FIELD_IN_CDB =0x2400 , +ZBC_E_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE =0x2100 , +ZBC_E_UNALIGNED_WRITE_COMMAND =0x2104 , +ZBC_E_WRITE_BOUNDARY_VIOLATION =0x2105 , +ZBC_E_ATTEMPT_TO_READ_INVALID_DATA =0x2106 , +ZBC_E_READ_BOUNDARY_VIOLATION =0x2107 , +ZBC_E_ZONE_IS_READ_ONLY =0x2708 , +ZBC_E_INSUFFICIENT_ZONE_RESOURCES =0x550E , +}; + +struct zbc_errno { +enum zbc_sk sk; +enum zbc_asc_ascq asc_ascq; +}; +typedef struct zbc_errno zbc_errno_t ; +struct f2fs_configuration {u_int32_t sector_size;u_int32_t reserved_segments;
@@ -273,6 +299,13 @@ struct f2fs_configuration {/* sload parameters */ char *from_dir;char *mount_point; + +/* to detect zbc error */ +int smr_mode; +u_int32_t nr_zones; +u_int32_t nr_conventional; +size_t zone_sectors; +zbc_errno_t zbd_errno; } __attribute__((packed));#ifdef CONFIG_64BIT
@@ -939,6 +972,8 @@ extern int dev_read_version(void *, __u64, size_t);extern void get_kernel_version (__u8 *);f2fs_hash_t f2fs_dentry_hash (const unsigned char *,int ); +extern int zbc_scsi_report_zones (struct f2fs_configuration *); +extern struct f2fs_configuration config;#define ALIGN (val, size) ((val) + (size) - 1) / (size)
lib/Makefile.am +1 -1
@@ -2,7 +2,7 @@ lib_LTLIBRARIES = libf2fs.la -libf2fs_la_SOURCES = libf2fs.c libf2fs_io.c +libf2fs_la_SOURCES = libf2fs.c libf2fs_io.c zbc.c libf2fs_la_CFLAGS = -Wall libf2fs_la_CPPFLAGS = -I$(top_srcdir)/include libf2fs_la_LDFLAGS = -version-info $(LIBF2FS_CURRENT):$(LIBF2FS_REVISION):$(LIBF2FS_AGE)
lib/libf2fs.c +17 -0
@@ -645,6 +645,23 @@ int f2fs_get_device_info(struct f2fs_configuration *c)MSG (0 ,"\tError: F2FS can support 16TB at most!!!\n" );return -1 ; } + +if (config.smr_mode) { +if (zbc_scsi_report_zones (c)) { +MSG (0 ,"\tError: Not proper SMR drive\n" ); +return -1 ; + } +MSG (0 ,"Info: SMR - ZONES = %u, CONV = %u, ZONE_SECTS = %lu\n" , + c->nr_zones, c->nr_conventional, + c->zone_sectors); +if (c->segs_per_sec ==1 ) + c->segs_per_sec = c->zone_sectors / + c->sectors_per_blk /DEFAULT_BLOCKS_PER_SEGMENT ; + } + c->segs_per_zone = c->segs_per_sec * c->secs_per_zone; + +MSG (0 ,"Info: Segments per section = %d\n" , config.segs_per_sec); +MSG (0 ,"Info: Sections per zone = %d\n" , config.secs_per_zone);MSG (0 ,"Info: sector size = %u\n" , c->sector_size); MSG(0, "Info: total sectors = %"PRIu64" (%"PRIu64" MB)\n", c->total_sectors, (c->total_sectors *
lib/zbc.c new file +647 -0
647 lines not on this page · raw message
lib/zbc.h new file +361 -0
361 lines not on this page · raw message
mkfs/f2fs_format.c +3 -1
@@ -703,6 +703,8 @@ static int f2fs_write_super_block(void)#ifndef WITH_ANDROID static int discard_obsolete_dnode (struct f2fs_node *raw_node,u_int64_t offset) { +if (config.smr_mode) +return 0 ; do { if (offset < get_sb(main_blkaddr) || offset >= get_sb(main_blkaddr) + get_sb(block_count))
@@ -781,7 +783,7 @@ static int f2fs_write_root_inode(void) config.blks_per_seg; main_area_node_seg_blk_offset *= blk_size_bytes; -DBG (1 ,"\tWriting root inode (hot node), at offset 0x%08" PRIx64"\n" , main_area_node_seg_blk_offset); +DBG (1 ,"\tWriting root inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" ,get_sb (main_blkaddr), config.cur_seg[CURSEG_HOT_NODE ], config.blks_per_seg, main_area_node_seg_blk_offset/512 );if (dev_write (raw_node, main_area_node_seg_blk_offset,F2FS_BLKSIZE )) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" );free (raw_node);
mkfs/f2fs_format_main.c +5 -4
@@ -38,6 +38,7 @@ static void mkfs_usage()MSG (0 ," -s # of segments per section [default:1]\n" );MSG (0 ," -z # of sections per zone [default:1]\n" );MSG (0 ," -t 0: nodiscard, 1: discard [default:1]\n" ); +MSG (0 ," -m support SMR device [default:0]\n" );MSG (0 ,"sectors: number of sectors. [default: determined by device size]\n" );exit (1 ); }
@@ -56,8 +57,6 @@ static void f2fs_show_info()if (config.vol_label)MSG (0 ,"Info: Label = %s\n" , config.vol_label); -MSG (0 ,"Info: Segments per section = %d\n" , config.segs_per_sec); -MSG (0 ,"Info: Sections per zone = %d\n" , config.secs_per_zone);MSG (0 ,"Info: Trim is %s\n" , config.trim ?"enabled" :"disabled" ); }
@@ -73,7 +72,7 @@ static void parse_feature(char *features)static void f2fs_parse_options (int argc,char *argv[]) { -static const char *option_string ="qa:d:e:l:o:O:s:z:t:" ; +static const char *option_string ="qa:d:e:l:mo:O:s:z:t:" ;int32_t option=0 ;while ((option =getopt (argc,argv,option_string)) !=EOF ) {
@@ -98,6 +97,9 @@ static void f2fs_parse_options(int argc, char *argv[]) } config.vol_label = optarg;break ; +case 'm' : + config.smr_mode =1 ; +break ;case 'o' : config.overprovision =atof (optarg);break ;
@@ -128,7 +130,6 @@ static void f2fs_parse_options(int argc, char *argv[])if ((optind +1 ) < argc) config.total_sectors =atoll (argv[optind+1 ]); - config.segs_per_zone = config.segs_per_sec * config.secs_per_zone; }int main (int argc,char *argv[])
Signature · 9 lines
2.8.3 ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e