]> git.neil.brown.name Git - LaFS.git/commitdiff
Better handling of changing a Directory into an InodeFile
authorNeilBrown <neilb@suse.de>
Fri, 13 Aug 2010 06:23:28 +0000 (16:23 +1000)
committerNeilBrown <neilb@suse.de>
Fri, 13 Aug 2010 06:23:28 +0000 (16:23 +1000)
- actually change the type !!!
- make sure the on-disk block gets a proper index update.

Note that the checkpointing before creating things in the FS is
important for this to be correct.

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

diff --git a/inode.c b/inode.c
index a17cd7e1d2f2f4e0ec8fa2c4687d0cf81eb3d0ad..ffb1b742081ceb792e40e1b2fd123700d1f54d07 100644 (file)
--- a/inode.c
+++ b/inode.c
@@ -1132,7 +1132,20 @@ void lafs_inode_fillblock(struct inode *ino)
        lai->trunc_gen = li->trunc_gen;
        lai->flags = li->flags;
        lai->filetype = li->type;
-       lai->metadata_size = cpu_to_le16(li->metadata_size);
+       if (lai->metadata_size != cpu_to_le16(li->metadata_size)) {
+               /* Changing metadata size is wierd.
+                * We will need to handle this somehow for xattrs
+                * For now we just want to cope with
+                * Dir -> InodeFile changes, and that guarantees us
+                * there is no index info - so just clear the index 
+                * area.
+                */
+               u16 *s = (u16*)(((char*)lai) + li->metadata_size);
+               BUG_ON(li->type != TypeInodeFile);
+               lai->metadata_size = cpu_to_le16(li->metadata_size);
+               memset(s, 0, ino->i_sb->s_blocksize - li->metadata_size);
+               *s = cpu_to_le16(IBLK_INDIRECT);
+       }
        lai->depth = li->depth;
 
        switch (li->type) {
diff --git a/super.c b/super.c
index 6c88d9ea317f5e3e9ee17d26919732127a8c9c77..f5b255d205111350b54ffabb5b81c4cfbb6e39a7 100644 (file)
--- a/super.c
+++ b/super.c
@@ -991,7 +991,9 @@ lafs_get_subset(struct file_system_type *fs_type,
                if (!err) {
                        struct fs_md *md;
                        /* OK, we are good to go making this filesystem */
-                       LAFSI(ino)->type = TypeDir;
+                       LAFSI(ino)->type = TypeInodeFile;
+                       LAFSI(ino)->metadata_size = (sizeof(struct la_inode) +
+                                                    sizeof(struct fs_metadata));
                        md = &LAFSI(ino)->md.fs;
                        md->usagetable = 0;
                        md->update_time = CURRENT_TIME.tv_sec;
@@ -1009,6 +1011,7 @@ lafs_get_subset(struct file_system_type *fs_type,
                        md->quota_inodes[1] = NULL;
                        md->quota_inodes[2] = NULL;
                        md->name[0] = '\0';
+                       lafs_dirty_dblock(inodb);
                        lafs_dirty_inode(ino);
                        /* We use a checkpoint to commit this change,
                         * it is too unusual to bother logging