Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 250457
b: refs/heads/master
c: cb14a18
h: refs/heads/master
i:
  250455: 8975eef
v: v3
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed May 16, 2011
1 parent 91a12b3 commit 55be22e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c49139d8096dc1c392455dbc3f158b46038fc9d4
refs/heads/master: cb14a18465686ea6add51b1008865b8174c28bd7
4 changes: 4 additions & 0 deletions trunk/fs/ubifs/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ static int switch_gc_head(struct ubifs_info *c)
if (err)
return err;

err = ubifs_wbuf_sync_nolock(wbuf);
if (err)
return err;

err = ubifs_add_bud_to_log(c, GCHD, gc_lnum, 0);
if (err)
return err;
Expand Down
12 changes: 3 additions & 9 deletions trunk/fs/ubifs/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf)
* @dtype: data type
*
* This function targets the write-buffer to logical eraseblock @lnum:@offs.
* The write-buffer is synchronized if it is not empty. Returns zero in case of
* success and a negative error code in case of failure.
* The write-buffer has to be empty. Returns zero in case of success and a
* negative error code in case of failure.
*/
int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs,
int dtype)
Expand All @@ -465,13 +465,7 @@ int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs,
ubifs_assert(offs >= 0 && offs <= c->leb_size);
ubifs_assert(offs % c->min_io_size == 0 && !(offs & 7));
ubifs_assert(lnum != wbuf->lnum);

if (wbuf->used > 0) {
int err = ubifs_wbuf_sync_nolock(wbuf);

if (err)
return err;
}
ubifs_assert(wbuf->used == 0);

spin_lock(&wbuf->lock);
wbuf->lnum = lnum;
Expand Down
25 changes: 15 additions & 10 deletions trunk/fs/ubifs/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,8 @@ static int reserve_space(struct ubifs_info *c, int jhead, int len)
* LEB with some empty space.
*/
lnum = ubifs_find_free_space(c, len, &offs, squeeze);
if (lnum >= 0) {
/* Found an LEB, add it to the journal head */
err = ubifs_add_bud_to_log(c, jhead, lnum, offs);
if (err)
goto out_return;
/* A new bud was successfully allocated and added to the log */
if (lnum >= 0)
goto out;
}

err = lnum;
if (err != -ENOSPC)
Expand Down Expand Up @@ -203,12 +197,23 @@ static int reserve_space(struct ubifs_info *c, int jhead, int len)
return 0;
}

err = ubifs_add_bud_to_log(c, jhead, lnum, 0);
if (err)
goto out_return;
offs = 0;

out:
/*
* Make sure we synchronize the write-buffer before we add the new bud
* to the log. Otherwise we may have a power cut after the log
* reference node for the last bud (@lnum) is written but before the
* write-buffer data are written to the next-to-last bud
* (@wbuf->lnum). And the effect would be that the recovery would see
* that there is corruption in the next-to-last bud.
*/
err = ubifs_wbuf_sync_nolock(wbuf);
if (err)
goto out_return;
err = ubifs_add_bud_to_log(c, jhead, lnum, offs);
if (err)
goto out_return;
err = ubifs_wbuf_seek_nolock(wbuf, lnum, offs, wbuf->dtype);
if (err)
goto out_unlock;
Expand Down

0 comments on commit 55be22e

Please sign in to comment.