Discussion:
[PATCH 5/6] f2fs: remove the redundant function cond_clear_inode_flag
Gu Zheng
2014-10-20 09:45:52 UTC
Permalink
Use clear_inode_flag to replace the redundant cond_clear_inode_flag.

Signed-off-by: Gu Zheng <***@cn.fujitsu.com>
---
fs/f2fs/acl.c | 4 ++--
fs/f2fs/f2fs.h | 9 ---------
2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index 83b9b5a..e8d78fb 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -229,7 +229,7 @@ static int __f2fs_set_acl(struct inode *inode, int type,
if (acl) {
value = f2fs_acl_to_disk(acl, &size);
if (IS_ERR(value)) {
- cond_clear_inode_flag(fi, FI_ACL_MODE);
+ clear_inode_flag(fi, FI_ACL_MODE);
return (int)PTR_ERR(value);
}
}
@@ -240,7 +240,7 @@ static int __f2fs_set_acl(struct inode *inode, int type,
if (!error)
set_cached_acl(inode, type, acl);

- cond_clear_inode_flag(fi, FI_ACL_MODE);
+ clear_inode_flag(fi, FI_ACL_MODE);
return error;
}

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 0aef88f..d227dc6 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1096,15 +1096,6 @@ static inline void set_acl_inode(struct f2fs_inode_info *fi, umode_t mode)
set_inode_flag(fi, FI_ACL_MODE);
}

-static inline int cond_clear_inode_flag(struct f2fs_inode_info *fi, int flag)
-{
- if (is_inode_flag_set(fi, FI_ACL_MODE)) {
- clear_inode_flag(fi, FI_ACL_MODE);
- return 1;
- }
- return 0;
-}
-
static inline void get_inline_info(struct f2fs_inode_info *fi,
struct f2fs_inode *ri)
{
--
1.7.7
Gu Zheng
2014-10-20 09:45:53 UTC
Permalink
Set raw_super default to NULL to avoid the possibly used
uninitialized warning, though we may never hit it in fact.

Signed-off-by: Gu Zheng <***@cn.fujitsu.com>
---
fs/f2fs/super.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 41d6f70..ed59c8e 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -922,7 +922,7 @@ retry:
static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
{
struct f2fs_sb_info *sbi;
- struct f2fs_super_block *raw_super;
+ struct f2fs_super_block *raw_super = NULL;
struct buffer_head *raw_super_buf;
struct inode *root;
long err = -EINVAL;
--
1.7.7
Gu Zheng
2014-10-20 09:45:49 UTC
Permalink
Signed-off-by: Gu Zheng <***@cn.fujitsu.com>
---
fs/f2fs/segment.c | 12 +-----------
1 files changed, 1 insertions(+), 11 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 923cb76..6fb7446 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1524,17 +1524,7 @@ int lookup_journal_in_cursum(struct f2fs_summary_block *sum, int type,
static struct page *get_current_sit_page(struct f2fs_sb_info *sbi,
unsigned int segno)
{
- struct sit_info *sit_i = SIT_I(sbi);
- unsigned int offset = SIT_BLOCK_OFFSET(segno);
- block_t blk_addr = sit_i->sit_base_addr + offset;
-
- check_seg_range(sbi, segno);
-
- /* calculate sit block address */
- if (f2fs_test_bit(offset, sit_i->sit_bitmap))
- blk_addr += sit_i->sit_blocks;
-
- return get_meta_page(sbi, blk_addr);
+ return get_meta_page(sbi, current_sit_addr(sbi, segno));
}

static struct page *get_next_sit_page(struct f2fs_sb_info *sbi,
--
1.7.7
Gu Zheng
2014-10-20 09:45:51 UTC
Permalink
Rename f2fs_set/clear_bit to f2fs_test_and_set/clear_bit, which mean
set/clear bit and return the old value, for better readability.

Signed-off-by: Gu Zheng <***@cn.fujitsu.com>
---
fs/f2fs/f2fs.h | 4 ++--
fs/f2fs/segment.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 3095a57..0aef88f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1020,7 +1020,7 @@ static inline int f2fs_test_bit(unsigned int nr, char *addr)
return mask & *addr;
}

-static inline int f2fs_set_bit(unsigned int nr, char *addr)
+static inline int f2fs_test_and_set_bit(unsigned int nr, char *addr)
{
int mask;
int ret;
@@ -1032,7 +1032,7 @@ static inline int f2fs_set_bit(unsigned int nr, char *addr)
return ret;
}

-static inline int f2fs_clear_bit(unsigned int nr, char *addr)
+static inline int f2fs_test_and_clear_bit(unsigned int nr, char *addr)
{
int mask;
int ret;
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 6fb7446..1146029 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -620,10 +620,10 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)

/* Update valid block bitmap */
if (del > 0) {
- if (f2fs_set_bit(offset, se->cur_valid_map))
+ if (f2fs_test_and_set_bit(offset, se->cur_valid_map))
f2fs_bug_on(sbi, 1);
} else {
- if (!f2fs_clear_bit(offset, se->cur_valid_map))
+ if (!f2fs_test_and_clear_bit(offset, se->cur_valid_map))
f2fs_bug_on(sbi, 1);
}
if (!f2fs_test_bit(offset, se->ckpt_valid_map))
--
1.7.7
Gu Zheng
2014-10-20 09:45:50 UTC
Permalink
Introduce f2fs_change_bit to simplify the change bit logic in
function set_to_next_nat{sit}.

Signed-off-by: Gu Zheng <***@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
Loading...