sys/vfs/hammer: Fix wrong parent localization for PFS root
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Thu, 10 Dec 2015 15:11:44 +0000 (00:11 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Fri, 11 Dec 2015 10:02:34 +0000 (19:02 +0900)
The idea of PFS root inode having ip localization value of its
parent directory's inode has been #if0'd after ea434b6f in 2008.

(Since then parent_obj_localization field of ondisk inode seems
to be always 0 because the field is never touched after it's
first allocated, unless it's a symlink which uses symlink[24]
part of union)

Since the field is now deprecated, using this as a localization
value of inode's parent is wrong when the inode is PFS root. It
should use a proper localization value HAMMER_DEF_LOCALIZATION
which is also 0.

Note that HAMMER userspace doesn't allow creating a PFS in PFS
unless the parent PFS is PFS0 (see hammer_cmd_pseudofs_create()),
so it doesn't need to consider the parent inode's localization
value other than the default localization value. If that's allowed,
there seems to be no easy way to tell the localization value.

Also remove parent_obj_localization field of ondisk inode since
it's no longer used after this commit.

sys/vfs/hammer/hammer_disk.h
sys/vfs/hammer/hammer_inode.c
sys/vfs/hammer/hammer_vnops.c

index b8b3c89..e4a53b7 100644 (file)
@@ -777,11 +777,6 @@ struct hammer_inode_data {
        uint64_t nlinks;        /* hard links */
        uint64_t size;          /* filesystem object size */
        union {
-               struct {
-                       uint32_t reserved03[4];
-                       uint32_t parent_obj_localization;
-                       uint32_t reserved04;
-               } obj;
                char    symlink[24];    /* HAMMER_INODE_BASESYMLEN */
        } ext;
        uint64_t mtime; /* mtime must be second-to-last */
index bfeeb94..9f1c107 100644 (file)
@@ -868,18 +868,6 @@ hammer_create_inode(hammer_transaction_t trans, struct vattr *vap,
         */
        if (dip)
                ip->ino_data.parent_obj_id = dip->ino_leaf.base.obj_id;
-#if 0
-       /*
-        * The parent_obj_localization field only applies to pseudo-fs roots.
-        * XXX this is no longer applicable, PFSs are no longer directly
-        * tied into the parent's directory structure.
-        */
-       if (ip->ino_data.obj_type == HAMMER_OBJTYPE_DIRECTORY &&
-           ip->obj_id == HAMMER_OBJID_ROOT) {
-               ip->ino_data.ext.obj.parent_obj_localization =
-                                               dip->obj_localization;
-       }
-#endif
 
        switch(ip->ino_leaf.base.obj_type) {
        case HAMMER_OBJTYPE_CDEV:
index 0e85b11..9378eca 100644 (file)
@@ -1325,7 +1325,7 @@ hammer_vop_nlookupdotdot(struct vop_nlookupdotdot_args *ap)
        lwkt_gettoken(&hmp->fs_token);
        parent_obj_id = dip->ino_data.parent_obj_id;
        if (dip->obj_id == HAMMER_OBJID_ROOT)
-               parent_obj_localization = dip->ino_data.ext.obj.parent_obj_localization;
+               parent_obj_localization = HAMMER_DEF_LOCALIZATION;
        else
                parent_obj_localization = dip->obj_localization;