Re: [dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Christian Brauner
On Wed, Sep 06, 2023 at 05:33:32PM +0200, Christian Brauner wrote: > > Currently, if we freeze a filesystem with "fsfreeze" and unmount it, the > > mount point is removed, but the filesystem stays active and it is leaked. > > You can't unfreeze it with "fsfreeze --unfreeze" because the mount poin

Re: [dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Christian Brauner
On Wed, Sep 06, 2023 at 03:26:21PM +0200, Mikulas Patocka wrote: > lvm may suspend any logical volume anytime. If lvm suspend races with > unmount, it may be possible that the kernel writes to the filesystem after > unmount successfully returned. The problem can be demonstrated with this > script:

Re: [dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Christian Brauner
> Currently, if we freeze a filesystem with "fsfreeze" and unmount it, the > mount point is removed, but the filesystem stays active and it is leaked. > You can't unfreeze it with "fsfreeze --unfreeze" because the mount point > is gone. (the only way how to recover it is "echo j>/proc/sysrq-trig

Re: [dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Christian Brauner
on unmount, to make sure that the filesystem is > > + * really unmounted when this function returns. > > + */ > > +void wait_and_deactivate_super(struct super_block *s) > > +{ > > + down_write(&s->s_umount); > > + while (s->s_writers.frozen !=

Re: [dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Christian Brauner
On Wed, Sep 06, 2023 at 06:01:06PM +0200, Mikulas Patocka wrote: > > > On Wed, 6 Sep 2023, Christian Brauner wrote: > > > > > IOW, you'd also hang on any umount of a bind-mount. IOW, every > > > > single container making use of this filesystems via bind-mounts would > > > > hang on umount and sh

Re: [dm-devel] [PATCH v15 03/12] block: add copy offload support

2023-09-06 Thread Hannes Reinecke
On 9/6/23 18:38, Nitesh Shetty wrote: Introduce blkdev_copy_offload to perform copy offload. Issue REQ_OP_COPY_SRC with source info along with taking a plug. This flows till request layer and waits for dst bio to arrive. Issue REQ_OP_COPY_DST with destination info and this bio reaches request lay

Re: [dm-devel] [PATCH v15 02/12] Add infrastructure for copy offload in block and request layer.

2023-09-06 Thread Hannes Reinecke
On 9/6/23 18:38, Nitesh Shetty wrote: We add two new opcode REQ_OP_COPY_SRC, REQ_OP_COPY_DST. Since copy is a composite operation involving src and dst sectors/lba, each needs to be represented by a separate bio to make it compatible with device mapper. We expect caller to take a plug and send bi

Re: [dm-devel] [PATCH v15 12/12] null_blk: add support for copy offload

2023-09-06 Thread kernel test robot
Hi Nitesh, kernel test robot noticed the following build warnings: [auto build test WARNING on c50216cfa084d5eb67dc10e646a3283da1595bb6] url: https://github.com/intel-lab-lkp/linux/commits/Nitesh-Shetty/block-Introduce-queue-limits-and-sysfs-for-copy-offload-support/20230907-015817 base: c

Re: [dm-devel] [PATCH 21/21] libmultipath: adapt to new semantics of dm_get_uuid()

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:34PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > dm_get_uuid() will return 1 for non-existing maps. Thus we don't need > to call dm_map_present() any more in alias_already_taken(). This changes > our semantics: previously we'd avoid using an alias for whic

Re: [dm-devel] [PATCH 20/21] libmultipath: dm_get_uuid(): return emtpy UUID for non-existing maps

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:33PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > libdevmapper will most probably not return a UUID for non-existing > maps anyway. But it's cheap to double-check here. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > --- > libmultipath

Re: [dm-devel] [PATCH 19/21] multipath-tools tests: fix alias tests

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:32PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > The different implementation of get_user_friendly_alias() and its helpers > necessitates changes in the unit tests. It would be nice if it didn't, but the > unit tests are too closely bound to the implementa

Re: [dm-devel] [PATCH 18/21] libmultipath: keep bindings in memory

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:31PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > Rather than opening the bindings file every time we must retrieve > a binding, keep the contents in memory and write the file only > if additions have been made. This simplifies the code, and should speed up

Re: [dm-devel] [PATCH 17/21] libmultipath: alias.c: factor out read_binding()

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:30PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > This way we can test the parsing of input lines from the bindings > file more easily. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > --- > libmultipath/alias.c | 58 +++

Re: [dm-devel] [PATCH 16/21] libmultipath: update_bindings_file: don't log temp file name

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:29PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > The name of the temp file is unlikely to be helpful for uses, > and hard to predict in the unit test. Omit it. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > --- > libmultipath/alias.c

Re: [dm-devel] [PATCH 15/21] libmultipath: update_bindings_file: use a single write()

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:28PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > Save code and syscalls by assembling the content in memory first. > write() may return less bytes written than expected. Deal with it. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > ---

Re: [dm-devel] [PATCH 14/21] libmultipath: update_bindings_file: take filename argument

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:27PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > This function just uses the file name, no other configuration > parameters. Also, pass the Bindings argument first to use the > same convention as the other functions in this file. > Reviewed-by: Benjamin M

Re: [dm-devel] [PATCH 13/21] libmultipath: alias.c: move bindings related code up

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:26PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > No code changes, just moving code. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > --- > libmultipath/alias.c | 239 ++- > 1 file changed, 120 in

Re: [dm-devel] [PATCH 12/21] libmultipath: rename fix_bindings_file() to update_bindings_file()

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:25PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > We will use this function in a more generic way, give it a more > generic name. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > --- > libmultipath/alias.c | 6 +++--- > 1 file changed,

Re: [dm-devel] [PATCH 11/21] libmultipath: add global variable for current bindings

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:24PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > Add a variable global_bindings that holds the currently active vector of > bindings. This variable is freed at program exit. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > --- > libmul

Re: [dm-devel] [PATCH 09/21] multipath-tools tests: convert mock_{failed, used}_alias to macros

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:22PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > This way we can further improve readability of the individual test > cases. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > --- > tests/alias.c | 98 +---

Re: [dm-devel] [PATCH 10/21] multipath-tools test: use mock_bindings_file() consistently

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:23PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > Further improve test readablity. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > --- > tests/alias.c | 186 ++ > 1 file changed, 80 inser

Re: [dm-devel] [PATCH 08/21] multipath-tools test: consistent use of macros in alias test

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:21PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > Used the macros introduced with the tests for get_user_friendly_alias() > also in the previously existing tests. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > --- > tests/alias.c | 80

Re: [dm-devel] [PATCH 07/21] multipath-tools tests: add tests for get_user_friendly_alias()

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:20PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > Signed-off-by: Martin Wilck > --- > tests/alias.c | 531 ++ > 1 file changed, 531 insertions(+) > > diff --git a/tests/alias.c b/tests/alias.c > index 11f20

Re: [dm-devel] [PATCH 06/21] multipath-tools test: simplify debugging for condlog mismatch

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:19PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > If there's a mismatch between expected and actual log message, > print both messages. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > --- > tests/test-log.c | 4 +++- > 1 file changed,

Re: [dm-devel] [PATCH 05/21] libmultipath: lookup_binding: add comment about the algorithm

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:18PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > When I read this code, I always get confused. Adding comments to > explain the algorithm. > > Signed-off-by: Martin Wilck > --- > libmultipath/alias.c | 35 +++ > 1 file ch

Re: [dm-devel] [PATCH 02/21] libmultipath: add alias_already_taken()

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:15PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > Factor out a trivial helper function. > > Signed-off-by: Martin Wilck > Cc: David Bond > --- > libmultipath/alias.c | 34 -- > 1 file changed, 20 insertions(+), 14 deletio

Re: [dm-devel] [PATCH 04/21] libmultipath: never allocate an alias that's already taken

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:17PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > If the bindings file is changed in a way that multipathd can't handle > (e.g. by swapping the aliases of two maps), multipathd must not try > to re-use an alias that is already used by another map. Creating

Re: [dm-devel] [PATCH 03/21] libmultipath: unify use_existing_alias() and get_user_friendly_alias()

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:16PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > These functions are only called from select_alias(). The logic > is more obvious when unified in a single function. > > Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski > Cc: David Bond > ---

Re: [dm-devel] [PATCH 01/21] libmultipath: sysfs_set_scsi_tmo: do nothing for ACT_DRY_RUN

2023-09-06 Thread Benjamin Marzinski
On Fri, Sep 01, 2023 at 08:02:14PM +0200, mwi...@suse.com wrote: > From: Martin Wilck > > "multipath -d" might change sysfs timeouts of SCSI devices. > Make sure it doesn't. > Reviewed-by: Benjamin Marzinski > Signed-off-by: Martin Wilck > Cc: Jehan Singh > --- > libmultipath/configure.c | 4

Re: [dm-devel] [PATCH v15 12/12] null_blk: add support for copy offload

2023-09-06 Thread kernel test robot
Hi Nitesh, kernel test robot noticed the following build warnings: [auto build test WARNING on c50216cfa084d5eb67dc10e646a3283da1595bb6] url: https://github.com/intel-lab-lkp/linux/commits/Nitesh-Shetty/block-Introduce-queue-limits-and-sysfs-for-copy-offload-support/20230907-015817 base: c

[dm-devel] [PATCH v15 10/12] dm: Enable copy offload for dm-linear target

2023-09-06 Thread Nitesh Shetty
Setting copy_offload_supported flag to enable offload. Signed-off-by: Nitesh Shetty --- drivers/md/dm-linear.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index f4448d520ee9..1d1ee30bbefb 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md

[dm-devel] [PATCH v15 11/12] null: Enable trace capability for null block

2023-09-06 Thread Nitesh Shetty
This is a prep patch to enable copy trace capability. At present only zoned null_block is using trace, so we decoupled trace and zoned dependency to make it usable in null_blk driver also. Signed-off-by: Nitesh Shetty Signed-off-by: Anuj Gupta --- drivers/block/null_blk/Makefile | 2 -- drivers

[dm-devel] [PATCH v15 12/12] null_blk: add support for copy offload

2023-09-06 Thread Nitesh Shetty
Implementation is based on existing read and write infrastructure. copy_max_bytes: A new configfs and module parameter is introduced, which can be used to set hardware/driver supported maximum copy limit. Only request based queue mode will support for copy offload. Added tracefs support to copy IO

[dm-devel] [PATCH v15 09/12] dm: Add support for copy offload

2023-09-06 Thread Nitesh Shetty
Before enabling copy for dm target, check if underlying devices and dm target support copy. Avoid split happening inside dm target. Fail early if the request needs split, currently splitting copy request is not supported. Signed-off-by: Nitesh Shetty --- drivers/md/dm-table.c | 37 ++

[dm-devel] [PATCH v15 07/12] nvme: add copy offload support

2023-09-06 Thread Nitesh Shetty
Current design only supports single source range. We receive a request with REQ_OP_COPY_SRC. Parse this request which consists of src(1st) and dst(2nd) bios. Form a copy command (TP 4065) trace event support for nvme_copy_cmd. Set the device copy limits to queue limits. Signed-off-by: Kanchan Jos

[dm-devel] [PATCH v15 08/12] nvmet: add copy command support for bdev and file ns

2023-09-06 Thread Nitesh Shetty
Add support for handling nvme_cmd_copy command on target. For bdev-ns if backing device supports copy offload we call device copy offload (blkdev_copy_offload). In case of partial completion from above or absence of device copy offload capability, we fallback to copy emulation (blkdev_copy_emulati

[dm-devel] [PATCH v15 06/12] fs, block: copy_file_range for def_blk_ops for direct block device

2023-09-06 Thread Nitesh Shetty
For direct block device opened with O_DIRECT, use copy_file_range to issue device copy offload, and fallback to generic_copy_file_range incase device copy offload capability is absent or the device files are not open with O_DIRECT. Signed-off-by: Anuj Gupta Signed-off-by: Nitesh Shetty --- bloc

[dm-devel] [PATCH v15 05/12] fs/read_write: Enable copy_file_range for block device.

2023-09-06 Thread Nitesh Shetty
From: Anuj Gupta This is a prep patch. Allow copy_file_range to work for block devices. Relaxing generic_copy_file_checks allows us to reuse the existing infra, instead of adding a new user interface for block copy offload. Change generic_copy_file_checks to use ->f_mapping->host for both inode_i

[dm-devel] [PATCH v15 04/12] block: add emulation for copy

2023-09-06 Thread Nitesh Shetty
For the devices which does not support copy, copy emulation is added. It is required for in-kernel users like fabrics, where file descriptor is not available and hence they can't use copy_file_range. Copy-emulation is implemented by reading from source into memory and writing to the corresponding d

[dm-devel] [PATCH v15 03/12] block: add copy offload support

2023-09-06 Thread Nitesh Shetty
Introduce blkdev_copy_offload to perform copy offload. Issue REQ_OP_COPY_SRC with source info along with taking a plug. This flows till request layer and waits for dst bio to arrive. Issue REQ_OP_COPY_DST with destination info and this bio reaches request layer and merges with src request. For any

[dm-devel] [PATCH v15 02/12] Add infrastructure for copy offload in block and request layer.

2023-09-06 Thread Nitesh Shetty
We add two new opcode REQ_OP_COPY_SRC, REQ_OP_COPY_DST. Since copy is a composite operation involving src and dst sectors/lba, each needs to be represented by a separate bio to make it compatible with device mapper. We expect caller to take a plug and send bio with source information, followed by b

[dm-devel] [PATCH v15 01/12] block: Introduce queue limits and sysfs for copy-offload support

2023-09-06 Thread Nitesh Shetty
Add device limits as sysfs entries, - copy_max_bytes (RW) - copy_max_hw_bytes (RO) Above limits help to split the copy payload in block layer. copy_max_bytes: maximum total length of copy in single payload. copy_max_hw_bytes: Reflects the device supported maximum limit. Reviewed-b

[dm-devel] [PATCH v15 00/12] Implement copy offload support

2023-09-06 Thread Nitesh Shetty
The patch series covers the points discussed in past and most recently in LSFMM'23[0]. We have covered the initial agreed requirements in this patch set and further additional features suggested by community. This is next iteration of our previous patch set v14[1]. Copy offload is performed using

Re: [dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Al Viro
On Wed, Sep 06, 2023 at 06:01:06PM +0200, Mikulas Patocka wrote: > Perhaps we could distinguish between FIFREEZE-initiated freezes and > device-mapper initiated freezes as well. And we could change the logic to > return -EBUSY if the freeze was initiated by FIFREEZE and to wait for > unfreeze i

Re: [dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Al Viro
On Wed, Sep 06, 2023 at 05:03:34PM +0200, Mikulas Patocka wrote: > > IOW, you'd also hang on any umount of a bind-mount. IOW, every > > single container making use of this filesystems via bind-mounts would > > hang on umount and shutdown. > > bind-mount doesn't modify "s->s_writers.frozen", so th

Re: [dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Mikulas Patocka
On Wed, 6 Sep 2023, Christian Brauner wrote: > On Wed, Sep 06, 2023 at 06:01:06PM +0200, Mikulas Patocka wrote: > > > > > > On Wed, 6 Sep 2023, Christian Brauner wrote: > > > > > > > IOW, you'd also hang on any umount of a bind-mount. IOW, every > > > > > single container making use of this

Re: [dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Mikulas Patocka
On Wed, 6 Sep 2023, Christian Brauner wrote: > > > IOW, you'd also hang on any umount of a bind-mount. IOW, every > > > single container making use of this filesystems via bind-mounts would > > > hang on umount and shutdown. > > > > bind-mount doesn't modify "s->s_writers.frozen", so the patch

Re: [dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Darrick J. Wong
On Wed, Sep 06, 2023 at 03:26:21PM +0200, Mikulas Patocka wrote: > lvm may suspend any logical volume anytime. If lvm suspend races with > unmount, it may be possible that the kernel writes to the filesystem after > unmount successfully returned. The problem can be demonstrated with this > script:

Re: [dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Mikulas Patocka
On Wed, 6 Sep 2023, Christian Brauner wrote: > > What happens: > > * dmsetup suspend calls freeze_bdev, that goes to freeze_super and it > > increments sb->s_active > > * then we unmount the filesystem, we go to cleanup_mnt, cleanup_mnt calls > > deactivate_super, deactivate_super sees that

[dm-devel] [PATCH] fix writing to the filesystem after unmount

2023-09-06 Thread Mikulas Patocka
lvm may suspend any logical volume anytime. If lvm suspend races with unmount, it may be possible that the kernel writes to the filesystem after unmount successfully returned. The problem can be demonstrated with this script: #!/bin/sh -ex modprobe brd rd_size=4194304 vgcreate vg /dev/ram0 lvcreat