From: Artem Bityutskiy <dedekind1@gmail.com>
To: linux-mtd@lists.infradead.org
Subject: [PATCH 09/30] UBIFS: harmonize znode flag helpers
Date: Thu, 9 Jun 2011 12:04:49 +0300 [thread overview]
Message-ID: <1307610310-28691-10-git-send-email-dedekind1@gmail.com> (raw)
In-Reply-To: <1307610310-28691-1-git-send-email-dedekind1@gmail.com>
From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
We have 3 znode flags: cow, obsolete, dirty. For the last flag we have a
'ubifs_zn_dirty()' helper function, but for the other 2 flags we use
'test_bit()' directly.
This patch makes the situation more consistent and introduces helpers for the
other 2 flags: 'ubifs_zn_cow()' and 'ubifs_zn_obsolete()'.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
fs/ubifs/commit.c | 2 +-
fs/ubifs/misc.h | 23 +++++++++++++++++++++++
fs/ubifs/tnc.c | 13 ++++++-------
fs/ubifs/tnc_commit.c | 8 ++++----
4 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c
index 8ab03d1..637e076 100644
--- a/fs/ubifs/commit.c
+++ b/fs/ubifs/commit.c
@@ -78,7 +78,7 @@ static int nothing_to_commit(struct ubifs_info *c)
* If the root TNC node is dirty, we definitely have something to
* commit.
*/
- if (c->zroot.znode && test_bit(DIRTY_ZNODE, &c->zroot.znode->flags))
+ if (c->zroot.znode && ubifs_zn_dirty(c->zroot.znode))
return 0;
/*
diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h
index 0b5296a..160cd90 100644
--- a/fs/ubifs/misc.h
+++ b/fs/ubifs/misc.h
@@ -39,6 +39,29 @@ static inline int ubifs_zn_dirty(const struct ubifs_znode *znode)
}
/**
+ * ubifs_zn_obsolete - check if znode is obsolete.
+ * @znode: znode to check
+ *
+ * This helper function returns %1 if @znode is obsolete and %0 otherwise.
+ */
+static inline int ubifs_zn_obsolete(const struct ubifs_znode *znode)
+{
+ return !!test_bit(OBSOLETE_ZNODE, &znode->flags);
+}
+
+/**
+ * ubifs_zn_cow - check if znode has to be copied on write.
+ * @znode: znode to check
+ *
+ * This helper function returns %1 if @znode is has COW flag set and %0
+ * otherwise.
+ */
+static inline int ubifs_zn_cow(const struct ubifs_znode *znode)
+{
+ return !!test_bit(COW_ZNODE, &znode->flags);
+}
+
+/**
* ubifs_wake_up_bgt - wake up background thread.
* @c: UBIFS file-system description object
*/
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index 48b6ee6..b32a537 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -223,7 +223,7 @@ static struct ubifs_znode *copy_znode(struct ubifs_info *c,
__set_bit(DIRTY_ZNODE, &zn->flags);
__clear_bit(COW_ZNODE, &zn->flags);
- ubifs_assert(!test_bit(OBSOLETE_ZNODE, &znode->flags));
+ ubifs_assert(!ubifs_zn_obsolete(znode));
__set_bit(OBSOLETE_ZNODE, &znode->flags);
if (znode->level != 0) {
@@ -271,7 +271,7 @@ static struct ubifs_znode *dirty_cow_znode(struct ubifs_info *c,
struct ubifs_znode *zn;
int err;
- if (!test_bit(COW_ZNODE, &znode->flags)) {
+ if (!ubifs_zn_cow(znode)) {
/* znode is not being committed */
if (!test_and_set_bit(DIRTY_ZNODE, &znode->flags)) {
atomic_long_inc(&c->dirty_zn_cnt);
@@ -2423,7 +2423,7 @@ static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n)
*/
do {
- ubifs_assert(!test_bit(OBSOLETE_ZNODE, &znode->flags));
+ ubifs_assert(!ubifs_zn_obsolete(znode));
ubifs_assert(ubifs_zn_dirty(znode));
zp = znode->parent;
@@ -2479,9 +2479,8 @@ static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n)
c->zroot.offs = zbr->offs;
c->zroot.len = zbr->len;
c->zroot.znode = znode;
- ubifs_assert(!test_bit(OBSOLETE_ZNODE,
- &zp->flags));
- ubifs_assert(test_bit(DIRTY_ZNODE, &zp->flags));
+ ubifs_assert(!ubifs_zn_obsolete(zp));
+ ubifs_assert(ubifs_zn_dirty(zp));
atomic_long_dec(&c->dirty_zn_cnt);
if (zp->cnext) {
@@ -2865,7 +2864,7 @@ static void tnc_destroy_cnext(struct ubifs_info *c)
struct ubifs_znode *znode = cnext;
cnext = cnext->cnext;
- if (test_bit(OBSOLETE_ZNODE, &znode->flags))
+ if (ubifs_zn_obsolete(znode))
kfree(znode);
} while (cnext && cnext != c->cnext);
}
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
index 8315387..f50c3e5 100644
--- a/fs/ubifs/tnc_commit.c
+++ b/fs/ubifs/tnc_commit.c
@@ -87,7 +87,7 @@ static int make_idx_node(struct ubifs_info *c, struct ubifs_idx_node *idx,
atomic_long_dec(&c->dirty_zn_cnt);
ubifs_assert(ubifs_zn_dirty(znode));
- ubifs_assert(test_bit(COW_ZNODE, &znode->flags));
+ ubifs_assert(ubifs_zn_cow(znode));
__clear_bit(DIRTY_ZNODE, &znode->flags);
__clear_bit(COW_ZNODE, &znode->flags);
@@ -639,7 +639,7 @@ static int get_znodes_to_commit(struct ubifs_info *c)
}
cnt += 1;
while (1) {
- ubifs_assert(!test_bit(COW_ZNODE, &znode->flags));
+ ubifs_assert(!ubifs_zn_cow(znode));
__set_bit(COW_ZNODE, &znode->flags);
znode->alt = 0;
cnext = find_next_dirty(znode);
@@ -888,7 +888,7 @@ static int write_index(struct ubifs_info *c)
cnext = znode->cnext;
ubifs_assert(ubifs_zn_dirty(znode));
- ubifs_assert(test_bit(COW_ZNODE, &znode->flags));
+ ubifs_assert(ubifs_zn_cow(znode));
/*
* It is important that other threads should see %DIRTY_ZNODE
@@ -983,7 +983,7 @@ static void free_obsolete_znodes(struct ubifs_info *c)
do {
znode = cnext;
cnext = znode->cnext;
- if (test_bit(OBSOLETE_ZNODE, &znode->flags))
+ if (ubifs_zn_obsolete(znode))
kfree(znode);
else {
znode->cnext = NULL;
--
1.7.2.3
next prev parent reply other threads:[~2011-06-09 9:01 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-09 9:04 [PATCH 00/30] UBIFS: latest patches Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 01/30] UBIFS: return EROFS in case of broken commit Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 02/30] UBIFS: lessen the size of debugging info data structure Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 03/30] UBIFS: dump stack when pnode or nnode reading fails Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 04/30] UBIFS: improve inode dumping function Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 05/30] UBIFS: rename dbg_check_dir_size function Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 06/30] UBIFS: minor cleanup: use S_ISREG helper Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 07/30] UBIFS: remove unnecessary brackets Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 08/30] UBIFS: remove dead code Artem Bityutskiy
2011-06-09 9:04 ` Artem Bityutskiy [this message]
2011-06-09 9:04 ` [PATCH 10/30] UBIFS: use correct flags in lprops Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 11/30] UBIFS: add few commentaries about TNC Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 12/30] UBIFS: amend debugging name check function prototype Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 13/30] UBIFS: amend debugging inode size " Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 14/30] UBIFS: introduce helper functions for debugging checks and tests Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 15/30] UBIFS: lessen amount of debugging check types Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 16/30] UBIFS: switch self-check knobs to debugfs Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 17/30] UBIFS: be more informative in failure mode Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 18/30] UBIFS: re-arrange debugging code a bit Artem Bityutskiy
2011-06-09 9:04 ` [PATCH 19/30] UBIFS: introduce debugfs helpers Artem Bityutskiy
2011-06-09 9:05 ` [PATCH 20/30] UBIFS: add global debugfs knobs Artem Bityutskiy
2011-06-09 9:05 ` [PATCH 21/30] UBIFS: remove unused and unneeded debugging function Artem Bityutskiy
2011-06-09 9:05 ` [PATCH 22/30] UBIFS: always print stacktrace when switching to R/O mode Artem Bityutskiy
2011-06-09 9:05 ` [PATCH 23/30] UBIFS: introduce more I/O helpers Artem Bityutskiy
2011-06-09 9:05 ` [PATCH 24/30] UBIFS: switch to ubifs_leb_read Artem Bityutskiy
2011-06-09 9:05 ` [PATCH 25/30] UBIFS: switch to ubifs_leb_write Artem Bityutskiy
2011-06-09 9:05 ` [PATCH 26/30] UBIFS: switch to I/O helpers Artem Bityutskiy
2011-06-09 9:05 ` [PATCH 27/30] UBIFS: stop re-defining UBI operations Artem Bityutskiy
2011-06-09 9:05 ` [PATCH 28/30] UBIFS: remove custom list of superblocks Artem Bityutskiy
2011-06-09 9:05 ` [PATCH 29/30] UBIFS: rename recovery testing variables Artem Bityutskiy
2011-06-09 9:05 ` [PATCH 30/30] UBIFS: improve power cut emulation testing Artem Bityutskiy
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=1307610310-28691-10-git-send-email-dedekind1@gmail.com \
--to=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.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).