Add TOASTY_WRITE_TRUNCATE_AFTER flag for HTTP PUT semantics
Adds support for truncating files after write operations, enabling proper HTTP PUT semantics where the entire file content should be replaced. Implementation: - Added TOASTY_WRITE_TRUNCATE_AFTER flag (0x02) to ToastyFS API - Updated file_tree_write() to accept truncate_after parameter: * When true, sets file size to exactly offset+length * Removes chunks beyond the new file size * Marks removed chunks for garbage collection - Metadata server extracts and passes truncate flag to file_tree_write() - WAL replay passes false for truncate_after (already handled in original write) - Web proxy PUT now uses both CREATE_IF_MISSING and TRUNCATE_AFTER flags - Updated documentation in PROTOCOL.txt, DESIGN.txt, and web/DESIGN.txt Benefits: - Proper HTTP PUT semantics (replace entire file content) - Efficient: single write operation truncates and updates file - Works with both sync and async APIs - Garbage collection automatically removes orphaned chunks
This commit is contained in:
@@ -54,6 +54,11 @@ Architecture
|
||||
with a default chunk size (4096 bytes) and retries the write.
|
||||
This operation is logged to the WAL to ensure crash consistency.
|
||||
|
||||
If the TOASTY_WRITE_TRUNCATE_AFTER flag is set, the file is
|
||||
truncated after the write, setting its size to exactly offset+length
|
||||
and discarding any data beyond that point. This is useful for HTTP
|
||||
PUT semantics where the entire file content should be replaced.
|
||||
|
||||
Note that write failures may cause chunks to be orphaned
|
||||
on chunk servers. This is solved by a garbage collection
|
||||
algorithm implemented by the synchronization messages
|
||||
|
||||
@@ -122,6 +122,10 @@ the metadata server:
|
||||
the metadata server will atomically create it with a default chunk
|
||||
size of 4096 bytes and retry the write operation. The creation is
|
||||
logged to the WAL for crash consistency.
|
||||
- TOASTY_WRITE_TRUNCATE_AFTER (0x02): Truncate the file after the write
|
||||
operation, setting the file size to exactly offset+length. Any data
|
||||
beyond this point is discarded. Useful for HTTP PUT semantics where
|
||||
the entire file content should be replaced.
|
||||
|
||||
The offset and length mark the region that is being written to.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user