linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] libf2fs: reset wanted_total_sectors by new sector_size
@ 2018-03-27 17:19 Jaegeuk Kim
  2018-03-28  2:40 ` Junling Zheng
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Jaegeuk Kim @ 2018-03-27 17:19 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: katao, Jaegeuk Kim

From: katao <katao@xiaomi.com>

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.
Link: https://issuetracker.google.com/issues/76407663

Signed-off-by: katao <katao@xiaomi.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
---
 lib/libf2fs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 0c684d5..5f11796 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -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) {
-- 
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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-04-03  5:57 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-27 17:19 [PATCH] libf2fs: reset wanted_total_sectors by new sector_size Jaegeuk Kim
2018-03-28  2:40 ` Junling Zheng
2018-03-28  9:04 ` [RFC PATCH] mkfs.f2fs: use 512B as the sector size criterion Junling Zheng
     [not found]   ` <CAK6vGd9zBAmYRkVn9PObVvdfX6RfEDc+bmD-gg-+9+SvxsueiQ@mail.gmail.com>
2018-03-29  2:09     ` Junling Zheng
2018-03-29  2:11       ` Jaegeuk Kim
2018-03-29  2:42       ` [RFC PATCH v2] " Junling Zheng
2018-03-30  9:28 ` [PATCH] libf2fs: reset wanted_total_sectors by new sector_size Chao Yu
2018-03-30 10:51   ` Junling Zheng
2018-03-30 11:26     ` Chao Yu
2018-03-30 11:34       ` Junling Zheng
2018-03-30 15:39         ` Jaegeuk Kim
2018-03-30 16:23           ` Jaegeuk Kim
2018-04-02  7:19           ` Chao Yu
2018-04-02 20:03             ` Jaegeuk Kim
2018-04-03  5:56               ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).