mkfs.f2fs: expand scalability of nat bitmap
PATCH v3 1/1 mkfs.f2fs: expand scalability of nat bitmap
Previously, our total node number (nat_bitmap) and total nat segment count will not monotonously increase along with image size, and max nat_bitmap size is limited by "CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1", it is with bad scalability when user wants to create more inode/node in larger image.
So this patch tries to relieve the limitation, by default, limitting total nat entry number with 20% of total block number.
Before:image_size(GB) nat_bitmap sit_bitmap nat_segment sit_segment
16 3836 64 36 2
32 3836 64 72 2
64 3772 128 116 4
128 3708 192 114 6
256 3580 320 110 10
512 3260 640 100 20
1024 2684 1216 82 38
2048 1468 2432 44 76
4096 3900 4800 120 150
After:image_size(GB) nat_bitmap sit_bitmap nat_segment sit_segment
16 256 64 8 2
32 512 64 16 2
64 960 128 30 4
128 1856 192 58 6
256 3712 320 116 10
512 7424 640 232 20
1024 14787 1216 462 38
2048 29504 2432 922 76
4096 59008 4800 1844 150
Add a new option '-i' to control turning on/off this feature.
---
v3:
- add a option '-i' to control turning on/off this feature.
fsck/f2fs.h | 19 +++++++++----- fsck/resize.c | 59 ++++++++++++++++++++++++++++++------------- include/f2fs_fs.h | 8 +++++- lib/libf2fs.c | 1 + mkfs/f2fs_format.c | 67 +++++++++++++++++++++++++++++++++---------------- mkfs/f2fs_format_main.c | 6 ++++- 6 files changed, 114 insertions(+), 46 deletions(-)
fsck/f2fs.h +13 -6
@@ -239,6 +239,12 @@ static inline unsigned int ofs_of_node(struct f2fs_node *node_blk)return flag >>OFFSET_BIT_SHIFT ; } +static inline bool is_set_ckpt_flags (struct f2fs_checkpoint *cp,unsigned int f) +{ +unsigned int ckpt_flags =le32_to_cpu (cp->ckpt_flags); +return ckpt_flags & f ?1 :0 ; +} +static inline unsigned long __bitmap_size (struct f2fs_sb_info *sbi,int flag) {struct f2fs_checkpoint *ckpt =F2FS_CKPT (sbi);
@@ -256,6 +262,13 @@ static inline void *__bitmap_ptr(struct f2fs_sb_info *sbi, int flag) {struct f2fs_checkpoint *ckpt =F2FS_CKPT (sbi);int offset; + +if (is_set_ckpt_flags (ckpt,CP_LARGE_NAT_BITMAP_FLAG )) { + offset = (flag ==SIT_BITMAP ) ? +le32_to_cpu (ckpt->nat_ver_bitmap_bytesize) :0 ; +return &ckpt->sit_nat_version_bitmap + offset; + } +if (le32_to_cpu (F2FS_RAW_SUPER (sbi)->cp_payload) >0 ) {if (flag ==NAT_BITMAP )return &ckpt->sit_nat_version_bitmap;
@@ -268,12 +281,6 @@ static inline void *__bitmap_ptr(struct f2fs_sb_info *sbi, int flag) } } -static inline bool is_set_ckpt_flags (struct f2fs_checkpoint *cp,unsigned int f) -{ -unsigned int ckpt_flags =le32_to_cpu (cp->ckpt_flags); -return ckpt_flags & f ?1 :0 ; -} -static inline block_t __start_cp_addr (struct f2fs_sb_info *sbi) {block_t start_addr =le32_to_cpu (F2FS_RAW_SUPER (sbi)->cp_blkaddr);
fsck/resize.c +42 -17
82 lines not on this page · raw message
include/f2fs_fs.h +7 -1
@@ -362,6 +362,7 @@ struct f2fs_configuration {int preen_mode;int ro;int preserve_limits;/* preserve quota limits */ +int large_nat_bitmap;__le32 feature;/* defined features */ /* defragmentation parameters */
@@ -614,6 +615,7 @@ struct f2fs_super_block {/* * For checkpoint */ +#define CP_LARGE_NAT_BITMAP_FLAG 0x00000400#define CP_NOCRC_RECOVERY_FLAG 0x00000200#define CP_TRIMMED_FLAG 0x00000100#define CP_NAT_BITS_FLAG 0x00000080
@@ -659,8 +661,10 @@ struct f2fs_checkpoint {unsigned char sit_nat_version_bitmap[1 ]; } __attribute__((packed)); -#define MAX_SIT_BITMAP_SIZE_IN_CKPT \ +#define MAX_SIT_BITMAP_SIZE_IN_CKPT \ (CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1 - 64) +#define MAX_BITMAP_SIZE_IN_CKPT \ + (CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1)/* * For orphan inode management
@@ -850,6 +854,8 @@ struct f2fs_node {#define NAT_ENTRY_PER_BLOCK (PAGE_CACHE_SIZE / sizeof(struct f2fs_nat_entry))#define NAT_BLOCK_OFFSET (start_nid) (start_nid / NAT_ENTRY_PER_BLOCK) +#define DEFAULT_NAT_ENTRY_RATIO 20 +#ifdef ANDROID_WINDOWS_HOST #pragma pack(1)#endif
lib/libf2fs.c +1 -0
@@ -623,6 +623,7 @@ void f2fs_init_configuration(void) c.ro =0 ; c.kd =-1 ; c.dry_run =0 ; + c.large_nat_bitmap =0 ; c.fixed_time =-1 ; }
mkfs/f2fs_format.c +46 -21
94 lines not on this page · raw message
mkfs/f2fs_format_main.c +5 -1
@@ -46,6 +46,7 @@ static void mkfs_usage()MSG (0 ," -d debug level [default:0]\n" );MSG (0 ," -e [extension list] e.g. \"mp3,gif,mov\"\n" );MSG (0 ," -f force overwrite the exist filesystem\n" ); +MSG (0 ," -i extended node bitmap, node ratio is 20%% by default\n" );MSG (0 ," -l label\n" );MSG (0 ," -m support zoned block device [default:0]\n" );MSG (0 ," -o overprovision ratio [default:5]\n" );
@@ -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:il:mo:O:s:S:z:t:f" ;int32_t option=0 ;while ((option =getopt (argc,argv,option_string)) !=EOF ) {
@@ -132,6 +133,9 @@ static void f2fs_parse_options(int argc, char *argv[])case 'e' : c.extension_list =strdup (optarg);break ; +case 'i' : + c.large_nat_bitmap =1 ; +break ;case 'l' :/*v: volume label */ if (strlen (optarg) >512 ) { MSG(0, "Error: Volume Label should be less than "
Signature · 6 lines
2.15.0.55.gc2ece9dc4de6 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot