Commit Graph
284 Commits
Author SHA1 Message Date
cozis 7af1bc27b5 Fix value of CHUNK_SERVER_RECONNECT_TIME by expressing it in seconds, also change it to a runtime-modifiable value 2025-11-15 12:10:26 +01:00
cozis 11054cae86 Add new chunk hashes to the cs_add_list when creating or updating them in the chunk server 2025-11-15 10:55:11 +01:00
cozis a366b46398 Bug fixes 2025-11-15 10:38:45 +01:00
cozis a11740ab41 Fix uninitialized BinaryReader struct when parsing auth response message 2025-11-14 21:14:33 +01:00
cozis bbae5fdb7f Fix compilation errors 2025-11-14 21:06:38 +01:00
cozis 3df1745d69 Add comments 2025-11-14 12:07:32 +01:00
cozis 2bbe1ac0e8 Clean up download logic for missing/lost chunks 2025-11-14 11:56:29 +01:00
Francesco CozzutoandGitHub 787807031b Merge pull request #11 from cozis/improve-chunk-management-policy
Improve chunk management policy
2025-11-14 01:17:57 +01:00
cozis 9a944feb01 Rewrote simulation scheduler and fixed some bugs 2025-11-14 01:16:48 +01:00
cozis 3a2173c154 Minor bug fixes 2025-11-13 23:37:42 +01:00
cozis 3048f3d66b Bug fixes 2025-11-13 23:02:25 +01:00
Francesco CozzutoandGitHub de3391c34a Merge pull request #10 from cozis/claude/measure-branch-coverage-0168rdcTg6viLER3ufRwoAye
Measure branch coverage of the simulation testing
2025-11-13 21:53:39 +01:00
Claude d4ecf6db17 Replace custom HTML generation with lcov/genhtml
Use the standard lcov tools instead of custom HTML generation.

Changes:
- Completely rewrite generate_coverage_html.sh to use lcov
- Install lcov if not available
- Use lcov to capture coverage data from .gcda files
- Use genhtml to create HTML reports with branch coverage
- Add scripts/README.md with usage instructions

Benefits:
- Professional HTML reports with standard lcov styling
- Better branch coverage visualization
- Sortable tables by line/function/branch coverage
- Source code view with execution counts
- Much simpler script (30 lines vs 200+ lines)

The reports now show:
- 32.1% branch coverage (781/2431 branches)
- 43.5% line coverage
- 61.3% function coverage
2025-11-13 20:41:28 +00:00
Claude abaa12c5b3 Remove all CSS styling from HTML reports, use browser defaults
Remove all custom styling and CSS to use only plain HTML with
browser default rendering.

Changes:
- Remove all <style> tags and CSS
- Remove CSS classes from generated HTML
- Simplify source code display to plain text format
- Use simple line number: execution count: source code format
- Browser will render with its own default styles

The reports are now pure HTML with no styling at all.
2025-11-13 20:26:20 +00:00
Claude b6b926a659 Simplify HTML coverage report styling to use minimal default styles
Remove fancy styling (rounded corners, shadows, progress bars, colors)
and use simple, clean HTML with basic tables and minimal CSS.

Changes:
- Use simple sans-serif font instead of Segoe UI
- Remove container divs, shadows, and rounded corners
- Replace progress bars with plain percentage text
- Simplify color scheme (light green/red for branch coverage)
- Remove emoji and decorative elements
- Clean up table styling to basic borders

The report is now much cleaner and follows standard HTML conventions.
2025-11-13 20:24:04 +00:00
Claude 4c0b3429f0 Add .gitattributes to enforce LF line endings for shell scripts
This fixes issues when running scripts in WSL where CRLF line endings
cause 'No such file or directory' errors. Also add a fix_line_endings.sh
script for users who already have the wrong line endings.
2025-11-13 20:07:57 +00:00
Claude d288b2896f Move coverage scripts to scripts/ directory and add Makefile targets
Reorganize coverage tooling for better project structure and easier usage.

Changes:
- Move measure_coverage.sh and generate_coverage_html.sh to scripts/
- Add Makefile targets:
  - make coverage-report: Generate text coverage summary (5s simulation)
  - make coverage-html: Generate HTML coverage report (5s simulation)
- Update measure_coverage.sh to find generate_coverage_html.sh using relative path

Usage:
  make coverage-report    # Quick text summary
  make coverage-html      # Full HTML report with branch details

The HTML report provides interactive visualization of which branches
were taken during simulation execution, with color-coded source views.
2025-11-13 19:58:14 +00:00
Claude b465d5282e Add HTML coverage reports with branch-level detail
Enhance the branch coverage measurement tool with HTML report generation
that shows exactly which branches were taken during simulation execution.

Changes:
- Add generate_coverage_html.sh script to create interactive HTML reports
- Update measure_coverage.sh with --html flag to generate reports
- Add *.gcov, *.gcda, *.gcno to .gitignore
- HTML reports show:
  - Overall coverage summary with visual progress bars
  - Per-file coverage breakdown with clickable links
  - Source code view with color-coded branch coverage
  - Green highlight: branches taken
  - Red highlight: branches not taken
  - Branch execution counts and percentages

Usage:
  ./measure_coverage.sh [duration] --html

The HTML report is generated in coverage_report/index.html and can be
viewed in any web browser. Each source file links to a detailed view
showing which specific branches were executed.
2025-11-13 19:55:08 +00:00
Claude 4b97b176bd Add branch coverage measurement for random simulation
This commit adds tooling to measure how many branches the random simulation
reaches during execution, which helps understand code coverage and identify
untested code paths.

Changes:
- Add coverage build target to Makefile with --coverage flags
- Create measure_coverage.sh script to build, run, and report branch coverage
- Add signal handlers (SIGINT/SIGTERM) to main_test.c for clean shutdown
- Update clean target to remove coverage files (*.gcda, *.gcno)

The script runs the simulation for a specified duration (default 5 seconds),
then uses gcov to analyze which branches were executed. In a 3-second run,
the simulation reaches approximately 32% of all branches (781/2431).

Usage:
  ./measure_coverage.sh [duration_in_seconds]

Example output shows per-file and total branch coverage statistics.
2025-11-13 19:35:06 +00:00
cozis 7b01ac6384 Fix compilation errors 2025-11-13 20:21:26 +01:00
cozis cdce267768 Update DESIGN.txt and code accordingly 2025-11-13 17:27:00 +01:00
cozis facd220c59 Fix corner case in DESIGN.txt 2025-11-13 12:18:34 +01:00
cozis 4ec47e66b4 Clean up chunk management section of DESIGN.txt 2025-11-13 12:09:29 +01:00
Claude 14cd2f1ac6 Fix compilation issues
Fixed compilation errors:
- Added <dirent.h> include to file_system.h for DIR type on Linux
- Replaced xxx placeholder in chunk_server.c with actual chunks_dir path
  using state->store.path
2025-11-13 00:47:56 +00:00
Claude 6c2ea4bce9 Fix DirectoryScanner implementation bugs
Fixed several bugs in the DirectoryScanner implementation:

Windows fixes:
- Fixed snprintf call missing buffer size parameter
- Fixed FindFirstFileA to use pattern (with wildcard) instead of path
- Changed sys_GetLastError() to GetLastError()
- Added scanner->first = false after using first result
- Removed TODO comment from cFileName usage (it's the correct field)

Linux fixes:
- Fixed typo: sys_reddir → sys_readdir
- Added missing 'done' field to DirectoryScanner struct
- Initialize scanner->done = false on successful opendir
- Fixed return value when scanner->done (should return 1, not -1)
2025-11-13 00:45:51 +00:00
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