erofs-utils: mkfs: avoid hanging if fragment is on and tmpdir is full
PATCH 1/1 erofs-utils: mkfs: avoid hanging if fragment is on and tmpdir is full
The main thread should respond to errors from the child process instead of waiting indefinitely.
Reported-by Daniel Colascione <[email protected]>
Signed-off-by Gao Xiang <[email protected]>
--- lib/compress.c | 14 +++++++++++--- lib/inode.c | 1 + 2 files changed, 12 insertions(+), 3 deletions(-)
lib/compress.c +11 -3
@@ -1338,8 +1338,11 @@ int erofs_commit_compressed_file(struct z_erofs_compress_ictx *ictx,if (inode->fragment_size) { ret =erofs_fragment_commit (inode, ictx->tofh); -if (ret) +if (ret) { +erofs_err ("failed to commit fragment for %s: %s" , + inode->i_srcpath,erofs_strerror (ret)); goto err_free_idata; + } inode->z_advise |=Z_EROFS_ADVISE_FRAGMENT_PCLUSTER ;erofs_sb_set_fragments (sbi); }
@@ -1822,8 +1825,13 @@ void *erofs_prepare_compressed_file(struct erofs_importer *im,if (!z_erofs_mt_enabled || all_fragments) {#ifdef EROFS_MT_ENABLED pthread_mutex_lock (&g_ictx.mutex); -if (g_ictx.seg_num) +while (g_ictx.seg_num) { +if (g_ictx.seg_num ==INT_MAX ) { +pthread_mutex_unlock (&g_ictx.mutex); +return ERR_PTR (-ECHILD ); + }pthread_cond_wait (&g_ictx.cond, &g_ictx.mutex); + } g_ictx.seg_num =1 ;pthread_mutex_unlock (&g_ictx.mutex);#endif
@@ -1974,7 +1982,7 @@ err_free_idata: out:#ifdef EROFS_MT_ENABLED pthread_mutex_lock (&ictx->mutex); - ictx->seg_num =0 ; + ictx->seg_num = ret <0 ?INT_MAX :0 ;pthread_cond_signal (&ictx->cond);pthread_mutex_unlock (&ictx->mutex);#endif
lib/inode.c +1 -0
@@ -786,6 +786,7 @@ int erofs_iflush(struct erofs_inode *inode)bool nlink_1 = true;int ret, fmt; +DBG_BUGON (inode->nid ==EROFS_NID_UNALLOCATED );DBG_BUGON (bh &&erofs_btell (bh, false) != off);if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode) ||S_ISFIFO (inode->i_mode) ||S_ISSOCK (inode->i_mode)) {
Signature · 1 line
2.43.0