diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-04-26 02:49:32 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-05-13 12:23:55 -0400 |
commit | 2405f5948119cdc1c28697fd3110124dad974898 (patch) | |
tree | 04bad5852693a5a18cb919c298e59dbf385c1d96 /fs/ubifs/recovery.c | |
parent | 2cd0a60cf49db4722445337b90fb06c9672f1128 (diff) |
UBIFS: remove duplicated code
We have duplicated code in 'ubifs_garbage_collect()' and
'ubifs_rcvry_gc_commit()', which is about handling the special case of free
LEB. In both cases we just want to garbage-collect the LEB using
'ubifs_garbage_collect_leb()'.
This patch teaches 'ubifs_garbage_collect_leb()' to handle free LEB's so that
the caller does not have to do this and the duplicated code is removed.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/recovery.c')
-rw-r--r-- | fs/ubifs/recovery.c | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c index 3dbad6fbd1eb..1a72046efed5 100644 --- a/fs/ubifs/recovery.c +++ b/fs/ubifs/recovery.c | |||
@@ -1125,25 +1125,10 @@ int ubifs_rcvry_gc_commit(struct ubifs_info *c) | |||
1125 | } | 1125 | } |
1126 | return err; | 1126 | return err; |
1127 | } | 1127 | } |
1128 | |||
1128 | ubifs_assert(!(lp.flags & LPROPS_INDEX)); | 1129 | ubifs_assert(!(lp.flags & LPROPS_INDEX)); |
1129 | lnum = lp.lnum; | 1130 | lnum = lp.lnum; |
1130 | if (lp.free + lp.dirty == c->leb_size) { | 1131 | |
1131 | /* An empty LEB was returned */ | ||
1132 | if (lp.free != c->leb_size) { | ||
1133 | err = ubifs_change_one_lp(c, lnum, c->leb_size, | ||
1134 | 0, 0, 0, 0); | ||
1135 | if (err) | ||
1136 | return err; | ||
1137 | } | ||
1138 | err = ubifs_leb_unmap(c, lnum); | ||
1139 | if (err) | ||
1140 | return err; | ||
1141 | c->gc_lnum = lnum; | ||
1142 | dbg_rcvry("allocated LEB %d for GC", lnum); | ||
1143 | /* Run the commit */ | ||
1144 | dbg_rcvry("committing"); | ||
1145 | return ubifs_run_commit(c); | ||
1146 | } | ||
1147 | /* | 1132 | /* |
1148 | * There was no empty LEB so the used space in the dirtiest LEB must fit | 1133 | * There was no empty LEB so the used space in the dirtiest LEB must fit |
1149 | * in the GC head LEB. | 1134 | * in the GC head LEB. |