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
This commit is contained in:
Linus Torvalds 2011-05-02 12:17:29 -07:00
commit adadfe48df
3 changed files with 16 additions and 37 deletions

View file

@ -174,26 +174,6 @@ void ubifs_add_bud(struct ubifs_info *c, struct ubifs_bud *bud)
spin_unlock(&c->buds_lock);
}
/**
* ubifs_create_buds_lists - create journal head buds lists for remount rw.
* @c: UBIFS file-system description object
*/
void ubifs_create_buds_lists(struct ubifs_info *c)
{
struct rb_node *p;
spin_lock(&c->buds_lock);
p = rb_first(&c->buds);
while (p) {
struct ubifs_bud *bud = rb_entry(p, struct ubifs_bud, rb);
struct ubifs_jhead *jhead = &c->jheads[bud->jhead];
list_add_tail(&bud->list, &jhead->buds_list);
p = rb_next(p);
}
spin_unlock(&c->buds_lock);
}
/**
* ubifs_add_bud_to_log - add a new bud to the log.
* @c: UBIFS file-system description object

View file

@ -59,6 +59,7 @@ enum {
* @new_size: truncation new size
* @free: amount of free space in a bud
* @dirty: amount of dirty space in a bud from padding and deletion nodes
* @jhead: journal head number of the bud
*
* UBIFS journal replay must compare node sequence numbers, which means it must
* build a tree of node information to insert into the TNC.
@ -80,6 +81,7 @@ struct replay_entry {
struct {
int free;
int dirty;
int jhead;
};
};
};
@ -159,6 +161,11 @@ static int set_bud_lprops(struct ubifs_info *c, struct replay_entry *r)
err = PTR_ERR(lp);
goto out;
}
/* Make sure the journal head points to the latest bud */
err = ubifs_wbuf_seek_nolock(&c->jheads[r->jhead].wbuf, r->lnum,
c->leb_size - r->free, UBI_SHORTTERM);
out:
ubifs_release_lprops(c);
return err;
@ -627,10 +634,6 @@ static int replay_bud(struct ubifs_info *c, int lnum, int offs, int jhead,
ubifs_assert(sleb->endpt - offs >= used);
ubifs_assert(sleb->endpt % c->min_io_size == 0);
if (sleb->endpt + c->min_io_size <= c->leb_size && !c->ro_mount)
err = ubifs_wbuf_seek_nolock(&c->jheads[jhead].wbuf, lnum,
sleb->endpt, UBI_SHORTTERM);
*dirty = sleb->endpt - offs - used;
*free = c->leb_size - sleb->endpt;
@ -653,12 +656,14 @@ out_dump:
* @sqnum: sequence number
* @free: amount of free space in bud
* @dirty: amount of dirty space from padding and deletion nodes
* @jhead: journal head number for the bud
*
* This function inserts a reference node to the replay tree and returns zero
* in case of success or a negative error code in case of failure.
*/
static int insert_ref_node(struct ubifs_info *c, int lnum, int offs,
unsigned long long sqnum, int free, int dirty)
unsigned long long sqnum, int free, int dirty,
int jhead)
{
struct rb_node **p = &c->replay_tree.rb_node, *parent = NULL;
struct replay_entry *r;
@ -688,6 +693,7 @@ static int insert_ref_node(struct ubifs_info *c, int lnum, int offs,
r->flags = REPLAY_REF;
r->free = free;
r->dirty = dirty;
r->jhead = jhead;
rb_link_node(&r->rb, parent, p);
rb_insert_color(&r->rb, &c->replay_tree);
@ -712,7 +718,7 @@ static int replay_buds(struct ubifs_info *c)
if (err)
return err;
err = insert_ref_node(c, b->bud->lnum, b->bud->start, b->sqnum,
free, dirty);
free, dirty, b->bud->jhead);
if (err)
return err;
}

View file

@ -1257,12 +1257,12 @@ static int mount_ubifs(struct ubifs_info *c)
goto out_free;
}
err = alloc_wbufs(c);
if (err)
goto out_cbuf;
sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id);
if (!c->ro_mount) {
err = alloc_wbufs(c);
if (err)
goto out_cbuf;
/* Create background thread */
c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name);
if (IS_ERR(c->bgt)) {
@ -1631,12 +1631,6 @@ static int ubifs_remount_rw(struct ubifs_info *c)
if (err)
goto out;
err = alloc_wbufs(c);
if (err)
goto out;
ubifs_create_buds_lists(c);
/* Create background thread */
c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name);
if (IS_ERR(c->bgt)) {
@ -1744,7 +1738,6 @@ static void ubifs_remount_ro(struct ubifs_info *c)
if (err)
ubifs_ro_mode(c, err);
free_wbufs(c);
vfree(c->orph_buf);
c->orph_buf = NULL;
kfree(c->write_reserve_buf);