diff options
Diffstat (limited to 'fs/ubifs')
-rw-r--r-- | fs/ubifs/commit.c | 8 | ||||
-rw-r--r-- | fs/ubifs/debug.c | 6 | ||||
-rw-r--r-- | fs/ubifs/journal.c | 7 | ||||
-rw-r--r-- | fs/ubifs/log.c | 19 |
4 files changed, 23 insertions, 17 deletions
diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c index aa13ad053b14..26b69b2d4a45 100644 --- a/fs/ubifs/commit.c +++ b/fs/ubifs/commit.c | |||
@@ -166,10 +166,6 @@ static int do_commit(struct ubifs_info *c) | |||
166 | err = ubifs_orphan_end_commit(c); | 166 | err = ubifs_orphan_end_commit(c); |
167 | if (err) | 167 | if (err) |
168 | goto out; | 168 | goto out; |
169 | old_ltail_lnum = c->ltail_lnum; | ||
170 | err = ubifs_log_end_commit(c, new_ltail_lnum); | ||
171 | if (err) | ||
172 | goto out; | ||
173 | err = dbg_check_old_index(c, &zroot); | 169 | err = dbg_check_old_index(c, &zroot); |
174 | if (err) | 170 | if (err) |
175 | goto out; | 171 | goto out; |
@@ -202,7 +198,9 @@ static int do_commit(struct ubifs_info *c) | |||
202 | c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS); | 198 | c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS); |
203 | else | 199 | else |
204 | c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_NO_ORPHS); | 200 | c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_NO_ORPHS); |
205 | err = ubifs_write_master(c); | 201 | |
202 | old_ltail_lnum = c->ltail_lnum; | ||
203 | err = ubifs_log_end_commit(c, new_ltail_lnum); | ||
206 | if (err) | 204 | if (err) |
207 | goto out; | 205 | goto out; |
208 | 206 | ||
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 177b0152fef4..7ed13e1e216a 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -334,9 +334,9 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node) | |||
334 | pr_err("\tkey_fmt %d (%s)\n", | 334 | pr_err("\tkey_fmt %d (%s)\n", |
335 | (int)sup->key_fmt, get_key_fmt(sup->key_fmt)); | 335 | (int)sup->key_fmt, get_key_fmt(sup->key_fmt)); |
336 | pr_err("\tflags %#x\n", sup_flags); | 336 | pr_err("\tflags %#x\n", sup_flags); |
337 | pr_err("\t big_lpt %u\n", | 337 | pr_err("\tbig_lpt %u\n", |
338 | !!(sup_flags & UBIFS_FLG_BIGLPT)); | 338 | !!(sup_flags & UBIFS_FLG_BIGLPT)); |
339 | pr_err("\t space_fixup %u\n", | 339 | pr_err("\tspace_fixup %u\n", |
340 | !!(sup_flags & UBIFS_FLG_SPACE_FIXUP)); | 340 | !!(sup_flags & UBIFS_FLG_SPACE_FIXUP)); |
341 | pr_err("\tmin_io_size %u\n", le32_to_cpu(sup->min_io_size)); | 341 | pr_err("\tmin_io_size %u\n", le32_to_cpu(sup->min_io_size)); |
342 | pr_err("\tleb_size %u\n", le32_to_cpu(sup->leb_size)); | 342 | pr_err("\tleb_size %u\n", le32_to_cpu(sup->leb_size)); |
@@ -2462,7 +2462,7 @@ static int power_cut_emulated(struct ubifs_info *c, int lnum, int write) | |||
2462 | 2462 | ||
2463 | if (chance(1, 2)) { | 2463 | if (chance(1, 2)) { |
2464 | d->pc_delay = 1; | 2464 | d->pc_delay = 1; |
2465 | /* Fail withing 1 minute */ | 2465 | /* Fail within 1 minute */ |
2466 | delay = prandom_u32() % 60000; | 2466 | delay = prandom_u32() % 60000; |
2467 | d->pc_timeout = jiffies; | 2467 | d->pc_timeout = jiffies; |
2468 | d->pc_timeout += msecs_to_jiffies(delay); | 2468 | d->pc_timeout += msecs_to_jiffies(delay); |
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index 0e045e75abd8..fb166e204441 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c | |||
@@ -546,15 +546,14 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir, | |||
546 | int aligned_dlen, aligned_ilen, sync = IS_DIRSYNC(dir); | 546 | int aligned_dlen, aligned_ilen, sync = IS_DIRSYNC(dir); |
547 | int last_reference = !!(deletion && inode->i_nlink == 0); | 547 | int last_reference = !!(deletion && inode->i_nlink == 0); |
548 | struct ubifs_inode *ui = ubifs_inode(inode); | 548 | struct ubifs_inode *ui = ubifs_inode(inode); |
549 | struct ubifs_inode *dir_ui = ubifs_inode(dir); | 549 | struct ubifs_inode *host_ui = ubifs_inode(dir); |
550 | struct ubifs_dent_node *dent; | 550 | struct ubifs_dent_node *dent; |
551 | struct ubifs_ino_node *ino; | 551 | struct ubifs_ino_node *ino; |
552 | union ubifs_key dent_key, ino_key; | 552 | union ubifs_key dent_key, ino_key; |
553 | 553 | ||
554 | dbg_jnl("ino %lu, dent '%.*s', data len %d in dir ino %lu", | 554 | dbg_jnl("ino %lu, dent '%.*s', data len %d in dir ino %lu", |
555 | inode->i_ino, nm->len, nm->name, ui->data_len, dir->i_ino); | 555 | inode->i_ino, nm->len, nm->name, ui->data_len, dir->i_ino); |
556 | ubifs_assert(dir_ui->data_len == 0); | 556 | ubifs_assert(mutex_is_locked(&host_ui->ui_mutex)); |
557 | ubifs_assert(mutex_is_locked(&dir_ui->ui_mutex)); | ||
558 | 557 | ||
559 | dlen = UBIFS_DENT_NODE_SZ + nm->len + 1; | 558 | dlen = UBIFS_DENT_NODE_SZ + nm->len + 1; |
560 | ilen = UBIFS_INO_NODE_SZ; | 559 | ilen = UBIFS_INO_NODE_SZ; |
@@ -658,7 +657,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir, | |||
658 | ui->synced_i_size = ui->ui_size; | 657 | ui->synced_i_size = ui->ui_size; |
659 | spin_unlock(&ui->ui_lock); | 658 | spin_unlock(&ui->ui_lock); |
660 | mark_inode_clean(c, ui); | 659 | mark_inode_clean(c, ui); |
661 | mark_inode_clean(c, dir_ui); | 660 | mark_inode_clean(c, host_ui); |
662 | return 0; | 661 | return 0; |
663 | 662 | ||
664 | out_finish: | 663 | out_finish: |
diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c index a47ddfc9be6b..c14628fbeee2 100644 --- a/fs/ubifs/log.c +++ b/fs/ubifs/log.c | |||
@@ -106,10 +106,14 @@ static inline long long empty_log_bytes(const struct ubifs_info *c) | |||
106 | h = (long long)c->lhead_lnum * c->leb_size + c->lhead_offs; | 106 | h = (long long)c->lhead_lnum * c->leb_size + c->lhead_offs; |
107 | t = (long long)c->ltail_lnum * c->leb_size; | 107 | t = (long long)c->ltail_lnum * c->leb_size; |
108 | 108 | ||
109 | if (h >= t) | 109 | if (h > t) |
110 | return c->log_bytes - h + t; | 110 | return c->log_bytes - h + t; |
111 | else | 111 | else if (h != t) |
112 | return t - h; | 112 | return t - h; |
113 | else if (c->lhead_lnum != c->ltail_lnum) | ||
114 | return 0; | ||
115 | else | ||
116 | return c->log_bytes; | ||
113 | } | 117 | } |
114 | 118 | ||
115 | /** | 119 | /** |
@@ -447,9 +451,9 @@ out: | |||
447 | * @ltail_lnum: new log tail LEB number | 451 | * @ltail_lnum: new log tail LEB number |
448 | * | 452 | * |
449 | * This function is called on when the commit operation was finished. It | 453 | * This function is called on when the commit operation was finished. It |
450 | * moves log tail to new position and unmaps LEBs which contain obsolete data. | 454 | * moves log tail to new position and updates the master node so that it stores |
451 | * Returns zero in case of success and a negative error code in case of | 455 | * the new log tail LEB number. Returns zero in case of success and a negative |
452 | * failure. | 456 | * error code in case of failure. |
453 | */ | 457 | */ |
454 | int ubifs_log_end_commit(struct ubifs_info *c, int ltail_lnum) | 458 | int ubifs_log_end_commit(struct ubifs_info *c, int ltail_lnum) |
455 | { | 459 | { |
@@ -477,7 +481,12 @@ int ubifs_log_end_commit(struct ubifs_info *c, int ltail_lnum) | |||
477 | spin_unlock(&c->buds_lock); | 481 | spin_unlock(&c->buds_lock); |
478 | 482 | ||
479 | err = dbg_check_bud_bytes(c); | 483 | err = dbg_check_bud_bytes(c); |
484 | if (err) | ||
485 | goto out; | ||
480 | 486 | ||
487 | err = ubifs_write_master(c); | ||
488 | |||
489 | out: | ||
481 | mutex_unlock(&c->log_mutex); | 490 | mutex_unlock(&c->log_mutex); |
482 | return err; | 491 | return err; |
483 | } | 492 | } |