From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 1/3] f2fs: introduce a flag to represent each nat entry information
Date: Wed, 17 Sep 2014 22:51:06 -0700 [thread overview]
Message-ID: <1411019468-2201-1-git-send-email-jaegeuk@kernel.org> (raw)
This patch introduces a flag in the nat entry structure to merge various
information such as checkpointed and fsync_done marks.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/node.c | 13 +++++++------
fs/f2fs/node.h | 28 ++++++++++++++++++++++++----
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index b32eb56..d19d6b1 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -131,7 +131,7 @@ int is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
read_lock(&nm_i->nat_tree_lock);
e = __lookup_nat_cache(nm_i, nid);
- if (e && !e->checkpointed)
+ if (e && !get_nat_flag(e, IS_CHECKPOINTED))
is_cp = 0;
read_unlock(&nm_i->nat_tree_lock);
return is_cp;
@@ -146,7 +146,7 @@ bool fsync_mark_done(struct f2fs_sb_info *sbi, nid_t nid)
read_lock(&nm_i->nat_tree_lock);
e = __lookup_nat_cache(nm_i, nid);
if (e)
- fsync_done = e->fsync_done;
+ fsync_done = get_nat_flag(e, HAS_FSYNC_MARK);
read_unlock(&nm_i->nat_tree_lock);
return fsync_done;
}
@@ -159,7 +159,7 @@ void fsync_mark_clear(struct f2fs_sb_info *sbi, nid_t nid)
write_lock(&nm_i->nat_tree_lock);
e = __lookup_nat_cache(nm_i, nid);
if (e)
- e->fsync_done = false;
+ set_nat_flag(e, HAS_FSYNC_MARK, false);
write_unlock(&nm_i->nat_tree_lock);
}
@@ -176,7 +176,7 @@ static struct nat_entry *grab_nat_entry(struct f2fs_nm_info *nm_i, nid_t nid)
}
memset(new, 0, sizeof(struct nat_entry));
nat_set_nid(new, nid);
- new->checkpointed = true;
+ set_nat_flag(new, IS_CHECKPOINTED, true);
list_add_tail(&new->list, &nm_i->nat_entries);
nm_i->nat_cnt++;
return new;
@@ -249,7 +249,7 @@ retry:
/* update fsync_mark if its inode nat entry is still alive */
e = __lookup_nat_cache(nm_i, ni->ino);
if (e)
- e->fsync_done = fsync_done;
+ set_nat_flag(e, HAS_FSYNC_MARK, fsync_done);
write_unlock(&nm_i->nat_tree_lock);
}
@@ -1349,7 +1349,8 @@ static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
read_lock(&nm_i->nat_tree_lock);
ne = __lookup_nat_cache(nm_i, nid);
if (ne &&
- (!ne->checkpointed || nat_get_blkaddr(ne) != NULL_ADDR))
+ (!get_nat_flag(ne, IS_CHECKPOINTED) ||
+ nat_get_blkaddr(ne) != NULL_ADDR))
allocated = true;
read_unlock(&nm_i->nat_tree_lock);
if (allocated)
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 324917d..3043778 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -39,10 +39,14 @@ struct node_info {
unsigned char version; /* version of the node */
};
+enum {
+ IS_CHECKPOINTED, /* is it checkpointed before? */
+ HAS_FSYNC_MARK, /* has the latest node fsync mark? */
+};
+
struct nat_entry {
struct list_head list; /* for clean or dirty nat list */
- bool checkpointed; /* whether it is checkpointed or not */
- bool fsync_done; /* whether the latest node has fsync mark */
+ unsigned char flag; /* for node information bits */
struct node_info ni; /* in-memory node information */
};
@@ -57,16 +61,32 @@ struct nat_entry {
#define __set_nat_cache_dirty(nm_i, ne) \
do { \
- ne->checkpointed = false; \
+ set_nat_flag(ne, IS_CHECKPOINTED, false); \
list_move_tail(&ne->list, &nm_i->dirty_nat_entries); \
} while (0)
#define __clear_nat_cache_dirty(nm_i, ne) \
do { \
- ne->checkpointed = true; \
+ set_nat_flag(ne, IS_CHECKPOINTED, true); \
list_move_tail(&ne->list, &nm_i->nat_entries); \
} while (0)
#define inc_node_version(version) (++version)
+static inline void set_nat_flag(struct nat_entry *ne,
+ unsigned int type, bool set)
+{
+ unsigned char mask = 0x01 << type;
+ if (set)
+ ne->flag |= mask;
+ else
+ ne->flag &= ~mask;
+}
+
+static inline bool get_nat_flag(struct nat_entry *ne, unsigned int type)
+{
+ unsigned char mask = 0x01 << type;
+ return ne->flag & mask;
+}
+
static inline void node_info_from_raw_nat(struct node_info *ni,
struct f2fs_nat_entry *raw_ne)
{
--
1.8.5.2 (Apple Git-48)
------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
next reply other threads:[~2014-09-18 5:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 5:51 Jaegeuk Kim [this message]
2014-09-18 5:51 ` [PATCH 2/3] f2fs: fix conditions to remain recovery information in f2fs_sync_file Jaegeuk Kim
2014-09-22 7:24 ` Chao Yu
2014-09-22 7:38 ` Huang Ying
2014-09-22 9:20 ` [f2fs-dev] " Chao Yu
2014-09-23 4:52 ` Jaegeuk Kim
2014-09-23 8:50 ` Chao Yu
2014-09-18 5:51 ` [PATCH 3/3] f2fs: fix roll-forward missing scenarios Jaegeuk Kim
[not found] ` <CAC=cRTPotgNXbuPwG95HHuWiicS2OiD5R3HsOqdMG+2b=8ZyEg@mail.gmail.com>
2014-09-20 16:23 ` Jaegeuk Kim
2014-09-20 23:22 ` Huang Ying
2014-09-21 3:36 ` Jaegeuk Kim
2014-09-22 2:13 ` Huang Ying
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1411019468-2201-1-git-send-email-jaegeuk@kernel.org \
--to=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).