From: NeilBrown Date: Fri, 4 Mar 2011 23:44:23 +0000 (+1100) Subject: Handle mount-time errors better. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=64527465b800be98f6d6e96bcc5f92df1b7dc0ac;p=LaFS.git Handle mount-time errors better. If we get an error during mount/roll-forward, we need to be careful during shutdown that we don't assume the filesystem was active. Signed-off-by: NeilBrown --- diff --git a/super.c b/super.c index 7429bc9..f6f66c7 100644 --- a/super.c +++ b/super.c @@ -819,13 +819,18 @@ lafs_put_super(struct super_block *sb) int ss; struct lafs_inode *li; - lafs_checkpoint_lock(fs); - lafs_checkpoint_start(fs); - if (sb == fs->prime_sb) - /* Don't incorporate any more segusage/quota updates. */ - set_bit(FinalCheckpoint, &fs->fsstate); - lafs_checkpoint_unlock_wait(fs); - lafs_cluster_wait_all(fs); + /* If !fs->thread, we never really mounted the fs, so this + * cleanup is inappropriate .. and cannot work anyway. + */ + if (fs->thread) { + lafs_checkpoint_lock(fs); + lafs_checkpoint_start(fs); + if (sb == fs->prime_sb) + /* Don't incorporate any more segusage/quota updates. */ + set_bit(FinalCheckpoint, &fs->fsstate); + lafs_checkpoint_unlock_wait(fs); + lafs_cluster_wait_all(fs); + } if (sb == fs->prime_sb) { int d; @@ -951,9 +956,12 @@ lafs_get_sb(struct file_system_type *fs_type, err = lafs_mount(fs); if (err == 0) err = lafs_start_thread(fs); - if (err) + if (err) { + /* Don't wait for any scan to finish ... */ + fs->scan.done = 1; + fs->checkpointing = 0; deactivate_locked_super(fs->prime_sb); - else { + } else { fs->prime_sb->s_flags |= MS_ACTIVE; simple_set_mnt(mnt, fs->prime_sb); } @@ -1353,6 +1361,9 @@ void lafs_destroy_inode(struct inode *inode) static int lafs_sync_fs(struct super_block *sb, int wait) { + if (fs_from_sb(sb)->thread == NULL) + /* Filesystem in not active - nothing to sync */ + return 0; if (!wait) /* We only reach here if s_dirt was set, so it * is reasonable to force a checkpoint.