Skip to contentSkip to conversation

mkfs.f2fs: introduce some macros to simplify coding style

PATCH New Changman Lee 1 participant 1 message Nov 17, 2014 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs.f2fs: introduce some macros to simplify coding style

This patch tries to simplify coding style for readability. Rename shortly
o rename super_block to sb

And, introduce some macros.
o set/get_cp
o set/get_sb
o next/prev_zone, last_zone and last_section
o ALIGN, SEG_ALIGN and ZONE_ALIGN

---
 include/f2fs_fs.h       |   6 +
 lib/libf2fs.c           |   1 +
 mkfs/f2fs_format.c      | 548 +++++++++++++++++++++++-------------------------
 mkfs/f2fs_format_main.c |   1 +
 4 files changed, 272 insertions(+), 284 deletions(-)
include/f2fs_fs.h +6 -0
index efddfca..0c3ba04 100644
@@ -230,6 +230,7 @@ struct f2fs_configuration {
 	u_int32_t cur_seg[6];
 	u_int32_t segs_per_sec;
 	u_int32_t secs_per_zone;
+	u_int32_t segs_per_zone;
 	u_int32_t start_sector;
 	u_int64_t total_sectors;
 	u_int32_t sectors_per_blk;
@@ -786,4 +787,9 @@ f2fs_hash_t f2fs_dentry_hash(const unsigned char *, int);
 
 extern struct f2fs_configuration config;
 
+#define ALIGN(val, size)	((val) + (size) - 1) / (size)
+#define SEG_ALIGN(blks)		ALIGN(blks, config.blks_per_seg)
+#define ZONE_ALIGN(blks)	ALIGN(blks, config.blks_per_seg * \
+					config.segs_per_zone)
+
 #endif	/*__F2FS_FS_H */
lib/libf2fs.c +1 -0
index 14e4164..8123528 100644
@@ -357,6 +357,7 @@ void f2fs_init_configuration(struct f2fs_configuration *c)
 	c->overprovision = 5;
 	c->segs_per_sec = 1;
 	c->secs_per_zone = 1;
+	c->segs_per_zone = 1;
 	c->heap = 1;
 	c->vol_label = "";
 	c->device_name = NULL;
mkfs/f2fs_format.c +264 -284

880 lines not on this page · raw message

mkfs/f2fs_format_main.c +1 -0
index e1f7c69..bba2085 100644
@@ -110,6 +110,7 @@ static void f2fs_parse_options(int argc, char *argv[])
 	config.reserved_segments  =
 			(2 * (100 / config.overprovision + 1) + 6)
 			* config.segs_per_sec;
+	config.segs_per_zone = config.segs_per_sec * config.secs_per_zone;
 }
 
 int main(int argc, char *argv[])
Signature · 9 lines
1.9.1


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk