Index: uspace/lib/ext4/Makefile
===================================================================
--- uspace/lib/ext4/Makefile	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/Makefile	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -36,4 +36,5 @@
 	libext4_bitmap.c \
 	libext4_block_group.c \
+	libext4_crc.c \
 	libext4_directory.c \
 	libext4_directory_index.c \
Index: uspace/lib/ext4/libext4.h
===================================================================
--- uspace/lib/ext4/libext4.h	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4.h	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -37,4 +37,5 @@
 #include "libext4_bitmap.h"
 #include "libext4_block_group.h"
+#include "libext4_crc.h"
 #include "libext4_directory.h"
 #include "libext4_directory_index.h"
Index: uspace/lib/ext4/libext4_balloc.c
===================================================================
--- uspace/lib/ext4/libext4_balloc.c	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_balloc.c	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -82,10 +82,13 @@
 
 
-int ext4_balloc_free_block(ext4_filesystem_t *fs, ext4_inode_ref_t *inode_ref, uint32_t block_addr)
+int ext4_balloc_free_block(ext4_inode_ref_t *inode_ref, uint32_t block_addr)
 {
 	int rc;
 
-	uint32_t block_group = ext4_balloc_get_bgid_of_block(fs->superblock, block_addr);
-	uint32_t index_in_group = ext4_balloc_blockaddr2_index_in_group(fs->superblock, block_addr);
+	ext4_filesystem_t *fs = inode_ref->fs;
+	ext4_superblock_t *sb = fs->superblock;
+
+	uint32_t block_group = ext4_balloc_get_bgid_of_block(sb, block_addr);
+	uint32_t index_in_group = ext4_balloc_blockaddr2_index_in_group(sb, block_addr);
 
 	ext4_block_group_ref_t *bg_ref;
@@ -97,5 +100,5 @@
 
 	uint32_t bitmap_block_addr = ext4_block_group_get_block_bitmap(
-			bg_ref->block_group, fs->superblock);
+			bg_ref->block_group, sb);
 	block_t *bitmap_block;
 	rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0);
@@ -116,23 +119,23 @@
 	}
 
-	uint32_t block_size = ext4_superblock_get_block_size(fs->superblock);
+	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(fs->superblock);
+	uint32_t sb_free_blocks = ext4_superblock_get_free_blocks_count(sb);
 	sb_free_blocks--;
-	ext4_superblock_set_free_blocks_count(fs->superblock, 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(fs->superblock, inode_ref->inode);
+	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(fs->superblock, inode_ref->inode, ino_blocks);
+	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, fs->superblock);
+			bg_ref->block_group, sb);
 	free_blocks++;
 	ext4_block_group_set_free_blocks_count(bg_ref->block_group,
-			fs->superblock, free_blocks);
+			sb, free_blocks);
 	bg_ref->dirty = true;
 
@@ -178,11 +181,13 @@
 
 
-static uint32_t ext4_balloc_find_goal(ext4_filesystem_t *fs, ext4_inode_ref_t *inode_ref)
+static uint32_t ext4_balloc_find_goal(ext4_inode_ref_t *inode_ref)
 {
 	int rc;
 	uint32_t goal = 0;
 
-	uint64_t inode_size = ext4_inode_get_size(fs->superblock, inode_ref->inode);
-	uint32_t block_size = ext4_superblock_get_block_size(fs->superblock);
+	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 inode_block_count = inode_size / block_size;
 
@@ -193,5 +198,5 @@
 	if (inode_block_count > 0) {
 		// TODO check retval
-		ext4_filesystem_get_inode_data_block_index(fs, inode_ref, inode_block_count - 1, &goal);
+		ext4_filesystem_get_inode_data_block_index(inode_ref, inode_block_count - 1, &goal);
 
 		// TODO
@@ -203,18 +208,18 @@
 
 	// Identify block group of inode
-	uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(fs->superblock);
+	uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb);
 	uint32_t block_group = (inode_ref->index - 1) / inodes_per_group;
-	block_size = ext4_superblock_get_block_size(fs->superblock);
+	block_size = ext4_superblock_get_block_size(sb);
 
 	ext4_block_group_ref_t *bg_ref;
-	rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref);
+	rc = ext4_filesystem_get_block_group_ref(inode_ref->fs, block_group, &bg_ref);
 	if (rc != EOK) {
 		return 0;
 	}
 
-	uint32_t block_group_count = ext4_superblock_get_block_group_count(fs->superblock);
+	uint32_t block_group_count = ext4_superblock_get_block_group_count(sb);
 	uint32_t inode_table_first_block = ext4_block_group_get_inode_table_first_block(
-			bg_ref->block_group, fs->superblock);
-	uint16_t inode_table_item_size = ext4_superblock_get_inode_size(fs->superblock);
+			bg_ref->block_group, sb);
+	uint16_t inode_table_item_size = ext4_superblock_get_inode_size(sb);
 	uint32_t inode_table_bytes;
 
@@ -223,5 +228,5 @@
 	} else {
 		// last block group could be smaller
-		uint32_t inodes_count_total = ext4_superblock_get_inodes_count(fs->superblock);
+		uint32_t inodes_count_total = ext4_superblock_get_inodes_count(sb);
 		inode_table_bytes =
 				(inodes_count_total - ((block_group_count - 1) * inodes_per_group))
@@ -242,5 +247,5 @@
 }
 
-int ext4_balloc_alloc_block(ext4_filesystem_t *fs,
+int ext4_balloc_alloc_block(
 		ext4_inode_ref_t *inode_ref, uint32_t *fblock)
 {
@@ -253,5 +258,5 @@
 
 	// Find GOAL
-	uint32_t goal = ext4_balloc_find_goal(fs, inode_ref);
+	uint32_t goal = ext4_balloc_find_goal(inode_ref);
 	if (goal == 0) {
 		// TODO
@@ -260,11 +265,13 @@
 	}
 
+	ext4_superblock_t *sb = inode_ref->fs->superblock;
+
 	// Load block group number for goal and relative index
-	uint32_t block_group = ext4_balloc_get_bgid_of_block(fs->superblock, goal);
-	uint32_t index_in_group = ext4_balloc_blockaddr2_index_in_group(fs->superblock, goal);
+	uint32_t block_group = ext4_balloc_get_bgid_of_block(sb, goal);
+	uint32_t index_in_group = ext4_balloc_blockaddr2_index_in_group(sb, goal);
 
 
 	ext4_block_group_ref_t *bg_ref;
-	rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref);
+	rc = ext4_filesystem_get_block_group_ref(inode_ref->fs, block_group, &bg_ref);
 	if (rc != EOK) {
 		EXT4FS_DBG("initial BG ref not loaded");
@@ -273,9 +280,9 @@
 
 	uint32_t first_in_group =
-			ext4_balloc_get_first_data_block_in_group(fs->superblock,
+			ext4_balloc_get_first_data_block_in_group(sb,
 					bg_ref->block_group, block_group);
 
 	uint32_t first_in_group_index = ext4_balloc_blockaddr2_index_in_group(
-			fs->superblock, first_in_group);
+			sb, first_in_group);
 
 	if (index_in_group < first_in_group_index) {
@@ -285,7 +292,7 @@
 	// Load bitmap
 	bitmap_block_addr = ext4_block_group_get_block_bitmap(bg_ref->block_group,
-			fs->superblock);
-
-	rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0);
+			sb);
+
+	rc = block_get(&bitmap_block, inode_ref->fs->device, bitmap_block_addr, 0);
 	if (rc != EOK) {
 		ext4_filesystem_put_block_group_ref(bg_ref);
@@ -311,5 +318,5 @@
 	}
 
-	uint32_t blocks_in_group = ext4_superblock_get_blocks_in_group(fs->superblock, block_group);
+	uint32_t blocks_in_group = ext4_superblock_get_blocks_in_group(sb, block_group);
 
 	uint32_t end_idx = (index_in_group + 63) & ~63;
@@ -331,5 +338,5 @@
 
 			allocated_block = ext4_balloc_index_in_group2blockaddr(
-					fs->superblock, tmp_idx, block_group);
+					sb, tmp_idx, block_group);
 
 			goto success;
@@ -349,5 +356,5 @@
 
 		allocated_block = ext4_balloc_index_in_group2blockaddr(
-				fs->superblock, rel_block_idx, block_group);
+				sb, rel_block_idx, block_group);
 
 		goto success;
@@ -365,5 +372,5 @@
 
 		allocated_block = ext4_balloc_index_in_group2blockaddr(
-				fs->superblock, rel_block_idx, block_group);
+				sb, rel_block_idx, block_group);
 
 		goto success;
@@ -375,5 +382,5 @@
 
 	// Try other block groups
-	uint32_t block_group_count = ext4_superblock_get_block_group_count(fs->superblock);
+	uint32_t block_group_count = ext4_superblock_get_block_group_count(sb);
 
 	uint32_t bgid = (block_group + 1) % block_group_count;
@@ -381,5 +388,5 @@
 
 	while (count > 0) {
-		rc = ext4_filesystem_get_block_group_ref(fs, bgid, &bg_ref);
+		rc = ext4_filesystem_get_block_group_ref(inode_ref->fs, bgid, &bg_ref);
 		if (rc != EOK) {
 			EXT4FS_DBG("errrrrrrrrrrr");
@@ -389,7 +396,7 @@
 		// Load bitmap
 		bitmap_block_addr = ext4_block_group_get_block_bitmap(
-				bg_ref->block_group, fs->superblock);
-
-		rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0);
+				bg_ref->block_group, sb);
+
+		rc = block_get(&bitmap_block, inode_ref->fs->device, bitmap_block_addr, 0);
 		if (rc != EOK) {
 			ext4_filesystem_put_block_group_ref(bg_ref);
@@ -399,11 +406,11 @@
 
 		first_in_group = ext4_balloc_get_first_data_block_in_group(
-				fs->superblock, bg_ref->block_group, bgid);
-		index_in_group = ext4_balloc_blockaddr2_index_in_group(fs->superblock,
+				sb, bg_ref->block_group, bgid);
+		index_in_group = ext4_balloc_blockaddr2_index_in_group(sb,
 						first_in_group);
-		blocks_in_group = ext4_superblock_get_blocks_in_group(fs->superblock, bgid);
+		blocks_in_group = ext4_superblock_get_blocks_in_group(sb, bgid);
 
 		first_in_group_index = ext4_balloc_blockaddr2_index_in_group(
-			fs->superblock, first_in_group);
+			sb, first_in_group);
 
 		if (index_in_group < first_in_group_index) {
@@ -422,5 +429,5 @@
 
 			allocated_block = ext4_balloc_index_in_group2blockaddr(
-					fs->superblock, rel_block_idx, bgid);
+					sb, rel_block_idx, bgid);
 
 			goto success;
@@ -438,5 +445,5 @@
 
 			allocated_block = ext4_balloc_index_in_group2blockaddr(
-					fs->superblock, rel_block_idx, bgid);
+					sb, rel_block_idx, bgid);
 
 			goto success;
@@ -456,24 +463,23 @@
 	; 	// Empty command - because of syntax
 	
-	uint32_t block_size = ext4_superblock_get_block_size(fs->superblock);
+	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(fs->superblock);
+	uint32_t sb_free_blocks = ext4_superblock_get_free_blocks_count(sb);
 	sb_free_blocks--;
-	ext4_superblock_set_free_blocks_count(fs->superblock, sb_free_blocks);
+	ext4_superblock_set_free_blocks_count(sb, sb_free_blocks);
 
 	// Update inode blocks (different block size!) count
 
-	uint64_t ino_blocks = ext4_inode_get_blocks_count(fs->superblock, inode_ref->inode);
+	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(fs->superblock, inode_ref->inode, ino_blocks);
+	ext4_inode_set_blocks_count(sb, inode_ref->inode, ino_blocks);
 	inode_ref->dirty = true;
 
 	// Update block group free blocks count
 	uint32_t bg_free_blocks = ext4_block_group_get_free_blocks_count(
-			bg_ref->block_group, fs->superblock);
+			bg_ref->block_group, sb);
 	bg_free_blocks--;
-	ext4_block_group_set_free_blocks_count(bg_ref->block_group,
-			fs->superblock, bg_free_blocks);
+	ext4_block_group_set_free_blocks_count(bg_ref->block_group, sb, bg_free_blocks);
 	bg_ref->dirty = true;
 
Index: uspace/lib/ext4/libext4_balloc.h
===================================================================
--- uspace/lib/ext4/libext4_balloc.h	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_balloc.h	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -37,8 +37,6 @@
 #include "libext4_types.h"
 
-extern int ext4_balloc_free_block(ext4_filesystem_t *,
-		ext4_inode_ref_t *, uint32_t);
-extern int ext4_balloc_alloc_block(ext4_filesystem_t *,
-		ext4_inode_ref_t *, uint32_t *);
+extern int ext4_balloc_free_block(ext4_inode_ref_t *, uint32_t);
+extern int ext4_balloc_alloc_block(ext4_inode_ref_t *, uint32_t *);
 
 #endif
Index: uspace/lib/ext4/libext4_crc.c
===================================================================
--- uspace/lib/ext4/libext4_crc.c	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
+++ uspace/lib/ext4/libext4_crc.c	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libext4
+ * @{
+ */ 
+
+/**
+ * @file	libext4_crc.c
+ * @brief	CRC checksumming implementation from Linux.
+ */
+
+#include <byteorder.h>
+#include "libext4.h"
+
+/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
+uint16_t const crc16_table[256] = {
+		0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
+		0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
+		0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
+		0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
+		0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
+		0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
+		0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
+		0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
+		0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
+		0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
+		0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
+		0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
+		0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
+		0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
+		0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
+		0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
+		0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
+		0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
+		0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
+		0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
+		0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
+		0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
+		0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
+		0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
+		0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
+		0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
+		0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
+		0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
+		0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
+		0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
+		0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
+		0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
+};
+
+static inline uint16_t crc16_byte(uint16_t crc, const uint8_t data)
+{
+	return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
+}
+
+/**
+ * crc16 - compute the CRC-16 for the data buffer
+ * @crc:        previous CRC value
+ * @buffer:     data pointer
+ * @len:        number of bytes in the buffer
+ *
+ * Returns the updated CRC value.
+ */
+uint16_t crc16(uint16_t crc, const uint8_t *buffer, size_t len)
+{
+		while (len--) {
+			crc = crc16_byte(crc, *buffer++);
+		}
+		return crc;
+}
+
+
+/**
+ * @}
+ */ 
Index: uspace/lib/ext4/libext4_crc.h
===================================================================
--- uspace/lib/ext4/libext4_crc.h	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
+++ uspace/lib/ext4/libext4_crc.h	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libext4
+ * @{
+ */ 
+
+#ifndef LIBEXT4_LIBEXT4_CRC_H_
+#define LIBEXT4_LIBEXT4_CRC_H_
+
+extern uint16_t crc16(uint16_t, const uint8_t *, size_t);
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/ext4/libext4_directory.c
===================================================================
--- uspace/lib/ext4/libext4_directory.c	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_directory.c	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -186,6 +186,6 @@
 
 		uint32_t next_block_phys_idx;
-		rc = ext4_filesystem_get_inode_data_block_index(it->fs,
-		    it->inode_ref, next_block_idx, &next_block_phys_idx);
+		rc = ext4_filesystem_get_inode_data_block_index(it->inode_ref,
+				next_block_idx, &next_block_phys_idx);
 		if (rc != EOK) {
 			return rc;
@@ -260,12 +260,14 @@
 }
 
-int ext4_directory_append_block(ext4_filesystem_t *fs,
-		ext4_inode_ref_t *inode_ref, uint32_t *fblock, uint32_t *iblock)
+int ext4_directory_append_block(ext4_inode_ref_t *inode_ref,
+		uint32_t *fblock, uint32_t *iblock)
 {
 	int rc;
 
+	ext4_superblock_t *sb = inode_ref->fs->superblock;
+
 	// Compute next block index and allocate data block
-	uint64_t inode_size = ext4_inode_get_size(fs->superblock, inode_ref->inode);
-	uint32_t block_size = ext4_superblock_get_block_size(fs->superblock);
+	uint64_t inode_size = ext4_inode_get_size(sb, inode_ref->inode);
+	uint32_t block_size = ext4_superblock_get_block_size(sb);
 
 	assert(inode_size % block_size == 0);
@@ -275,12 +277,12 @@
 
 	uint32_t phys_block;
-	rc =  ext4_balloc_alloc_block(fs, inode_ref, &phys_block);
+	rc =  ext4_balloc_alloc_block(inode_ref, &phys_block);
 	if (rc != EOK) {
 		return rc;
 	}
 
-	rc = ext4_filesystem_set_inode_data_block_index(fs, inode_ref, new_block_idx, phys_block);
+	rc = ext4_filesystem_set_inode_data_block_index(inode_ref, new_block_idx, phys_block);
 	if (rc != EOK) {
-		ext4_balloc_free_block(fs, inode_ref, phys_block);
+		ext4_balloc_free_block(inode_ref, phys_block);
 		return rc;
 	}
@@ -313,5 +315,5 @@
 }
 
-int ext4_directory_add_entry(ext4_filesystem_t *fs, ext4_inode_ref_t * parent,
+int ext4_directory_add_entry(ext4_inode_ref_t * parent,
 		const char *name, ext4_inode_ref_t *child)
 {
@@ -319,4 +321,6 @@
 
 	EXT4FS_DBG("adding entry to directory \%u [ino = \%u, name = \%s]", parent->index, child->index, name);
+
+	ext4_filesystem_t *fs = parent->fs;
 
 	// Index adding (if allowed)
@@ -324,5 +328,5 @@
 			ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX)) {
 
-		rc = ext4_directory_dx_add_entry(fs, parent, child, name);
+		rc = ext4_directory_dx_add_entry(parent, child, name);
 
 		// Check if index is not corrupted
@@ -356,5 +360,5 @@
 	for (iblock = 0; iblock < total_blocks; ++iblock) {
 
-		rc = ext4_filesystem_get_inode_data_block_index(fs, parent, iblock, &fblock);
+		rc = ext4_filesystem_get_inode_data_block_index(parent, iblock, &fblock);
 		if (rc != EOK) {
 			return rc;
@@ -384,5 +388,5 @@
 	// No free block found - needed to allocate next block
 
-	rc = ext4_directory_append_block(fs, parent, &fblock, &iblock);
+	rc = ext4_directory_append_block(parent, &fblock, &iblock);
 	if (rc != EOK) {
 		return rc;
@@ -411,16 +415,17 @@
 }
 
-int ext4_directory_find_entry(ext4_filesystem_t *fs,
-		ext4_directory_search_result_t *result, ext4_inode_ref_t *parent,
-		const char *name)
+int ext4_directory_find_entry(ext4_directory_search_result_t *result,
+		ext4_inode_ref_t *parent, const char *name)
 {
 	int rc;
 	uint32_t name_len = strlen(name);
 
+	ext4_superblock_t *sb = parent->fs->superblock;
+
 	// Index search
-	if (ext4_superblock_has_feature_compatible(fs->superblock, EXT4_FEATURE_COMPAT_DIR_INDEX) &&
+	if (ext4_superblock_has_feature_compatible(sb, EXT4_FEATURE_COMPAT_DIR_INDEX) &&
 			ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX)) {
 
-		rc = ext4_directory_dx_find_entry(result, fs, parent, name_len, name);
+		rc = ext4_directory_dx_find_entry(result, parent, name_len, name);
 
 		// Check if index is not corrupted
@@ -437,11 +442,11 @@
 
 	uint32_t iblock, fblock;
-	uint32_t block_size = ext4_superblock_get_block_size(fs->superblock);
-	uint32_t inode_size = ext4_inode_get_size(fs->superblock, parent->inode);
+	uint32_t block_size = ext4_superblock_get_block_size(sb);
+	uint32_t inode_size = ext4_inode_get_size(sb, parent->inode);
 	uint32_t total_blocks = inode_size / block_size;
 
 	for (iblock = 0; iblock < total_blocks; ++iblock) {
 
-		rc = ext4_filesystem_get_inode_data_block_index(fs, parent, iblock, &fblock);
+		rc = ext4_filesystem_get_inode_data_block_index(parent, iblock, &fblock);
 		if (rc != EOK) {
 			return rc;
@@ -449,5 +454,5 @@
 
 		block_t *block;
-		rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);
+		rc = block_get(&block, parent->fs->device, fblock, BLOCK_FLAGS_NONE);
 		if (rc != EOK) {
 			return rc;
@@ -456,5 +461,5 @@
 		// find block entry
 		ext4_directory_entry_ll_t *res_entry;
-		rc = ext4_directory_find_in_block(block, fs->superblock, name_len, name, &res_entry);
+		rc = ext4_directory_find_in_block(block, sb, name_len, name, &res_entry);
 		if (rc == EOK) {
 			result->block = block;
@@ -476,10 +481,9 @@
 
 
-int ext4_directory_remove_entry(ext4_filesystem_t* fs,
-		ext4_inode_ref_t *parent, const char *name)
+int ext4_directory_remove_entry(ext4_inode_ref_t *parent, const char *name)
 {
 	int rc;
 
-	if (!ext4_inode_is_type(fs->superblock, parent->inode,
+	if (!ext4_inode_is_type(parent->fs->superblock, parent->inode,
 	    EXT4_INODE_MODE_DIRECTORY)) {
 		return ENOTDIR;
@@ -487,5 +491,5 @@
 
 	ext4_directory_search_result_t result;
-	rc  = ext4_directory_find_entry(fs, &result, parent, name);
+	rc  = ext4_directory_find_entry(&result, parent, name);
 	if (rc != EOK) {
 		return rc;
Index: uspace/lib/ext4/libext4_directory.h
===================================================================
--- uspace/lib/ext4/libext4_directory.h	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_directory.h	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -58,16 +58,15 @@
 extern int ext4_directory_iterator_fini(ext4_directory_iterator_t *);
 
-extern int ext4_directory_append_block(ext4_filesystem_t *,
-		ext4_inode_ref_t *, uint32_t *, uint32_t *);
+extern int ext4_directory_append_block(ext4_inode_ref_t *,
+		uint32_t *, uint32_t *);
 
 extern void ext4_directory_write_entry(ext4_superblock_t *,
 		ext4_directory_entry_ll_t *, uint16_t, ext4_inode_ref_t *,
 		const char *, size_t);
-extern int ext4_directory_add_entry(ext4_filesystem_t *, ext4_inode_ref_t *,
+extern int ext4_directory_add_entry(ext4_inode_ref_t *,
 		const char *, ext4_inode_ref_t *);
-extern int ext4_directory_find_entry(ext4_filesystem_t *,
-		ext4_directory_search_result_t *, ext4_inode_ref_t *, const char *);
-extern int ext4_directory_remove_entry(ext4_filesystem_t* ,
+extern int ext4_directory_find_entry(ext4_directory_search_result_t *,
 		ext4_inode_ref_t *, const char *);
+extern int ext4_directory_remove_entry(ext4_inode_ref_t *, const char *);
 
 extern int ext4_directory_try_insert_entry(ext4_superblock_t *,
Index: uspace/lib/ext4/libext4_directory_index.c
===================================================================
--- uspace/lib/ext4/libext4_directory_index.c	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_directory_index.c	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -189,5 +189,5 @@
 
 static int ext4_directory_dx_get_leaf(ext4_hash_info_t *hinfo,
-		ext4_filesystem_t *fs, ext4_inode_ref_t *inode_ref, block_t *root_block,
+		ext4_inode_ref_t *inode_ref, block_t *root_block,
 		ext4_directory_dx_block_t **dx_block, ext4_directory_dx_block_t *dx_blocks)
 {
@@ -239,10 +239,11 @@
 
         uint32_t fblock;
-        rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref, next_block, &fblock);
+        rc = ext4_filesystem_get_inode_data_block_index(
+        		inode_ref, next_block, &fblock);
         if (rc != EOK) {
         	return rc;
         }
 
-        rc = block_get(&tmp_block, fs->device, fblock, BLOCK_FLAGS_NONE);
+        rc = block_get(&tmp_block, inode_ref->fs->device, fblock, BLOCK_FLAGS_NONE);
         if (rc != EOK) {
         	return rc;
@@ -250,7 +251,8 @@
 
 		entries = ((ext4_directory_dx_node_t *) tmp_block->data)->entries;
-		limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)entries);
-
-        uint16_t entry_space = ext4_superblock_get_block_size(fs->superblock)
+		limit = ext4_directory_dx_countlimit_get_limit(
+				(ext4_directory_dx_countlimit_t *)entries);
+
+        uint16_t entry_space = ext4_superblock_get_block_size(inode_ref->fs->superblock)
         		- sizeof(ext4_directory_dx_dot_entry_t);
         entry_space = entry_space / sizeof(ext4_directory_dx_entry_t);
@@ -270,6 +272,5 @@
 
 
-static int ext4_directory_dx_next_block(ext4_filesystem_t *fs,
-		ext4_inode_ref_t *inode_ref, uint32_t hash,
+static int ext4_directory_dx_next_block(ext4_inode_ref_t *inode_ref, uint32_t hash,
 		ext4_directory_dx_block_t *handle, ext4_directory_dx_block_t *handles)
 {
@@ -310,5 +311,5 @@
     	uint32_t block_idx = ext4_directory_dx_entry_get_block(p->position);
     	uint32_t block_addr;
-    	rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref, block_idx, &block_addr);
+    	rc = ext4_filesystem_get_inode_data_block_index(inode_ref, block_idx, &block_addr);
     	if (rc != EOK) {
     		return rc;
@@ -316,5 +317,5 @@
 
     	block_t *block;
-    	rc = block_get(&block, fs->device, block_addr, BLOCK_FLAGS_NONE);
+    	rc = block_get(&block, inode_ref->fs->device, block_addr, BLOCK_FLAGS_NONE);
     	if (rc != EOK) {
     		return rc;
@@ -334,5 +335,5 @@
 
 int ext4_directory_dx_find_entry(ext4_directory_search_result_t *result,
-		ext4_filesystem_t *fs, ext4_inode_ref_t *inode_ref, size_t name_len, const char *name)
+		ext4_inode_ref_t *inode_ref, size_t name_len, const char *name)
 {
 	int rc;
@@ -340,8 +341,10 @@
 	// get direct block 0 (index root)
 	uint32_t root_block_addr;
-	rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref, 0, &root_block_addr);
+	rc = ext4_filesystem_get_inode_data_block_index(inode_ref, 0, &root_block_addr);
 	if (rc != EOK) {
 		return rc;
 	}
+
+	ext4_filesystem_t *fs = inode_ref->fs;
 
 	block_t *root_block;
@@ -361,5 +364,5 @@
 	ext4_directory_dx_block_t dx_blocks[2];
 	ext4_directory_dx_block_t *dx_block, *tmp;
-	rc = ext4_directory_dx_get_leaf(&hinfo, fs, inode_ref, root_block, &dx_block, dx_blocks);
+	rc = ext4_directory_dx_get_leaf(&hinfo, inode_ref, root_block, &dx_block, dx_blocks);
 	if (rc != EOK) {
 		block_put(root_block);
@@ -372,5 +375,5 @@
 		uint32_t leaf_block_idx = ext4_directory_dx_entry_get_block(dx_block->position);
 		uint32_t leaf_block_addr;
-    	rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref, leaf_block_idx, &leaf_block_addr);
+    	rc = ext4_filesystem_get_inode_data_block_index(inode_ref, leaf_block_idx, &leaf_block_addr);
     	if (rc != EOK) {
     		goto cleanup;
@@ -400,5 +403,5 @@
 		}
 
-		rc = ext4_directory_dx_next_block(fs, inode_ref, hinfo.hash, dx_block, &dx_blocks[0]);
+		rc = ext4_directory_dx_next_block(inode_ref, hinfo.hash, dx_block, &dx_blocks[0]);
 		if (rc < 0) {
 			goto cleanup;
@@ -524,5 +527,5 @@
 	uint32_t new_fblock;
 	uint32_t new_iblock;
-	rc = ext4_directory_append_block(fs, inode_ref, &new_fblock, &new_iblock);
+	rc = ext4_directory_append_block(inode_ref, &new_fblock, &new_iblock);
 	if (rc != EOK) {
 		free(sort_array);
@@ -648,5 +651,5 @@
 		uint32_t new_fblock;
 		uint32_t new_iblock;
-		rc =  ext4_directory_append_block(fs, inode_ref, &new_fblock, &new_iblock);
+		rc =  ext4_directory_append_block(inode_ref, &new_fblock, &new_iblock);
 		if (rc != EOK) {
 			return rc;
@@ -740,6 +743,6 @@
 }
 
-int ext4_directory_dx_add_entry(ext4_filesystem_t *fs,
-		ext4_inode_ref_t *parent, ext4_inode_ref_t *child, const char *name)
+int ext4_directory_dx_add_entry(ext4_inode_ref_t *parent,
+		ext4_inode_ref_t *child, const char *name)
 {
 	int rc = EOK;
@@ -748,8 +751,10 @@
 	// get direct block 0 (index root)
 	uint32_t root_block_addr;
-	rc = ext4_filesystem_get_inode_data_block_index(fs, parent, 0, &root_block_addr);
+	rc = ext4_filesystem_get_inode_data_block_index(parent, 0, &root_block_addr);
 	if (rc != EOK) {
 		return rc;
 	}
+
+	ext4_filesystem_t *fs = parent->fs;
 
 	block_t *root_block;
@@ -770,5 +775,5 @@
 	ext4_directory_dx_block_t dx_blocks[2];
 	ext4_directory_dx_block_t *dx_block, *dx_it;
-	rc = ext4_directory_dx_get_leaf(&hinfo, fs, parent, root_block, &dx_block, dx_blocks);
+	rc = ext4_directory_dx_get_leaf(&hinfo, parent, root_block, &dx_block, dx_blocks);
 	if (rc != EOK) {
 		rc = EXT4_ERR_BAD_DX_DIR;
@@ -780,5 +785,5 @@
 	uint32_t leaf_block_idx = ext4_directory_dx_entry_get_block(dx_block->position);
 	uint32_t leaf_block_addr;
-   	rc = ext4_filesystem_get_inode_data_block_index(fs, parent, leaf_block_idx, &leaf_block_addr);
+   	rc = ext4_filesystem_get_inode_data_block_index(parent, leaf_block_idx, &leaf_block_addr);
    	if (rc != EOK) {
    		goto release_index;
Index: uspace/lib/ext4/libext4_directory_index.h
===================================================================
--- uspace/lib/ext4/libext4_directory_index.h	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_directory_index.h	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -67,6 +67,6 @@
 
 extern int ext4_directory_dx_find_entry(ext4_directory_search_result_t *,
-		ext4_filesystem_t *, ext4_inode_ref_t *, size_t, const char *);
-extern int ext4_directory_dx_add_entry(ext4_filesystem_t *,
+		ext4_inode_ref_t *, size_t, const char *);
+extern int ext4_directory_dx_add_entry(
 		ext4_inode_ref_t *, ext4_inode_ref_t *, const char *);
 
Index: uspace/lib/ext4/libext4_extent.c
===================================================================
--- uspace/lib/ext4/libext4_extent.c	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_extent.c	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -218,117 +218,35 @@
 }
 
-// Reading routine without saving blocks to path
-//static int ext4_extent_find_extent(ext4_filesystem_t *fs,
-//		ext4_inode_ref_t *inode_ref, uint32_t iblock, ext4_extent_t *extent)
-//{
-//	int rc;
-//
-//	block_t* block = NULL;
-//
-//	ext4_extent_header_t *header = ext4_inode_get_extent_header(inode_ref->inode);
-//	while (ext4_extent_header_get_depth(header) != 0) {
-//
-//		ext4_extent_index_t *index;
-//		ext4_extent_binsearch_idx(header, &index, iblock);
-//
-//		uint64_t child = ext4_extent_index_get_leaf(index);
-//
-//		if (block != NULL) {
-//			block_put(block);
-//		}
-//
-//		rc = block_get(&block, fs->device, child, BLOCK_FLAGS_NONE);
-//		if (rc != EOK) {
-//			return rc;
-//		}
-//
-//		header = (ext4_extent_header_t *)block->data;
-//	}
-//
-//
-//	ext4_extent_t* tmp_extent;
-//	ext4_extent_binsearch(header, &tmp_extent, iblock);
-//
-//	memcpy(extent, tmp_extent, sizeof(ext4_extent_t));
-//
-//	return EOK;
-//}
-
-static int ext4_extent_find_extent(ext4_filesystem_t *fs,
-		ext4_inode_ref_t *inode_ref, uint32_t iblock, ext4_extent_path_t **ret_path)
+// Reading routine without saving blocks to path - for saving memory during finding block
+int ext4_extent_find_block(ext4_inode_ref_t *inode_ref, uint32_t iblock, uint32_t *fblock)
 {
 	int rc;
 
-	ext4_extent_header_t *eh =
-			ext4_inode_get_extent_header(inode_ref->inode);
-
-	uint16_t depth = ext4_extent_header_get_depth(eh);
-
-	ext4_extent_path_t *tmp_path;
-
-	// Added 2 for possible tree growing
-	tmp_path = malloc(sizeof(ext4_extent_path_t) * (depth + 2));
-	if (tmp_path == NULL) {
-		return ENOMEM;
-	}
-
-	tmp_path[0].block = inode_ref->block;
-	tmp_path[0].header = eh;
-
-	uint16_t pos = 0;
-	while (ext4_extent_header_get_depth(eh) != 0) {
-
-		ext4_extent_binsearch_idx(tmp_path[pos].header, &tmp_path[pos].index, iblock);
-
-		tmp_path[pos].depth = depth;
-		tmp_path[pos].extent = NULL;
-
-		assert(tmp_path[pos].index != NULL);
-
-		uint64_t fblock = ext4_extent_index_get_leaf(tmp_path[pos].index);
-
-		block_t *block;
-		rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);
+	block_t* block = NULL;
+
+	ext4_extent_header_t *header = ext4_inode_get_extent_header(inode_ref->inode);
+	while (ext4_extent_header_get_depth(header) != 0) {
+
+		ext4_extent_index_t *index;
+		ext4_extent_binsearch_idx(header, &index, iblock);
+
+		uint64_t child = ext4_extent_index_get_leaf(index);
+
+		if (block != NULL) {
+			block_put(block);
+		}
+
+		rc = block_get(&block, inode_ref->fs->device, child, BLOCK_FLAGS_NONE);
 		if (rc != EOK) {
-			// TODO cleanup
-			EXT4FS_DBG("ERRRR");
 			return rc;
 		}
 
-		pos++;
-
-		eh = (ext4_extent_header_t *)block->data;
-		tmp_path[pos].block = block;
-		tmp_path[pos].header = eh;
-
-	}
-
-	tmp_path[pos].depth = 0;
-	tmp_path[pos].extent = NULL;
-	tmp_path[pos].index = NULL;
-
-    /* find extent */
-	ext4_extent_binsearch(tmp_path[pos].header, &tmp_path[pos].extent, iblock);
-
-	*ret_path = tmp_path;
-
-	return EOK;
-}
-
-
-int ext4_extent_find_block(ext4_filesystem_t *fs,
-		ext4_inode_ref_t *inode_ref, uint32_t iblock, uint32_t *fblock)
-{
-	int rc;
-
-	ext4_extent_path_t *path;
-	rc = ext4_extent_find_extent(fs, inode_ref, iblock, &path);
-	if (rc != EOK) {
-		return rc;
-	}
-
-	uint16_t depth = path->depth;
-
-	ext4_extent_t *extent = path[depth].extent;
+		header = (ext4_extent_header_t *)block->data;
+	}
+
+
+	ext4_extent_t* extent;
+	ext4_extent_binsearch(header, &extent, iblock);
+
 
 	uint32_t phys_block;
@@ -338,18 +256,109 @@
 	*fblock = phys_block;
 
-	// Put loaded blocks
-	// From 1 -> 0 is a block with inode data
-	for (uint16_t i = 1; i < depth; ++i) {
-		if (path[i].block) {
-			block_put(path[i].block);
-		}
-	}
-
-	// Destroy temporary data structure
-	free(path);
+	if (block != NULL) {
+		block_put(block);
+	}
+
 
 	return EOK;
-
-}
+}
+
+//static int ext4_extent_find_extent(ext4_filesystem_t *fs,
+//		ext4_inode_ref_t *inode_ref, uint32_t iblock, ext4_extent_path_t **ret_path)
+//{
+//	int rc;
+//
+//	ext4_extent_header_t *eh =
+//			ext4_inode_get_extent_header(inode_ref->inode);
+//
+//	uint16_t depth = ext4_extent_header_get_depth(eh);
+//
+//	ext4_extent_path_t *tmp_path;
+//
+//	// Added 2 for possible tree growing
+//	tmp_path = malloc(sizeof(ext4_extent_path_t) * (depth + 2));
+//	if (tmp_path == NULL) {
+//		return ENOMEM;
+//	}
+//
+//	tmp_path[0].block = inode_ref->block;
+//	tmp_path[0].header = eh;
+//
+//	uint16_t pos = 0;
+//	while (ext4_extent_header_get_depth(eh) != 0) {
+//
+//		ext4_extent_binsearch_idx(tmp_path[pos].header, &tmp_path[pos].index, iblock);
+//
+//		tmp_path[pos].depth = depth;
+//		tmp_path[pos].extent = NULL;
+//
+//		assert(tmp_path[pos].index != NULL);
+//
+//		uint64_t fblock = ext4_extent_index_get_leaf(tmp_path[pos].index);
+//
+//		block_t *block;
+//		rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);
+//		if (rc != EOK) {
+//			// TODO cleanup
+//			EXT4FS_DBG("ERRRR");
+//			return rc;
+//		}
+//
+//		pos++;
+//
+//		eh = (ext4_extent_header_t *)block->data;
+//		tmp_path[pos].block = block;
+//		tmp_path[pos].header = eh;
+//
+//	}
+//
+//	tmp_path[pos].depth = 0;
+//	tmp_path[pos].extent = NULL;
+//	tmp_path[pos].index = NULL;
+//
+//    /* find extent */
+//	ext4_extent_binsearch(tmp_path[pos].header, &tmp_path[pos].extent, iblock);
+//
+//	*ret_path = tmp_path;
+//
+//	return EOK;
+//}
+
+
+//int ext4_extent_find_block(ext4_filesystem_t *fs,
+//		ext4_inode_ref_t *inode_ref, uint32_t iblock, uint32_t *fblock)
+//{
+//	int rc;
+//
+//	ext4_extent_path_t *path;
+//	rc = ext4_extent_find_extent(fs, inode_ref, iblock, &path);
+//	if (rc != EOK) {
+//		return rc;
+//	}
+//
+//	uint16_t depth = path->depth;
+//
+//	ext4_extent_t *extent = path[depth].extent;
+//
+//	uint32_t phys_block;
+//	phys_block = ext4_extent_get_start(extent) + iblock;
+//	phys_block -= ext4_extent_get_first_block(extent);
+//
+//	*fblock = phys_block;
+//
+//	// Put loaded blocks
+//	// From 1 -> 0 is a block with inode data
+//	for (uint16_t i = 1; i < depth; ++i) {
+//		if (path[i].block) {
+//			block_put(path[i].block);
+//		}
+//	}
+//
+//	// Destroy temporary data structure
+//	free(path);
+//
+//	return EOK;
+//
+//}
 
 /**
Index: uspace/lib/ext4/libext4_extent.h
===================================================================
--- uspace/lib/ext4/libext4_extent.h	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_extent.h	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -61,6 +61,5 @@
 extern void ext4_extent_header_set_generation(ext4_extent_header_t *, uint32_t);
 
-extern int ext4_extent_find_block(ext4_filesystem_t *, ext4_inode_ref_t *,
-		uint32_t, uint32_t *);
+extern int ext4_extent_find_block(ext4_inode_ref_t *, uint32_t, uint32_t *);
 #endif
 
Index: uspace/lib/ext4/libext4_filesystem.c
===================================================================
--- uspace/lib/ext4/libext4_filesystem.c	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_filesystem.c	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -169,4 +169,6 @@
 
 	newref->block_group = newref->block->data + offset;
+	newref->fs = fs;
+	newref->index = bgid;
 	newref->dirty = false;
 
@@ -176,4 +178,37 @@
 }
 
+static uint16_t ext4_filesystem_bg_checksum(ext4_superblock_t *sb, uint32_t bgid,
+                            ext4_block_group_t *bg)
+{
+	uint16_t crc = 0;
+
+	if (ext4_superblock_has_feature_read_only(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
+
+		void *base = bg;
+		void *checksum = &bg->checksum;
+
+		uint32_t offset = (uint32_t)(checksum - base);
+
+		uint32_t le_group = host2uint32_t_le(bgid);
+
+		crc = crc16(~0, sb->uuid, sizeof(sb->uuid));
+		crc = crc16(crc, (uint8_t *)&le_group, sizeof(le_group));
+		crc = crc16(crc, (uint8_t *)bg, offset);
+
+		offset += sizeof(bg->checksum); /* skip checksum */
+
+		/* for checksum of struct ext4_group_desc do the rest...*/
+		if ((ext4_superblock_has_feature_incompatible(sb, EXT4_FEATURE_INCOMPAT_64BIT)) &&
+			offset < ext4_superblock_get_desc_size(sb)) {
+
+			crc = crc16(crc, ((uint8_t *)bg) + offset, ext4_superblock_get_desc_size(sb) - offset);
+		}
+	}
+
+	return crc;
+
+}
+
+
 int ext4_filesystem_put_block_group_ref(ext4_block_group_ref_t *ref)
 {
@@ -181,4 +216,9 @@
 
 	if (ref->dirty) {
+		 uint16_t checksum = ext4_filesystem_bg_checksum(
+				ref->fs->superblock, ref->index, ref->block_group);
+
+		 ext4_block_group_set_checksum(ref->block_group, checksum);
+
 		ref->block->dirty = true;
 	}
@@ -242,5 +282,6 @@
 	 * in the reference
 	 */
-	newref->index = index+1;
+	newref->index = index + 1;
+	newref->fs = fs;
 	newref->dirty = false;
 
@@ -321,5 +362,5 @@
 }
 
-int ext4_filesystem_free_inode(ext4_filesystem_t *fs, ext4_inode_ref_t *inode_ref)
+int ext4_filesystem_free_inode(ext4_inode_ref_t *inode_ref)
 {
 	int rc;
@@ -330,5 +371,5 @@
 	uint32_t fblock = ext4_inode_get_indirect_block(inode_ref->inode, 0);
 	if (fblock != 0) {
-		rc = ext4_balloc_free_block(fs, inode_ref, fblock);
+		rc = ext4_balloc_free_block(inode_ref, fblock);
 		if (rc != EOK) {
 			return rc;
@@ -337,4 +378,6 @@
 		ext4_inode_set_indirect_block(inode_ref->inode, 0, 0);
 	}
+
+	ext4_filesystem_t *fs = inode_ref->fs;
 
 	block_t *block;
@@ -355,5 +398,5 @@
 
 			if (ind_block != 0) {
-				rc = ext4_balloc_free_block(fs, inode_ref, ind_block);
+				rc = ext4_balloc_free_block(inode_ref, ind_block);
 				if (rc != EOK) {
 					block_put(block);
@@ -364,5 +407,5 @@
 
 		block_put(block);
-		rc = ext4_balloc_free_block(fs, inode_ref, fblock);
+		rc = ext4_balloc_free_block(inode_ref, fblock);
 		if (rc != EOK) {
 			return rc;
@@ -398,5 +441,5 @@
 
 					if (ind_subblock != 0) {
-						rc = ext4_balloc_free_block(fs, inode_ref, ind_subblock);
+						rc = ext4_balloc_free_block(inode_ref, ind_subblock);
 						if (rc != EOK) {
 							block_put(subblock);
@@ -411,5 +454,5 @@
 			}
 
-			rc = ext4_balloc_free_block(fs, inode_ref, ind_block);
+			rc = ext4_balloc_free_block(inode_ref, ind_block);
 			if (rc != EOK) {
 				block_put(block);
@@ -421,5 +464,5 @@
 
 		block_put(block);
-		rc = ext4_balloc_free_block(fs, inode_ref, fblock);
+		rc = ext4_balloc_free_block(inode_ref, fblock);
 		if (rc != EOK) {
 			return rc;
@@ -445,15 +488,17 @@
 }
 
-int ext4_filesystem_truncate_inode(ext4_filesystem_t *fs,
+int ext4_filesystem_truncate_inode(
 		ext4_inode_ref_t *inode_ref, aoff64_t new_size)
 {
 	int rc;
 
-	if (! ext4_inode_can_truncate(fs->superblock, inode_ref->inode)) {
+	ext4_superblock_t *sb = inode_ref->fs->superblock;
+
+	if (! ext4_inode_can_truncate(sb, inode_ref->inode)) {
 		// Unable to truncate
 		return EINVAL;
 	}
 
-	aoff64_t old_size = ext4_inode_get_size(fs->superblock, inode_ref->inode);
+	aoff64_t old_size = ext4_inode_get_size(sb, inode_ref->inode);
 	if (old_size == new_size) {
 		// Nothing to do
@@ -467,5 +512,5 @@
 
 	aoff64_t size_diff = old_size - new_size;
-	uint32_t block_size  = ext4_superblock_get_block_size(fs->superblock);
+	uint32_t block_size  = ext4_superblock_get_block_size(sb);
 	uint32_t diff_blocks_count = size_diff / block_size;
 	if (size_diff % block_size != 0) {
@@ -480,5 +525,5 @@
 	// starting from 1 because of logical blocks are numbered from 0
 	for (uint32_t i = 1; i <= diff_blocks_count; ++i) {
-		rc = ext4_filesystem_release_inode_block(fs, inode_ref, old_blocks_count - i);
+		rc = ext4_filesystem_release_inode_block(inode_ref, old_blocks_count - i);
 		if (rc != EOK) {
 			return rc;
@@ -493,9 +538,10 @@
 }
 
-int ext4_filesystem_get_inode_data_block_index(ext4_filesystem_t *fs,
-		ext4_inode_ref_t *inode_ref, aoff64_t iblock, uint32_t* fblock)
-{
-	int rc;
-
+int ext4_filesystem_get_inode_data_block_index(ext4_inode_ref_t *inode_ref,
+		aoff64_t iblock, uint32_t* fblock)
+{
+	int rc;
+
+	ext4_filesystem_t *fs = inode_ref->fs;
 
 	uint32_t current_block;
@@ -504,5 +550,5 @@
 	if (ext4_superblock_has_feature_incompatible(fs->superblock, EXT4_FEATURE_INCOMPAT_EXTENTS) &&
 			ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS)) {
-		rc = ext4_extent_find_block(fs, inode_ref, iblock, &current_block);
+		rc = ext4_extent_find_block(inode_ref, iblock, &current_block);
 
 		if (rc != EOK) {
@@ -591,9 +637,10 @@
 
 
-int ext4_filesystem_set_inode_data_block_index(ext4_filesystem_t *fs,
-		ext4_inode_ref_t *inode_ref, aoff64_t iblock, uint32_t fblock)
-{
-	int rc;
-
+int ext4_filesystem_set_inode_data_block_index(ext4_inode_ref_t *inode_ref,
+		aoff64_t iblock, uint32_t fblock)
+{
+	int rc;
+
+	ext4_filesystem_t *fs = inode_ref->fs;
 
 	/* Handle inode using extents */
@@ -635,5 +682,5 @@
 
 	if (current_block == 0) {
-		rc = ext4_balloc_alloc_block(fs, inode_ref, &new_block_addr);
+		rc = ext4_balloc_alloc_block(inode_ref, &new_block_addr);
 		if (rc != EOK) {
 			return rc;
@@ -646,5 +693,5 @@
 		rc = block_get(&new_block, fs->device, new_block_addr, BLOCK_FLAGS_NOREAD);
 		if (rc != EOK) {
-			ext4_balloc_free_block(fs, inode_ref, new_block_addr);
+			ext4_balloc_free_block(inode_ref, new_block_addr);
 			return rc;
 		}
@@ -674,5 +721,5 @@
 
 		if ((level > 1) && (current_block == 0)) {
-			rc = ext4_balloc_alloc_block(fs, inode_ref, &new_block_addr);
+			rc = ext4_balloc_alloc_block(inode_ref, &new_block_addr);
 			if (rc != EOK) {
 				block_put(block);
@@ -727,5 +774,5 @@
 }
 
-int ext4_filesystem_release_inode_block(ext4_filesystem_t *fs,
+int ext4_filesystem_release_inode_block(
 		ext4_inode_ref_t *inode_ref, uint32_t iblock)
 {
@@ -733,4 +780,6 @@
 
 	uint32_t fblock;
+
+	ext4_filesystem_t *fs = inode_ref->fs;
 
 	/* TODO Handle extents */
@@ -772,5 +821,5 @@
 
 		ext4_inode_set_direct_block(inode, iblock, 0);
-		return ext4_balloc_free_block(fs, inode_ref, fblock);
+		return ext4_balloc_free_block(inode_ref, fblock);
 	}
 
@@ -837,14 +886,15 @@
 	}
 
-	return ext4_balloc_free_block(fs, inode_ref, fblock);
-
-}
-
-int ext4_filesystem_add_orphan(ext4_filesystem_t *fs,
-		ext4_inode_ref_t *inode_ref)
-{
-	uint32_t next_orphan = ext4_superblock_get_last_orphan(fs->superblock);
+	return ext4_balloc_free_block(inode_ref, fblock);
+
+}
+
+int ext4_filesystem_add_orphan(ext4_inode_ref_t *inode_ref)
+{
+	uint32_t next_orphan = ext4_superblock_get_last_orphan(
+			inode_ref->fs->superblock);
 	ext4_inode_set_deletion_time(inode_ref->inode, next_orphan);
-	ext4_superblock_set_last_orphan(fs->superblock, inode_ref->index);
+	ext4_superblock_set_last_orphan(
+			inode_ref->fs->superblock, inode_ref->index);
 	inode_ref->dirty = true;
 
@@ -852,10 +902,10 @@
 }
 
-int ext4_filesystem_delete_orphan(ext4_filesystem_t *fs,
-		ext4_inode_ref_t *inode_ref)
-{
-	int rc;
-
-	uint32_t last_orphan = ext4_superblock_get_last_orphan(fs->superblock);
+int ext4_filesystem_delete_orphan(ext4_inode_ref_t *inode_ref)
+{
+	int rc;
+
+	uint32_t last_orphan = ext4_superblock_get_last_orphan(
+			inode_ref->fs->superblock);
 	assert(last_orphan > 0);
 
@@ -863,5 +913,5 @@
 
 	if (last_orphan == inode_ref->index) {
-		ext4_superblock_set_last_orphan(fs->superblock, next_orphan);
+		ext4_superblock_set_last_orphan(inode_ref->fs->superblock, next_orphan);
 		ext4_inode_set_deletion_time(inode_ref->inode, 0);
 		inode_ref->dirty = true;
@@ -870,5 +920,5 @@
 
 	ext4_inode_ref_t *current;
-	rc = ext4_filesystem_get_inode_ref(fs, last_orphan, &current);
+	rc = ext4_filesystem_get_inode_ref(inode_ref->fs, last_orphan, &current);
 	if (rc != EOK) {
 		return rc;
@@ -889,5 +939,5 @@
 		ext4_filesystem_put_inode_ref(current);
 
-		rc = ext4_filesystem_get_inode_ref(fs, next_orphan, &current);
+		rc = ext4_filesystem_get_inode_ref(inode_ref->fs, next_orphan, &current);
 		if (rc != EOK) {
 			return rc;
Index: uspace/lib/ext4/libext4_filesystem.h
===================================================================
--- uspace/lib/ext4/libext4_filesystem.h	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_filesystem.h	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -49,17 +49,17 @@
 extern int ext4_filesystem_alloc_inode(ext4_filesystem_t *,
 		ext4_inode_ref_t **, int);
-extern int ext4_filesystem_free_inode(ext4_filesystem_t *, ext4_inode_ref_t *);
-extern int ext4_filesystem_truncate_inode(ext4_filesystem_t *,
-		ext4_inode_ref_t *, aoff64_t);
-extern int ext4_filesystem_get_inode_data_block_index(ext4_filesystem_t *,
-	ext4_inode_ref_t *, aoff64_t iblock, uint32_t *);
-extern int ext4_filesystem_set_inode_data_block_index(ext4_filesystem_t *,
-		ext4_inode_ref_t *, aoff64_t, uint32_t);
-extern int ext4_filesystem_release_inode_block(ext4_filesystem_t *,
+extern int ext4_filesystem_free_inode(ext4_inode_ref_t *);
+extern int ext4_filesystem_truncate_inode(ext4_inode_ref_t *, aoff64_t);
+extern int ext4_filesystem_get_inode_data_block_index(ext4_inode_ref_t *,
+		aoff64_t iblock, uint32_t *);
+extern int ext4_filesystem_set_inode_data_block_index(ext4_inode_ref_t *,
+		aoff64_t, uint32_t);
+extern int ext4_filesystem_release_inode_block(
 		ext4_inode_ref_t *, uint32_t);
-extern int ext4_filesystem_add_orphan(ext4_filesystem_t *,
-		ext4_inode_ref_t *);
-extern int ext4_filesystem_delete_orphan(ext4_filesystem_t *,
-		ext4_inode_ref_t *);
+extern int ext4_filesystem_add_orphan(ext4_inode_ref_t *);
+extern int ext4_filesystem_delete_orphan(ext4_inode_ref_t *);
+
+extern uint16_t ext4_group_desc_csum(ext4_superblock_t *, uint32_t,
+		ext4_block_group_t *);
 #endif
 
Index: uspace/lib/ext4/libext4_ialloc.c
===================================================================
--- uspace/lib/ext4/libext4_ialloc.c	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_ialloc.c	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -111,4 +111,11 @@
 	ext4_block_group_set_free_inodes_count(bg_ref->block_group,
 			sb, free_inodes);
+
+	uint32_t unused_inodes = ext4_block_group_get_itable_unused(
+			bg_ref->block_group, sb);
+	unused_inodes++;
+	ext4_block_group_set_itable_unused(bg_ref->block_group, sb, unused_inodes);
+
+
 	bg_ref->dirty = true;
 
@@ -186,4 +193,8 @@
 			ext4_block_group_set_free_inodes_count(bg, sb, free_inodes);
 
+			uint16_t unused_inodes = ext4_block_group_get_itable_unused(bg, sb);
+			unused_inodes--;
+			ext4_block_group_set_itable_unused(bg, sb, unused_inodes);
+
 			if (is_dir) {
 				used_dirs++;
Index: uspace/lib/ext4/libext4_types.h
===================================================================
--- uspace/lib/ext4/libext4_types.h	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/lib/ext4/libext4_types.h	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -194,4 +194,16 @@
 
 /*****************************************************************************/
+
+typedef struct ext4_filesystem {
+	service_id_t device;
+	ext4_superblock_t *	superblock;
+	aoff64_t inode_block_limits[4];
+	aoff64_t inode_blocks_per_level[4];
+} ext4_filesystem_t;
+
+
+/*****************************************************************************/
+
+
 /*
  * Structure of a blocks group descriptor
@@ -222,4 +234,6 @@
 	block_t *block; // Reference to a block containing this block group descr
 	ext4_block_group_t *block_group;
+	ext4_filesystem_t *fs;
+	uint32_t index;
 	bool dirty;
 } ext4_block_group_ref_t;
@@ -229,20 +243,10 @@
 #define EXT4_BLOCK_MAX_GROUP_DESCRIPTOR_SIZE 64
 
-
-/*****************************************************************************/
-
-typedef struct ext4_filesystem {
-	service_id_t device;
-	ext4_superblock_t *	superblock;
-	aoff64_t inode_block_limits[4];
-	aoff64_t inode_blocks_per_level[4];
-} ext4_filesystem_t;
+/*****************************************************************************/
+
 
 #define EXT4_MIN_BLOCK_SIZE		1024  //1 KiB
 #define EXT4_MAX_BLOCK_SIZE 	65536 //64 KiB
 #define EXT4_REV0_INODE_SIZE	128
-
-/*****************************************************************************/
-
 
 #define EXT4_INODE_BLOCK_SIZE				512
@@ -346,4 +350,5 @@
 	block_t *block; // Reference to a block containing this inode
 	ext4_inode_t *inode;
+	ext4_filesystem_t *fs;
 	uint32_t index; // Index number of this inode
 	bool dirty;
Index: uspace/srv/fs/ext4fs/ext4fs.c
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs.c	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/srv/fs/ext4fs/ext4fs.c	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -61,5 +61,5 @@
 			ext4fs_vfs_info.instance = strtol(argv[2], NULL, 10);
 		else {
-			printf(NAME " Unrecognized parameters");
+			printf(NAME " Unrecognized parameters\n");
 			return -1;
 		}
Index: uspace/srv/fs/ext4fs/ext4fs_ops.c
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision 38384ae40b4db14e20d7a0cea4f60dfedb6a7f5f)
+++ uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision 1ac1ab45ddda2b390c1b5c8f669d639559500b3d)
@@ -211,5 +211,5 @@
 
 	ext4_directory_search_result_t result;
-	rc = ext4_directory_find_entry(fs, &result, eparent->inode_ref, component);
+	rc = ext4_directory_find_entry(&result, eparent->inode_ref, component);
 	if (rc != EOK) {
 		if (rc == ENOENT) {
@@ -448,5 +448,5 @@
 	ext4_inode_ref_t *inode_ref = enode->inode_ref;
 
-	rc = ext4_filesystem_truncate_inode(fs, inode_ref, 0);
+	rc = ext4_filesystem_truncate_inode(inode_ref, 0);
 	if (rc != EOK) {
 		ext4fs_node_put(fn);
@@ -456,5 +456,5 @@
 	uint32_t rev_level = ext4_superblock_get_rev_level(fs->superblock);
 	if (rev_level > 0) {
-		ext4_filesystem_delete_orphan(fs, inode_ref);
+		ext4_filesystem_delete_orphan(inode_ref);
 	}
 
@@ -465,5 +465,5 @@
 	inode_ref->dirty = true;
 
-	rc = ext4_filesystem_free_inode(fs, inode_ref);
+	rc = ext4_filesystem_free_inode(inode_ref);
 	if (rc != EOK) {
 		ext4fs_node_put(fn);
@@ -489,5 +489,5 @@
 
 	// Add entry to parent directory
-	rc = ext4_directory_add_entry(fs, parent->inode_ref, name, child->inode_ref);
+	rc = ext4_directory_add_entry(parent->inode_ref, name, child->inode_ref);
 	if (rc != EOK) {
 		return rc;
@@ -497,14 +497,14 @@
 	if (ext4_inode_is_type(fs->superblock, child->inode_ref->inode, EXT4_INODE_MODE_DIRECTORY)) {
 
-		rc = ext4_directory_add_entry(fs, child->inode_ref, ".", child->inode_ref);
+		rc = ext4_directory_add_entry(child->inode_ref, ".", child->inode_ref);
 		if (rc != EOK) {
-			ext4_directory_remove_entry(fs, parent->inode_ref, name);
+			ext4_directory_remove_entry(parent->inode_ref, name);
 			return rc;
 		}
 
-		rc = ext4_directory_add_entry(fs, child->inode_ref, "..", parent->inode_ref);
+		rc = ext4_directory_add_entry(child->inode_ref, "..", parent->inode_ref);
 		if (rc != EOK) {
-			ext4_directory_remove_entry(fs, parent->inode_ref, name);
-			ext4_directory_remove_entry(fs, child->inode_ref, ".");
+			ext4_directory_remove_entry(parent->inode_ref, name);
+			ext4_directory_remove_entry(child->inode_ref, ".");
 			return rc;
 		}
@@ -546,5 +546,5 @@
 	ext4_inode_ref_t *parent = EXT4FS_NODE(pfn)->inode_ref;
 	ext4_filesystem_t *fs = EXT4FS_NODE(pfn)->instance->filesystem;
-	rc = ext4_directory_remove_entry(fs, parent, name);
+	rc = ext4_directory_remove_entry(parent, name);
 	if (rc != EOK) {
 		return rc;
@@ -576,5 +576,5 @@
 	uint32_t rev_level = ext4_superblock_get_rev_level(fs->superblock);
 	if ((rev_level > 0) && (lnk_count == 0)) {
-		ext4_filesystem_add_orphan(fs, child_inode_ref);
+		ext4_filesystem_add_orphan(child_inode_ref);
 	}
 
@@ -1002,6 +1002,5 @@
 	/* Get the real block number */
 	uint32_t fs_block;
-	rc = ext4_filesystem_get_inode_data_block_index(inst->filesystem,
-		inode_ref, file_block, &fs_block);
+	rc = ext4_filesystem_get_inode_data_block_index(inode_ref, file_block, &fs_block);
 	if (rc != EOK) {
 		async_answer_0(callid, rc);
@@ -1090,5 +1089,5 @@
 
 	ext4_inode_ref_t *inode_ref = enode->inode_ref;
-	rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref, iblock, &fblock);
+	rc = ext4_filesystem_get_inode_data_block_index(inode_ref, iblock, &fblock);
 	if (rc != EOK) {
 		ext4fs_node_put(fn);
@@ -1098,5 +1097,5 @@
 
 	if (fblock == 0) {
-		rc =  ext4_balloc_alloc_block(fs, inode_ref, &fblock);
+		rc =  ext4_balloc_alloc_block(inode_ref, &fblock);
 		if (rc != EOK) {
 			ext4fs_node_put(fn);
@@ -1105,7 +1104,7 @@
 		}
 
-		rc = ext4_filesystem_set_inode_data_block_index(fs, inode_ref, iblock, fblock);
+		rc = ext4_filesystem_set_inode_data_block_index(inode_ref, iblock, fblock);
 		if (rc != EOK) {
-			ext4_balloc_free_block(fs, inode_ref, fblock);
+			ext4_balloc_free_block(inode_ref, fblock);
 			ext4fs_node_put(fn);
 			async_answer_0(callid, rc);
@@ -1169,7 +1168,6 @@
 	ext4fs_node_t *enode = EXT4FS_NODE(fn);
 	ext4_inode_ref_t *inode_ref = enode->inode_ref;
-	ext4_filesystem_t *fs = enode->instance->filesystem;
-
-	rc = ext4_filesystem_truncate_inode(fs, inode_ref, new_size);
+
+	rc = ext4_filesystem_truncate_inode(inode_ref, new_size);
 	ext4fs_node_put(fn);
 
