Skip to contentSkip to conversation

mkfs.f2fs: support large sector size

PATCH In review Chao Yu 2 participants 3 messages Jan 30, 2015 – Jan 31, 2015 Library code

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 mkfs.f2fs: support large sector size

Since f2fs support large sector size in commit 55cf9cb63f0e "f2fs: support large sector size", block device with sector size of 512/1024/2048/4096 bytes can be supported.

But mkfs.f2fs still use default sector size: 512 bytes as sector size, let's fix this issue in this patch.

---
 lib/libf2fs.c            | 2 +-
 mkfs/f2fs_format.c       | 6 +++---
 mkfs/f2fs_format_utils.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
lib/libf2fs.c +1 -1
index 8123528..9b9578b 100644
@@ -504,7 +504,7 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
 	MSG(0, "Info: total sectors = %"PRIu64" (in 512bytes)\n",
 					c->total_sectors);
 	if (c->total_sectors <
-			(F2FS_MIN_VOLUME_SIZE / DEFAULT_SECTOR_SIZE)) {
+			(F2FS_MIN_VOLUME_SIZE / c->sector_size)) {
 		MSG(0, "Error: Min volume size supported is %d\n",
 				F2FS_MIN_VOLUME_SIZE);
 		return -1;
mkfs/f2fs_format.c +3 -3
index a8d2db6..861fe2f 100644
@@ -198,10 +198,10 @@ static int f2fs_prepare_super_block(void)
 	set_sb(block_count, config.total_sectors >> log_sectors_per_block);
 
 	zone_align_start_offset =
-		(config.start_sector * DEFAULT_SECTOR_SIZE +
+		(config.start_sector * config.sector_size +
 		2 * F2FS_BLKSIZE + zone_size_bytes - 1) /
 		zone_size_bytes * zone_size_bytes -
-		config.start_sector * DEFAULT_SECTOR_SIZE;
+		config.start_sector * config.sector_size;
 
 	if (config.start_sector % DEFAULT_SECTORS_PER_BLOCK) {
 		MSG(1, "\tWARN: Align start sector number to the page unit\n");
@@ -211,7 +211,7 @@ static int f2fs_prepare_super_block(void)
 				DEFAULT_SECTORS_PER_BLOCK);
 	}
 
-	set_sb(segment_count, (config.total_sectors * DEFAULT_SECTOR_SIZE -
+	set_sb(segment_count, (config.total_sectors * config.sector_size -
 				zone_align_start_offset) / segment_size_bytes);
 
 	set_sb(segment0_blkaddr, zone_align_start_offset / blk_size_bytes);
mkfs/f2fs_format_utils.c +1 -1
index 88b9953..a0f85f5 100644
@@ -36,7 +36,7 @@ int f2fs_trim_device()
 		return 0;
 
 	range[0] = 0;
-	range[1] = config.total_sectors * DEFAULT_SECTOR_SIZE;
+	range[1] = config.total_sectors * config.sector_size;
 
 	if (fstat(config.fd, &stat_buf) < 0 ) {
 		MSG(1, "\tError: Failed to get the device stat!!!\n");
Signature · 10 lines
2.2.1



------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
#1 lore raw
Quoted 19 lines · Chao Yu

Since f2fs support large sector size in commit 55cf9cb63f0e "f2fs: support large sector size", block device with sector size of 512/1024/2048/4096 bytes can be supported.

But mkfs.f2fs still use default sector size: 512 bytes as sector size, let's fix this issue in this patch.

---
 lib/libf2fs.c            | 2 +-
 mkfs/f2fs_format.c       | 6 +++---
 mkfs/f2fs_format_utils.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
lib/libf2fs.c +0 -0
index 8123528..9b9578b 100644

lib/libf2fs.c int f2fs_get_device_info(struct f2fs_configuration *c) · line 504

Quoted 1 line
lib/libf2fs.c +0 -0
@@ -504,7 +504,7 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
        MSG(0, "Info: total sectors = %"PRIu64" (in 512bytes)\n",

Should using c->sector_size instead 512bytes here ?

Quoted 13 lines
lib/libf2fs.c +1 -1
                                        c->total_sectors);
        if (c->total_sectors <
-                       (F2FS_MIN_VOLUME_SIZE / DEFAULT_SECTOR_SIZE)) {
+                       (F2FS_MIN_VOLUME_SIZE / c->sector_size)) {
                MSG(0, "Error: Min volume size supported is %d\n",
                                F2FS_MIN_VOLUME_SIZE);
                return -1;
mkfs/f2fs_format.c +0 -0
index a8d2db6..861fe2f 100644
@@ -198,10 +198,10 @@ static int f2fs_prepare_super_block(void)
        set_sb(block_count, config.total_sectors >> log_sectors_per_block);

mkfs/f2fs_format.c static int f2fs_prepare_super_block(void) · line 206

Quoted 10 lines
mkfs/f2fs_format.c +2 -2
 
        zone_align_start_offset =
-               (config.start_sector * DEFAULT_SECTOR_SIZE +
+               (config.start_sector * config.sector_size +
                2 * F2FS_BLKSIZE + zone_size_bytes - 1) /
                zone_size_bytes * zone_size_bytes -
-               config.start_sector * DEFAULT_SECTOR_SIZE;
+               config.start_sector * config.sector_size;
 
        if (config.start_sector % DEFAULT_SECTORS_PER_BLOCK) {

and,
DEFAULT_SECTORS_PER_BLOCK should be instead by config.sectors_per_blk at the same patch ?

thanks,
Kinglong Mee

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/

author
#2 lore raw

Hi Kinglong,

Quoted 22 lines

-----Original Message-----
From: Kinglong Mee [mailto:[email protected]]
Sent: Friday, January 30, 2015 8:04 PM
To: Chao Yu
Cc: Jaegeuk Kim; Changman Lee; [email protected]
Subject: Re: [f2fs-dev] [PATCH] mkfs.f2fs: support large sector size

Quoted 14 lines · Chao Yu

Since f2fs support large sector size in commit 55cf9cb63f0e "f2fs: support large sector size", block device with sector size of 512/1024/2048/4096 bytes can be supported.

But mkfs.f2fs still use default sector size: 512 bytes as sector size, let's fix this issue in this patch.

---
 lib/libf2fs.c            | 2 +-
 mkfs/f2fs_format.c       | 6 +++---
 mkfs/f2fs_format_utils.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
Quoted 8 lines

lib/libf2fs.c int f2fs_get_device_info(struct f2fs_configuration *c) · line 504

Quoted 6 lines
lib/libf2fs.c +0 -0
index 8123528..9b9578b 100644
@@ -504,7 +504,7 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
        MSG(0, "Info: total sectors = %"PRIu64" (in 512bytes)\n",

Should using c->sector_size instead 512bytes here ?

Right, I will fix this.

Quoted 23 lines
Quoted 23 lines
lib/libf2fs.c +1 -1
                                        c->total_sectors);
        if (c->total_sectors <
-                       (F2FS_MIN_VOLUME_SIZE / DEFAULT_SECTOR_SIZE)) {
+                       (F2FS_MIN_VOLUME_SIZE / c->sector_size)) {
                MSG(0, "Error: Min volume size supported is %d\n",
                                F2FS_MIN_VOLUME_SIZE);
                return -1;
mkfs/f2fs_format.c +2 -2
index a8d2db6..861fe2f 100644
@@ -198,10 +198,10 @@ static int f2fs_prepare_super_block(void)
        set_sb(block_count, config.total_sectors >> log_sectors_per_block);
 
        zone_align_start_offset =
-               (config.start_sector * DEFAULT_SECTOR_SIZE +
+               (config.start_sector * config.sector_size +
                2 * F2FS_BLKSIZE + zone_size_bytes - 1) /
                zone_size_bytes * zone_size_bytes -
-               config.start_sector * DEFAULT_SECTOR_SIZE;
+               config.start_sector * config.sector_size;
 
Quoted 5 lines

mkfs/f2fs_format.c static int f2fs_prepare_super_block(void) · line 206

Quoted 1 line
mkfs/f2fs_format.c +0 -0
        if (config.start_sector % DEFAULT_SECTORS_PER_BLOCK) {

and,
DEFAULT_SECTORS_PER_BLOCK should be instead by config.sectors_per_blk at the same patch ?

That's right, will fix.

Thank you for the review. :)

Regards,

Quoted 3 lines

thanks,
Kinglong Mee

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/