]> git.neil.brown.name Git - LaFS.git/commitdiff
FORMAT CHANGE: add parent field to InodeFile
authorNeilBrown <neilb@suse.de>
Tue, 3 May 2011 05:29:22 +0000 (15:29 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 3 May 2011 05:29:22 +0000 (15:29 +1000)
As an InodeFile for a subset looks like a directory,
it needs a 'parent' pointer.

Signed-off-by: NeilBrown <neilb@suse.de>
dir.c
inode.c
layout.h
state.h
super.c

diff --git a/dir.c b/dir.c
index c4a024a2ed30e614bc9f4bd34666f83d52309194..c8fd15a006ffe1983dd2bac4dc74576a562e3a5f 100644 (file)
--- 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 d489f498ff7375fdb6c629c09319902a424a3d0c..d46b771c9f8ad40a96f658a6a6535b893a4ef056 100644 (file)
--- 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]);
index fed1473127e572ff9644ebb40e544926298a6782..ceb1d1c647488fa7a631ef3367b363ffaf90655e 100644 (file)
--- 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 903682a1a5f9ec131e546b4383b5bdedee4e5aa3..765b295b2519bb12a0f4bbdb71e0839fd364b45d 100644 (file)
--- 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 6e03eff7648abc2473d887e109aec76f3634a5ec..81c32e2878f38524ff7f3799362d863631914fff 100644 (file)
--- 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);