Skip to contentSkip to conversation

libf2fs: reset wanted_total_sectors by new sector_size

PATCH In review Jaegeuk Kim 3 participants 15 messages Mar 27, 2018 – Apr 3, 2018 1 message not in the archive Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libf2fs: reset wanted_total_sectors by new sector_size

From: katao <[email protected]>

The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

This bug was reported to Google Issue Tracker.

---
 lib/libf2fs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/libf2fs.c +8 -1
index 0c684d5..5f11796 100644
@@ -799,8 +799,15 @@ int get_device_info(int i)
 #ifdef BLKSSZGET
 		if (ioctl(fd, BLKSSZGET, &sector_size) < 0)
 			MSG(0, "\tError: Using the default sector size\n");
-		else if (dev->sector_size < sector_size)
+		else if (dev->sector_size < sector_size){
+			/*
+			 * wanted_total_sectors need to be reset by new
+			 * sector_size.
+			 */
+			c.wanted_total_sectors = (c.wanted_total_sectors *
+						dev->sector_size) / sector_size;
 			dev->sector_size = sector_size;
+		}
 #endif
 #ifdef BLKGETSIZE64
 		if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {
Signature · 6 lines
2.15.0.531.g2ccb3012c9-goog


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
#1 lore raw

Hi, Jaegeuk:

Quoted 10 lines · Jaegeuk Kim

From: katao <[email protected]>

The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

This bug was reported to Google Issue Tracker.

This fix is puzzling...

IMO, we should not recalculate wanted_total_sectors here. c.wanted_total_sectors is got from user in f2fs_parse_options. Users must know the sector size of device they use, and they need to pass a correct wanted_total_sectors to mkfs.f2fs.

Thanks,
Junling

Quoted 18 lines
---
 lib/libf2fs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/libf2fs.c +2 -1
index 0c684d5..5f11796 100644
@@ -799,8 +799,15 @@ int get_device_info(int i)
 #ifdef BLKSSZGET
 		if (ioctl(fd, BLKSSZGET, &sector_size) < 0)
 			MSG(0, "\tError: Using the default sector size\n");
-		else if (dev->sector_size < sector_size)
+		else if (dev->sector_size < sector_size){
+			/*

lib/libf2fs.c int get_device_info(int i) · line 813

Quoted 10 lines
lib/libf2fs.c +6 -0
+			 * wanted_total_sectors need to be reset by new
+			 * sector_size.
+			 */
+			c.wanted_total_sectors = (c.wanted_total_sectors *
+						dev->sector_size) / sector_size;
 			dev->sector_size = sector_size;
+		}
 #endif
 #ifdef BLKGETSIZE64
 		if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

#2 lore raw

RFC PATCH 1/1 mkfs.f2fs: use 512B as the sector size criterion

In reply to Jaegeuk Kim

Use 512 bytes as the sector size criterion while specifying the amount of sectors passed to mkfs.

---
 lib/libf2fs.c           | 11 ++++++++---
 mkfs/f2fs_format_main.c |  2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)
lib/libf2fs.c +8 -3
index 5f11796..5fdcdde 100644
@@ -1002,9 +1002,14 @@ int f2fs_get_device_info(void)
 		if (get_device_info(i))
 			return -1;
 
-	if (c.wanted_total_sectors < c.total_sectors) {
-		MSG(0, "Info: total device sectors = %"PRIu64" (in %u bytes)\n",
-				c.total_sectors, c.sector_size);
+	if (c.wanted_total_sectors > c.total_sectors)
+		MSG(0, "Warning: total sectors = %"PRIu64", "
+			"wanted sectors = %"PRIu64", in %u bytes\n",
+			c.total_sectors, c.wanted_total_sectors, c.sector_size);
+	else {
+		MSG(0, "Info: total sectors = %"PRIu64", "
+			"wanted sectors = %"PRIu64", in %u bytes\n",
+			c.total_sectors, c.wanted_total_sectors, c.sector_size);
 		c.total_sectors = c.wanted_total_sectors;
 		c.devices[0].total_sectors = c.total_sectors;
 	}
mkfs/f2fs_format_main.c +1 -1
index f23fd84..71fd7c2 100644
@@ -57,7 +57,7 @@ static void mkfs_usage()
 	MSG(0, "  -S sparse mode\n");
 	MSG(0, "  -t 0: nodiscard, 1: discard [default:1]\n");
 	MSG(0, "  -z # of sections per zone [default:1]\n");
-	MSG(0, "sectors: number of sectors. [default: determined by device size]\n");
+	MSG(0, "sectors: number of sectors (in 512 bytes). [default: determined by device size]\n");
 	exit(1);
 }
 
Signature · 6 lines
2.16.2


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

A message that is not in the archive (sent off-list or not yet received): CAK6vGd9zBAmYRkVn9PObVvdfX6RfEDc+bmD-gg-+9+SvxsueiQ@mail.gmail.com

#4 lore raw

Re: [RFC PATCH] mkfs.f2fs: use 512B as the sector size criterion

Hi Jaegeuk,

Quoted 30 lines · Jaegeuk Kim

Hi Junling,

On Wed, Mar 28, 2018 at 2:04 AM, Junling Zheng <[email protected] <mailto:[email protected]>> wrote:

Use 512 bytes as the sector size criterion while specifying the amount of sectors passed to mkfs.

Signed-off-by Junling Zheng <[email protected] <mailto:[email protected]>>

---
lib/libf2fs.c | 11 ++++++++---
mkfs/f2fs_format_main.c | 2 +-
2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c index 5f11796..5fdcdde 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -1002,9 +1002,14 @@ int f2fs_get_device_info(void)
if (get_device_info(i))
return -1;

- if (c.wanted_total_sectors < c.total_sectors) {
- MSG(0, "Info: total device sectors = %"PRIu64" (in %u bytes)\n",
- c.total_sectors, c.sector_size);
+ if (c.wanted_total_sectors > c.total_sectors)
+ MSG(0, "Warning: total sectors = %"PRIu64", "
+ "wanted sectors = %"PRIu64", in %u bytes\n",
+ c.total_sectors, c.wanted_total_sectors, c.sector_size);

Quoted 2 lines

This seems not warning message. IMO, it'd be enough to inform just wanted size over device size?

This warning will not break mkfs, just a warning to inform user, and mkfs will use c.total_sectors to format device :)

Quoted 21 lines
 

    +       else {
    +               MSG(0, "Info: total sectors = %"PRIu64", "
    +                       "wanted sectors = %"PRIu64", in %u bytes\n",
    +                       c.total_sectors, c.wanted_total_sectors, c.sector_size);
                    c.total_sectors = c.wanted_total_sectors;
                    c.devices[0].total_sectors = c.total_sectors;
            }
    diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
    index f23fd84..71fd7c2 100644
    --- a/mkfs/f2fs_format_main.c
    +++ b/mkfs/f2fs_format_main.c
    @@ -57,7 +57,7 @@ static void mkfs_usage()
            MSG(0, "  -S sparse mode\n");
            MSG(0, "  -t 0: nodiscard, 1: discard [default:1]\n");
            MSG(0, "  -z # of sections per zone [default:1]\n");
    -       MSG(0, "sectors: number of sectors. [default: determined by device size]\n");
    +       MSG(0, "sectors: number of sectors (in 512 bytes). [default: determined by device size]\n");
Quoted 1 line

We also need to specify this in man page.

OK, I'll add it.

Quoted 13 lines
 

            exit(1);
     }

    --
    2.16.2
Signature · 1 line
Jaegeuk Kim

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

#5 lore raw

Re: [RFC PATCH] mkfs.f2fs: use 512B as the sector size criterion

Quoted 33 lines · Junling Zheng

Hi Jaegeuk,

Quoted 30 lines · Jaegeuk Kim

Hi Junling,

On Wed, Mar 28, 2018 at 2:04 AM, Junling Zheng <[email protected] <mailto:[email protected]>> wrote:

Use 512 bytes as the sector size criterion while specifying the amount of sectors passed to mkfs.

Signed-off-by Junling Zheng <[email protected] <mailto:[email protected]>>

---
lib/libf2fs.c | 11 ++++++++---
mkfs/f2fs_format_main.c | 2 +-
2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c index 5f11796..5fdcdde 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -1002,9 +1002,14 @@ int f2fs_get_device_info(void)
if (get_device_info(i))
return -1;

- if (c.wanted_total_sectors < c.total_sectors) {
- MSG(0, "Info: total device sectors = %"PRIu64" (in %u bytes)\n",
- c.total_sectors, c.sector_size);
+ if (c.wanted_total_sectors > c.total_sectors)
+ MSG(0, "Warning: total sectors = %"PRIu64", "
+ "wanted sectors = %"PRIu64", in %u bytes\n",
+ c.total_sectors, c.wanted_total_sectors, c.sector_size);

Quoted 5 lines
Quoted 2 lines

This seems not warning message. IMO, it'd be enough to inform just wanted size over device size?

This warning will not break mkfs, just a warning to inform user, and mkfs will use c.total_sectors to format device :)

"Warning:" is warning. :P

Quoted 42 lines
Quoted 22 lines
 

    +       else {
    +               MSG(0, "Info: total sectors = %"PRIu64", "
    +                       "wanted sectors = %"PRIu64", in %u bytes\n",
    +                       c.total_sectors, c.wanted_total_sectors, c.sector_size);
                    c.total_sectors = c.wanted_total_sectors;
                    c.devices[0].total_sectors = c.total_sectors;
            }
    diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
    index f23fd84..71fd7c2 100644
    --- a/mkfs/f2fs_format_main.c
    +++ b/mkfs/f2fs_format_main.c
    @@ -57,7 +57,7 @@ static void mkfs_usage()
            MSG(0, "  -S sparse mode\n");
            MSG(0, "  -t 0: nodiscard, 1: discard [default:1]\n");
            MSG(0, "  -z # of sections per zone [default:1]\n");
    -       MSG(0, "sectors: number of sectors. [default: determined by device size]\n");
    +       MSG(0, "sectors: number of sectors (in 512 bytes). [default: determined by device size]\n");
Quoted 1 line

We also need to specify this in man page.

OK, I'll add it.

Quoted 13 lines
 

            exit(1);
     }

    --
    2.16.2
Signature · 1 line
Jaegeuk Kim
Quoted 7 lines

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

#6 lore raw

RFC PATCH v2 1/1 mkfs.f2fs: use 512B as the sector size criterion

In reply to Junling Zheng

Use 512 bytes as the sector size criterion while specifying the amount of sectors passed to mkfs.

---
Changes from v1:
- specify the sector size criterion in man page
- replace "Warning" with "Info" while wanted size is over device size

 lib/libf2fs.c           | 5 +++--
 man/mkfs.f2fs.8         | 2 +-
 mkfs/f2fs_format_main.c | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
lib/libf2fs.c +3 -2
index 5f11796..906f789 100644
@@ -1002,9 +1002,10 @@ int f2fs_get_device_info(void)
 		if (get_device_info(i))
 			return -1;
 
+	MSG(0, "Info: total sectors = %"PRIu64", "
+		"wanted sectors = %"PRIu64", in %u bytes\n",
+		c.total_sectors, c.wanted_total_sectors, c.sector_size);
 	if (c.wanted_total_sectors < c.total_sectors) {
-		MSG(0, "Info: total device sectors = %"PRIu64" (in %u bytes)\n",
-				c.total_sectors, c.sector_size);
 		c.total_sectors = c.wanted_total_sectors;
 		c.devices[0].total_sectors = c.total_sectors;
 	}
man/mkfs.f2fs.8 +1 -1
index c2f9c86..e48ce39 100644
@@ -63,7 +63,7 @@ mkfs.f2fs \- create an F2FS file system
 is used to create a f2fs file system (usually in a disk partition).
 \fIdevice\fP is the special file corresponding to the device (e.g.
 \fI/dev/sdXX\fP).
-\fIsectors\fP is optionally given for specifing the filesystem size.
+\fIsectors\fP (in 512 bytes) is optionally given for specifing the filesystem size.
 .PP
 The exit code returned by
 .B mkfs.f2fs
mkfs/f2fs_format_main.c +1 -1
index f23fd84..71fd7c2 100644
@@ -57,7 +57,7 @@ static void mkfs_usage()
 	MSG(0, "  -S sparse mode\n");
 	MSG(0, "  -t 0: nodiscard, 1: discard [default:1]\n");
 	MSG(0, "  -z # of sections per zone [default:1]\n");
-	MSG(0, "sectors: number of sectors. [default: determined by device size]\n");
+	MSG(0, "sectors: number of sectors (in 512 bytes). [default: determined by device size]\n");
 	exit(1);
 }
 
Signature · 6 lines
2.16.2


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
#7 lore raw
In reply to Jaegeuk Kim

Hi All,

Quoted 9 lines · Jaegeuk Kim

From: katao <[email protected]>

The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

This bug was reported to Google Issue Tracker.

I don't think this is the right way, since now we have changed previous sector_counter's meaning, some applications, for example, like xfstests will get device's real sector size via blockdev --getsize64, then calculate total wanted sector count by total_wanted_size / real_sector_size, if we changed default sector size to 512bytes, xfstests will pass a wrong sector number, result in getting wrong partition size.

For something worse, in order to get the correct sector number, we have to change the way of calculation method of xfstests for new mkfs, but how can xfstests know the current version of mkfs is new or old...

I think the change didn't consider backward compatibility of mkfs, so, in order to keep that, we'd better to let user pass the right sector number based on their device, or we can introduce a new parameter to indicate user wanted total size.

How do you think?

Thanks,

Quoted 19 lines
---
 lib/libf2fs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/libf2fs.c +2 -1
index 0c684d5..5f11796 100644
@@ -799,8 +799,15 @@ int get_device_info(int i)
 #ifdef BLKSSZGET
 		if (ioctl(fd, BLKSSZGET, &sector_size) < 0)
 			MSG(0, "\tError: Using the default sector size\n");
-		else if (dev->sector_size < sector_size)
+		else if (dev->sector_size < sector_size){
+			/*

lib/libf2fs.c int get_device_info(int i) · line 813

Quoted 10 lines
lib/libf2fs.c +6 -0
+			 * wanted_total_sectors need to be reset by new
+			 * sector_size.
+			 */
+			c.wanted_total_sectors = (c.wanted_total_sectors *
+						dev->sector_size) / sector_size;
 			dev->sector_size = sector_size;
+		}
 #endif
 #ifdef BLKGETSIZE64
 		if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

#8 lore raw

Hi,

Quoted 24 lines · Chao Yu

Hi All,

Quoted 9 lines · Jaegeuk Kim

From: katao <[email protected]>

The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

This bug was reported to Google Issue Tracker.

I don't think this is the right way, since now we have changed previous sector_counter's meaning, some applications, for example, like xfstests will get device's real sector size via blockdev --getsize64, then calculate total wanted sector count by total_wanted_size / real_sector_size, if we changed default sector size to 512bytes, xfstests will pass a wrong sector number, result in getting wrong partition size.

For something worse, in order to get the correct sector number, we have to change the way of calculation method of xfstests for new mkfs, but how can xfstests know the current version of mkfs is new or old...

Quoted 7 lines

I think the change didn't consider backward compatibility of mkfs, so, in order to keep that, we'd better to let user pass the right sector number based on their device, or we can introduce a new parameter to indicate user wanted total size.

How do you think?

Agree. It's not backward-compatible. Most users can pass the correct sector number calculated by the real sector size. For those very few users using 512B despite of the actual sector size, all we need to do is informing them the real sector size.

Thanks,
Junling

Quoted 26 lines

Thanks,

Quoted 24 lines
---
 lib/libf2fs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/libf2fs.c +7 -1
index 0c684d5..5f11796 100644
@@ -799,8 +799,15 @@ int get_device_info(int i)
 #ifdef BLKSSZGET
 		if (ioctl(fd, BLKSSZGET, &sector_size) < 0)
 			MSG(0, "\tError: Using the default sector size\n");
-		else if (dev->sector_size < sector_size)
+		else if (dev->sector_size < sector_size){
+			/*
+			 * wanted_total_sectors need to be reset by new
+			 * sector_size.
+			 */
+			c.wanted_total_sectors = (c.wanted_total_sectors *
+						dev->sector_size) / sector_size;
 			dev->sector_size = sector_size;
Quoted 9 lines

lib/libf2fs.c int get_device_info(int i) · line 813

Quoted 5 lines
lib/libf2fs.c +1 -0
+		}
 #endif
 #ifdef BLKGETSIZE64
 		if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {

.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

#9 lore raw
Quoted 32 lines · Junling Zheng

Hi,

Quoted 29 lines · Chao Yu

Hi All,

Quoted 9 lines · Jaegeuk Kim

From: katao <[email protected]>

The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

This bug was reported to Google Issue Tracker.

I don't think this is the right way, since now we have changed previous sector_counter's meaning, some applications, for example, like xfstests will get device's real sector size via blockdev --getsize64, then calculate total wanted sector count by total_wanted_size / real_sector_size, if we changed default sector size to 512bytes, xfstests will pass a wrong sector number, result in getting wrong partition size.

For something worse, in order to get the correct sector number, we have to change the way of calculation method of xfstests for new mkfs, but how can xfstests know the current version of mkfs is new or old...

I think the change didn't consider backward compatibility of mkfs, so, in order to keep that, we'd better to let user pass the right sector number based on their device, or we can introduce a new parameter to indicate user wanted total size.

Quoted 6 lines
Quoted 2 lines

How do you think?

Agree. It's not backward-compatible. Most users can pass the correct sector number calculated by the real sector size. For those very few users using 512B despite of the actual sector size, all we need to do is informing them the real sector size.

The problem is via passed sector number, we can't know user has already knew the real sector size or not, so we don't have any chance to info them.

Thanks,

Quoted 42 lines

Thanks,
Junling

Quoted 26 lines

Thanks,

Quoted 24 lines
---
 lib/libf2fs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/libf2fs.c +7 -1
index 0c684d5..5f11796 100644
@@ -799,8 +799,15 @@ int get_device_info(int i)
 #ifdef BLKSSZGET
 		if (ioctl(fd, BLKSSZGET, &sector_size) < 0)
 			MSG(0, "\tError: Using the default sector size\n");
-		else if (dev->sector_size < sector_size)
+		else if (dev->sector_size < sector_size){
+			/*
+			 * wanted_total_sectors need to be reset by new
+			 * sector_size.
+			 */
+			c.wanted_total_sectors = (c.wanted_total_sectors *
+						dev->sector_size) / sector_size;
 			dev->sector_size = sector_size;
Quoted 9 lines

lib/libf2fs.c int get_device_info(int i) · line 813

Quoted 5 lines
lib/libf2fs.c +1 -0
+		}
 #endif
 #ifdef BLKGETSIZE64
 		if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {

.

Quoted 2 lines

.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

#10 lore raw
Quoted 36 lines · Chao Yu
Quoted 35 lines · Junling Zheng

Hi,

Quoted 31 lines · Chao Yu

Hi All,

Quoted 9 lines · Jaegeuk Kim

From: katao <[email protected]>

The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

This bug was reported to Google Issue Tracker.

I don't think this is the right way, since now we have changed previous sector_counter's meaning, some applications, for example, like xfstests will get device's real sector size via blockdev --getsize64, then calculate total wanted sector count by total_wanted_size / real_sector_size, if we changed default sector size to 512bytes, xfstests will pass a wrong sector number, result in getting wrong partition size.

For something worse, in order to get the correct sector number, we have to change the way of calculation method of xfstests for new mkfs, but how can xfstests know the current version of mkfs is new or old...

I think the change didn't consider backward compatibility of mkfs, so, in order to keep that, we'd better to let user pass the right sector number based on their device, or we can introduce a new parameter to indicate user wanted total size.

How do you think?

Quoted 7 lines
Quoted 3 lines

Agree. It's not backward-compatible. Most users can pass the correct sector number calculated by the real sector size. For those very few users using 512B despite of the actual sector size, all we need to do is informing them the real sector size.

The problem is via passed sector number, we can't know user has already knew the real sector size or not, so we don't have any chance to info them.

Yeah, we can't guess users' behaviors. And only when wanted size is over device size, we can inform users the real sector size.

Quoted 44 lines

Thanks,

Quoted 42 lines

Thanks,
Junling

Quoted 35 lines

Thanks,

Quoted 19 lines
---
 lib/libf2fs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/libf2fs.c +2 -1
index 0c684d5..5f11796 100644
@@ -799,8 +799,15 @@ int get_device_info(int i)
 #ifdef BLKSSZGET
 		if (ioctl(fd, BLKSSZGET, &sector_size) < 0)
 			MSG(0, "\tError: Using the default sector size\n");
-		else if (dev->sector_size < sector_size)
+		else if (dev->sector_size < sector_size){
+			/*

lib/libf2fs.c int get_device_info(int i) · line 813

Quoted 10 lines
lib/libf2fs.c +6 -0
+			 * wanted_total_sectors need to be reset by new
+			 * sector_size.
+			 */
+			c.wanted_total_sectors = (c.wanted_total_sectors *
+						dev->sector_size) / sector_size;
 			dev->sector_size = sector_size;
+		}
 #endif
 #ifdef BLKGETSIZE64
 		if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {

.

Quoted 6 lines
Quoted 2 lines

.

.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

#11 lore raw
Quoted 41 lines · Junling Zheng
Quoted 40 lines · Chao Yu
Quoted 38 lines · Junling Zheng

Hi,

Quoted 24 lines · Chao Yu

Hi All,

Quoted 9 lines · Jaegeuk Kim

From: katao <[email protected]>

The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

This bug was reported to Google Issue Tracker.

I don't think this is the right way, since now we have changed previous sector_counter's meaning, some applications, for example, like xfstests will get device's real sector size via blockdev --getsize64, then calculate total wanted sector count by total_wanted_size / real_sector_size, if we changed default sector size to 512bytes, xfstests will pass a wrong sector number, result in getting wrong partition size.

For something worse, in order to get the correct sector number, we have to change the way of calculation method of xfstests for new mkfs, but how can xfstests know the current version of mkfs is new or old...

Quoted 7 lines

I think the change didn't consider backward compatibility of mkfs, so, in order to keep that, we'd better to let user pass the right sector number based on their device, or we can introduce a new parameter to indicate user wanted total size.

How do you think?

Agree. It's not backward-compatible. Most users can pass the correct sector number calculated by the real sector size. For those very few users using 512B despite of the actual sector size, all we need to do is informing them the real sector size.

Quoted 6 lines
Quoted 3 lines

The problem is via passed sector number, we can't know user has already knew the real sector size or not, so we don't have any chance to info them.

Yeah, we can't guess users' behaviors. And only when wanted size is over device size, we can inform users the real sector size.

So, current problem would be that wanted_total_sectors is given by:
- device sector size in xfstests
- 4KB in fs_mgr in Android
- 512B in recovery in Android

And, my concern is why user always needs to think about sector_size to give target image size, and I thought 512B would be good to set as a default smallest value.

Setting it 512B by default can give some confusion to users tho, it won't hurt the existing partitions or images. So, I bet users will get noticed quickly, when formatting new partition under this rule.

For xfstests, we're able to add another testcase in /f2fs to check this is applied or not by simply testing some wanted_total_sectors numbers on different sector sizes.

Thanks,

Quoted 45 lines
Quoted 45 lines

Thanks,

Quoted 42 lines

Thanks,
Junling

Quoted 35 lines

Thanks,

Quoted 19 lines
---
 lib/libf2fs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/libf2fs.c +2 -1
index 0c684d5..5f11796 100644
@@ -799,8 +799,15 @@ int get_device_info(int i)
 #ifdef BLKSSZGET
 		if (ioctl(fd, BLKSSZGET, &sector_size) < 0)
 			MSG(0, "\tError: Using the default sector size\n");
-		else if (dev->sector_size < sector_size)
+		else if (dev->sector_size < sector_size){
+			/*

lib/libf2fs.c int get_device_info(int i) · line 813

Quoted 10 lines
lib/libf2fs.c +6 -0
+			 * wanted_total_sectors need to be reset by new
+			 * sector_size.
+			 */
+			c.wanted_total_sectors = (c.wanted_total_sectors *
+						dev->sector_size) / sector_size;
 			dev->sector_size = sector_size;
+		}
 #endif
 #ifdef BLKGETSIZE64
 		if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {

.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

.

.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

#12 lore raw
Quoted 54 lines · Jaegeuk Kim
Quoted 41 lines · Junling Zheng
Quoted 40 lines · Chao Yu
Quoted 38 lines · Junling Zheng

Hi,

Quoted 24 lines · Chao Yu

Hi All,

Quoted 9 lines · Jaegeuk Kim

From: katao <[email protected]>

The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

This bug was reported to Google Issue Tracker.

I don't think this is the right way, since now we have changed previous sector_counter's meaning, some applications, for example, like xfstests will get device's real sector size via blockdev --getsize64, then calculate total wanted sector count by total_wanted_size / real_sector_size, if we changed default sector size to 512bytes, xfstests will pass a wrong sector number, result in getting wrong partition size.

For something worse, in order to get the correct sector number, we have to change the way of calculation method of xfstests for new mkfs, but how can xfstests know the current version of mkfs is new or old...

Quoted 7 lines

I think the change didn't consider backward compatibility of mkfs, so, in order to keep that, we'd better to let user pass the right sector number based on their device, or we can introduce a new parameter to indicate user wanted total size.

How do you think?

Agree. It's not backward-compatible. Most users can pass the correct sector number calculated by the real sector size. For those very few users using 512B despite of the actual sector size, all we need to do is informing them the real sector size.

Quoted 6 lines
Quoted 3 lines

The problem is via passed sector number, we can't know user has already knew the real sector size or not, so we don't have any chance to info them.

Yeah, we can't guess users' behaviors. And only when wanted size is over device size, we can inform users the real sector size.

So, current problem would be that wanted_total_sectors is given by:
- device sector size in xfstests
- 4KB in fs_mgr in Android
- 512B in recovery in Android

Quoted 7 lines

And, my concern is why user always needs to think about sector_size to give target image size, and I thought 512B would be good to set as a default smallest value.

Setting it 512B by default can give some confusion to users tho, it won't hurt the existing partitions or images. So, I bet users will get noticed quickly, when formatting new partition under this rule.

So, I just integrated two patches in terms of this issue. Could you take a look at this?

Quoted 1 line

From 9e615dd0a350d336a8067c64d9ef2bb7ce43a3e5 Mon Sep 17 00:00:00 2001

From: katao <[email protected]>
Date: Tue, 27 Mar 2018 13:25:46 +0800
Subject: [PATCH] libf2fs,mkfs.f2fs: reset wanted_total_sectors by new
sector_size

Use 512 bytes as the sector size criterion while specifying the amount of sectors passed to mkfs.

Then, the args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes). get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

---
 lib/libf2fs.c           | 21 ++++++++++++++++++---
 man/mkfs.f2fs.8         |  2 +-
 mkfs/f2fs_format_main.c |  2 +-
 3 files changed, 20 insertions(+), 5 deletions(-)
lib/libf2fs.c +18 -3
index ffdbccb..af1ca65 100644
@@ -812,8 +812,21 @@ int get_device_info(int i)
 #ifdef BLKSSZGET
 		if (ioctl(fd, BLKSSZGET, &sector_size) < 0)
 			MSG(0, "\tError: Using the default sector size\n");
-		else if (dev->sector_size < sector_size)
+		else if (dev->sector_size < sector_size){
+			/*
+			 * wanted_total_sectors need to be reset by new
+			 * sector_size.
+			 */
+			if (c.wanted_total_sectors != -1) {
+				c.wanted_total_sectors =
+					(c.wanted_total_sectors *
+						dev->sector_size) / sector_size;
+				MSG(0, "Warn: change wanted sectors = %"PRIu64""
+					" (in %u bytes)\n",
+					c.wanted_total_sectors, sector_size);
+			}
 			dev->sector_size = sector_size;
+		}
 #endif
 #ifdef BLKGETSIZE64
 		if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {
@@ -1008,9 +1021,11 @@ int f2fs_get_device_info(void)
 		if (get_device_info(i))
 			return -1;
 
-	if (c.wanted_total_sectors < c.total_sectors) {
-		MSG(0, "Info: total device sectors = %"PRIu64" (in %u bytes)\n",
+	MSG(0, "Info: total device sectors = %"PRIu64" (in %u bytes)\n",
 				c.total_sectors, c.sector_size);
+	if (c.wanted_total_sectors < c.total_sectors) {
+		MSG(0, "Info: wanted sectors = %"PRIu64" (in 512 bytes)\n",
+				c.wanted_total_sectors);
 		c.total_sectors = c.wanted_total_sectors;
 		c.devices[0].total_sectors = c.total_sectors;
 	}
man/mkfs.f2fs.8 +1 -1
index c2f9c86..e48ce39 100644
@@ -63,7 +63,7 @@ mkfs.f2fs \- create an F2FS file system
 is used to create a f2fs file system (usually in a disk partition).
 \fIdevice\fP is the special file corresponding to the device (e.g.
 \fI/dev/sdXX\fP).
-\fIsectors\fP is optionally given for specifing the filesystem size.
+\fIsectors\fP (in 512 bytes) is optionally given for specifing the filesystem size.
 .PP
 The exit code returned by
 .B mkfs.f2fs
mkfs/f2fs_format_main.c +1 -1
index e522b2f..f8361b2 100644
@@ -55,7 +55,7 @@ static void mkfs_usage()
 	MSG(0, "  -S sparse mode\n");
 	MSG(0, "  -t 0: nodiscard, 1: discard [default:1]\n");
 	MSG(0, "  -z # of sections per zone [default:1]\n");
-	MSG(0, "sectors: number of sectors. [default: determined by device size]\n");
+	MSG(0, "sectors: number of sectors (in 512 bytes). [default: determined by device size]\n");
 	exit(1);
 }
 
Signature · 6 lines
2.15.0.531.g2ccb3012c9-goog


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
#13 lore raw
In reply to Jaegeuk Kim
Quoted 49 lines · Jaegeuk Kim
Quoted 41 lines · Junling Zheng
Quoted 40 lines · Chao Yu
Quoted 38 lines · Junling Zheng

Hi,

Quoted 24 lines · Chao Yu

Hi All,

Quoted 9 lines · Jaegeuk Kim

From: katao <[email protected]>

The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

This bug was reported to Google Issue Tracker.

I don't think this is the right way, since now we have changed previous sector_counter's meaning, some applications, for example, like xfstests will get device's real sector size via blockdev --getsize64, then calculate total wanted sector count by total_wanted_size / real_sector_size, if we changed default sector size to 512bytes, xfstests will pass a wrong sector number, result in getting wrong partition size.

For something worse, in order to get the correct sector number, we have to change the way of calculation method of xfstests for new mkfs, but how can xfstests know the current version of mkfs is new or old...

Quoted 7 lines

I think the change didn't consider backward compatibility of mkfs, so, in order to keep that, we'd better to let user pass the right sector number based on their device, or we can introduce a new parameter to indicate user wanted total size.

How do you think?

Agree. It's not backward-compatible. Most users can pass the correct sector number calculated by the real sector size. For those very few users using 512B despite of the actual sector size, all we need to do is informing them the real sector size.

Quoted 6 lines
Quoted 3 lines

The problem is via passed sector number, we can't know user has already knew the real sector size or not, so we don't have any chance to info them.

Yeah, we can't guess users' behaviors. And only when wanted size is over device size, we can inform users the real sector size.

Quoted 8 lines

So, current problem would be that wanted_total_sectors is given by:
- device sector size in xfstests
- 4KB in fs_mgr in Android
- 512B in recovery in Android

And, my concern is why user always needs to think about sector_size to give target image size, and I thought 512B would be good to set as a default smallest value.

Of course, IMO, the most direct way is let user pass image size to mkfs.f2fs instead of caculated sector size, I think that will make all happy.

Quoted 4 lines

Setting it 512B by default can give some confusion to users tho, it won't hurt the existing partitions or images. So, I bet users will get noticed quickly, when formatting new partition under this rule.

For those f2fs users, who makes image based on non-512B sector device, once they upgrade mkfs.f2fs, they will encounter this issue, that may make bad reputation.

For interface in f2fs private ioctl, sysfs entry, or syscall, we keep the rule that once we want to do some change on it, we will not change the old interface directly, instead, introduce a new one to keep backward compatibility of old one. Still, I hope we can keep that rule in mkfs.f2fs parameter.

Quoted 4 lines

For xfstests, we're able to add another testcase in /f2fs to check this is applied or not by simply testing some wanted_total_sectors numbers on different sector sizes.

But, for people who upgrade mkfs but not the newly introduced testcase will encounter this issue.

I just make xfstests as an example, I doubt there will be more user/application on phone/server/pc scenario may be impacted by this.

Thanks,

Quoted 52 lines

Thanks,

Quoted 49 lines
Quoted 49 lines

Thanks,

Quoted 44 lines

Thanks,
Junling

Quoted 26 lines

Thanks,

Quoted 24 lines
---
 lib/libf2fs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/libf2fs.c +7 -1
index 0c684d5..5f11796 100644
@@ -799,8 +799,15 @@ int get_device_info(int i)
 #ifdef BLKSSZGET
 		if (ioctl(fd, BLKSSZGET, &sector_size) < 0)
 			MSG(0, "\tError: Using the default sector size\n");
-		else if (dev->sector_size < sector_size)
+		else if (dev->sector_size < sector_size){
+			/*
+			 * wanted_total_sectors need to be reset by new
+			 * sector_size.
+			 */
+			c.wanted_total_sectors = (c.wanted_total_sectors *
+						dev->sector_size) / sector_size;
 			dev->sector_size = sector_size;
Quoted 9 lines

lib/libf2fs.c int get_device_info(int i) · line 813

Quoted 5 lines
lib/libf2fs.c +1 -0
+		}
 #endif
 #ifdef BLKGETSIZE64
 		if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {

.

.

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

.

.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

#14 lore raw
Quoted 55 lines · Chao Yu
Quoted 54 lines · Jaegeuk Kim
Quoted 41 lines · Junling Zheng
Quoted 40 lines · Chao Yu
Quoted 38 lines · Junling Zheng

Hi,

Quoted 24 lines · Chao Yu

Hi All,

Quoted 9 lines · Jaegeuk Kim

From: katao <[email protected]>

The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

This bug was reported to Google Issue Tracker.

I don't think this is the right way, since now we have changed previous sector_counter's meaning, some applications, for example, like xfstests will get device's real sector size via blockdev --getsize64, then calculate total wanted sector count by total_wanted_size / real_sector_size, if we changed default sector size to 512bytes, xfstests will pass a wrong sector number, result in getting wrong partition size.

For something worse, in order to get the correct sector number, we have to change the way of calculation method of xfstests for new mkfs, but how can xfstests know the current version of mkfs is new or old...

Quoted 7 lines

I think the change didn't consider backward compatibility of mkfs, so, in order to keep that, we'd better to let user pass the right sector number based on their device, or we can introduce a new parameter to indicate user wanted total size.

How do you think?

Agree. It's not backward-compatible. Most users can pass the correct sector number calculated by the real sector size. For those very few users using 512B despite of the actual sector size, all we need to do is informing them the real sector size.

Quoted 6 lines
Quoted 3 lines

The problem is via passed sector number, we can't know user has already knew the real sector size or not, so we don't have any chance to info them.

Yeah, we can't guess users' behaviors. And only when wanted size is over device size, we can inform users the real sector size.

So, current problem would be that wanted_total_sectors is given by:
- device sector size in xfstests
- 4KB in fs_mgr in Android
- 512B in recovery in Android

Quoted 6 lines
Quoted 3 lines

And, my concern is why user always needs to think about sector_size to give target image size, and I thought 512B would be good to set as a default smallest value.

Of course, IMO, the most direct way is let user pass image size to mkfs.f2fs instead of caculated sector size, I think that will make all happy.

No, it can become too large number.

Quoted 6 lines
Quoted 5 lines

Setting it 512B by default can give some confusion to users tho, it won't hurt the existing partitions or images. So, I bet users will get noticed quickly, when formatting new partition under this rule.

Quoted 7 lines

For those f2fs users, who makes image based on non-512B sector device, once they upgrade mkfs.f2fs, they will encounter this issue, that may make bad reputation.

For interface in f2fs private ioctl, sysfs entry, or syscall, we keep the rule that once we want to do some change on it, we will not change the old interface directly, instead, introduce a new one to keep backward compatibility of old one. Still, I hope we can keep that rule in mkfs.f2fs parameter.

Okay, so in order to give more flexible ways, it'd be fine to add wanted_sector_size by "-w" so that we could blow out all the existing concern like this.

From: katao <[email protected]>
Date: Tue, 27 Mar 2018 13:25:46 +0800
Subject: [PATCH] libf2fs,mkfs.f2fs: add wanted_sector_size for
wanted_total_sectors

The wanted_total_sectors was determined by device sector size, but sometimes we don't know precise sector_size by default. So, let's give wanted_sector_size in such the ambiguous situation.

---
 include/f2fs_fs.h       |  1 +
 lib/libf2fs.c           | 13 +++++++++++++
 man/mkfs.f2fs.8         |  8 ++++++++
 mkfs/f2fs_format_main.c |  6 +++++-
 4 files changed, 27 insertions(+), 1 deletion(-)
include/f2fs_fs.h +1 -0
index 053ccbe..2d75d39 100644
@@ -335,6 +335,7 @@ struct f2fs_configuration {
 	u_int64_t device_size;
 	u_int64_t total_sectors;
 	u_int64_t wanted_total_sectors;
+	u_int64_t wanted_sector_size;
 	u_int64_t target_sectors;
 	u_int32_t sectors_per_blk;
 	u_int32_t blks_per_seg;
lib/libf2fs.c +13 -0
index ffdbccb..bb7fe2e 100644
@@ -593,6 +593,7 @@ void f2fs_init_configuration(void)
 	c.blks_per_seg = DEFAULT_BLOCKS_PER_SEGMENT;
 	c.rootdev_name = get_rootdev();
 	c.wanted_total_sectors = -1;
+	c.wanted_sector_size = -1;
 	c.zoned_mode = 0;
 	c.zoned_model = 0;
 	c.zone_blocks = 0;
@@ -900,6 +901,18 @@ int get_device_info(int i)
 				dev->zone_blocks);
 	}
 #endif
+	/* adjust wanted_total_sectors */
+	if (c.wanted_total_sectors != -1) {
+		MSG(0, "Info: wanted sectors = %"PRIu64" (in %"PRIu64" bytes)\n",
+				c.wanted_total_sectors, c.wanted_sector_size);
+		if (c.wanted_sector_size == -1) {
+			c.wanted_sector_size = dev->sector_size;
+		} else if (dev->sector_size != c.wanted_sector_size) {
+			c.wanted_total_sectors *= c.wanted_sector_size;
+			c.wanted_total_sectors /= dev->sector_size;
+		}
+	}
+
 	c.total_sectors += dev->total_sectors;
 	return 0;
 }
man/mkfs.f2fs.8 +8 -0
index c2f9c86..442c0ea 100644
@@ -53,6 +53,10 @@ mkfs.f2fs \- create an F2FS file system
 .I nodiscard/discard
 ]
 [
+.B \-w
+.I specific sector_size for target sectors
+]
+[
 .B \-z
 .I #-of-sections-per-zone
 ]
@@ -125,6 +129,10 @@ Specify 1 or 0 to enable/disable discard policy.
 If the value is equal to 1, discard policy is enabled, otherwise is disable.
 The default value is 1.
 .TP
+.BI \-w "sector-size"
+Specify the sector size in bytes along with given target sectors.
+Without it, the sectors will be calculated by device sector size.
+.TP
 .BI \-z " #-of-sections-per-zone"
 Specify the number of sections per zone. A zone consists of multiple sections.
 F2FS allocates segments for active logs with separated zones as much as possible.
mkfs/f2fs_format_main.c +5 -1
index e522b2f..19f0854 100644
@@ -54,6 +54,7 @@ static void mkfs_usage()
 	MSG(0, "  -s # of segments per section [default:1]\n");
 	MSG(0, "  -S sparse mode\n");
 	MSG(0, "  -t 0: nodiscard, 1: discard [default:1]\n");
+	MSG(0, "  -w wanted sector size\n");
 	MSG(0, "  -z # of sections per zone [default:1]\n");
 	MSG(0, "sectors: number of sectors. [default: determined by device size]\n");
 	exit(1);
@@ -102,7 +103,7 @@ static void parse_feature(const char *features)
 
 static void f2fs_parse_options(int argc, char *argv[])
 {
-	static const char *option_string = "qa:c:d:e:l:mo:O:s:S:z:t:f";
+	static const char *option_string = "qa:c:d:e:l:mo:O:s:S:z:t:fw:";
 	int32_t option=0;
 
 	while ((option = getopt(argc,argv,option_string)) != EOF) {
@@ -166,6 +167,9 @@ static void f2fs_parse_options(int argc, char *argv[])
 		case 'f':
 			force_overwrite = 1;
 			break;
+		case 'w':
+			c.wanted_sector_size = atoi(optarg);
+			break;
 		default:
 			MSG(0, "\tError: Unknown option %c\n",option);
 			mkfs_usage();
Signature · 6 lines
2.15.0.531.g2ccb3012c9-goog


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Reviewed-by
#15 lore raw
Quoted 74 lines · Jaegeuk Kim
Quoted 55 lines · Chao Yu
Quoted 54 lines · Jaegeuk Kim
Quoted 41 lines · Junling Zheng
Quoted 40 lines · Chao Yu
Quoted 38 lines · Junling Zheng

Hi,

Quoted 24 lines · Chao Yu

Hi All,

Quoted 9 lines · Jaegeuk Kim

From: katao <[email protected]>

The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors.

This bug was reported to Google Issue Tracker.

I don't think this is the right way, since now we have changed previous sector_counter's meaning, some applications, for example, like xfstests will get device's real sector size via blockdev --getsize64, then calculate total wanted sector count by total_wanted_size / real_sector_size, if we changed default sector size to 512bytes, xfstests will pass a wrong sector number, result in getting wrong partition size.

For something worse, in order to get the correct sector number, we have to change the way of calculation method of xfstests for new mkfs, but how can xfstests know the current version of mkfs is new or old...

Quoted 7 lines

I think the change didn't consider backward compatibility of mkfs, so, in order to keep that, we'd better to let user pass the right sector number based on their device, or we can introduce a new parameter to indicate user wanted total size.

How do you think?

Agree. It's not backward-compatible. Most users can pass the correct sector number calculated by the real sector size. For those very few users using 512B despite of the actual sector size, all we need to do is informing them the real sector size.

Quoted 6 lines
Quoted 3 lines

The problem is via passed sector number, we can't know user has already knew the real sector size or not, so we don't have any chance to info them.

Yeah, we can't guess users' behaviors. And only when wanted size is over device size, we can inform users the real sector size.

So, current problem would be that wanted_total_sectors is given by:
- device sector size in xfstests
- 4KB in fs_mgr in Android
- 512B in recovery in Android

Quoted 6 lines
Quoted 3 lines

And, my concern is why user always needs to think about sector_size to give target image size, and I thought 512B would be good to set as a default smallest value.

Of course, IMO, the most direct way is let user pass image size to mkfs.f2fs instead of caculated sector size, I think that will make all happy.

No, it can become too large number.

Quoted 9 lines
Quoted 5 lines

Setting it 512B by default can give some confusion to users tho, it won't hurt the existing partitions or images. So, I bet users will get noticed quickly, when formatting new partition under this rule.

For those f2fs users, who makes image based on non-512B sector device, once they upgrade mkfs.f2fs, they will encounter this issue, that may make bad reputation.

Quoted 8 lines
Quoted 4 lines

For interface in f2fs private ioctl, sysfs entry, or syscall, we keep the rule that once we want to do some change on it, we will not change the old interface directly, instead, introduce a new one to keep backward compatibility of old one. Still, I hope we can keep that rule in mkfs.f2fs parameter.

Okay, so in order to give more flexible ways, it'd be fine to add wanted_sector_size by "-w" so that we could blow out all the existing concern like this.

That's better.

Quoted 6 lines

From: katao <[email protected]>
Date: Tue, 27 Mar 2018 13:25:46 +0800
Subject: [PATCH] libf2fs,mkfs.f2fs: add wanted_sector_size for
wanted_total_sectors

Quoted 7 lines

The wanted_total_sectors was determined by device sector size, but sometimes we don't know precise sector_size by default. So, let's give wanted_sector_size in such the ambiguous situation.

Thanks,

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot