From c356e5d53fd7689417895ecf4347f425e9b0913a Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 13 Aug 2010 16:23:28 +1000 Subject: [PATCH] Better handling of changing a Directory into an InodeFile - 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 --- inode.c | 15 ++++++++++++++- super.c | 5 ++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/inode.c b/inode.c index a17cd7e..ffb1b74 100644 --- 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 6c88d9e..f5b255d 100644 --- 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 -- 2.39.5