Index: uspace/lib/ext4/libext4_bitmap.c
===================================================================
--- uspace/lib/ext4/libext4_bitmap.c	(revision 1c1c736062b304923291358a7e8a09b107f8d6ab)
+++ uspace/lib/ext4/libext4_bitmap.c	(revision 35f48f2356b9a59df7e8e43a80a9bc8b567441b8)
@@ -167,10 +167,19 @@
 	rc = ext4_bitmap_find_free_bit_and_set(block->data, &rel_block_idx, block_size);
 
-	// if ENOSPC - try next block group - try next block groups
 
+	if (rc != EOK) {
+		EXT4FS_DBG("no block found");
+		// TODO if ENOSPC - try next block group - try next block groups
+	}
 
+	// TODO decrement superblock free blocks count
+	//uint32_t sb_free_blocks = ext4_superblock_get_free_blocks_count(sb);
+	//sb_free_blocks--;
+	//ext4_superblock_set_free_blocks_count(sb, sb_free_blocks);
 
-
-	// TODO decrement superblock & block group free blocks count
+	uint32_t bg_free_blocks = ext4_block_group_get_free_blocks_count(bg_ref->block_group);
+	bg_free_blocks++;
+	ext4_block_group_set_free_blocks_count(bg_ref->block_group, bg_free_blocks);
+	bg_ref->dirty = true;
 
 	// return
Index: uspace/lib/ext4/libext4_filesystem.c
===================================================================
--- uspace/lib/ext4/libext4_filesystem.c	(revision 1c1c736062b304923291358a7e8a09b107f8d6ab)
+++ uspace/lib/ext4/libext4_filesystem.c	(revision 35f48f2356b9a59df7e8e43a80a9bc8b567441b8)
@@ -363,4 +363,93 @@
 
 
+int ext4_filesystem_set_inode_data_block_index(ext4_filesystem_t *fs,
+		ext4_inode_t *inode, aoff64_t iblock, uint32_t fblock)
+{
+
+//	int rc;
+//	uint32_t offset_in_block;
+//	uint32_t current_block;
+//	aoff64_t block_offset_in_level;
+//	int i;
+//	int level;
+//	block_t *block;
+
+	/* Handle inode using extents */
+	if (ext4_superblock_has_feature_compatible(fs->superblock, EXT4_FEATURE_INCOMPAT_EXTENTS) &&
+			ext4_inode_has_flag(inode, EXT4_INODE_FLAG_EXTENTS)) {
+		// TODO
+		return ENOTSUP;
+
+	}
+
+	/* Handle simple case when we are dealing with direct reference */
+	if (iblock < EXT4_INODE_DIRECT_BLOCK_COUNT) {
+		ext4_inode_set_direct_block(inode, (uint32_t)iblock, fblock);
+		return EOK;
+	}
+
+//	/* Determine the indirection level needed to get the desired block */
+//	level = -1;
+//	for (i = 1; i < 4; i++) {
+//		if (iblock < fs->inode_block_limits[i]) {
+//			level = i;
+//			break;
+//		}
+//	}
+//
+//	if (level == -1) {
+//		return EIO;
+//	}
+//
+//	/* Compute offsets for the topmost level */
+//	block_offset_in_level = iblock - fs->inode_block_limits[level-1];
+//	current_block = ext4_inode_get_indirect_block(inode, level-1);
+//	offset_in_block = block_offset_in_level / fs->inode_blocks_per_level[level-1];
+//
+//	/* Navigate through other levels, until we find the block number
+//	 * or find null reference meaning we are dealing with sparse file
+//	 */
+//	while (level > 0) {
+//		rc = block_get(&block, fs->device, current_block, 0);
+//		if (rc != EOK) {
+//			return rc;
+//		}
+//
+//		current_block = uint32_t_le2host(((uint32_t*)block->data)[offset_in_block]);
+//
+//		rc = block_put(block);
+//		if (rc != EOK) {
+//			return rc;
+//		}
+//
+//		if (current_block == 0) {
+//			/* This is a sparse file */
+//			*fblock = 0;
+//			return EOK;
+//		}
+//
+//		level -= 1;
+//
+//		/* If we are on the last level, break here as
+//		 * there is no next level to visit
+//		 */
+//		if (level == 0) {
+//			break;
+//		}
+//
+//		/* Visit the next level */
+//		block_offset_in_level %= fs->inode_blocks_per_level[level];
+//		offset_in_block = block_offset_in_level / fs->inode_blocks_per_level[level-1];
+//	}
+//
+//	*fblock = current_block;
+//
+//	return EOK;
+//
+//
+
+	return EOK;
+}
+
 int ext4_filesystem_release_inode_block(ext4_filesystem_t *fs,
 		ext4_inode_ref_t *inode_ref, uint32_t iblock)
Index: uspace/lib/ext4/libext4_filesystem.h
===================================================================
--- uspace/lib/ext4/libext4_filesystem.h	(revision 1c1c736062b304923291358a7e8a09b107f8d6ab)
+++ uspace/lib/ext4/libext4_filesystem.h	(revision 35f48f2356b9a59df7e8e43a80a9bc8b567441b8)
@@ -62,4 +62,6 @@
 extern int ext4_filesystem_get_inode_data_block_index(ext4_filesystem_t *,
 	ext4_inode_t *, aoff64_t iblock, uint32_t *);
+extern int ext4_filesystem_set_inode_data_block_index(ext4_filesystem_t *,
+		ext4_inode_t *, aoff64_t, uint32_t);
 extern int ext4_filesystem_release_inode_block(ext4_filesystem_t *,
 		ext4_inode_ref_t *, uint32_t);
