linux/fs/erofs
Gao Xiang cc4b2dd95f erofs: fix infinite loop due to a race of filling compressed_bvecs
I encountered a race issue after lengthy (~594647 secs) stress tests on
a 64k-page arm64 VM with several 4k-block EROFS images.  The timing
is like below:

z_erofs_try_inplace_io                  z_erofs_fill_bio_vec
  cmpxchg(&compressed_bvecs[].page,
          NULL, ..)
                                        [access bufvec]
  compressed_bvecs[] = *bvec;

Previously, z_erofs_submit_queue() just accessed bufvec->page only, so
other fields in bufvec didn't matter.  After the subpage block support
is landed, .offset and .end can be used too, but filling bufvec isn't
an atomic operation which can cause inconsistency.

Let's use a spinlock to keep the atomicity of each bufvec.  More
specifically, just reuse the existing spinlock `pcl->obj.lockref.lock`
since it's rarely used (also it takes a short time if even used) as long
as the pcluster has a reference.

Fixes: 192351616a ("erofs: support I/O submission for sub-page compressed blocks")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Yue Hu <huyue2@coolpad.com>
Reviewed-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20240125120039.3228103-1-hsiangkao@linux.alibaba.com
2024-01-26 18:07:36 +08:00
..
compress.h erofs: simplify compression configuration parser 2023-10-31 06:57:19 +08:00
data.c erofs: fix NULL dereference of dif->bdev_handle in fscache mode 2023-11-17 19:55:46 +08:00
decompressor_deflate.c erofs: make erofs_{err,info}() support NULL sb parameter 2024-01-10 19:59:39 +08:00
decompressor_lzma.c erofs: tidy up redundant includes 2023-10-31 06:58:49 +08:00
decompressor.c Changes since last update: 2024-01-18 18:12:26 -08:00
dir.c erofs: keep meta inode into erofs_buf 2023-04-17 01:15:50 +08:00
erofs_fs.h erofs: update on-disk format for xattr name filter 2023-08-11 12:11:44 +08:00
fscache.c erofs: get rid of unneeded GFP_NOFS 2024-01-25 11:24:19 +08:00
inode.c erofs: get rid of unneeded GFP_NOFS 2024-01-25 11:24:19 +08:00
internal.h Changes since last update: 2023-11-02 07:53:57 -10:00
Kconfig netfs, fscache: Combine fscache with netfs 2023-12-24 15:08:46 +00:00
Makefile erofs: DEFLATE compression support 2023-08-11 12:11:17 +08:00
namei.c erofs: sunset erofs_dbg() 2023-04-17 01:15:54 +08:00
pcpubuf.c erofs: mark z_erofs_lzma_init/erofs_pcpubuf_init w/ __init 2023-03-09 22:49:30 +08:00
super.c erofs: make erofs_{err,info}() support NULL sb parameter 2024-01-10 19:59:39 +08:00
sysfs.c erofs: make kobj_type structures constant 2023-02-15 08:11:26 +08:00
utils.c erofs: get rid of unneeded GFP_NOFS 2024-01-25 11:24:19 +08:00
xattr.c erofs: move erofs_xattr_handlers and xattr_handler_map to .rodata 2023-10-09 16:24:17 +02:00
xattr.h erofs: move erofs_xattr_handlers and xattr_handler_map to .rodata 2023-10-09 16:24:17 +02:00
zdata.c erofs: fix infinite loop due to a race of filling compressed_bvecs 2024-01-26 18:07:36 +08:00
zmap.c Changes since last update: 2024-01-18 18:12:26 -08:00