You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, not sure how to translate that into the dune tests but I ran into an issue with the following C code when writing onto a chamelon fs:
#include <stdio.h>
#include <assert.h>
#include <string.h>
#define BLOC_SIZE 512
#define FN "test.bin"
char small[BLOC_SIZE/4-1];
char addi[BLOC_SIZE];
int main()
{
FILE* fd;
for (size_t i=0; i<sizeof(small); ++i)
small[i]='#';
for (size_t i=0; i<sizeof(addi); ++i)
addi[i]='@';
// create a "just a bit under quarter block_size" file
assert((fd = fopen(FN, "r+")) != NULL);
assert(fwrite(small, sizeof(char), sizeof(small), fd) == sizeof(small));
assert(fflush(fd) == 0);
assert(fclose(fd) == 0);
// now append data at the end of FN
assert((fd = fopen(FN, "r+")) != NULL);
assert(fseek(fd, sizeof(small), SEEK_SET)!=-1);
assert(fwrite(addi, sizeof(char), sizeof(addi), fd) == sizeof(addi));
assert(fflush(fd) == 0);
assert(fclose(fd) == 0);
return 0;
}
This is my bumb function for set_partial, this is use for both fwrite calls (with offset arguments at 0, and block_size/4 respectively):
let write root path ~offset newdata_length newdata =
let pathkey = Mirage_kv.Key.v path in
get_before root pathkey offset >>= fun before ->
Log.warn (fun f -> f "got %d bytes before offset %d" (Cstruct.length before) offset) ;
get_after root pathkey (offset+newdata_length) >>= fun after ->
Log.warn (fun f -> f "got %d bytes after offset %d" (Cstruct.length after) (offset+newdata_length)) ;
let newdata = Cstruct.concat [before; newdata; after] in
Log.warn (fun f -> f "will write %d bytes" (Cstruct.length newdata)) ;
Chamelon.remove root pathkey >>*= fun () ->
Log.warn (fun f -> f "old file is now removed" ) ;
Chamelon.set root pathkey (Cstruct.to_string newdata) >>*= fun () ->
Log.warn (fun f -> f "new file is now created" ) ;
Lwt.return_unit
So far the debug logs I got are (melt with mines, I put some comments below to help understanding):
2022-10-06 19:48:19 +02:00: DBG [sshfs_protocol] [SSH_FXP_WRITE 17] '/test.bin' @127 (512) <- this is the 2nd fwrite call (append data)
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] name "test.bin" is associated with id 4 on blockpair 0,
1
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] found 3 entries for id 4 in 0,
1
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] after compaction, there were 3 entries for id 4 in 0,
1
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] found 3 entries with name test.bin
2022-10-06 19:48:19 +02:00: WRN [sshfs_fs] got 127 bytes before offset 127 <- this is the log call after the first get_partial
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] getting size on key /test.bin
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] name "test.bin" is associated with id 4 on blockpair 0,
1
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] found 3 entries for id 4 in 0,
1
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] after compaction, there were 3 entries for id 4 in 0,
1
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] found 1 entries with name test.bin
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] name "test.bin" is associated with id 4 on blockpair 0,
1
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] found 3 entries for id 4 in 0,
1
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] after compaction, there were 3 entries for id 4 in 0,
1
2022-10-06 19:48:19 +02:00: DBG [chamelon-fs] found 3 entries with name test.bin <- and hangs
Don't hesitate to ask me for any other helpful information :)
The text was updated successfully, but these errors were encountered:
Update: I just tried to show the value returned by the size call on the line [chamelon-fs] getting size on key /test.bin and it's 512 (the block size), which totally makes sense!
To explain a bit the situation, before the hangs I have test.bin (size=512B, usefull data=127B), I try to append some data at the end (512).
I read from 0 to 127 (read_before)
I read from 127+512 (=offset+new_data_length) to 512 (=size) : it hangs
I try with various append sized data, and it turns out that when the final size (real size + appending size) is above half a block it hangs :(
palainp
changed the title
Append data and becomes bigger than block_size/4
Append data and becomes bigger than block_size/2
Oct 7, 2022
Hi, not sure how to translate that into the dune tests but I ran into an issue with the following C code when writing onto a chamelon fs:
This is my bumb function for set_partial, this is use for both fwrite calls (with offset arguments at 0, and block_size/4 respectively):
So far the debug logs I got are (melt with mines, I put some comments below to help understanding):
Don't hesitate to ask me for any other helpful information :)
The text was updated successfully, but these errors were encountered: