Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 130857
b: refs/heads/master
c: 49d128a
h: refs/heads/master
i:
  130855: 638bb7b
v: v3
  • Loading branch information
Adrian Hunter authored and Artem Bityutskiy committed Jan 26, 2009
1 parent ceb3afd commit fa1b99f
Show file tree
Hide file tree
Showing 4 changed files with 27 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: b4978e949104844224ecf786170c9263efa601f3
refs/heads/master: 49d128aa60751a010640f4763d11577e2f508853
38 changes: 19 additions & 19 deletions trunk/fs/ubifs/orphan.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* Orphans are accumulated in a rb-tree. When an inode's link count drops to
* zero, the inode number is added to the rb-tree. It is removed from the tree
* when the inode is deleted. Any new orphans that are in the orphan tree when
* the commit is run, are written to the orphan area in 1 or more orph nodes.
* the commit is run, are written to the orphan area in 1 or more orphan nodes.
* If the orphan area is full, it is consolidated to make space. There is
* always enough space because validation prevents the user from creating more
* than the maximum number of orphans allowed.
Expand Down Expand Up @@ -231,7 +231,7 @@ static int tot_avail_orphs(struct ubifs_info *c)
}

/**
* do_write_orph_node - write a node
* do_write_orph_node - write a node to the orphan head.
* @c: UBIFS file-system description object
* @len: length of node
* @atomic: write atomically
Expand Down Expand Up @@ -264,11 +264,11 @@ static int do_write_orph_node(struct ubifs_info *c, int len, int atomic)
}

/**
* write_orph_node - write an orph node
* write_orph_node - write an orphan node.
* @c: UBIFS file-system description object
* @atomic: write atomically
*
* This function builds an orph node from the cnext list and writes it to the
* This function builds an orphan node from the cnext list and writes it to the
* orphan head. On success, %0 is returned, otherwise a negative error code
* is returned.
*/
Expand Down Expand Up @@ -326,11 +326,11 @@ static int write_orph_node(struct ubifs_info *c, int atomic)
}

/**
* write_orph_nodes - write orph nodes until there are no more to commit
* write_orph_nodes - write orphan nodes until there are no more to commit.
* @c: UBIFS file-system description object
* @atomic: write atomically
*
* This function writes orph nodes for all the orphans to commit. On success,
* This function writes orphan nodes for all the orphans to commit. On success,
* %0 is returned, otherwise a negative error code is returned.
*/
static int write_orph_nodes(struct ubifs_info *c, int atomic)
Expand Down Expand Up @@ -478,14 +478,14 @@ int ubifs_orphan_end_commit(struct ubifs_info *c)
}

/**
* clear_orphans - erase all LEBs used for orphans.
* ubifs_clear_orphans - erase all LEBs used for orphans.
* @c: UBIFS file-system description object
*
* If recovery is not required, then the orphans from the previous session
* are not needed. This function locates the LEBs used to record
* orphans, and un-maps them.
*/
static int clear_orphans(struct ubifs_info *c)
int ubifs_clear_orphans(struct ubifs_info *c)
{
int lnum, err;

Expand Down Expand Up @@ -547,9 +547,9 @@ static int insert_dead_orphan(struct ubifs_info *c, ino_t inum)
* do_kill_orphans - remove orphan inodes from the index.
* @c: UBIFS file-system description object
* @sleb: scanned LEB
* @last_cmt_no: cmt_no of last orph node read is passed and returned here
* @last_cmt_no: cmt_no of last orphan node read is passed and returned here
* @outofdate: whether the LEB is out of date is returned here
* @last_flagged: whether the end orph node is encountered
* @last_flagged: whether the end orphan node is encountered
*
* This function is a helper to the 'kill_orphans()' function. It goes through
* every orphan node in a LEB and for every inode number recorded, removes
Expand Down Expand Up @@ -580,18 +580,18 @@ static int do_kill_orphans(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
/*
* The commit number on the master node may be less, because
* of a failed commit. If there are several failed commits in a
* row, the commit number written on orph nodes will continue to
* increase (because the commit number is adjusted here) even
* row, the commit number written on orphan nodes will continue
* to increase (because the commit number is adjusted here) even
* though the commit number on the master node stays the same
* because the master node has not been re-written.
*/
if (cmt_no > c->cmt_no)
c->cmt_no = cmt_no;
if (cmt_no < *last_cmt_no && *last_flagged) {
/*
* The last orph node had a higher commit number and was
* flagged as the last written for that commit number.
* That makes this orph node, out of date.
* The last orphan node had a higher commit number and
* was flagged as the last written for that commit
* number. That makes this orphan node, out of date.
*/
if (!first) {
ubifs_err("out of order commit number %llu in "
Expand Down Expand Up @@ -658,10 +658,10 @@ static int kill_orphans(struct ubifs_info *c)
/*
* Orph nodes always start at c->orph_first and are written to each
* successive LEB in turn. Generally unused LEBs will have been unmapped
* but may contain out of date orph nodes if the unmap didn't go
* through. In addition, the last orph node written for each commit is
* but may contain out of date orphan nodes if the unmap didn't go
* through. In addition, the last orphan node written for each commit is
* marked (top bit of orph->cmt_no is set to 1). It is possible that
* there are orph nodes from the next commit (i.e. the commit did not
* there are orphan nodes from the next commit (i.e. the commit did not
* complete successfully). In that case, no orphans will have been lost
* due to the way that orphans are written, and any orphans added will
* be valid orphans anyway and so can be deleted.
Expand Down Expand Up @@ -718,7 +718,7 @@ int ubifs_mount_orphans(struct ubifs_info *c, int unclean, int read_only)
if (unclean)
err = kill_orphans(c);
else if (!read_only)
err = clear_orphans(c);
err = ubifs_clear_orphans(c);

return err;
}
Expand Down
6 changes: 6 additions & 0 deletions trunk/fs/ubifs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,12 @@ static int ubifs_remount_rw(struct ubifs_info *c)
err = ubifs_recover_inl_heads(c, c->sbuf);
if (err)
goto out;
} else {
/* A readonly mount is not allowed to have orphans */
ubifs_assert(c->tot_orphans == 0);
err = ubifs_clear_orphans(c);
if (err)
goto out;
}

if (!(c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY))) {
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/ubifs/ubifs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,7 @@ void ubifs_delete_orphan(struct ubifs_info *c, ino_t inum);
int ubifs_orphan_start_commit(struct ubifs_info *c);
int ubifs_orphan_end_commit(struct ubifs_info *c);
int ubifs_mount_orphans(struct ubifs_info *c, int unclean, int read_only);
int ubifs_clear_orphans(struct ubifs_info *c);

/* lpt.c */
int ubifs_calc_lpt_geom(struct ubifs_info *c);
Expand Down

0 comments on commit fa1b99f

Please sign in to comment.