]> git.neil.brown.name Git - LaFS.git/commitdiff
Handle mount-time errors better.
authorNeilBrown <neilb@suse.de>
Fri, 4 Mar 2011 23:44:23 +0000 (10:44 +1100)
committerNeilBrown <neilb@suse.de>
Fri, 4 Mar 2011 23:44:23 +0000 (10:44 +1100)
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 <neilb@suse.de>
super.c

diff --git a/super.c b/super.c
index 7429bc9177d62956721f313edaa95ab24d9da9f3..f6f66c75224d39010be0f4e5fc06c13d6a6b1800 100644 (file)
--- 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.