Commit Graph
159 Commits
Author SHA1 Message Date
Claude c903567309 Add mocks for file search system calls (Windows and Linux)
Added mock implementations for file/directory search operations to
support both Windows and Linux in the simulation environment.

Windows mocks:
- FindFirstFileA: Wraps real search handle in descriptor
- FindNextFileA: Forwards to real API
- FindClose: Properly cleans up search handles

Linux mocks:
- opendir: Wraps real DIR* handle in descriptor
- readdir: Forwards to real API
- closedir: Properly cleans up directory handles

Common changes:
- Added DESC_DIRECTORY descriptor type to track directory handles
- Added real_d field to Descriptor for directory handles (HANDLE on Windows, DIR* on Linux)
- Updated close_desc to handle directory cleanup on both platforms
- Added sys_* macros for both BUILD_TEST and non-BUILD_TEST modes
- Added <dirent.h> include for Linux directory operations
2025-11-13 00:44:31 +00:00
cozis 83c2ccb2ca Implement DirectoryScanner object 2025-11-13 01:35:15 +01:00
cozis 88189c6693 Draft of the chunk server endpoint that returns the list of all chunks 2025-11-13 01:09:01 +01:00
cozis e4c5390ca7 Implement CHUNK_LIST endpoints on the metadata server 2025-11-13 00:43:18 +01:00
cozis 7012f582d2 Add chunk management notes to DESIGN.txt 2025-11-12 12:13:52 +01:00
cozis d598ccedb2 Use a default timeout of -1 when metadata_server_step and chunk_server_step don't set an explicit one 2025-11-11 11:38:00 +01:00
cozis 641c1999ad Add notes on the chunk management strategy to DESIGN.txt 2025-11-11 10:48:23 +01:00
cozis 012dc6bdb3 Add TODO.txt entry for logging 2025-11-10 23:19:12 +01:00
Claude e1869b4cf1 Fix DOWNLOAD_LOCATIONS message implementation
Fixed critical bugs in the DOWNLOAD_LOCATIONS message exchange between
metadata server and chunk server:

Metadata server changes:
- Fixed bug using wrong index (j instead of holders[j]) when writing
  chunk server addresses
- Added missing hash field to the message (was only read, never written)
- Added trace output for STATE_UPDATE_ERROR messages
- Pre-read all missing chunks before building response

Chunk server changes:
- Updated message parser to match metadata server's message format
- Changed from group-based format to per-chunk format
- Updated type sizes (uint32_t for counts instead of uint8_t/uint16_t)
- Correctly accumulates addresses from all holders before adding to
  pending download list

The message now follows this structure:
- num_missing (uint32_t)
- For each missing chunk:
  - num_holders (uint32_t)
  - For each holder: server addresses (num_ipv4, num_ipv6, addresses)
  - hash (SHA256)

Tested successfully with mousefs_random_test under valgrind with no
memory errors detected.
2025-11-10 22:01:24 +00:00
cozis 9a3a874514 Implement DOWNLOAD_LOCATIONS message in metadata server 2025-11-10 22:48:41 +01:00
cozis 8d169bc107 Modify Makefile to remove object files on clean 2025-11-10 20:21:54 +01:00
cozis 67f0cad0b8 Changes to Makefile 2025-11-10 19:30:07 +01:00
Claude 7f5ceeb24f Add build target for libmousefs_client.a static library
- Add CLIENT_CFILES and CLIENT_OFILES variables to Makefile
- Add rules to build object files and create static library
- Include libmousefs_client.a in the 'all' target
- Update clean target to remove library and object files
- Update .gitignore to ignore *.o and *.a build artifacts

The library includes: client.c, basic.c, tcp.c, message.c
2025-11-10 18:12:30 +00:00
Claude 1a297989d4 Rename project from TinyDFS to MouseFS
- Renamed TinyDFS.h to MouseFS.h
- Updated all type names: TinyDFS -> MouseFS, TinyDFS_Entity -> MouseFS_Entity, TinyDFS_Result -> MouseFS_Result
- Updated all enum values: TINYDFS_RESULT_* -> MOUSEFS_RESULT_*
- Updated all function names: tinydfs_* -> mousefs_*
- Updated all variable names: tdfs -> mfs
- Updated references in all source files, headers, examples, and documentation
- Updated Makefile build targets: tinydfs_* -> mousefs_*
2025-11-10 18:00:05 +00:00
cozis debbd08ce6 Add TODO.txt entry 2025-11-10 18:51:12 +01:00
Claude 1fb07e0b4d Fix chunk download system bugs and implement periodic retry
- Fix inverted binary_read error checks in process_metadata_server_download_locations
- Fix array indexing bugs (use correct loop variables j and k instead of i)
- Fix IPv4 port array type from uint8_t to uint16_t
- Fix reader cursor advancement in process_client_upload_chunk
- Enable periodic download retry mechanism by calling start_download_if_necessary
2025-11-10 17:46:33 +00:00
cozis d25d79c1f1 Clean up state update logic in chunk server 2025-11-10 18:36:11 +01:00
Claude ade03ac6f3 Implement chunk server state update handling
Fix how chunk servers handle state updates from the metadata server
based on the design in DESIGN.txt. The implementation now:

1. Checks if chunks in the add_list exist in the chunk store and
   collects any missing chunks
2. Unmarks chunks in the add_list that were previously marked for removal
3. Marks chunks in the rem_list for removal with timestamps
4. Responds with SUCCESS if all chunks are present, or ERROR with the
   list of missing chunks

Added:
- RemovalList data structure to track chunks marked for deletion with
  timestamps
- chunk_store_exists() to check if a chunk file exists
- Helper functions for removal list management (init, free, add, remove, find)

This implements the garbage collection mechanism described in DESIGN.txt
where chunks are marked for removal and can be unmarked if they appear
in the add_list again.
2025-11-10 16:58:13 +00:00
cozis 81ecbf3a80 Remove outdated code 2025-11-10 17:48:43 +01:00
cozis 50dd662057 Add asserts 2025-11-10 17:24:15 +01:00
cozis 8ea71ac236 Fix bug in client 2025-11-10 16:03:16 +01:00
cozis 6a608051d6 Clean up timeout code in metadata server 2025-11-10 15:07:38 +01:00
Claude 02b58a26a7 Implement periodic health checks for chunk servers
This implements the periodic STATE_UPDATE mechanism described in DESIGN.txt
lines 80-99, where the metadata server periodically sends synchronization
messages to chunk servers.

Changes:

1. Added timing fields to ChunkServerPeer:
   - last_sync_time: tracks when STATE_UPDATE was last sent
   - last_response_time: tracks when chunk server last responded

2. Added health check configuration constants (config.h):
   - HEALTH_CHECK_INTERVAL: 30 seconds between STATE_UPDATE messages
   - HEALTH_CHECK_TIMEOUT: 90 seconds before marking server as unhealthy

3. Implemented send_state_update() function:
   - Serializes and sends add_list and rem_list to chunk servers
   - Updates last_sync_time when messages are sent

4. Added message handlers for chunk server responses:
   - process_chunk_server_state_update_success(): merges add_list into old_list,
     clears pending lists, updates last_response_time
   - process_chunk_server_state_update_error(): handles missing chunks,
     updates last_response_time, logs errors

5. Implemented periodic timer logic in metadata_server_step():
   - Calculates when next STATE_UPDATE should be sent to each chunk server
   - Sends updates when HEALTH_CHECK_INTERVAL has elapsed
   - Logs warnings when chunk servers haven't responded within HEALTH_CHECK_TIMEOUT
   - Sets appropriate poll() timeout to wake up for next health check

The implementation ensures that:
- Chunk servers receive regular synchronization messages with add_list/rem_list
- The metadata server tracks chunk server health based on response times
- STATE_UPDATE messages are sent periodically (every 30 seconds by default)
- Failed/missing chunks are detected and logged for recovery

This completes the health check mechanism described in the architecture design,
enabling the metadata server to maintain accurate state with chunk servers and
detect unhealthy servers.
2025-11-10 12:50:15 +00:00
cozis 1d3ce1247e Add DESIGN.txt 2025-11-10 13:36:28 +01:00
cozis 747ab5aaea Remove old TODO comment 2025-11-10 13:27:51 +01:00
cozis 9ea4ee5223 Remove solved TODO from TODO.txt and fix a bug in file_tree_read 2025-11-10 12:51:12 +01:00
cozis 9cdf636eb6 Bug fix 2025-11-10 12:41:18 +01:00
cozis 36925309da Bug fix 2025-11-10 12:26:25 +01:00
cozis 62d7439ddd Set sockets as non-blocking and fix chunk server timeout 2025-11-09 21:30:22 +01:00
Francesco CozzutoandGitHub 99c406fbe5 Merge pull request #9 from cozis/claude/set-sockets-nonblocking-011CUxtZsiieE2szQupw9Ghm
Set sockets as non-blocking in tcp.c and add blocking checks
2025-11-09 20:52:50 +01:00
Claude 1a2c02203d Set sockets as non-blocking in tcp.c and add blocking checks
Changes:
- Added is_nonblocking flag to Descriptor structure in system.c
- Implemented mock_fcntl (Linux) and mock_ioctlsocket (Windows) to handle setting sockets as non-blocking
- Set all sockets as non-blocking in tcp.c:
  - Listen sockets in create_listen_socket()
  - Accepted sockets in tcp_translate_events()
  - Connecting sockets in tcp_connect()
- Added checks in mock_accept(), mock_recv(), and mock_send() to abort the simulation if a socket would block but is not configured as non-blocking
- This ensures proper non-blocking socket configuration and helps catch blocking socket errors during simulation
2025-11-09 19:51:09 +00:00
cozis bab8558511 Progress 2025-11-09 20:36:08 +01:00
cozis d13ad3ae6c Progress 2025-11-09 19:43:24 +01:00
cozis ecef79cc53 Progress 2025-11-09 19:06:23 +01:00
cozis bf1a18b9d0 Progress 2025-11-09 18:19:17 +01:00
cozis 753aba9e63 Progress 2025-11-09 17:39:53 +01:00
Francesco CozzutoandGitHub 058b03ba53 Merge pull request #8 from cozis/claude/remove-simulated-time-var-011CUxaeDKCx1PPFbXjhj7p3
Remove simulated_time variable and use current_time instead
2025-11-09 16:52:58 +01:00
Claude 8ec512e3ce Remove simulated_time variable and use current_time instead
- Removed simulated_time struct timespec variable
- Updated mock_QueryPerformanceCounter to convert current_time (nanoseconds) to performance counter ticks
- Updated mock_clock_gettime to convert current_time (nanoseconds) to timespec format
- All time tracking now uses the unified current_time variable
2025-11-09 15:51:39 +00:00
cozis 5f018c18b4 Progress 2025-11-09 16:49:15 +01:00
cozis 3d1368938b Progress 2025-11-09 16:20:50 +01:00
cozis 8d56a32bd1 Progress 2025-11-09 14:32:02 +01:00
cozis bc12f86598 Progress 2025-11-09 14:15:19 +01:00
cozis d2140bdb13 Progress 2025-11-09 14:12:19 +01:00
cozis c3e20eceef Progress 2025-11-09 13:20:04 +01:00
cozis 7282176a9c Progress 2025-11-09 12:58:17 +01:00
cozis a2e949e5e4 Progress 2025-11-09 12:51:51 +01:00
cozis 739d6a7aee Progress 2025-11-09 12:08:22 +01:00
cozis 88735d1595 Progress 2025-11-08 23:44:37 +01:00
Francesco CozzutoandGitHub f335c6f329 Merge pull request #7 from cozis/claude/fix-as-011CUw81oePGJUvH3eAuvBjP
Claude
2025-11-08 22:36:07 +01:00
cozis 537fbc655f Progress 2025-11-08 22:35:20 +01:00