eloc.logicalBlockNum = *block;
        eloc.partitionReferenceNum =
                                iinfo->i_location.partitionReferenceNum;
-       elen = inode->i_size;
+       elen = inode->i_sb->s_blocksize;
        iinfo->i_lenExtents = elen;
        epos.bh = NULL;
        epos.block = iinfo->i_location;
 
                }
 
                block = dinfo->i_location.logicalBlockNum;
-
        } else {
                block = udf_get_lb_pblock(dir->i_sb, dinfo->i_location, 0);
                fibh->sbh = fibh->ebh = NULL;
        }
 
 add:
+       if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
+               elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1);
+               if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
+                       epos.offset -= sizeof(short_ad);
+               else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
+                       epos.offset -= sizeof(long_ad);
+               udf_write_aext(dir, &epos, eloc, elen, 1);
+       }
        f_pos += nfidlen;
 
        if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB &&
                if (!fibh->sbh)
                        return NULL;
                epos.block = dinfo->i_location;
-               eloc.logicalBlockNum = block;
-               eloc.partitionReferenceNum =
-                               dinfo->i_location.partitionReferenceNum;
-               elen = dir->i_sb->s_blocksize;
                epos.offset = udf_file_entry_alloc_offset(dir);
-               if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
-                       epos.offset += sizeof(short_ad);
-               else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
-                       epos.offset += sizeof(long_ad);
+               /* Load extent udf_expand_dir_adinicb() has created */
+               udf_current_aext(dir, &epos, &eloc, &elen, 1);
        }
 
        if (sb->s_blocksize - fibh->eoffset >= nfidlen) {