#define META 1
/* including inline xattrs, extent */
#define INODE 2
+/* directory data */
+#define DIRA 3
/* shared xattrs */
-#define XATTR 3
+#define XATTR 4
/* device table */
-#define DEVT 4
+#define DEVT 5
struct erofs_bhops {
bool (*preflush)(struct erofs_buffer_head *bh);
if (type == INODE) {
*type_ret = META;
return sizeof(struct erofs_inode_compact);
+ } else if (type == DIRA) {
+ *type_ret = META;
+ return erofs_blksiz();
} else if (type == XATTR) {
*type_ret = META;
return sizeof(struct erofs_xattr_entry);
/* allocate main data for a inode */
static int __allocate_inode_bh_data(struct erofs_inode *inode,
- unsigned long nblocks)
+ unsigned long nblocks,
+ int type)
{
struct erofs_buffer_head *bh;
int ret;
}
/* allocate main data buffer */
- bh = erofs_balloc(DATA, erofs_pos(nblocks), 0, 0);
+ bh = erofs_balloc(type, erofs_pos(nblocks), 0, 0);
if (IS_ERR(bh))
return PTR_ERR(bh);
q = used = blkno = 0;
/* allocate dir main data */
- ret = __allocate_inode_bh_data(dir, erofs_blknr(dir->i_size));
+ ret = __allocate_inode_bh_data(dir, erofs_blknr(dir->i_size), DIRA);
if (ret)
return ret;
inode->datalayout = EROFS_INODE_FLAT_INLINE;
- ret = __allocate_inode_bh_data(inode, nblocks);
+ ret = __allocate_inode_bh_data(inode, nblocks, DATA);
if (ret)
return ret;
inode->datalayout = EROFS_INODE_FLAT_INLINE;
nblocks = inode->i_size / erofs_blksiz();
- ret = __allocate_inode_bh_data(inode, nblocks);
+ ret = __allocate_inode_bh_data(inode, nblocks, DATA);
if (ret)
return ret;
goto exit;
}
+ /* make sure that the super block should be the very first blocks */
+ (void)erofs_mapbh(sb_bh->block);
+ if (erofs_btell(sb_bh, false) != 0) {
+ erofs_err("failed to reserve erofs_super_block");
+ goto exit;
+ }
+
err = erofs_load_compress_hints();
if (err) {
erofs_err("failed to load compress hints %s",