From: NeilBrown Date: Mon, 9 Aug 2010 10:43:15 +0000 (+1000) Subject: Revise handling of filesystem inconsistency: nlink == 0 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=30fa453596b0a84dd42bf13241911df79c60c1d3;p=LaFS.git Revise handling of filesystem inconsistency: nlink == 0 Our handling wasn't really correct, and made the less-safe assumption. So change it to simply increment the linkcount. Signed-off-by: NeilBrown --- diff --git a/inode.c b/inode.c index 1a5ad6c..5eb6271 100644 --- 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",