Skip to contentSkip to conversation

mkfs: set BLKDISCARD by default

PATCH New Jaegeuk Kim 1 participant 1 message Jun 13, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs: set BLKDISCARD by default

And let's show some debug info as well.

---
 mkfs/Makefile.am         | 2 +-
 mkfs/f2fs_format_utils.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
mkfs/Makefile.am +1 -1
index 68cab66..ff136a7 100644
@@ -1,7 +1,7 @@
 ## Makefile.am
 
 AM_CPPFLAGS = ${libuuid_CFLAGS} -I$(top_srcdir)/include
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -DBLKDISCARD
 sbin_PROGRAMS = mkfs.f2fs
 mkfs_f2fs_SOURCES = f2fs_format_main.c f2fs_format.c f2fs_format_utils.c
 mkfs_f2fs_LDADD = ${libuuid_LIBS} $(top_builddir)/lib/libf2fs.la
mkfs/f2fs_format_utils.c +5 -1
index 5cc2a32..8f7e094 100644
@@ -36,8 +36,12 @@ int f2fs_trim_device()
 	if (S_ISREG(stat_buf.st_mode))
 		return 0;
 	else if (S_ISBLK(stat_buf.st_mode)) {
-		if (ioctl(config.fd, BLKDISCARD, &range) < 0)
+		if (ioctl(config.fd, BLKDISCARD, &range) < 0) {
 			MSG(0, "Info: This device doesn't support TRIM\n");
+		} else {
+			MSG(0, "Info: Discarded %lu sectors\n",
+						config.total_sectors);
+		}
 	} else
 		return -1;
 #endif
Signature · 9 lines
1.8.5.2 (Apple Git-48)


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems