Introduce f2fs_change_bit to simplify the change bit logic in
function set_to_next_nat{sit}.

Signed-off-by: Gu Zheng <guz.f...@cn.fujitsu.com>
---
 fs/f2fs/f2fs.h    |    9 +++++++++
 fs/f2fs/node.h    |    5 +----
 fs/f2fs/segment.h |    5 +----
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 8171e80..3095a57 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1044,6 +1044,15 @@ static inline int f2fs_clear_bit(unsigned int nr, char 
*addr)
        return ret;
 }
 
+static inline void f2fs_change_bit(unsigned int nr, char *addr)
+{
+       int mask;
+
+       addr += (nr >> 3);
+       mask = 1 << (7 - (nr & 0x07));
+       *addr ^= mask;
+}
+
 /* used for f2fs_inode_info->flags */
 enum {
        FI_NEW_INODE,           /* indicate newly allocated inode */
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 8d5e6e0..acb71e5 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -192,10 +192,7 @@ static inline void set_to_next_nat(struct f2fs_nm_info 
*nm_i, nid_t start_nid)
 {
        unsigned int block_off = NAT_BLOCK_OFFSET(start_nid);
 
-       if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
-               f2fs_clear_bit(block_off, nm_i->nat_bitmap);
-       else
-               f2fs_set_bit(block_off, nm_i->nat_bitmap);
+       f2fs_change_bit(block_off, nm_i->nat_bitmap);
 }
 
 static inline void fill_node_footer(struct page *page, nid_t nid,
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 2495bec..6723ccc 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -657,10 +657,7 @@ static inline void set_to_next_sit(struct sit_info *sit_i, 
unsigned int start)
 {
        unsigned int block_off = SIT_BLOCK_OFFSET(start);
 
-       if (f2fs_test_bit(block_off, sit_i->sit_bitmap))
-               f2fs_clear_bit(block_off, sit_i->sit_bitmap);
-       else
-               f2fs_set_bit(block_off, sit_i->sit_bitmap);
+       f2fs_change_bit(block_off, sit_i->sit_bitmap);
 }
 
 static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi)
-- 
1.7.7


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to