Index: uspace/lib/ext4/libext4_balloc.c
===================================================================
--- uspace/lib/ext4/libext4_balloc.c	(revision 936132ff0b54d1b2bd6bd546cb86e46059b5eedf)
+++ uspace/lib/ext4/libext4_balloc.c	(revision b73530a450b7d9935f07bbea318d1235e05f20f3)
@@ -569,4 +569,81 @@
 }
 
+int ext4_balloc_try_alloc_block(ext4_inode_ref_t *inode_ref, uint32_t fblock)
+{
+	int rc;
+
+	ext4_filesystem_t *fs = inode_ref->fs;
+	ext4_superblock_t *sb = fs->superblock;
+
+	uint32_t block_group = ext4_balloc_get_bgid_of_block(sb, fblock);
+	uint32_t index_in_group = ext4_balloc_blockaddr2_index_in_group(sb, fblock);
+
+	ext4_block_group_ref_t *bg_ref;
+	rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref);
+	if (rc != EOK) {
+		EXT4FS_DBG("error in loading bg_ref \%d", rc);
+		return rc;
+	}
+
+	uint32_t bitmap_block_addr = ext4_block_group_get_block_bitmap(
+			bg_ref->block_group, sb);
+	block_t *bitmap_block;
+	rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0);
+	if (rc != EOK) {
+		EXT4FS_DBG("error in loading bitmap \%d", rc);
+		return rc;
+	}
+
+	bool free = ext4_bitmap_is_free_bit(bitmap_block->data, index_in_group);
+
+	if (free) {
+		ext4_bitmap_set_bit(bitmap_block->data, index_in_group);
+		bitmap_block->dirty = true;
+	}
+
+	rc = block_put(bitmap_block);
+	if (rc != EOK) {
+		// Error in saving bitmap
+		ext4_filesystem_put_block_group_ref(bg_ref);
+		EXT4FS_DBG("error in saving bitmap \%d", rc);
+		return rc;
+	}
+
+	if (!free) {
+		rc = EINVAL;
+		goto terminate;
+	}
+
+	uint32_t block_size = ext4_superblock_get_block_size(sb);
+
+	// Update 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);
+
+	// Update inode blocks count
+	uint64_t ino_blocks = ext4_inode_get_blocks_count(sb, inode_ref->inode);
+	ino_blocks += block_size / EXT4_INODE_BLOCK_SIZE;
+	ext4_inode_set_blocks_count(sb, inode_ref->inode, ino_blocks);
+	inode_ref->dirty = true;
+
+	// Update block group free blocks count
+	uint32_t free_blocks = ext4_block_group_get_free_blocks_count(
+			bg_ref->block_group, sb);
+	free_blocks--;
+	ext4_block_group_set_free_blocks_count(bg_ref->block_group,
+			sb, free_blocks);
+	bg_ref->dirty = true;
+
+terminate:
+
+	rc = ext4_filesystem_put_block_group_ref(bg_ref);
+	if (rc != EOK) {
+		EXT4FS_DBG("error in saving bg_ref \%d", rc);
+		return rc;
+	}
+
+	return rc;
+}
 
 /**
Index: uspace/lib/ext4/libext4_balloc.h
===================================================================
--- uspace/lib/ext4/libext4_balloc.h	(revision 936132ff0b54d1b2bd6bd546cb86e46059b5eedf)
+++ uspace/lib/ext4/libext4_balloc.h	(revision b73530a450b7d9935f07bbea318d1235e05f20f3)
@@ -41,4 +41,5 @@
 		uint32_t , uint32_t);
 extern int ext4_balloc_alloc_block(ext4_inode_ref_t *, uint32_t *);
+extern int ext4_balloc_try_alloc_block(ext4_inode_ref_t *, uint32_t);
 
 #endif
Index: uspace/lib/ext4/libext4_extent.c
===================================================================
--- uspace/lib/ext4/libext4_extent.c	(revision 936132ff0b54d1b2bd6bd546cb86e46059b5eedf)
+++ uspace/lib/ext4/libext4_extent.c	(revision b73530a450b7d9935f07bbea318d1235e05f20f3)
@@ -223,4 +223,17 @@
 	int rc;
 
+	uint64_t inode_size = ext4_inode_get_size(
+			inode_ref->fs->superblock, inode_ref->inode);
+
+	uint32_t block_size = ext4_superblock_get_block_size(
+			inode_ref->fs->superblock);
+
+	uint32_t last_idx = (inode_size - 1) / block_size;
+
+	if (iblock > last_idx) {
+		*fblock = 0;
+		return EOK;
+	}
+
 	block_t* block = NULL;
 
@@ -549,7 +562,13 @@
 	ext4_superblock_t *sb = inode_ref->fs->superblock;
 	uint64_t inode_size = ext4_inode_get_size(sb, inode_ref->inode);
-
 	uint32_t block_size = ext4_superblock_get_block_size(sb);
-	uint32_t new_block_idx = inode_size / block_size;
+
+	uint32_t new_block_idx = 0;
+	if (inode_size > 0) {
+		if ((inode_size % block_size) != 0) {
+			inode_size += block_size - (inode_size % block_size);
+		}
+		new_block_idx = inode_size / block_size;
+	}
 
 	ext4_extent_path_t *path;
@@ -565,6 +584,9 @@
 	}
 
-	// if extent == NULL -> add extent to leaf
+	// if extent == NULL -> add extent to empty leaf
 	if (path_ptr->extent == NULL) {
+
+		EXT4FS_DBG("NULL extent");
+
 		ext4_extent_t *ext = EXT4_EXTENT_FIRST(path_ptr->header);
 		ext4_extent_set_block_count(ext, 0);
@@ -579,8 +601,11 @@
 	if (ext4_extent_get_block_count(path_ptr->extent) == 0) {
 
+		EXT4FS_DBG("no blocks in extent");
+
 		// Add first block to the extent
 
 		rc = ext4_balloc_alloc_block(inode_ref, &phys_block);
 		if (rc != EOK) {
+			EXT4FS_DBG("error in allocation");
 			goto finish;
 		}
@@ -588,4 +613,5 @@
 		ext4_extent_set_block_count(path_ptr->extent, 1);
 		ext4_extent_set_start(path_ptr->extent, phys_block);
+		ext4_extent_set_first_block(path_ptr->extent, new_block_idx);
 
 		path_ptr->block->dirty = true;
@@ -594,9 +620,33 @@
 
 	} else {
-		// try allocate scceeding extent block
-
+		// try allocate succeeding extent block
+
+		EXT4FS_DBG("existing extent");
+
+		uint16_t blocks = ext4_extent_get_block_count(path_ptr->extent);
+
+		if (blocks < (1 << 15)) {
+			// there is place for more blocks
+
+			EXT4FS_DBG("appending block to existing extent");
+
+			uint64_t last = ext4_extent_get_start(path_ptr->extent) + blocks - 1;
+
+			rc = ext4_balloc_try_alloc_block(inode_ref, last + 1);
+			if (rc == EOK) {
+				path_ptr->block->dirty = true;
+				ext4_extent_set_block_count(path_ptr->extent, blocks + 1);
+				phys_block = last + 1;
+				goto finish;
+			}
+
+			if (rc != EINVAL) {
+				goto finish;
+			}
+		}
+
+		// Add new extent
 		// TODO
 		assert(false);
-
 	}
 
Index: uspace/lib/ext4/libext4_filesystem.c
===================================================================
--- uspace/lib/ext4/libext4_filesystem.c	(revision 936132ff0b54d1b2bd6bd546cb86e46059b5eedf)
+++ uspace/lib/ext4/libext4_filesystem.c	(revision b73530a450b7d9935f07bbea318d1235e05f20f3)
@@ -578,9 +578,14 @@
 
 int ext4_filesystem_get_inode_data_block_index(ext4_inode_ref_t *inode_ref,
-		aoff64_t iblock, uint32_t* fblock)
+		aoff64_t iblock, uint32_t *fblock)
 {
 	int rc;
 
 	ext4_filesystem_t *fs = inode_ref->fs;
+
+	if (ext4_inode_get_size(fs->superblock, inode_ref->inode) == 0) {
+		*fblock = 0;
+		return EOK;
+	}
 
 	uint32_t current_block;
