Skip to content

Commit 014eb04

Browse files
Artem BityutskiyArtem Bityutskiy
authored andcommitted
UBIFS: increment commit number earlier
Increment the commit number at the beginnig of the commit, instead of doing this after the commit. This is needed for further optimizations. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
1 parent fd6c6b5 commit 014eb04

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎fs/ubifs/commit.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static int do_commit(struct ubifs_info *c)
7474
goto out_up;
7575
}
7676

77+
c->cmt_no += 1;
7778
err = ubifs_gc_start_commit(c);
7879
if (err)
7980
goto out_up;
@@ -115,7 +116,7 @@ static int do_commit(struct ubifs_info *c)
115116
goto out;
116117

117118
mutex_lock(&c->mst_mutex);
118-
c->mst_node->cmt_no = cpu_to_le64(++c->cmt_no);
119+
c->mst_node->cmt_no = cpu_to_le64(c->cmt_no);
119120
c->mst_node->log_lnum = cpu_to_le32(new_ltail_lnum);
120121
c->mst_node->root_lnum = cpu_to_le32(zroot.lnum);
121122
c->mst_node->root_offs = cpu_to_le32(zroot.offs);

‎fs/ubifs/log.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum)
412412
return -ENOMEM;
413413

414414
cs->ch.node_type = UBIFS_CS_NODE;
415-
cs->cmt_no = cpu_to_le64(c->cmt_no + 1);
415+
cs->cmt_no = cpu_to_le64(c->cmt_no);
416416
ubifs_prepare_node(c, cs, UBIFS_CS_NODE_SZ, 0);
417417

418418
/*

‎fs/ubifs/orphan.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ static int write_orph_node(struct ubifs_info *c, int atomic)
310310
c->cmt_orphans -= cnt;
311311
spin_unlock(&c->orphan_lock);
312312
if (c->cmt_orphans)
313-
orph->cmt_no = cpu_to_le64(c->cmt_no + 1);
313+
orph->cmt_no = cpu_to_le64(c->cmt_no);
314314
else
315315
/* Mark the last node of the commit */
316-
orph->cmt_no = cpu_to_le64((c->cmt_no + 1) | (1ULL << 63));
316+
orph->cmt_no = cpu_to_le64((c->cmt_no) | (1ULL << 63));
317317
ubifs_assert(c->ohead_offs + len <= c->leb_size);
318318
ubifs_assert(c->ohead_lnum >= c->orph_first);
319319
ubifs_assert(c->ohead_lnum <= c->orph_last);

‎fs/ubifs/ubifs.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,8 @@ struct ubifs_mount_opts {
865865
* @highest_inum: highest used inode number
866866
* @vfs_gen: VFS inode generation counter
867867
* @max_sqnum: current global sequence number
868-
* @cmt_no: commit number (last successfully completed commit)
868+
* @cmt_no: commit number of the last successfully completed commit, protected
869+
* by @commit_sem
869870
* @cnt_lock: protects @highest_inum, @vfs_gen, and @max_sqnum counters
870871
* @fmt_version: UBIFS on-flash format version
871872
* @uuid: UUID from super block

0 commit comments

Comments
 (0)