Merge branch 'for-linus' of git://git.infradead.org/ubifs-2.6
* 'for-linus' of git://git.infradead.org/ubifs-2.6: UBIFS: seek journal heads to the latest bud in replay UBIFS: do not free write-buffers when in R/O mode
···175}176177/**178- * ubifs_create_buds_lists - create journal head buds lists for remount rw.179- * @c: UBIFS file-system description object180- */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.199 * @c: UBIFS file-system description object200 * @jhead: journal head the bud belongs to
···175}176177/**00000000000000000000178 * ubifs_add_bud_to_log - add a new bud to the log.179 * @c: UBIFS file-system description object180 * @jhead: journal head the bud belongs to
+12-6
fs/ubifs/replay.c
···59 * @new_size: truncation new size60 * @free: amount of free space in a bud61 * @dirty: amount of dirty space in a bud from padding and deletion nodes062 *63 * UBIFS journal replay must compare node sequence numbers, which means it must64 * build a tree of node information to insert into the TNC.···81 struct {82 int free;83 int dirty;084 };85 };86};···161 err = PTR_ERR(lp);162 goto out;163 }00000164out:165 ubifs_release_lprops(c);166 return err;···634 ubifs_assert(sleb->endpt - offs >= used);635 ubifs_assert(sleb->endpt % c->min_io_size == 0);636637- if (sleb->endpt + c->min_io_size <= c->leb_size && !c->ro_mount)638- err = ubifs_wbuf_seek_nolock(&c->jheads[jhead].wbuf, lnum,639- sleb->endpt, UBI_SHORTTERM);640-641 *dirty = sleb->endpt - offs - used;642 *free = c->leb_size - sleb->endpt;643···656 * @sqnum: sequence number657 * @free: amount of free space in bud658 * @dirty: amount of dirty space from padding and deletion nodes0659 *660 * This function inserts a reference node to the replay tree and returns zero661 * in case of success or a negative error code in case of failure.662 */663static int insert_ref_node(struct ubifs_info *c, int lnum, int offs,664- unsigned long long sqnum, int free, int dirty)0665{666 struct rb_node **p = &c->replay_tree.rb_node, *parent = NULL;667 struct replay_entry *r;···693 r->flags = REPLAY_REF;694 r->free = free;695 r->dirty = dirty;0696697 rb_link_node(&r->rb, parent, p);698 rb_insert_color(&r->rb, &c->replay_tree);···718 if (err)719 return err;720 err = insert_ref_node(c, b->bud->lnum, b->bud->start, b->sqnum,721- free, dirty);722 if (err)723 return err;724 }
···59 * @new_size: truncation new size60 * @free: amount of free space in a bud61 * @dirty: amount of dirty space in a bud from padding and deletion nodes62+ * @jhead: journal head number of the bud63 *64 * UBIFS journal replay must compare node sequence numbers, which means it must65 * build a tree of node information to insert into the TNC.···80 struct {81 int free;82 int dirty;83+ int jhead;84 };85 };86};···159 err = PTR_ERR(lp);160 goto out;161 }162+163+ /* Make sure the journal head points to the latest bud */164+ err = ubifs_wbuf_seek_nolock(&c->jheads[r->jhead].wbuf, r->lnum,165+ c->leb_size - r->free, UBI_SHORTTERM);166+167out:168 ubifs_release_lprops(c);169 return err;···627 ubifs_assert(sleb->endpt - offs >= used);628 ubifs_assert(sleb->endpt % c->min_io_size == 0);6290000630 *dirty = sleb->endpt - offs - used;631 *free = c->leb_size - sleb->endpt;632···653 * @sqnum: sequence number654 * @free: amount of free space in bud655 * @dirty: amount of dirty space from padding and deletion nodes656+ * @jhead: journal head number for the bud657 *658 * This function inserts a reference node to the replay tree and returns zero659 * in case of success or a negative error code in case of failure.660 */661static int insert_ref_node(struct ubifs_info *c, int lnum, int offs,662+ unsigned long long sqnum, int free, int dirty,663+ int jhead)664{665 struct rb_node **p = &c->replay_tree.rb_node, *parent = NULL;666 struct replay_entry *r;···688 r->flags = REPLAY_REF;689 r->free = free;690 r->dirty = dirty;691+ r->jhead = jhead;692693 rb_link_node(&r->rb, parent, p);694 rb_insert_color(&r->rb, &c->replay_tree);···712 if (err)713 return err;714 err = insert_ref_node(c, b->bud->lnum, b->bud->start, b->sqnum,715+ free, dirty, b->bud->jhead);716 if (err)717 return err;718 }
+4-11
fs/ubifs/super.c
···1257 goto out_free;1258 }125900001260 sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id);1261 if (!c->ro_mount) {1262- err = alloc_wbufs(c);1263- if (err)1264- goto out_cbuf;1265-1266 /* Create background thread */1267 c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name);1268 if (IS_ERR(c->bgt)) {···1631 if (err)1632 goto out;16331634- err = alloc_wbufs(c);1635- if (err)1636- goto out;1637-1638- ubifs_create_buds_lists(c);1639-1640 /* Create background thread */1641 c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name);1642 if (IS_ERR(c->bgt)) {···1738 if (err)1739 ubifs_ro_mode(c, err);17401741- free_wbufs(c);1742 vfree(c->orph_buf);1743 c->orph_buf = NULL;1744 kfree(c->write_reserve_buf);
···1257 goto out_free;1258 }12591260+ err = alloc_wbufs(c);1261+ if (err)1262+ goto out_cbuf;1263+1264 sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id);1265 if (!c->ro_mount) {00001266 /* Create background thread */1267 c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name);1268 if (IS_ERR(c->bgt)) {···1631 if (err)1632 goto out;16330000001634 /* Create background thread */1635 c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name);1636 if (IS_ERR(c->bgt)) {···1744 if (err)1745 ubifs_ro_mode(c, err);174601747 vfree(c->orph_buf);1748 c->orph_buf = NULL;1749 kfree(c->write_reserve_buf);