]> git.neil.brown.name Git - LaFS.git/commitdiff
Revise handling of filesystem inconsistency: nlink == 0
authorNeilBrown <neilb@suse.de>
Mon, 9 Aug 2010 10:43:15 +0000 (20:43 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 9 Aug 2010 10:43:15 +0000 (20:43 +1000)
Our handling wasn't really correct, and made the less-safe
assumption.
So change it to simply increment the linkcount.

Signed-off-by: NeilBrown <neilb@suse.de>
inode.c

diff --git a/inode.c b/inode.c
index 1a5ad6cee920cfa4039383f2204c6530efd719ff..5eb6271080788385297c657badcde001043b3543 100644 (file)
--- a/inode.c
+++ b/inode.c
@@ -342,15 +342,18 @@ lafs_import_inode(struct inode *ino, struct datablock *b)
                i->parent = le32_to_cpu(l->parent);
                ino->i_nlink = le32_to_cpu(l->linkcount);
                if (ino->i_nlink == 0 && list_empty(&b->orphans)) {
-                       /* Pop this block on the orphan list just in case */
-                       struct fs *fs = fs_from_inode(ino);
-                       spin_lock(&fs->lock);
-                       if (list_empty(&b->orphans)) {
-                               list_add_tail(&b->orphans, &fs->pending_orphans);
-                               getdref(b, MKREF(orphan_list));
-                               lafs_wake_cleaner(fs);
-                       }
-                       spin_unlock(&fs->lock);
+                       /* This block should already be on the orphan
+                        * list, otherwise there is a filesystem
+                        * inconsistency.
+                        * Either the orphan file is wrong, or the
+                        * linkcount is wrong.
+                        * It is safest to assume the later - either
+                        * was an FS check would be needed to fix it.
+                        */
+                       /* FIXME set a superblock flag requesting
+                        * directory linkage checking
+                        */
+                       ino->i_nlink = 1;
                }
 
                dprintk("  mode = 0%o uid %d size %lld\n",