This patch fixes wrong discarding size.
Signed-off-by: Jaegeuk Kim <[email protected]>
---
mkfs/f2fs_format.c | 2 +-
mkfs/f2fs_format_utils.c | 7 +++----
mkfs/f2fs_format_utils.h | 2 +-
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 659c73c..1453b6b 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -948,7 +948,7 @@ int f2fs_format_device(void)
}
if (c.trim) {
- err = f2fs_trim_device(c.fd);
+ err = f2fs_trim_device(c.fd, c.total_sectors * c.sector_size);
if (err < 0) {
MSG(0, "\tError: Failed to trim whole device!!!\n");
goto exit;
diff --git a/mkfs/f2fs_format_utils.c b/mkfs/f2fs_format_utils.c
index eb8e3c0..ba93308 100644
--- a/mkfs/f2fs_format_utils.c
+++ b/mkfs/f2fs_format_utils.c
@@ -34,7 +34,7 @@
#define BLKSECDISCARD _IO(0x12,125)
#endif
-int f2fs_trim_device(int fd)
+int f2fs_trim_device(int fd, u_int64_t bytes)
{
unsigned long long range[2];
struct stat stat_buf;
@@ -45,7 +45,7 @@ int f2fs_trim_device(int fd)
}
range[0] = 0;
- range[1] = stat_buf.st_size;
+ range[1] = bytes;
#if defined(WITH_BLKDISCARD) && defined(BLKDISCARD)
MSG(0, "Info: Discarding device\n");
@@ -70,8 +70,7 @@ int f2fs_trim_device(int fd)
if (ioctl(fd, BLKDISCARD, &range) < 0) {
MSG(0, "Info: This device doesn't support
BLKDISCARD\n");
} else {
- MSG(0, "Info: Discarded %lu MB\n",
- stat_buf.st_size >> 20);
+ MSG(0, "Info: Discarded %llu MB\n", range[1] >> 20);
}
} else
return -1;
diff --git a/mkfs/f2fs_format_utils.h b/mkfs/f2fs_format_utils.h
index bc91aa3..ed28c58 100644
--- a/mkfs/f2fs_format_utils.h
+++ b/mkfs/f2fs_format_utils.h
@@ -12,5 +12,5 @@
extern struct f2fs_configuration c;
-int f2fs_trim_device(int);
+int f2fs_trim_device(int, u_int64_t);
int f2fs_format_device(void);
--
2.8.3
------------------------------------------------------------------------------
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