diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /fs/ubifs/log.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'fs/ubifs/log.c')
-rw-r--r-- | fs/ubifs/log.c | 54 |
1 files changed, 10 insertions, 44 deletions
diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c index c345e125f42c..affea9494ae2 100644 --- a/fs/ubifs/log.c +++ b/fs/ubifs/log.c | |||
@@ -100,20 +100,6 @@ struct ubifs_wbuf *ubifs_get_wbuf(struct ubifs_info *c, int lnum) | |||
100 | } | 100 | } |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * next_log_lnum - switch to the next log LEB. | ||
104 | * @c: UBIFS file-system description object | ||
105 | * @lnum: current log LEB | ||
106 | */ | ||
107 | static inline int next_log_lnum(const struct ubifs_info *c, int lnum) | ||
108 | { | ||
109 | lnum += 1; | ||
110 | if (lnum > c->log_last) | ||
111 | lnum = UBIFS_LOG_LNUM; | ||
112 | |||
113 | return lnum; | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * empty_log_bytes - calculate amount of empty space in the log. | 103 | * empty_log_bytes - calculate amount of empty space in the log. |
118 | * @c: UBIFS file-system description object | 104 | * @c: UBIFS file-system description object |
119 | */ | 105 | */ |
@@ -159,7 +145,7 @@ void ubifs_add_bud(struct ubifs_info *c, struct ubifs_bud *bud) | |||
159 | jhead = &c->jheads[bud->jhead]; | 145 | jhead = &c->jheads[bud->jhead]; |
160 | list_add_tail(&bud->list, &jhead->buds_list); | 146 | list_add_tail(&bud->list, &jhead->buds_list); |
161 | } else | 147 | } else |
162 | ubifs_assert(c->replaying && (c->vfs_sb->s_flags & MS_RDONLY)); | 148 | ubifs_assert(c->replaying && c->ro_mount); |
163 | 149 | ||
164 | /* | 150 | /* |
165 | * Note, although this is a new bud, we anyway account this space now, | 151 | * Note, although this is a new bud, we anyway account this space now, |
@@ -175,26 +161,6 @@ void ubifs_add_bud(struct ubifs_info *c, struct ubifs_bud *bud) | |||
175 | } | 161 | } |
176 | 162 | ||
177 | /** | 163 | /** |
178 | * ubifs_create_buds_lists - create journal head buds lists for remount rw. | ||
179 | * @c: UBIFS file-system description object | ||
180 | */ | ||
181 | void ubifs_create_buds_lists(struct ubifs_info *c) | ||
182 | { | ||
183 | struct rb_node *p; | ||
184 | |||
185 | spin_lock(&c->buds_lock); | ||
186 | p = rb_first(&c->buds); | ||
187 | while (p) { | ||
188 | struct ubifs_bud *bud = rb_entry(p, struct ubifs_bud, rb); | ||
189 | struct ubifs_jhead *jhead = &c->jheads[bud->jhead]; | ||
190 | |||
191 | list_add_tail(&bud->list, &jhead->buds_list); | ||
192 | p = rb_next(p); | ||
193 | } | ||
194 | spin_unlock(&c->buds_lock); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * ubifs_add_bud_to_log - add a new bud to the log. | 164 | * ubifs_add_bud_to_log - add a new bud to the log. |
199 | * @c: UBIFS file-system description object | 165 | * @c: UBIFS file-system description object |
200 | * @jhead: journal head the bud belongs to | 166 | * @jhead: journal head the bud belongs to |
@@ -223,8 +189,8 @@ int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs) | |||
223 | } | 189 | } |
224 | 190 | ||
225 | mutex_lock(&c->log_mutex); | 191 | mutex_lock(&c->log_mutex); |
226 | 192 | ubifs_assert(!c->ro_media && !c->ro_mount); | |
227 | if (c->ro_media) { | 193 | if (c->ro_error) { |
228 | err = -EROFS; | 194 | err = -EROFS; |
229 | goto out_unlock; | 195 | goto out_unlock; |
230 | } | 196 | } |
@@ -277,7 +243,7 @@ int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs) | |||
277 | ref->jhead = cpu_to_le32(jhead); | 243 | ref->jhead = cpu_to_le32(jhead); |
278 | 244 | ||
279 | if (c->lhead_offs > c->leb_size - c->ref_node_alsz) { | 245 | if (c->lhead_offs > c->leb_size - c->ref_node_alsz) { |
280 | c->lhead_lnum = next_log_lnum(c, c->lhead_lnum); | 246 | c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum); |
281 | c->lhead_offs = 0; | 247 | c->lhead_offs = 0; |
282 | } | 248 | } |
283 | 249 | ||
@@ -445,7 +411,7 @@ int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum) | |||
445 | 411 | ||
446 | /* Switch to the next log LEB */ | 412 | /* Switch to the next log LEB */ |
447 | if (c->lhead_offs) { | 413 | if (c->lhead_offs) { |
448 | c->lhead_lnum = next_log_lnum(c, c->lhead_lnum); | 414 | c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum); |
449 | c->lhead_offs = 0; | 415 | c->lhead_offs = 0; |
450 | } | 416 | } |
451 | 417 | ||
@@ -466,7 +432,7 @@ int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum) | |||
466 | 432 | ||
467 | c->lhead_offs += len; | 433 | c->lhead_offs += len; |
468 | if (c->lhead_offs == c->leb_size) { | 434 | if (c->lhead_offs == c->leb_size) { |
469 | c->lhead_lnum = next_log_lnum(c, c->lhead_lnum); | 435 | c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum); |
470 | c->lhead_offs = 0; | 436 | c->lhead_offs = 0; |
471 | } | 437 | } |
472 | 438 | ||
@@ -553,7 +519,7 @@ int ubifs_log_post_commit(struct ubifs_info *c, int old_ltail_lnum) | |||
553 | } | 519 | } |
554 | mutex_lock(&c->log_mutex); | 520 | mutex_lock(&c->log_mutex); |
555 | for (lnum = old_ltail_lnum; lnum != c->ltail_lnum; | 521 | for (lnum = old_ltail_lnum; lnum != c->ltail_lnum; |
556 | lnum = next_log_lnum(c, lnum)) { | 522 | lnum = ubifs_next_log_lnum(c, lnum)) { |
557 | dbg_log("unmap log LEB %d", lnum); | 523 | dbg_log("unmap log LEB %d", lnum); |
558 | err = ubifs_leb_unmap(c, lnum); | 524 | err = ubifs_leb_unmap(c, lnum); |
559 | if (err) | 525 | if (err) |
@@ -662,7 +628,7 @@ static int add_node(struct ubifs_info *c, void *buf, int *lnum, int *offs, | |||
662 | err = ubifs_leb_change(c, *lnum, buf, sz, UBI_SHORTTERM); | 628 | err = ubifs_leb_change(c, *lnum, buf, sz, UBI_SHORTTERM); |
663 | if (err) | 629 | if (err) |
664 | return err; | 630 | return err; |
665 | *lnum = next_log_lnum(c, *lnum); | 631 | *lnum = ubifs_next_log_lnum(c, *lnum); |
666 | *offs = 0; | 632 | *offs = 0; |
667 | } | 633 | } |
668 | memcpy(buf + *offs, node, len); | 634 | memcpy(buf + *offs, node, len); |
@@ -732,7 +698,7 @@ int ubifs_consolidate_log(struct ubifs_info *c) | |||
732 | ubifs_scan_destroy(sleb); | 698 | ubifs_scan_destroy(sleb); |
733 | if (lnum == c->lhead_lnum) | 699 | if (lnum == c->lhead_lnum) |
734 | break; | 700 | break; |
735 | lnum = next_log_lnum(c, lnum); | 701 | lnum = ubifs_next_log_lnum(c, lnum); |
736 | } | 702 | } |
737 | if (offs) { | 703 | if (offs) { |
738 | int sz = ALIGN(offs, c->min_io_size); | 704 | int sz = ALIGN(offs, c->min_io_size); |
@@ -752,7 +718,7 @@ int ubifs_consolidate_log(struct ubifs_info *c) | |||
752 | /* Unmap remaining LEBs */ | 718 | /* Unmap remaining LEBs */ |
753 | lnum = write_lnum; | 719 | lnum = write_lnum; |
754 | do { | 720 | do { |
755 | lnum = next_log_lnum(c, lnum); | 721 | lnum = ubifs_next_log_lnum(c, lnum); |
756 | err = ubifs_leb_unmap(c, lnum); | 722 | err = ubifs_leb_unmap(c, lnum); |
757 | if (err) | 723 | if (err) |
758 | return err; | 724 | return err; |