Skip to contentSkip to conversation

erofs-utils: change temporal buffer to non static

PATCH In review Noboru Asai 3 participants 4 messages Apr 8, 2024 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: change temporal buffer to non static

In multi-threaded mode, each thread must use a different buffer in tryrecompress_trailing function, so change this buffer to non static.

---
 lib/compress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/compress.c +1 -1
index 641fde6..7415fda 100644
@@ -447,7 +447,7 @@ static void tryrecompress_trailing(struct z_erofs_compress_sctx *ctx,
 				   void *out, unsigned int *compressedsize)
 {
 	struct erofs_sb_info *sbi = ctx->ictx->inode->sbi;
-	static char tmp[Z_EROFS_PCLUSTER_MAX_SIZE];
+	char tmp[Z_EROFS_PCLUSTER_MAX_SIZE];
 	unsigned int count;
 	int ret = *compressedsize;
 
Signature · 1 line
2.44.0
#1 lore raw

Hi Noboru,

AFAIK, this tryrecompress_trailing is only used when may_inline is true, indicating that

this segment is the last one in the file. In the current inner-file implementation, it means

that only one worker will use the tmp buffer at a given time.

In fact, the static modifier is removed in the first version of the patchset, but the change

is reversed during the review. I think Xiang may share his opinion about this.

Thanks,

Yifan Zhao

Quoted 21 lines · Noboru Asai

In multi-threaded mode, each thread must use a different buffer in tryrecompress_trailing function, so change this buffer to non static.

---
  lib/compress.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/compress.c +1 -1
index 641fde6..7415fda 100644
@@ -447,7 +447,7 @@ static void tryrecompress_trailing(struct z_erofs_compress_sctx *ctx,
  				   void *out, unsigned int *compressedsize)
  {
  	struct erofs_sb_info *sbi = ctx->ictx->inode->sbi;
-	static char tmp[Z_EROFS_PCLUSTER_MAX_SIZE];
+	char tmp[Z_EROFS_PCLUSTER_MAX_SIZE];
  	unsigned int count;
  	int ret = *compressedsize;
 
#2 lore raw

Hi Yifan,

Quoted 5 lines · Yifan Zhao

Hi Noboru,

AFAIK, this tryrecompress_trailing is only used when may_inline is true, indicating that

Quoted 8 lines

this segment is the last one in the file. In the current inner-file implementation, it means

that only one worker will use the tmp buffer at a given time.

In fact, the static modifier is removed in the first version of the patchset, but the change

is reversed during the review. I think Xiang may share his opinion about this.

Yes, I think it will impact inter-file implementation, but that doesn't matter since we'll finally enable this. So I will apply this first :)

Thanks,
Gao Xiang

Quoted 27 lines

Thanks,

Yifan Zhao

Quoted 20 lines · Noboru Asai

In multi-threaded mode, each thread must use a different buffer in tryrecompress_trailing function, so change this buffer to non static.

---
  lib/compress.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
lib/compress.c +1 -1
index 641fde6..7415fda 100644
@@ -447,7 +447,7 @@ static void tryrecompress_trailing(struct z_erofs_compress_sctx *ctx,
                      void *out, unsigned int *compressedsize)
   {
       struct erofs_sb_info *sbi = ctx->ictx->inode->sbi;
-    static char tmp[Z_EROFS_PCLUSTER_MAX_SIZE];
+    char tmp[Z_EROFS_PCLUSTER_MAX_SIZE];
       unsigned int count;
       int ret = *compressedsize;