public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Utkal Singh <singhutkal015@gmail.com>, linux-erofs@lists.ozlabs.org
Cc: chao@kernel.org
Subject: Re: [PATCH] erofs-utils: lib/diskbuf: fix MT data race in erofs_diskbuf_reserve()
Date: Thu, 2 Apr 2026 13:53:41 +0800	[thread overview]
Message-ID: <96bba5e7-936e-45fa-bb01-2fee4dfb843d@linux.alibaba.com> (raw)
In-Reply-To: <20260402050424.24308-1-singhutkal015@gmail.com>



On 2026/4/2 13:04, Utkal Singh wrote:
> Two threads calling erofs_diskbuf_reserve() concurrently can both
> observe strm->locked == false and both advance tailoffset, silently

How?

> producing an incorrect offset in the output image. Add a
> pthread_mutex_t to serialize access.
> 
> The commit path also gains the missing strm->locked = false reset;
> without it, locked was set once and never cleared, making the flag
> a latch rather than a guard.
> 
> libpthread is already a build requirement (-lpthread in
> lib/Makefile.am) and pthread_mutex_t is used identically in
> lib/workqueue.c and lib/compress.c, so no build system changes
> are required.
> 
> Fixes: 13f7268 ("erofs-utils: lib: introduce multi-threaded I/O framework")
> Signed-off-by: Utkal Singh <singhutkal015@gmail.com>
> ---
>   lib/diskbuf.c | 18 +++++++++++++++---
>   1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/diskbuf.c b/lib/diskbuf.c
> index 0bf42da..ccfeaa4 100644
> --- a/lib/diskbuf.c
> +++ b/lib/diskbuf.c
> @@ -2,6 +2,7 @@
>   #include "erofs/diskbuf.h"
>   #include "erofs/internal.h"
>   #include "erofs/print.h"
> +#include <pthread.h>
>   #include <stdio.h>
>   #include <errno.h>
>   #include <sys/stat.h>
> @@ -15,6 +16,7 @@ static struct erofs_diskbufstrm {
>   	int fd;
>   	unsigned int alignsize;
>   	bool locked;
> +	pthread_mutex_t lock;

Do you ever notice erofs_mutex_t and include/erofs/lock.h?

By the way, I sincerely hope you pay less attention
of this project since I've told you the reasons in
emails before.

It won't help with your gsoc proposal.  Thanks for
your efforts and contributions to the EROFS project.

Thanks,
Gao Xiang


      reply	other threads:[~2026-04-02  5:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02  5:04 [PATCH] erofs-utils: lib/diskbuf: fix MT data race in erofs_diskbuf_reserve() Utkal Singh
2026-04-02  5:53 ` Gao Xiang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=96bba5e7-936e-45fa-bb01-2fee4dfb843d@linux.alibaba.com \
    --to=hsiangkao@linux.alibaba.com \
    --cc=chao@kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=singhutkal015@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox