[f2fs] code refactoring:
change mount option #define to constexpr and inline function(f2fs_internal.h)

  (comment: #80, #749  https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/511842)

Change-Id: Ia8dc117317bc962845eb706fa0a1343651aa1e76
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/531070
Reviewed-by: Brett Wilson <brettw@google.com>
diff --git a/f2fs_internal.h b/f2fs_internal.h
index 74ccad1..c504c36 100644
--- a/f2fs_internal.h
+++ b/f2fs_internal.h
@@ -12,17 +12,13 @@
 /*
  * For mount options
  */
-constexpr uint64_t kMOUNT_BG_GC = 0x00000001;
-constexpr uint64_t kMOUNT_DISABLE_ROLL_FORWARD = 0x00000002;
-constexpr uint64_t kMOUNT_DISCARD = 0x00000004;
-constexpr uint64_t kMOUNT_NOHEAP = 0x00000008;
-constexpr uint64_t kMOUNT_XATTR_USER = 0x00000010;
-constexpr uint64_t kMOUNT_POSIX_ACL = 0x00000020;
-constexpr uint64_t kMOUNT_DISABLE_EXT_IDENTIFY = 0x00000040;
-
-#define clear_opt(sbi, option) ((sbi)->mount_opt.opt &= ~kMOUNT_##option)
-#define set_opt(sbi, option) ((sbi)->mount_opt.opt |= kMOUNT_##option)
-#define test_opt(sbi, option) ((sbi)->mount_opt.opt & kMOUNT_##option)
+constexpr uint64_t kMountBgGC = 0x00000001;
+constexpr uint64_t kMountDisableRollForward = 0x00000002;
+constexpr uint64_t kMountDiscard = 0x00000004;
+constexpr uint64_t kMountNoheap = 0x00000008;
+constexpr uint64_t kMountXattrUser = 0x00000010;
+constexpr uint64_t kMountPosixAcl = 0x00000020;
+constexpr uint64_t kMountDisableExtIdentify = 0x00000040;
 
 struct MountInfo {
   uint64_t opt;
@@ -394,6 +390,10 @@
 //  return (SbInfo *)sb->s_fs_info;
 //}
 
+inline void ClearOpt(SbInfo *sbi, uint64_t option) { sbi->mount_opt.opt &= ~option; }
+inline void SetOpt(SbInfo *sbi, uint64_t option) { sbi->mount_opt.opt |= option; }
+inline uint64_t TestOpt(SbInfo *sbi, uint64_t option) { return sbi->mount_opt.opt & option; }
+
 static inline const SuperBlock *RawSuper(SbInfo *sbi) {
   return static_cast<const SuperBlock *>(sbi->raw_super);
 }
diff --git a/namei.cc b/namei.cc
index cc8ec7a..50b046b 100644
--- a/namei.cc
+++ b/namei.cc
@@ -103,7 +103,7 @@
 
   vnode->i_name_sp_ = name;
 
-  if (!test_opt(&sbi, DISABLE_EXT_IDENTIFY))
+  if (!TestOpt(&sbi, kMountDisableExtIdentify))
     SetColdFile(name.data());
 
   SetInodeFlag(&vnode->fi_, InodeInfoFlag::kFiIncLink);
diff --git a/segment.cc b/segment.cc
index 2dafcd5..46288a3 100644
--- a/segment.cc
+++ b/segment.cc
@@ -529,7 +529,7 @@
 
 #if 0  // porting needed (Trim)
     /* Let's use trim */
-    // if (test_opt(sbi, DISCARD))
+    // if (TestOpt(sbi, kMountDiscard))
     //	blkdev_issue_discard(sbi->sb->s_bdev,
     //			StartBlock(sbi, segno) <<
     //			sbi->log_sectors_per_block,
@@ -845,7 +845,7 @@
   if (type == CursegType::kCursegWarmData || type == CursegType::kCursegColdData)
     dir = static_cast<int>(AllocDirection::kAllocRight);
 
-  if (test_opt(&sbi, NOHEAP))
+  if (TestOpt(&sbi, kMountNoheap))
     dir = static_cast<int>(AllocDirection::kAllocRight);
 
   GetNewSegment(&segno, new_sec, dir);
diff --git a/super.cc b/super.cc
index f0fc7b6..18ae823 100644
--- a/super.cc
+++ b/super.cc
@@ -153,17 +153,17 @@
 // }
 
 // int F2fs::F2fsShowOptions(/*seq_file *seq*/) {
-  // if (test_opt(sbi, BG_GC))
+  // if (TestOpt(sbi, kMountBgGC))
   //   seq_puts(seq, ",background_gc_on");
   // else
   //   seq_puts(seq, ",background_gc_off");
-  // if (test_opt(sbi, DISABLE_ROLL_FORWARD))
+  // if (TestOpt(sbi, kMountDisableRollForward))
   //   seq_puts(seq, ",disable_roll_forward");
-  // if (test_opt(sbi, DISCARD))
+  // if (TestOpt(sbi, kMountDiscard))
   //   seq_puts(seq, ",discard");
-  // if (test_opt(sbi, NOHEAP))
+  // if (TestOpt(sbi, kMountNoheap))
   //   seq_puts(seq, ",no_heap_alloc");
-  // if (test_opt(sbi, DISABLE_EXT_IDENTIFY))
+  // if (TestOpt(sbi, kMountDisableExtIdentify))
   //   seq_puts(seq, ",disable_ext_indentify");
 
   // seq_printf(seq, ",active_logs=%u", sbi->active_logs);
@@ -229,16 +229,16 @@
 
   //   switch (token) {
   //   case Opt_gc_background_off:
-  //     clear_opt(sbi_.get(), BbGc);
+  //     ClearOpt(&sbi_.get(), kMountBgGC);
   //     break;
   //   case Opt_disable_roll_forward:
-  //     set_opt(sbi_.get(), DisableRollF);
+  //     SetOpt(sbi_.get(), kMountDisableRollForward);
   //     break;
   //   case Opt_discard:
-  //     set_opt(sbi_.get(), DISCARD);
+  //     SetOpt(sbi_.get(), kMountDiscard);
   //     break;
   //   case Opt_noheap:
-  //     set_opt(sbi_.get(), NOHEAP);
+  //     SetOpt(sbi_.get(), kMountNoheap);
   //     break;
   //   case Opt_active_logs:
   //     if (args->from && match_int(args, &arg))
@@ -248,7 +248,7 @@
   //     sbi_.get()->active_logs = arg;
   //     break;
   //   case Opt_disable_ext_identify:
-  //     set_opt(sbi_.get(), DISABLE_EXT_IDENTIFY);
+  //     SetOpt(sbi_.get(), kMountDisableExtIdentify);
   //     break;
   //   default:
   //     return -EINVAL;
@@ -353,13 +353,13 @@
 #endif
 
   /* mount options are fixed as below */
-  clear_opt(sbi_, BG_GC);
-  clear_opt(sbi_, DISCARD);
-  set_opt(sbi_, NOHEAP);
-  clear_opt(sbi_, XATTR_USER);
-  clear_opt(sbi_, POSIX_ACL);
+  ClearOpt(sbi_.get(), kMountBgGC);
+  ClearOpt(sbi_.get(), kMountDiscard);
+  SetOpt(sbi_.get(), kMountNoheap);
+  ClearOpt(sbi_.get(), kMountXattrUser);
+  ClearOpt(sbi_.get(), kMountPosixAcl);
   sbi_->active_logs = kNrCursegType;
-  set_opt(sbi_, DISABLE_EXT_IDENTIFY);
+  SetOpt(sbi_.get(), kMountDisableExtIdentify);
 
 #if 0  // porting needed
   /* parse mount options */
@@ -385,7 +385,7 @@
   // sb->s_fs_info = sbi_.get();
   // sb->s_time_gran = 1;
   // sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
-  //  (test_opt(sbi_, POSIX_ACL) ? MS_POSIXACL : 0);
+  //  (TestOpt(sbi_.get(), kMountPosixAcl) ? MS_POSIXACL : 0);
   // memcpy(&sb->s_uuid, RawSb().uuid, sizeof(RawSb().uuid));
 
   /* init f2fs-specific super block info */
@@ -481,7 +481,7 @@
 
   /* recover fsynced data */
   if (!(sbi_->ckpt->ckpt_flags & kCpUmountFlag) &&
-        !test_opt(sbi_.get(), DISABLE_ROLL_FORWARD)) {
+        !TestOpt(sbi_.get(), kMountDisableExtIdentify)) {
     RecoverFsyncData();
   }