}
-static void make_dentry_ptr(struct f2fs_dentry_ptr *d, void *src, int type)
+void make_dentry_ptr(struct f2fs_dentry_ptr *d, void *src, int type)
{
if (type == 1) {
struct f2fs_dentry_block *t = (struct f2fs_dentry_block *)src;
d->max = NR_DENTRY_IN_BLOCK;
+ d->nr_bitmap = SIZE_OF_DENTRY_BITMAP;
d->bitmap = t->dentry_bitmap;
d->dentry = t->dentry;
d->filename = t->filename;
} else {
struct f2fs_inline_dentry *t = (struct f2fs_inline_dentry *)src;
d->max = NR_INLINE_DENTRY;
+ d->nr_bitmap = INLINE_DENTRY_BITMAP_SIZE;
d->bitmap = t->dentry_bitmap;
d->dentry = t->dentry;
d->filename = t->filename;
ASSERT(ret >= 0);
if (!dir_level) {
- struct f2fs_inline_dentry *inline_dentry;
struct f2fs_dentry_block *dentry_blk;
+ struct f2fs_dentry_ptr src, dst;
dentry_blk = calloc(BLOCK_SZ, 1);
ASSERT(dentry_blk);
if (dn.data_blkaddr == NULL_ADDR)
new_data_block(sbi, dentry_blk, &dn, CURSEG_HOT_DATA);
- inline_dentry = (struct f2fs_inline_dentry *)inline_data;
+ make_dentry_ptr(&src, (void *)inline_data, 2);
+ make_dentry_ptr(&dst, (void *)dentry_blk, 1);
+
/* copy data from inline dentry block to new dentry block */
- memcpy(dentry_blk->dentry_bitmap, inline_dentry->dentry_bitmap,
- INLINE_DENTRY_BITMAP_SIZE);
- memset(dentry_blk->dentry_bitmap + INLINE_DENTRY_BITMAP_SIZE, 0,
- SIZE_OF_DENTRY_BITMAP - INLINE_DENTRY_BITMAP_SIZE);
-
- memcpy(dentry_blk->dentry, inline_dentry->dentry,
- sizeof(struct f2fs_dir_entry) * NR_INLINE_DENTRY);
- memcpy(dentry_blk->filename, inline_dentry->filename,
- NR_INLINE_DENTRY * F2FS_SLOT_LEN);
+ memcpy(dst.bitmap, src.bitmap, src.nr_bitmap);
+ memset(dst.bitmap + src.nr_bitmap, 0,
+ dst.nr_bitmap - src.nr_bitmap);
+
+ memcpy(dst.dentry, src.dentry, SIZE_OF_DIR_ENTRY * src.max);
+ memcpy(dst.filename, src.filename, src.max * F2FS_SLOT_LEN);
ret = dev_write_block(dentry_blk, dn.data_blkaddr);
ASSERT(ret >= 0);
struct f2fs_node *node_blk, struct child_info *child)
{
struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
- struct f2fs_inline_dentry *de_blk;
+ struct f2fs_dentry_ptr d;
+ void *inline_dentry;
int dentries;
- de_blk = inline_data_addr(node_blk);
- ASSERT(de_blk != NULL);
+ inline_dentry = inline_data_addr(node_blk);
+ ASSERT(inline_dentry != NULL);
+
+ make_dentry_ptr(&d, inline_dentry, 2);
fsck->dentry_depth++;
dentries = __chk_dentries(sbi, child,
- de_blk->dentry_bitmap,
- de_blk->dentry, de_blk->filename,
- NR_INLINE_DENTRY, 1,
+ d.bitmap, d.dentry, d.filename, d.max, 1,
file_enc_name(&node_blk->i));
if (dentries < 0) {
DBG(1, "[%3d] Inline Dentry Block Fixed hash_codes\n\n",
DBG(1, "[%3d] Inline Dentry Block Done : "
"dentries:%d in %d slots (len:%d)\n\n",
fsck->dentry_depth, dentries,
- (int)NR_INLINE_DENTRY, F2FS_NAME_LEN);
+ d.max, F2FS_NAME_LEN);
}
fsck->dentry_depth--;
return dentries;
struct dnode_of_data *, unsigned int);
void get_dnode_of_data(struct f2fs_sb_info *, struct dnode_of_data *,
pgoff_t, int);
+void make_dentry_ptr(struct f2fs_dentry_ptr *, void *, int);
int f2fs_create(struct f2fs_sb_info *, struct dentry *);
int f2fs_mkdir(struct f2fs_sb_info *, struct dentry *);
int f2fs_symlink(struct f2fs_sb_info *, struct dentry *);