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) {
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;
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