#2579 closed bug (fixed)
File cache failure with read-only volumes.
Reported by: | bga | Owned by: | axeld |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | File Systems/BFS | Version: | R1/pre-alpha1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description (last modified by )
I finally managed to get my IDE controller to work and mounted my Zeta partition under Haiku. Just to be safe, I mounted it read-only. To my surprise, I can not read any file on the volume. Here is what I get:
/Zeta 1.2/home> cat readat_test.cpp cat: readat_test.cpp: Read-only file system
Syslog shows:
KERN: file_cache: read pages failed: Read-only file system
And strace:
/Zeta 1.2/home> strace cat readat_test [ 728] _kern_image_relocated(0x681) (215 us) [ 728] --- SIGCONT (Continued) --- [ 728] _kern_create_sem(0x0, "exit stack lock") = 0x00003856 (15 us) [ 728] _kern_create_sem(0x1, "fork lock") = 0x00003857 (15 us) [ 728] _kern_get_system_info(0x7ffeecb4, 0x1fc) = 0x00000000 No error (7 us) [ 728] _kern_reserve_heap_address_range([0x18000000], 0x1, 0x48000000) = 0x00000000 No error (7 us) [ 728] _kern_create_area("heap", 0x2c29f0, 0x1, 0x32000, 0x0, 0x33) = 0x00001d6a (22 us) [ 728] _kern_acquire_sem(0x3857) = 0x00000000 No error (0 us) [ 728] _kern_release_sem(0x3857) = 0x00000000 No error (1 us) [ 728] _kern_create_sem(0x1, "env lock") = 0x00003858 (1 us) [ 728] _kern_acquire_sem(0x3857) = 0x00000000 No error (0 us) [ 728] _kern_release_sem(0x3857) = 0x00000000 No error (0 us) [ 728] _kern_create_sem(0x0, "user group") = 0x00003859 (15 us) [ 728] _kern_set_area_protection(0x1d64, 0x15) = 0x00000000 No error (14 us) [ 728] _kern_set_area_protection(0x1d66, 0x15) = 0x00000000 No error (23 us) [ 728] _kern_release_sem(0x3849) = 0x00000000 No error (0 us) [ 728] _kern_release_sem(0x3856) = 0x00000000 No error (0 us) [ 728] _kern_acquire_sem(0x3858) = 0x00000000 No error (0 us) [ 728] _kern_release_sem(0x3858) = 0x00000000 No error (0 us) [ 728] _kern_read_stat(0x1, (nil), false, 0x7ffeef3c, 0x3c) = 0x00000000 No error (1 us) [ 728] _kern_open(0xffffffff, "readat_test", 0x0, 0x0) = 0x00000003 (19 us) [ 728] _kern_read_stat(0x3, (nil), false, 0x7ffeef3c, 0x3c) = 0x00000000 No error (1 us) [ 728] _kern_read(0x3, 0xffffffffffffffff, 0x1802d000, 0x1000) = 0x80006008 (159 us) /bin/cat: [ 728] _kern_write(0x2, 0xffffffffffffffff, 0x7ffec85c, 0xa) = 0x0000000a (4 us) readat_test[ 728] _kern_write(0x2, 0xffffffffffffffff, 0x7ffec85c, 0xb) = 0x0000000b (3 us) : Read-only file system[ 728] _kern_write(0x2, 0xffffffffffffffff, 0x7ffec3fc, 0x17) = 0x00000017 (8 us) [ 728] _kern_write(0x2, 0xffffffffffffffff, 0x2b518b, 0x1) = 0x00000001 (3 us) [ 728] _kern_close(0x3) = 0x00000000 No error (2 us) [ 728] _kern_close(0x1) = 0x00000000 No error (0 us) [ 728] _kern_close(0x2) = 0x00000000 No error (1 us) [ 728] _kern_release_sem(0x3856) = 0x00000000 No error (0 us) [ 728] _kern_exit_team(0x1) (2 us)
It seems the problem is the _kern_write() calls in a read-only volume. But why does reading a file result in a write operation?
Change History (6)
comment:1 by , 16 years ago
Description: | modified (diff) |
---|
comment:2 by , 16 years ago
Makes sense. Still, I do not understand why I am getting a read-only error when reading a file (more specifically, reading pages from the file system.
comment:3 by , 16 years ago
I tracked down this to the bfs_io() code:
static status_t bfs_io(fs_volume* _volume, fs_vnode* _node, void* _cookie, io_request* request) {
Volume* volume = (Volume*)_volume->private_volume; Inode* inode = (Inode*)_node->private_node;
if (volume->IsReadOnly())
return B_READ_ONLY_DEVICE;
if (inode->FileCache() == NULL)
RETURN_ERROR(B_BAD_VALUE);
We lock the node here and will unlock it in the "finished" hook. rw_lock_read_lock(&inode->Lock());
return do_iterative_fd_io(volume->Device(), request,
iterative_io_get_vecs_hook, iterative_io_finished_hook, inode);
}
Why does it return an error if the volume is read only? I do not know enough about this code to know if this is necessary or not but, worse case scenario, I think vfs_vnode_io() should check for this error from the io() VFS call and fall back to the synchronous version instead of immediatelly propagating this error back (with results in this bug).
comment:4 by , 16 years ago
I went ahead and removed the check for read-only devices in bfs_io() in my local tree. Now I can read files from the volume even if it is read-only and I did not notice any side-effects (but then, again, I didn't do much).
comment:6 by , 16 years ago
Component: | - General → File Systems/BFS |
---|
I think _kern_write(0x2, ...) is a write to stdout.