ext2: Cache physical location of current content block
diff --git a/src/filo-fs-ext2.adb b/src/filo-fs-ext2.adb
index ee9265b..db1c1a3 100644
--- a/src/filo-fs-ext2.adb
+++ b/src/filo-fs-ext2.adb
@@ -754,6 +754,7 @@
if Success then
State.Inode.I := Inode;
+ State.Inode.Map_Cache := (others => <>);
State.S := File_Opened;
end if;
end;
@@ -956,12 +957,16 @@
Physical : FSBlock_Offset;
Success : Boolean;
begin
- if State.Inode.Use_Extents then
+ if State.Inode.Map_Cache.Logical = Block_Offset (Logical) then
+ Physical := State.Inode.Map_Cache.Phys;
+ Success := True;
+ elsif State.Inode.Use_Extents then
Extent_Block_Map (State, Logical, Physical, Success);
else
Ext2_Block_Map (State, Logical, Physical, Success);
end if;
exit when not Success;
+ State.Inode.Map_Cache := (Phys => Physical, Logical => Block_Offset (Logical));
if Physical > 0 then
Cache_FSBlock