Re: [RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-05-07 Thread Christoph Hellwig
On Wed, May 07, 2025 at 03:33:23PM +0800, Zhang Yi wrote: > On 2025/5/6 20:11, Christoph Hellwig wrote: > > On Tue, May 06, 2025 at 07:16:56PM +0800, Zhang Yi wrote: > >> Sorry, but I don't understand your suggestion. The > >> STATX_ATTR_WRITE_ZEROES_UNMAP attribute only indicate whether the bdev >

Re: [RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-05-07 Thread Darrick J. Wong
On Wed, May 07, 2025 at 03:33:23PM +0800, Zhang Yi wrote: > On 2025/5/6 20:11, Christoph Hellwig wrote: > > On Tue, May 06, 2025 at 07:16:56PM +0800, Zhang Yi wrote: > >> Sorry, but I don't understand your suggestion. The > >> STATX_ATTR_WRITE_ZEROES_UNMAP attribute only indicate whether the bdev >

[PATCH v2 1/8] kpartx_id: fix shellcheck reported errors

2025-05-07 Thread Martin Wilck
Found by Fedora's static analysis [1]. [1] https://openscanhub.fedoraproject.org/task/51915/log/device-mapper-multipath-0.11.1-1.fc43/scan-results.html#def41 Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- kpartx/kpartx_id | 8 1 file changed, 4 insertions(+), 4 delet

[PATCH v2 8/8] libmpathutil: remove VECTOR_DEFAULT_SIZE macro

2025-05-07 Thread Martin Wilck
We always add or remove a single element in vector_add_slot() and vector_remove_slot(). Use of the VECTOR_DEFAULT_SIZE macro suggests that its value can be changed, but this is not the case. Remove the macro. Signed-off-by: Martin Wilck --- libmpathutil/vector.c | 4 ++-- libmpathutil/vector.h

[PATCH v2 4/8] libmpathutil: vector_del_slot: modify v->allocated if realloc fails

2025-05-07 Thread Martin Wilck
We use v->allocated with the semantics of "length" or "number of used elements" of a vector. If realloc() fails while deleting an element, we should keep the previously allocated v->slot array but still decrement "allocated" in order to avoid accessing invalid vector elements. The next successful

[PATCH v2 3/8] libmpathpersist: fix memory leak in mpath_prout_rel()

2025-05-07 Thread Martin Wilck
Found by Fedora's static analysis [1]. [1] https://openscanhub.fedoraproject.org/task/51915/log/device-mapper-multipath-0.11.1-1.fc43/scan-results.html#def44 Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmpathpersist/mpath_persist_int.c | 12 ++-- 1 file changed,

[PATCH v2 6/8] libmultipath: prioritizers/iet: fix possible NULL dereference

2025-05-07 Thread Martin Wilck
Found by Fedora's static analysis [1]. [1] https://openscanhub.fedoraproject.org/task/51915/log/device-mapper-multipath-0.11.1-1.fc43/scan-results.html#def68 Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/prioritizers/iet.c | 3 +++ 1 file changed, 3 insertions(+

[PATCH v2 0/8] multipath-tools: static analyzer fixes

2025-05-07 Thread Martin Wilck
Xose has kindly informed me about the warnings from Fedora's static code analysis tool. I'm sending a couple of related fixes here. In the cover letter of v1 of this series [1], I'd included a discussion of what I considered false positives, but many of those might actually be real, as subsequent

[PATCH v2 7/8] libmpathutil: remove vector_repack()

2025-05-07 Thread Martin Wilck
This function is unused, and its implementation looks odd. Remove it. Signed-off-by: Martin Wilck --- libmpathutil/vector.c | 13 - libmpathutil/vector.h | 1 - 2 files changed, 14 deletions(-) diff --git a/libmpathutil/vector.c b/libmpathutil/vector.c index f69d644..6ad5dd5 100644

[PATCH v2 5/8] libmultipath: fix undefined behavior in 31-bit shift

2025-05-07 Thread Martin Wilck
Error: CPPCHECK_WARNING (CWE-758): [#def61] multipath-tools-0.11.1/libmultipath/nvme-ioctl.c:572: error[shiftTooManyBitsSigned]: Shifting signed 32-bit value by 31 bits is undefined behaviour Found by Fedora's static analysis [1]. [1] https://openscanhub.fedoraproject.org/task/51915/log/device-m

[PATCH v2 2/8] kpartx: fix file descriptor leak

2025-05-07 Thread Martin Wilck
Found by Fedora's static analysis [1]. [1] https://openscanhub.fedoraproject.org/task/51915/log/device-mapper-multipath-0.11.1-1.fc43/scan-results.html#def43 Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- kpartx/kpartx.c | 14 +++--- 1 file changed, 7 insertions(+), 7

[PATCH 18/19] btrfs: use bdev_rw_virt in scrub_one_super

2025-05-07 Thread Christoph Hellwig
Replace the code building a bio from a kernel direct map address and submitting it synchronously with the bdev_rw_virt helper. Signed-off-by: Christoph Hellwig Acked-by: David Sterba Reviewed-by: Damien Le Moal Reviewed-by: Johannes Thumshirn Reviewed-by: Qu Wenruo --- fs/btrfs/scrub.c | 10

[PATCH 04/19] block: add a bio_add_vmalloc helpers

2025-05-07 Thread Christoph Hellwig
Add a helper to add a vmalloc region to a bio, abstracting away the vmalloc addresses from the underlying pages and another one wrapping it for the simple case where all data fits into a single bio. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Johannes Thumshirn ---

Re: LVM RAID1 regression in 6.15-rc5, bisected

2025-05-07 Thread Bart Van Assche
On 5/7/25 3:40 AM, Malte Schröder wrote: kernel 6.15-rc5 fails to access lvs which use mirroring (lvcreate -m1). Last working release is -rc4. Reverting 5a2a6c428190f945c5cbf5791f72dbea83e97f66 fixes the issue. From commit f1aff4bc199cb92c055668caed65505e3b4d2656 in Linus' master branch: Fixes

Re: [PATCH 0/6] multipath-tools: static analyzer fixes

2025-05-07 Thread Benjamin Marzinski
On Mon, May 05, 2025 at 06:29:52PM +0200, Martin Wilck wrote: > Xose has kindly informed me about the warnings from Fedora's static > code analysis tool. > > I'm sending a couple of related fixes here. Most of the warnings > appear to be false positives though, see below (a second look by > anothe

Re: [PATCH 02/19] block: add a bdev_rw_virt helper

2025-05-07 Thread Jens Axboe
On 5/7/25 6:04 AM, Christoph Hellwig wrote: > +/** > + * bdev_rw_virt - synchronously read into / write from kernel mapping > + * @bdev:block device to access > + * @sector: sector to access > + * @data:data to read/write > + * @len: length in byte to read/write > + * @op:

Re: add more bio helpers v3

2025-05-07 Thread Jens Axboe
On Wed, 07 May 2025 14:04:24 +0200, Christoph Hellwig wrote: > this series adds more block layer helpers to remove boilerplate code when > adding memory to a bio or to even do the entire synchronous I/O. > > The main aim is to avoid having to convert to a struct page in the caller > when adding

[PATCH 19/19] hfsplus: use bdev_rw_virt in hfsplus_submit_bio

2025-05-07 Thread Christoph Hellwig
Replace the code building a bio from a kernel direct map address and submitting it synchronously with the bdev_rw_virt helper. Signed-off-by: Christoph Hellwig Acked-by: Yangtao Li Reviewed-by: Damien Le Moal Reviewed-by: Johannes Thumshirn --- fs/hfsplus/wrapper.c | 46 +-

[PATCH 06/19] block: pass the operation to bio_{map,copy}_kern

2025-05-07 Thread Christoph Hellwig
That way the bio can be allocated with the right operation already set and there is no need to pass the separated 'reading' argument. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Johannes Thumshirn --- block/blk-map.c | 30

[PATCH 05/19] block: remove the q argument from blk_rq_map_kern

2025-05-07 Thread Christoph Hellwig
Remove the q argument from blk_rq_map_kern and the internal helpers called by it as the queue can trivially be derived from the request. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Johannes Thumshirn --- block/blk-map.c| 2

[PATCH 15/19] xfs: simplify xfs_buf_submit_bio

2025-05-07 Thread Christoph Hellwig
Convert the __bio_add_page(..., virt_to_page(), ...) pattern to the bio_add_virt_nofail helper implementing it and use bio_add_vmalloc to insulate xfs from the details of adding vmalloc memory to a bio. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal --- fs/xfs/xfs_buf.c | 43 +

[PATCH 11/19] zonefs: use bdev_rw_virt in zonefs_read_super

2025-05-07 Thread Christoph Hellwig
Switch zonefs_read_super to allocate the superblock buffer using kmalloc which falls back to the page allocator for PAGE_SIZE allocation but gives us a kernel virtual address and then use bdev_rw_virt to perform the synchronous read into it. Signed-off-by: Christoph Hellwig Acked-by: Damien Le Mo

[PATCH 17/19] xfs: simplify building the bio in xlog_write_iclog

2025-05-07 Thread Christoph Hellwig
Use the bio_add_virt_nofail and bio_add_vmalloc helpers to abstract away the details of the memory allocation. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: "Darrick J. Wong" --- fs/xfs/xfs_log.c | 32 ++-- 1 file changed, 6 insertions(+)

[PATCH 14/19] dm-integrity: use bio_add_virt_nofail

2025-05-07 Thread Christoph Hellwig
Convert the __bio_add_page(..., virt_to_page(), ...) pattern to the bio_add_virt_nofail helper implementing it, and do the same for the similar pattern using bio_add_page for adding the first segment after a bio allocation as that can't fail either. Signed-off-by: Christoph Hellwig Acked-by: Miku

[PATCH 13/19] dm-bufio: use bio_add_virt_nofail

2025-05-07 Thread Christoph Hellwig
Convert the __bio_add_page(..., virt_to_page(), ...) pattern to the bio_add_virt_nofail helper implementing it. Signed-off-by: Christoph Hellwig Acked-by: Mikulas Patocka Reviewed-by: Damien Le Moal Reviewed-by: Johannes Thumshirn --- drivers/md/dm-bufio.c | 2 +- 1 file changed, 1 insertion(

[PATCH 16/19] xfs: simplify xfs_rw_bdev

2025-05-07 Thread Christoph Hellwig
Delegate to bdev_rw_virt when operating on non-vmalloc memory and use bio_add_vmalloc_chunk to insulate xfs from the details of adding vmalloc memory to a bio. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_bio_io.c | 30 ---

[PATCH 10/19] gfs2: use bdev_rw_virt in gfs2_read_super

2025-05-07 Thread Christoph Hellwig
Switch gfs2_read_super to allocate the superblock buffer using kmalloc which falls back to the page allocator for PAGE_SIZE allocation but gives us a kernel virtual address and then use bdev_rw_virt to perform the synchronous read into it. Signed-off-by: Christoph Hellwig Reviewed-by: Andreas Gru

[PATCH 12/19] PM: hibernate: split and simplify hib_submit_io

2025-05-07 Thread Christoph Hellwig
Split hib_submit_io into a sync and async version. The sync version is a small wrapper around bdev_rw_virt which implements all the logic to add a kernel direct mapping range to a bio and synchronously submits it, while the async version is slightly simplified using the bio_add_virt_nofail for add

[PATCH 09/19] rnbd-srv: use bio_add_virt_nofail

2025-05-07 Thread Christoph Hellwig
Use the bio_add_virt_nofail to add a single kernel virtual address to a bio as that can't fail. Signed-off-by: Christoph Hellwig Acked-by: Jack Wang Reviewed-by: Damien Le Moal Reviewed-by: Johannes Thumshirn --- drivers/block/rnbd/rnbd-srv.c | 7 +-- 1 file changed, 1 insertion(+), 6 del

[PATCH 07/19] block: simplify bio_map_kern

2025-05-07 Thread Christoph Hellwig
Rewrite bio_map_kern using the new bio_add_* helpers and drop the kerneldoc comment that is superfluous for an internal helper. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Johannes Thumshirn --- block/blk-map.c | 56

[PATCH 08/19] bcache: use bio_add_virt_nofail

2025-05-07 Thread Christoph Hellwig
Convert the __bio_add_page(..., virt_to_page(), ...) pattern to the bio_add_virt_nofail helper implementing it. Signed-off-by: Christoph Hellwig Acked-by: Coly Li Reviewed-by: Damien Le Moal Reviewed-by: Johannes Thumshirn --- drivers/md/bcache/super.c | 3 +-- 1 file changed, 1 insertion(+),

[PATCH 02/19] block: add a bdev_rw_virt helper

2025-05-07 Thread Christoph Hellwig
Add a helper to perform synchronous I/O on a kernel direct map range. Currently this is implemented in various places in usually not very efficient ways, so provide a generic helper instead. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: J

[PATCH 03/19] block: add a bio_add_max_vecs helper

2025-05-07 Thread Christoph Hellwig
Add a helper to check how many bio_vecs are needed to add a kernel virtual address range to a bio, accounting for the always contiguous direct mapping and vmalloc mappings that usually need a bio_vec per page sized chunk. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by:

[PATCH 01/19] block: add a bio_add_virt_nofail helper

2025-05-07 Thread Christoph Hellwig
Add a helper to add a directly mapped kernel virtual address to a bio so that callers don't have to convert to pages or folios. For now only the _nofail variant is provided as that is what all the obvious callers want. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Ha

add more bio helpers v3

2025-05-07 Thread Christoph Hellwig
Hi all, this series adds more block layer helpers to remove boilerplate code when adding memory to a bio or to even do the entire synchronous I/O. The main aim is to avoid having to convert to a struct page in the caller when adding kernel direct mapping or vmalloc memory. Changes since v2: - r

LVM RAID1 regression in 6.15-rc5, bisected

2025-05-07 Thread Malte Schröder
Hi, kernel 6.15-rc5 fails to access lvs which use mirroring (lvcreate -m1). Last working release is -rc4. Reverting 5a2a6c428190f945c5cbf5791f72dbea83e97f66 fixes the issue. Output of "lvs" when broken:   /dev/mapper/vg_nvme-wine_games: open failed: No such file or directory   Expected raid segm

Re: [RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-05-07 Thread Zhang Yi
On 2025/5/6 23:55, Darrick J. Wong wrote: > On Tue, May 06, 2025 at 02:10:12PM +0200, Christoph Hellwig wrote: >> On Tue, May 06, 2025 at 07:25:06PM +0800, Zhang Yi wrote: >>> + if (request_mask & STATX_WRITE_ZEROES_UNMAP && >>> + bdev_write_zeroes_unmap(bdev)) >>> + s

Re: [RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-05-07 Thread Zhang Yi
On 2025/5/6 20:11, Christoph Hellwig wrote: > On Tue, May 06, 2025 at 07:16:56PM +0800, Zhang Yi wrote: >> Sorry, but I don't understand your suggestion. The >> STATX_ATTR_WRITE_ZEROES_UNMAP attribute only indicate whether the bdev >> and the block device that under the specified file support unmap

Re: [PATCH 4/6] libmpathutil: silence compiler warning in vector_del_slot()

2025-05-07 Thread Martin Wilck
On Tue, 2025-05-06 at 18:01 -0400, Benjamin Marzinski wrote: > On Mon, May 05, 2025 at 06:29:56PM +0200, Martin Wilck wrote: > > Try to silence a gcc warning. Also, replace the wrong-looking > > VECTOR_DEFAULT_SIZE by 1 (after all, we've just deleted a single > > element). > > > > Found by Fedora'

Re: [PATCH 0/6] multipath-tools: static analyzer fixes

2025-05-07 Thread Martin Wilck
On Tue, 2025-05-06 at 18:26 -0400, Benjamin Marzinski wrote: > On Mon, May 05, 2025 at 06:29:52PM +0200, Martin Wilck wrote: > > Xose has kindly informed me about the warnings from Fedora's static > > code analysis tool. > > > > I'm sending a couple of related fixes here. Most of the warnings > >