From: NeilBrown Date: Tue, 3 May 2011 05:29:22 +0000 (+1000) Subject: FORMAT CHANGE: add parent field to InodeFile X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=97a68e3a7fcce29400039f0ca72fae0ed19514ba;p=LaFS.git FORMAT CHANGE: add parent field to InodeFile As an InodeFile for a subset looks like a directory, it needs a 'parent' pointer. Signed-off-by: NeilBrown --- diff --git a/dir.c b/dir.c index c4a024a..c8fd15a 100644 --- a/dir.c +++ b/dir.c @@ -791,7 +791,14 @@ lafs_dir_roll_mini(struct inode *dir, int handle, int dirop, dir_create_commit(&doh, fs, dir, name, len, rr->inode->i_ino, mode_to_dt(rr->inode->i_mode)); - LAFSI(rr->inode)->md.file.parent = dir->i_ino; + switch (LAFSI(rr->inode)->type) { + case TypeFile: + LAFSI(rr->inode)->md.file.parent = dir->i_ino; + break; + case TypeInodeFile: + LAFSI(rr->inode)->md.fs.parent = dir->i_ino; + break; + } if (inode) { if (S_ISDIR(inode->i_mode)) inode_dec_link_count(inode); @@ -1456,7 +1463,14 @@ retry: new_dentry->d_name.len, old_inode->i_ino, mode_to_dt(old_inode->i_mode)); - LAFSI(old_inode)->md.file.parent = new_dir->i_ino; + switch (LAFSI(old_inode)->type) { + case TypeFile: + LAFSI(old_inode)->md.file.parent = new_dir->i_ino; + break; + case TypeInodeFile: + LAFSI(old_inode)->md.fs.parent = new_dir->i_ino; + break; + } if (new_inode) { if (S_ISDIR(new_inode->i_mode)) inode_dec_link_count(new_inode); diff --git a/inode.c b/inode.c index d489f49..d46b771 100644 --- a/inode.c +++ b/inode.c @@ -310,6 +310,7 @@ lafs_import_inode(struct inode *ino, struct datablock *b) i->blocks_unalloc = 0; i->creation_age = le64_to_cpu(l->creation_age); i->inodes_used = le32_to_cpu(l->inodes_used); + i->parent = le32_to_cpu(l->parent); i->quota_inums[0] = le32_to_cpu(l->quota_inodes[0]); i->quota_inums[1] = le32_to_cpu(l->quota_inodes[1]); i->quota_inums[2] = le32_to_cpu(l->quota_inodes[2]); @@ -766,6 +767,7 @@ void lafs_inode_init(struct datablock *b, int type, int mode, struct inode *dir) l->blocks_allowed = 0; l->creation_age = fs->wc[0].cluster_seq; l->inodes_used = 0; + l->parent = 0; l->quota_inodes[0] = 0; l->quota_inodes[1] = 0; l->quota_inodes[2] = 0; @@ -1441,6 +1443,7 @@ void lafs_inode_fillblock(struct inode *ino) l->blocks_allowed = cpu_to_le64(i->blocks_allowed); l->creation_age = cpu_to_le64(i->creation_age); l->inodes_used = cpu_to_le32(i->inodes_used); + l->parent = cpu_to_le32(i->parent); l->quota_inodes[0] = cpu_to_le32(i->quota_inums[0]); l->quota_inodes[1] = cpu_to_le32(i->quota_inums[1]); l->quota_inodes[2] = cpu_to_le32(i->quota_inums[2]); diff --git a/layout.h b/layout.h index fed1473..ceb1d1c 100644 --- a/layout.h +++ b/layout.h @@ -136,6 +136,8 @@ struct la_inode { u64 blocks_allowed; u64 creation_age; u32 inodes_used; + u32 parent; /* Make it easier to look like + * a directory */ u32 quota_inodes[3]; u16 snapshot_usage_table; u16 pad; diff --git a/state.h b/state.h index 903682a..765b295 100644 --- a/state.h +++ b/state.h @@ -605,6 +605,7 @@ struct lafs_inode { u64 blocks_unalloc; /* FIXME what is this for ?? */ u64 creation_age; + u32 parent; /* like 'parent' in directory */ u32 inodes_used; u32 quota_inums[3]; struct inode *quota_inodes[3]; diff --git a/super.c b/super.c index 6e03eff..81c32e2 100644 --- a/super.c +++ b/super.c @@ -1104,13 +1104,13 @@ lafs_get_subset(struct file_system_type *fs_type, err = lafs_pin_dblock(inodb, ReleaseSpace); if (!err) { struct fs_md *md; + u32 parent = LAFSI(ino)->md.file.parent; /* OK, we are good to go making this filesystem */ LAFSI(ino)->type = TypeInodeFile; LAFSI(ino)->metadata_size = (sizeof(struct la_inode) + sizeof(struct fs_metadata)); ino->i_op = &lafs_subset_ino_operations; ino->i_fop = &lafs_subset_file_operations; - /* FIXME we lose md->parent here - what to do?? */ md = &LAFSI(ino)->md.fs; md->usagetable = 0; ino->i_mtime = current_fs_time(sb); @@ -1122,6 +1122,7 @@ lafs_get_subset(struct file_system_type *fs_type, /* FIXME should I be using inode_init here */ md->creation_age = fs->wc[0].cluster_seq; md->inodes_used = 0; + md->parent = parent; md->quota_inums[0] = 0; md->quota_inums[1] = 0; md->quota_inums[2] = 0; @@ -1175,7 +1176,7 @@ static struct dentry *subset_lookup(struct inode *dir, struct dentry *dentry, static int subset_readdir(struct file *filp, void *dirent, filldir_t filldir) { struct dentry *dentry = filp->f_dentry; - //struct lafs_inodee *lai = LAFSI(dentry->d_inode); + struct lafs_inode *lai = LAFSI(dentry->d_inode); ino_t ino; loff_t i = filp->f_pos; @@ -1188,7 +1189,7 @@ static int subset_readdir(struct file *filp, void *dirent, filldir_t filldir) i++; /* fallthrough */ case 1: - ino = 2; /* FIXME need parent for subset! */ + ino = lai->md.fs.parent; if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0) break; filp->f_pos++; @@ -1286,9 +1287,18 @@ static struct dentry *lafs_fh_to_parent(struct super_block *sb, struct fid *fid, static struct dentry *lafs_get_parent(struct dentry *child) { - ino_t inum = LAFSI(child->d_inode)->md.file.parent; - struct inode *inode = lafs_iget(LAFSI(child->d_inode)->filesys, - inum, SYNC); + ino_t inum = 0; + struct inode *inode; + switch(LAFSI(child->d_inode)->type) { + case TypeFile: + inum = LAFSI(child->d_inode)->md.file.parent; + break; + case TypeInodeFile: + inum = LAFSI(child->d_inode)->md.fs.parent; + break; + } + inode = lafs_iget(LAFSI(child->d_inode)->filesys, + inum, SYNC); if (IS_ERR(inode)) return ERR_CAST(inode); return d_obtain_alias(inode);