Commit f42eed7cba7f83197b0ffbb023e7d89a0b2fd71d
Committed by
Artem Bityutskiy
1 parent
1f42596ec0
Exists in
master
and in
4 other branches
UBIFS: harmonize znode flag helpers
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>
Showing 4 changed files with 34 additions and 12 deletions Side-by-side Diff
fs/ubifs/commit.c
fs/ubifs/misc.h
... | ... | @@ -39,6 +39,29 @@ |
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 | + */ | |
47 | +static 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 | + */ | |
59 | +static inline int ubifs_zn_cow(const struct ubifs_znode *znode) | |
60 | +{ | |
61 | + return !!test_bit(COW_ZNODE, &znode->flags); | |
62 | +} | |
63 | + | |
64 | +/** | |
42 | 65 | * ubifs_wake_up_bgt - wake up background thread. |
43 | 66 | * @c: UBIFS file-system description object |
44 | 67 | */ |
fs/ubifs/tnc.c
... | ... | @@ -223,7 +223,7 @@ |
223 | 223 | __set_bit(DIRTY_ZNODE, &zn->flags); |
224 | 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 | 227 | __set_bit(OBSOLETE_ZNODE, &znode->flags); |
228 | 228 | |
229 | 229 | if (znode->level != 0) { |
... | ... | @@ -271,7 +271,7 @@ |
271 | 271 | struct ubifs_znode *zn; |
272 | 272 | int err; |
273 | 273 | |
274 | - if (!test_bit(COW_ZNODE, &znode->flags)) { | |
274 | + if (!ubifs_zn_cow(znode)) { | |
275 | 275 | /* znode is not being committed */ |
276 | 276 | if (!test_and_set_bit(DIRTY_ZNODE, &znode->flags)) { |
277 | 277 | atomic_long_inc(&c->dirty_zn_cnt); |
... | ... | @@ -2423,7 +2423,7 @@ |
2423 | 2423 | */ |
2424 | 2424 | |
2425 | 2425 | do { |
2426 | - ubifs_assert(!test_bit(OBSOLETE_ZNODE, &znode->flags)); | |
2426 | + ubifs_assert(!ubifs_zn_obsolete(znode)); | |
2427 | 2427 | ubifs_assert(ubifs_zn_dirty(znode)); |
2428 | 2428 | |
2429 | 2429 | zp = znode->parent; |
... | ... | @@ -2479,9 +2479,8 @@ |
2479 | 2479 | c->zroot.offs = zbr->offs; |
2480 | 2480 | c->zroot.len = zbr->len; |
2481 | 2481 | c->zroot.znode = znode; |
2482 | - ubifs_assert(!test_bit(OBSOLETE_ZNODE, | |
2483 | - &zp->flags)); | |
2484 | - ubifs_assert(test_bit(DIRTY_ZNODE, &zp->flags)); | |
2482 | + ubifs_assert(!ubifs_zn_obsolete(zp)); | |
2483 | + ubifs_assert(ubifs_zn_dirty(zp)); | |
2485 | 2484 | atomic_long_dec(&c->dirty_zn_cnt); |
2486 | 2485 | |
2487 | 2486 | if (zp->cnext) { |
... | ... | @@ -2865,7 +2864,7 @@ |
2865 | 2864 | struct ubifs_znode *znode = cnext; |
2866 | 2865 | |
2867 | 2866 | cnext = cnext->cnext; |
2868 | - if (test_bit(OBSOLETE_ZNODE, &znode->flags)) | |
2867 | + if (ubifs_zn_obsolete(znode)) | |
2869 | 2868 | kfree(znode); |
2870 | 2869 | } while (cnext && cnext != c->cnext); |
2871 | 2870 | } |
fs/ubifs/tnc_commit.c
... | ... | @@ -87,7 +87,7 @@ |
87 | 87 | atomic_long_dec(&c->dirty_zn_cnt); |
88 | 88 | |
89 | 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 | 92 | __clear_bit(DIRTY_ZNODE, &znode->flags); |
93 | 93 | __clear_bit(COW_ZNODE, &znode->flags); |
... | ... | @@ -639,7 +639,7 @@ |
639 | 639 | } |
640 | 640 | cnt += 1; |
641 | 641 | while (1) { |
642 | - ubifs_assert(!test_bit(COW_ZNODE, &znode->flags)); | |
642 | + ubifs_assert(!ubifs_zn_cow(znode)); | |
643 | 643 | __set_bit(COW_ZNODE, &znode->flags); |
644 | 644 | znode->alt = 0; |
645 | 645 | cnext = find_next_dirty(znode); |
... | ... | @@ -888,7 +888,7 @@ |
888 | 888 | cnext = znode->cnext; |
889 | 889 | |
890 | 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 | 894 | * It is important that other threads should see %DIRTY_ZNODE |
... | ... | @@ -983,7 +983,7 @@ |
983 | 983 | do { |
984 | 984 | znode = cnext; |
985 | 985 | cnext = znode->cnext; |
986 | - if (test_bit(OBSOLETE_ZNODE, &znode->flags)) | |
986 | + if (ubifs_zn_obsolete(znode)) | |
987 | 987 | kfree(znode); |
988 | 988 | else { |
989 | 989 | znode->cnext = NULL; |