From 7da606ab42d4bf789fa78dca4de9efb3304d5a1d Mon Sep 17 00:00:00 2001 From: Mansi Pandey Date: Fri, 29 Aug 2025 17:17:30 +0100 Subject: [PATCH 1/2] Do not append an empty buffer to am empty S3 object during RELEASE Signed-off-by: Mansi Pandey --- mountpoint-s3-fs/src/fs/handles.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mountpoint-s3-fs/src/fs/handles.rs b/mountpoint-s3-fs/src/fs/handles.rs index c2ba30154..1ddbc71ab 100644 --- a/mountpoint-s3-fs/src/fs/handles.rs +++ b/mountpoint-s3-fs/src/fs/handles.rs @@ -296,8 +296,13 @@ where ) -> Result { match self { UploadState::AppendInProgress { - request, initial_etag, .. + request, initial_etag, written_bytes } => { + // No data upload should be pending completion as part of the release, because we commit on flush + if written_bytes == 0 && request.current_offset() == 0 { + Self::finish(fs, ino, initial_etag).await; + return Ok(false); + } Self::complete_append(fs, ino, key, request, initial_etag).await?; Ok(true) } From cbc5eb8fe271ca99ee8c2039d7b976f28cf66a20 Mon Sep 17 00:00:00 2001 From: Mansi Pandey Date: Mon, 1 Sep 2025 16:45:23 +0100 Subject: [PATCH 2/2] Add a previously_flushed flag and update commit conditions in Release and Flush Signed-off-by: Mansi Pandey --- mountpoint-s3-fs/src/fs/handles.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mountpoint-s3-fs/src/fs/handles.rs b/mountpoint-s3-fs/src/fs/handles.rs index 1ddbc71ab..1266f1903 100644 --- a/mountpoint-s3-fs/src/fs/handles.rs +++ b/mountpoint-s3-fs/src/fs/handles.rs @@ -77,6 +77,7 @@ where request, initial_etag, written_bytes: 0, + previously_flushed: false, }) } else { let request = fs @@ -119,6 +120,7 @@ pub enum UploadState { request: AppendUploadRequest, initial_etag: Option, written_bytes: usize, + previously_flushed: bool, }, MPUInProgress { request: UploadRequest, @@ -196,6 +198,7 @@ where request, initial_etag, written_bytes, + .. } => { let current_offset = request.current_offset(); match Self::commit_append(request, &handle.location).await { @@ -212,6 +215,7 @@ where request, initial_etag, written_bytes, + previously_flushed: true, // Mark that the "append" has seen a Flush at least once }; Ok(()) } @@ -240,8 +244,12 @@ where open_pid: u32, ) -> Result<(), Error> { match self { - UploadState::AppendInProgress { written_bytes, .. } => { - if *written_bytes == 0 || !are_from_same_process(open_pid, pid) { + UploadState::AppendInProgress { + written_bytes, + previously_flushed, + .. + } => { + if (*written_bytes == 0 && !*previously_flushed) || !are_from_same_process(open_pid, pid) { // Commit current changes, but do not close the write handle. return self.commit(fs, handle).await; } @@ -296,10 +304,13 @@ where ) -> Result { match self { UploadState::AppendInProgress { - request, initial_etag, written_bytes + request, + initial_etag, + written_bytes, + previously_flushed, } => { - // No data upload should be pending completion as part of the release, because we commit on flush - if written_bytes == 0 && request.current_offset() == 0 { + // No data upload should be pending completion as part of the release - if we have not written anything locally AND we already committed on a preceding Flush + if written_bytes == 0 && previously_flushed { Self::finish(fs, ino, initial_etag).await; return Ok(false); }