aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ubifs/commit.c2
-rw-r--r--fs/ubifs/misc.h23
-rw-r--r--fs/ubifs/tnc.c13
-rw-r--r--fs/ubifs/tnc_commit.c8
4 files changed, 34 insertions, 12 deletions
diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c
index 8ab03d12d5c0..637e07673c3a 100644
--- a/fs/ubifs/commit.c
+++ b/fs/ubifs/commit.c
@@ -78,7 +78,7 @@ static int nothing_to_commit(struct ubifs_info *c)
78 * If the root TNC node is dirty, we definitely have something to 78 * If the root TNC node is dirty, we definitely have something to
79 * commit. 79 * commit.
80 */ 80 */
81 if (c->zroot.znode && test_bit(DIRTY_ZNODE, &c->zroot.znode->flags)) 81 if (c->zroot.znode && ubifs_zn_dirty(c->zroot.znode))
82 return 0; 82 return 0;
83 83
84 /* 84 /*
diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h
index 0b5296a9a4c5..160cd909e957 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)
39} 39}
40 40
41/** 41/**
42 * ubifs_zn_obsolete - check if znode is obsolete.
43 * @znode: znode to check
44 *
45 * This helper function returns %1 if @znode is obsolete and %0 otherwise.
46 */
47static inline int ubifs_zn_obsolete(const struct ubifs_znode *znode)
48{
49 return !!test_bit(OBSOLETE_ZNODE, &znode->flags);
50}
51
52/**
53 * ubifs_zn_cow - check if znode has to be copied on write.
54 * @znode: znode to check
55 *
56 * This helper function returns %1 if @znode is has COW flag set and %0
57 * otherwise.
58 */
59static inline int ubifs_zn_cow(const struct ubifs_znode *znode)
60{
61 return !!test_bit(COW_ZNODE, &znode->flags);
62}
63
64/**
42 * ubifs_wake_up_bgt - wake up background thread. 65 * ubifs_wake_up_bgt - wake up background thread.
43 * @c: UBIFS file-system description object 66 * @c: UBIFS file-system description object
44 */ 67 */
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index 48b6ee6fa848..b32a5376b7b4 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,
223 __set_bit(DIRTY_ZNODE, &zn->flags); 223 __set_bit(DIRTY_ZNODE, &zn->flags);
224 __clear_bit(COW_ZNODE, &zn->flags); 224 __clear_bit(COW_ZNODE, &zn->flags);
225 225
226 ubifs_assert(!test_bit(OBSOLETE_ZNODE, &znode->flags)); 226 ubifs_assert(!ubifs_zn_obsolete(znode));
227 __set_bit(OBSOLETE_ZNODE, &znode->flags); 227 __set_bit(OBSOLETE_ZNODE, &znode->flags);
228 228
229 if (znode->level != 0) { 229 if (znode->level != 0) {
@@ -271,7 +271,7 @@ static struct ubifs_znode *dirty_cow_znode(struct ubifs_info *c,
271 struct ubifs_znode *zn; 271 struct ubifs_znode *zn;
272 int err; 272 int err;
273 273
274 if (!test_bit(COW_ZNODE, &znode->flags)) { 274 if (!ubifs_zn_cow(znode)) {
275 /* znode is not being committed */ 275 /* znode is not being committed */
276 if (!test_and_set_bit(DIRTY_ZNODE, &znode->flags)) { 276 if (!test_and_set_bit(DIRTY_ZNODE, &znode->flags)) {
277 atomic_long_inc(&c->dirty_zn_cnt); 277 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)
2423 */ 2423 */
2424 2424
2425 do { 2425 do {
2426 ubifs_assert(!test_bit(OBSOLETE_ZNODE, &znode->flags)); 2426 ubifs_assert(!ubifs_zn_obsolete(znode));
2427 ubifs_assert(ubifs_zn_dirty(znode)); 2427 ubifs_assert(ubifs_zn_dirty(znode));
2428 2428
2429 zp = znode->parent; 2429 zp = znode->parent;
@@ -2479,9 +2479,8 @@ static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n)
2479 c->zroot.offs = zbr->offs; 2479 c->zroot.offs = zbr->offs;
2480 c->zroot.len = zbr->len; 2480 c->zroot.len = zbr->len;
2481 c->zroot.znode = znode; 2481 c->zroot.znode = znode;
2482 ubifs_assert(!test_bit(OBSOLETE_ZNODE, 2482 ubifs_assert(!ubifs_zn_obsolete(zp));
2483 &zp->flags)); 2483 ubifs_assert(ubifs_zn_dirty(zp));
2484 ubifs_assert(test_bit(DIRTY_ZNODE, &zp->flags));
2485 atomic_long_dec(&c->dirty_zn_cnt); 2484 atomic_long_dec(&c->dirty_zn_cnt);
2486 2485
2487 if (zp->cnext) { 2486 if (zp->cnext) {
@@ -2865,7 +2864,7 @@ static void tnc_destroy_cnext(struct ubifs_info *c)
2865 struct ubifs_znode *znode = cnext; 2864 struct ubifs_znode *znode = cnext;
2866 2865
2867 cnext = cnext->cnext; 2866 cnext = cnext->cnext;
2868 if (test_bit(OBSOLETE_ZNODE, &znode->flags)) 2867 if (ubifs_zn_obsolete(znode))
2869 kfree(znode); 2868 kfree(znode);
2870 } while (cnext && cnext != c->cnext); 2869 } while (cnext && cnext != c->cnext);
2871} 2870}
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
index 8315387be3fd..f50c3e5da263 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,
87 atomic_long_dec(&c->dirty_zn_cnt); 87 atomic_long_dec(&c->dirty_zn_cnt);
88 88
89 ubifs_assert(ubifs_zn_dirty(znode)); 89 ubifs_assert(ubifs_zn_dirty(znode));
90 ubifs_assert(test_bit(COW_ZNODE, &znode->flags)); 90 ubifs_assert(ubifs_zn_cow(znode));
91 91
92 __clear_bit(DIRTY_ZNODE, &znode->flags); 92 __clear_bit(DIRTY_ZNODE, &znode->flags);
93 __clear_bit(COW_ZNODE, &znode->flags); 93 __clear_bit(COW_ZNODE, &znode->flags);
@@ -639,7 +639,7 @@ static int get_znodes_to_commit(struct ubifs_info *c)
639 } 639 }
640 cnt += 1; 640 cnt += 1;
641 while (1) { 641 while (1) {
642 ubifs_assert(!test_bit(COW_ZNODE, &znode->flags)); 642 ubifs_assert(!ubifs_zn_cow(znode));
643 __set_bit(COW_ZNODE, &znode->flags); 643 __set_bit(COW_ZNODE, &znode->flags);
644 znode->alt = 0; 644 znode->alt = 0;
645 cnext = find_next_dirty(znode); 645 cnext = find_next_dirty(znode);
@@ -888,7 +888,7 @@ static int write_index(struct ubifs_info *c)
888 cnext = znode->cnext; 888 cnext = znode->cnext;
889 889
890 ubifs_assert(ubifs_zn_dirty(znode)); 890 ubifs_assert(ubifs_zn_dirty(znode));
891 ubifs_assert(test_bit(COW_ZNODE, &znode->flags)); 891 ubifs_assert(ubifs_zn_cow(znode));
892 892
893 /* 893 /*
894 * It is important that other threads should see %DIRTY_ZNODE 894 * It is important that other threads should see %DIRTY_ZNODE
@@ -983,7 +983,7 @@ static void free_obsolete_znodes(struct ubifs_info *c)
983 do { 983 do {
984 znode = cnext; 984 znode = cnext;
985 cnext = znode->cnext; 985 cnext = znode->cnext;
986 if (test_bit(OBSOLETE_ZNODE, &znode->flags)) 986 if (ubifs_zn_obsolete(znode))
987 kfree(znode); 987 kfree(znode);
988 else { 988 else {
989 znode->cnext = NULL; 989 znode->cnext = NULL;