struct erofs_inode *erofs_iget_by_nid(erofs_nid_t nid);
unsigned int erofs_iput(struct erofs_inode *inode);
erofs_nid_t erofs_lookupnid(struct erofs_inode *inode);
+int erofs_iflush(struct erofs_inode *inode);
struct erofs_dentry *erofs_d_alloc(struct erofs_inode *parent,
const char *name);
int erofs_rebuild_dump_tree(struct erofs_inode *dir);
return write_uncompressed_file_from_fd(inode, fd);
}
-static int erofs_bh_flush_write_inode(struct erofs_buffer_head *bh)
+int erofs_iflush(struct erofs_inode *inode)
{
- struct erofs_inode *const inode = bh->fsprivate;
- struct erofs_sb_info *sbi = inode->sbi;
const u16 icount = EROFS_INODE_XATTR_ICOUNT(inode->xattr_isize);
- erofs_off_t off = erofs_btell(bh, false);
+ struct erofs_sb_info *sbi = inode->sbi;
+ erofs_off_t off;
union {
struct erofs_inode_compact dic;
struct erofs_inode_extended die;
- } u = { {0}, };
+ } u = {};
int ret;
+ if (inode->bh)
+ off = erofs_btell(inode->bh, false);
+ else
+ off = erofs_iloc(inode);
+
switch (inode->inode_isize) {
case sizeof(struct erofs_inode_compact):
u.dic.i_format = cpu_to_le16(0 | (inode->datalayout << 1));
return ret;
}
}
+ return 0;
+}
+static int erofs_bh_flush_write_inode(struct erofs_buffer_head *bh)
+{
+ struct erofs_inode *inode = bh->fsprivate;
+ int ret;
+
+ DBG_BUGON(inode->bh != bh);
+ ret = erofs_iflush(inode);
+ if (ret)
+ return ret;
inode->bh = NULL;
erofs_iput(inode);
return erofs_bh_flush_generic_end(bh);