From: Yifan Zhao <[email protected]>

-ENOSPC can be a normal compression fallback when fragments are off.
Keep the global compression context reusable for that case while
preserving the fatal state for real errors.

Fixes: a729584ef975 ("erofs-utils: mkfs: avoid hanging if fragment is on and 
tmpdir is full")
Reported-by: Bastian Schmitz <[email protected]>
Closes: https://github.com/erofs/erofs-utils/issues/50
Assisted-by: Codex:GPT-5.5
Signed-off-by: Yifan Zhao <[email protected]>
---
 lib/compress.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/compress.c b/lib/compress.c
index ea07409..2a43b81 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -2031,7 +2031,11 @@ err_free_idata:
 out:
 #ifdef EROFS_MT_ENABLED
        pthread_mutex_lock(&ictx->mutex);
-       ictx->seg_num = ret < 0 ? INT_MAX : 0;
+       if (ret < 0 && (ret != -ENOSPC || inode->fragment_size))
+               /* mark as failed to avoid further processing */
+               ictx->seg_num = INT_MAX;
+       else
+               ictx->seg_num = 0;
        pthread_cond_signal(&ictx->cond);
        pthread_mutex_unlock(&ictx->mutex);
 #endif
-- 
2.47.3


Reply via email to