Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 206343
b: refs/heads/master
c: 6c12516
h: refs/heads/master
i:
  206341: a767549
  206339: 64ad491
  206335: 441ebf9
v: v3
  • Loading branch information
Ryusuke Konishi committed Jul 23, 2010
1 parent 43e9307 commit 0f83054
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 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: 2d72b99ecdf8cbb5d9422c54b401d9d590b2faf5
refs/heads/master: 6c12516083cf51b6e576691ac6e20c4a32f4edb9
52 changes: 50 additions & 2 deletions trunk/fs/nilfs2/the_nilfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
static LIST_HEAD(nilfs_objects);
static DEFINE_SPINLOCK(nilfs_lock);

static int nilfs_valid_sb(struct nilfs_super_block *sbp);

void nilfs_set_last_segment(struct the_nilfs *nilfs,
sector_t start_blocknr, u64 seq, __u64 cno)
{
Expand Down Expand Up @@ -316,8 +318,50 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)

err = nilfs_search_super_root(nilfs, &ri);
if (unlikely(err)) {
printk(KERN_ERR "NILFS: error searching super root.\n");
goto failed;
struct nilfs_super_block **sbp = nilfs->ns_sbp;
int blocksize;

if (err != -EINVAL)
goto scan_error;

if (!nilfs_valid_sb(sbp[1])) {
printk(KERN_WARNING
"NILFS warning: unable to fall back to spare"
"super block\n");
goto scan_error;
}
printk(KERN_INFO
"NILFS: try rollback from an earlier position\n");

/*
* restore super block with its spare and reconfigure
* relevant states of the nilfs object.
*/
memcpy(sbp[0], sbp[1], nilfs->ns_sbsize);
nilfs->ns_crc_seed = le32_to_cpu(sbp[0]->s_crc_seed);
nilfs->ns_sbwtime = le64_to_cpu(sbp[0]->s_wtime);

/* verify consistency between two super blocks */
blocksize = BLOCK_SIZE << le32_to_cpu(sbp[0]->s_log_block_size);
if (blocksize != nilfs->ns_blocksize) {
printk(KERN_WARNING
"NILFS warning: blocksize differs between "
"two super blocks (%d != %d)\n",
blocksize, nilfs->ns_blocksize);
goto scan_error;
}

err = nilfs_store_log_cursor(nilfs, sbp[0]);
if (err)
goto scan_error;

/* drop clean flag to allow roll-forward and recovery */
nilfs->ns_mount_state &= ~NILFS_VALID_FS;
valid_fs = 0;

err = nilfs_search_super_root(nilfs, &ri);
if (err)
goto scan_error;
}

err = nilfs_load_super_root(nilfs, ri.ri_super_root);
Expand Down Expand Up @@ -371,6 +415,10 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
sbi->s_super->s_flags = s_flags;
return 0;

scan_error:
printk(KERN_ERR "NILFS: error searching super root.\n");
goto failed;

failed_unload:
nilfs_mdt_destroy(nilfs->ns_cpfile);
nilfs_mdt_destroy(nilfs->ns_sufile);
Expand Down

0 comments on commit 0f83054

Please sign in to comment.