linux-2.6-block.git
6 months agodm vdo int-map: return VDO_SUCCESS on success
Mike Snitzer [Tue, 13 Feb 2024 18:17:53 +0000 (12:17 -0600)]
dm vdo int-map: return VDO_SUCCESS on success

Update all callers to check for VDO_SUCCESS (most already did).
Also fix whitespace for update_mapping() parameters.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo: check for VDO_SUCCESS return value from memory-alloc functions
Mike Snitzer [Tue, 13 Feb 2024 18:06:53 +0000 (12:06 -0600)]
dm vdo: check for VDO_SUCCESS return value from memory-alloc functions

VDO_SUCCESS and UDS_SUCCESS were used interchangably, update all
callers of VDO's memory-alloc functions to consistently check for
VDO_SUCCESS.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo memory-alloc: return VDO_SUCCESS on success
Mike Snitzer [Tue, 13 Feb 2024 17:37:05 +0000 (11:37 -0600)]
dm vdo memory-alloc: return VDO_SUCCESS on success

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo errors: remove unused error codes
Matthew Sakai [Wed, 28 Feb 2024 00:22:59 +0000 (19:22 -0500)]
dm vdo errors: remove unused error codes

Also define VDO_SUCCESS in a more central location, and
rename error block constants for clarity.

Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
6 months agodm vdo memory-alloc: rename vdo_do_allocation to __vdo_do_allocation
Mike Snitzer [Tue, 13 Feb 2024 17:17:00 +0000 (11:17 -0600)]
dm vdo memory-alloc: rename vdo_do_allocation to __vdo_do_allocation

__vdo_do_allocation shouldn't be used outside of memory-alloc.h, so
add hidden prefix.

Also, tabify the vdo_allocate_extended macro.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo memory-alloc: change from uds_ to vdo_ namespace
Mike Snitzer [Tue, 13 Feb 2024 16:55:50 +0000 (10:55 -0600)]
dm vdo memory-alloc: change from uds_ to vdo_ namespace

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm-vdo: change unnamed enums to defines
Bruce Johnston [Mon, 26 Feb 2024 22:04:43 +0000 (17:04 -0500)]
dm-vdo: change unnamed enums to defines

Signed-off-by: Bruce Johnston <bjohnsto@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
6 months agodm vdo: remove outdated pointer_map reference
Matthew Sakai [Fri, 23 Feb 2024 01:48:16 +0000 (20:48 -0500)]
dm vdo: remove outdated pointer_map reference

Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
6 months agodm vdo: update module comments
Matthew Sakai [Fri, 23 Feb 2024 01:44:29 +0000 (20:44 -0500)]
dm vdo: update module comments

Update outdated comments referring to separate VDO and UDS
modules.

Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
6 months agodm vdo indexer delta-index: fix typos in comments
Matthew Sakai [Sat, 20 Jan 2024 03:27:27 +0000 (22:27 -0500)]
dm vdo indexer delta-index: fix typos in comments

Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
6 months agodm vdo: fix various function names referenced in comment blocks
Jiapeng Chong [Wed, 21 Feb 2024 09:17:31 +0000 (17:17 +0800)]
dm vdo: fix various function names referenced in comment blocks

No functional modification involved.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
6 months agodm vdo: move indexer files into sub-directory
Mike Snitzer [Thu, 8 Feb 2024 21:55:29 +0000 (15:55 -0600)]
dm vdo: move indexer files into sub-directory

The goal is to assist high-level understanding of which code is
conceptually specific to VDO's indexer.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo: remove unnecessary indexer.h includes
Matthew Sakai [Tue, 20 Feb 2024 03:23:07 +0000 (22:23 -0500)]
dm vdo: remove unnecessary indexer.h includes

Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
6 months agodm vdo: clean up scnprintf usage
Chung Chung [Mon, 19 Feb 2024 20:58:24 +0000 (15:58 -0500)]
dm vdo: clean up scnprintf usage

Ignore scnprintf return status since it is not necessary. Change
write_* functions type from int to void since we no longer return
any result. Also, clean up any code that checks or uses any scnprintf
return results.
Check uds_allocate return code which was previous ignored, return
and log error when uds_allocate failed.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Chung Chung <cchung@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
6 months agodm vdo: include <asm/current.h> to resolve current being undeclared
Mike Snitzer [Tue, 13 Feb 2024 15:51:19 +0000 (10:51 -0500)]
dm vdo: include <asm/current.h> to resolve current being undeclared

Reported when building on loongarch.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Bruce Johnston <bjohnsto@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo indexer-volume: fix missing mutex_lock in process_entry
Mike Snitzer [Sun, 11 Feb 2024 19:49:42 +0000 (14:49 -0500)]
dm vdo indexer-volume: fix missing mutex_lock in process_entry

Must mutex_lock after dm_bufio_read, before dm_bufio_read error
handling, otherwise process_entry error path will return without
volume->read_threads_mutex held. This fixes potential double
mutex_unlock.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo flush: initialize return to NULL in allocate_flush
Mike Snitzer [Sun, 11 Feb 2024 19:07:18 +0000 (14:07 -0500)]
dm vdo flush: initialize return to NULL in allocate_flush

Otherwise, error path could result in allocate_flush's subsequent
check for flush being non-NULL leading to false positive.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
6 months agodm vdo slab-depot: delete unnecessary check in allocate_components
Dan Carpenter [Fri, 9 Feb 2024 13:06:05 +0000 (16:06 +0300)]
dm vdo slab-depot: delete unnecessary check in allocate_components

This is a duplicate check so it can't be true.  Delete it.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
6 months agodm vdo memory-alloc: simplify allocations_allowed()
Mike Snitzer [Fri, 9 Feb 2024 20:14:21 +0000 (14:14 -0600)]
dm vdo memory-alloc: simplify allocations_allowed()

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo: remove internal ticket references
Susan LeGendre-McGhee [Thu, 15 Feb 2024 16:35:15 +0000 (11:35 -0500)]
dm vdo: remove internal ticket references

Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
6 months agodm vdo thread-device: rename all methods to reflect vdo-only use
Mike Snitzer [Fri, 9 Feb 2024 20:53:05 +0000 (14:53 -0600)]
dm vdo thread-device: rename all methods to reflect vdo-only use

Also moved vdo_init()'s call to vdo_initialize_thread_device_registry
next to other registry initialization.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo thread-registry: rename all methods to reflect vdo-only use
Mike Snitzer [Fri, 9 Feb 2024 20:04:34 +0000 (14:04 -0600)]
dm vdo thread-registry: rename all methods to reflect vdo-only use

Otherwise, uds_ prefix is misleading (vdo_ is the new catch-all for
code that is used by vdo-only or _both_ vdo and the indexer code).

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo thread-utils: cleanup included headers
Mike Snitzer [Fri, 9 Feb 2024 19:17:05 +0000 (13:17 -0600)]
dm vdo thread-utils: cleanup included headers

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo thread-utils: further cleanup of thread functions
Mike Snitzer [Fri, 9 Feb 2024 18:08:09 +0000 (12:08 -0600)]
dm vdo thread-utils: further cleanup of thread functions

Change thread function prefix from "uds_" to "vdo_" and fix
vdo_join_threads() to return void.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo thread-utils: remove all uds_*_mutex wrappers
Mike Snitzer [Fri, 9 Feb 2024 18:35:10 +0000 (12:35 -0600)]
dm vdo thread-utils: remove all uds_*_mutex wrappers

Just use mutex_init, mutex_lock and mutex_unlock.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo thread-utils: push uds_*_cond interface down to indexer
Mike Snitzer [Fri, 9 Feb 2024 19:06:00 +0000 (13:06 -0600)]
dm vdo thread-utils: push uds_*_cond interface down to indexer

Only used by indexer components. Also return void from
uds_init_cond(), remove uds_destroy_cond(), and fix up
all callers.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo: fold thread-cond-var.c into thread-utils
Mike Snitzer [Fri, 9 Feb 2024 15:54:53 +0000 (09:54 -0600)]
dm vdo: fold thread-cond-var.c into thread-utils

Further cleanup is needed for thread-utils interfaces given many
functions should return void or be removed entirely because they
amount to obfuscation via wrappers.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo indexer: rename uds.h to indexer.h
Mike Snitzer [Fri, 9 Feb 2024 18:16:13 +0000 (12:16 -0600)]
dm vdo indexer: rename uds.h to indexer.h

Also remove unnecessary include from funnel-queue.c.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo: rename uds-threads.[ch] to thread-utils.[ch]
Mike Snitzer [Fri, 9 Feb 2024 16:10:03 +0000 (10:10 -0600)]
dm vdo: rename uds-threads.[ch] to thread-utils.[ch]

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo indexer sparse-cache: cleanup threads_barrier code
Mike Snitzer [Fri, 9 Feb 2024 17:30:00 +0000 (11:30 -0600)]
dm vdo indexer sparse-cache: cleanup threads_barrier code

Rename 'barrier' to 'threads_barrier', remove useless
uds_destroy_barrier(), return void from remaining methods and
clean up uds_make_sparse_cache() accordingly.

Also remove uds_ prefix from the 2 remaining threads_barrier
functions.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo uds-threads: push 'barrier' down to sparse-cache
Mike Snitzer [Fri, 9 Feb 2024 17:09:14 +0000 (11:09 -0600)]
dm vdo uds-threads: push 'barrier' down to sparse-cache

The sparse-cache is the only user of the 'barrier' data structure,
so just move it private to it.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo uds-threads: eliminate uds_*_semaphore interfaces
Mike Snitzer [Fri, 9 Feb 2024 16:46:04 +0000 (10:46 -0600)]
dm vdo uds-threads: eliminate uds_*_semaphore interfaces

The implementation of thread 'barrier' data structure does not require
overdone private semaphore wrappers.  Also rename the barrier
structure's 'mutex' member (a semaphore) to 'lock'.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo: make uds_*_semaphore interface private to uds-threads.c
Mike Snitzer [Fri, 9 Feb 2024 15:54:53 +0000 (09:54 -0600)]
dm vdo: make uds_*_semaphore interface private to uds-threads.c

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo block-map: rename page state name from "UDS_FREE" to "FREE"
Mike Snitzer [Tue, 13 Feb 2024 17:04:11 +0000 (11:04 -0600)]
dm vdo block-map: rename page state name from "UDS_FREE" to "FREE"

Only used for log message, but no need for "UDS_" prefix.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
6 months agodm vdo volume-index: fix an assert statement in start_restoring_volume_sub_index()
Harshit Mogalapalli [Mon, 12 Feb 2024 10:25:04 +0000 (02:25 -0800)]
dm vdo volume-index: fix an assert statement in start_restoring_volume_sub_index()

Use "==" instead of "=" in ASSERT() statement.

Fixes: ef074a31e88e ("dm vdo: implement the volume index")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo logger: update logging to start with "device-mapper: vdo"
Mike Snitzer [Wed, 14 Feb 2024 23:25:14 +0000 (18:25 -0500)]
dm vdo logger: update logging to start with "device-mapper: vdo"

Stops short of actually using DM's various logging macros (e.g. DMERR,
DMINFO, etc) because VDO's logger isn't quite compatible with them.

Also switch emit_log_message_to_kernel() from open-coding printk with
log-level to using corresponding pr_ macro.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Bruce Johnston <bjohnsto@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo logger: switch UDS_LOG_NOTICE to be alias for UDS_LOG_INFO
Mike Snitzer [Wed, 14 Feb 2024 23:25:13 +0000 (18:25 -0500)]
dm vdo logger: switch UDS_LOG_NOTICE to be alias for UDS_LOG_INFO

Prepare to bring VDO's logging closer to DM's logging by eliminating
support for KERN_NOTICE log level (DM hasn't ever had a need for it).

Only one message in index-session.c used UDS_LOG_NOTICE, convert it to
log with uds_log_info().

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Bruce Johnston <bjohnsto@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: tweak wait_for_completion_interruptible callers
Mike Snitzer [Wed, 14 Feb 2024 15:25:39 +0000 (10:25 -0500)]
dm vdo: tweak wait_for_completion_interruptible callers

Update uds_join_threads to delay in wait_for_completion_interruptible
loop. And cleanup style nits in perform_admin_operation().

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo delta-index: fix various small nits
Mike Snitzer [Wed, 14 Feb 2024 04:57:12 +0000 (23:57 -0500)]
dm vdo delta-index: fix various small nits

Fix some needless line wrapping (given surrounding context), missing
braces and some stale or incorrect references to data structure or
function name.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo chapter_index: fix a few small nits
Mike Snitzer [Wed, 14 Feb 2024 04:57:11 +0000 (23:57 -0500)]
dm vdo chapter_index: fix a few small nits

Add missing braces and raise one function arg up a line to eliminate
line wrap.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: cleanup style for comments in structs
Mike Snitzer [Wed, 14 Feb 2024 04:57:10 +0000 (23:57 -0500)]
dm vdo: cleanup style for comments in structs

Use /* ... */ rather than /** ... */ if for no other reason than
syntax highlighting is improved (at least for me, in emacs: comments
are now red, code is yellow. Previously comments were also yellow).

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo dedupe: fix various small nits
Mike Snitzer [Wed, 14 Feb 2024 04:57:09 +0000 (23:57 -0500)]
dm vdo dedupe: fix various small nits

Add a __must_hold sparse annotation to launch_dedupe_state_change that
reflects its ASSERTION code comments about locking requirements, add
some extra braces and fix a couple typos.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo string-utils: remove unnecessary includes
Mike Snitzer [Wed, 14 Feb 2024 04:57:08 +0000 (23:57 -0500)]
dm vdo string-utils: remove unnecessary includes

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo message-stats: reformat to remove excessive newlines
Ken Raeburn [Wed, 14 Feb 2024 01:14:56 +0000 (20:14 -0500)]
dm vdo message-stats: reformat to remove excessive newlines

Signed-off-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: use #define for NO_CHAPTER and NO_CHAPTER_INDEX_ENTRY
Mike Snitzer [Wed, 7 Feb 2024 16:12:44 +0000 (11:12 -0500)]
dm vdo: use #define for NO_CHAPTER and NO_CHAPTER_INDEX_ENTRY

Avoids unconventional use of 'static const' and enum in headers.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: move encoding constants to encodings.c
Susan LeGendre-McGhee [Tue, 6 Feb 2024 02:04:22 +0000 (21:04 -0500)]
dm vdo: move encoding constants to encodings.c

Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add documentation details on zones and locking
Matthew Sakai [Wed, 7 Feb 2024 03:00:42 +0000 (22:00 -0500)]
dm vdo: add documentation details on zones and locking

Add details describing the vdo zone and thread model to the
documentation comments for major vdo components. Also added
some high-level description of the block map structure.

Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add vio life cycle details to design doc
Matthew Sakai [Sat, 3 Feb 2024 04:32:03 +0000 (23:32 -0500)]
dm vdo: add vio life cycle details to design doc

Add more documentation details for most aspects of the data_vio
read and write processes. Also correct a few minor errors and
rewrite some text for clarity.

Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add vdo documentation to device-mapper index
Matthew Sakai [Thu, 8 Feb 2024 16:39:41 +0000 (11:39 -0500)]
dm vdo: add vdo documentation to device-mapper index

Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo recovery-journal: fix sparse 'mixed bitwiseness' warning
Mike Snitzer [Tue, 6 Feb 2024 02:04:21 +0000 (21:04 -0500)]
dm vdo recovery-journal: fix sparse 'mixed bitwiseness' warning

Only one user of WRITE_FLAGS so no need to factor it out in an enum
(which causes sparse's 'mixed bitwiseness' warning).  Just use the
flags in the only consumer.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo dedupe: silence sparse warnings about locking context imbalances
Mike Snitzer [Tue, 6 Feb 2024 02:04:20 +0000 (21:04 -0500)]
dm vdo dedupe: silence sparse warnings about locking context imbalances

Annotate both open_index() and close_index() with
__must_hold(&zones->lock) to silence these sparse warnings:
 warning: context imbalance in 'close_index' - unexpected unlock
 warning: context imbalance in 'open_index' - unexpected unlock

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo data-vio: silence sparse warnings about locking context imbalances
Mike Snitzer [Tue, 6 Feb 2024 02:04:19 +0000 (21:04 -0500)]
dm vdo data-vio: silence sparse warnings about locking context imbalances

Factor wait_permit() out from acquire_permit() so that the latter
always holds the spinlock and the former always releases it.

Otherwise sparse complains about locking context imbalances due to
conditional spin_unlock in acquire_permit:
 warning: context imbalance in 'acquire_permit' - different lock contexts for basic block
 warning: context imbalance in 'vdo_launch_bio' - unexpected unlock

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: fix various blk_opf_t sparse warnings
Mike Snitzer [Tue, 6 Feb 2024 02:04:18 +0000 (21:04 -0500)]
dm vdo: fix various blk_opf_t sparse warnings

Use proper blk_opf_t type rather than unsigned int.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: fix sparse 'warning: Using plain integer as NULL pointer'
Mike Snitzer [Tue, 6 Feb 2024 02:04:17 +0000 (21:04 -0500)]
dm vdo: fix sparse 'warning: Using plain integer as NULL pointer'

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: fix sparse warnings about missing statics
Mike Snitzer [Tue, 6 Feb 2024 02:04:16 +0000 (21:04 -0500)]
dm vdo: fix sparse warnings about missing statics

Addresses various sparse warnings like:
warning: symbol 'SYMBOL' was not declared. Should it be static?

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: rename struct configuration to uds_configuration
Mike Snitzer [Tue, 30 Jan 2024 00:51:46 +0000 (19:51 -0500)]
dm vdo: rename struct configuration to uds_configuration

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: rename struct geometry to index_geometry
Mike Snitzer [Tue, 30 Jan 2024 00:51:45 +0000 (19:51 -0500)]
dm vdo: rename struct geometry to index_geometry

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo index: fix various small nits
Mike Snitzer [Sat, 27 Jan 2024 03:01:27 +0000 (22:01 -0500)]
dm vdo index: fix various small nits

Add braces around multi-line while loops and if statements. Also
remove excess newlines.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Chung Chung <cchung@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo dedupe: fix various small nits
Mike Snitzer [Sat, 27 Jan 2024 03:01:26 +0000 (22:01 -0500)]
dm vdo dedupe: fix various small nits

Remove extra blank line, mark function inline, add missing
braces, and fix a typo in a comment.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Chung Chung <cchung@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo slab-depot: fix various small nits
Mike Snitzer [Sat, 27 Jan 2024 03:01:25 +0000 (22:01 -0500)]
dm vdo slab-depot: fix various small nits

Comment typo, whitespace issues, mark function inline.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Chung Chung <cchung@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo data-vio: rename is_trim flag to is_discard
Mike Snitzer [Sat, 27 Jan 2024 02:45:31 +0000 (21:45 -0500)]
dm vdo data-vio: rename is_trim flag to is_discard

Eliminate use of "trim" in favor of "discard" since it reflects the
top-level Linux discard primative rather than the ATA specific ditto.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: rename vdo_map_to_system_error to vdo_status_to_errno
Mike Snitzer [Sat, 27 Jan 2024 02:42:29 +0000 (21:42 -0500)]
dm vdo: rename vdo_map_to_system_error to vdo_status_to_errno

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: rename uds_map_to_system_error to uds_status_to_errno
Mike Snitzer [Sat, 27 Jan 2024 02:42:28 +0000 (21:42 -0500)]
dm vdo: rename uds_map_to_system_error to uds_status_to_errno

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: slight cleanup of UDS error codes
Mike Snitzer [Sat, 27 Jan 2024 02:42:27 +0000 (21:42 -0500)]
dm vdo: slight cleanup of UDS error codes

No need to increment each UDS_ error code manually (relative to
UDS_ERROR_CODE_BASE).

Also, remove unused PRP_BLOCK_START and PRP_BLOCK_END.

Lastly, UDS_SUCCESS and VDO_SUCCESS are used interchangeably; so best
to explicitly set VDO_SUCCESS equal to UDS_SUCCESS.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo block-map: rename struct cursors member to 'completion'
Mike Snitzer [Sat, 27 Jan 2024 02:35:49 +0000 (21:35 -0500)]
dm vdo block-map: rename struct cursors member to 'completion'

'completion' is more informative name for a 'struct vdo_completion'
than 'parent'.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo block-map: avoid extra dereferences to access vdo object
Mike Snitzer [Sat, 27 Jan 2024 02:35:48 +0000 (21:35 -0500)]
dm vdo block-map: avoid extra dereferences to access vdo object

The vdo_page_cache's 'vdo' is the same as the block_map's vdo
instance, so use that to save 2 extra dereferences.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo block-map: remove extra vdo arg from initialize_block_map_zone
Mike Snitzer [Sat, 27 Jan 2024 02:35:47 +0000 (21:35 -0500)]
dm vdo block-map: remove extra vdo arg from initialize_block_map_zone

The block_map is passed to initialize_block_map_zone, but the
block_map's vdo member is already initialized with the same vdo
instance, so just use it.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo block-map: use uds_log_ratelimit() rather than open code it
Mike Snitzer [Sat, 27 Jan 2024 02:35:46 +0000 (21:35 -0500)]
dm vdo block-map: use uds_log_ratelimit() rather than open code it

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo block-map: fix a few small nits
Mike Snitzer [Sat, 27 Jan 2024 02:35:45 +0000 (21:35 -0500)]
dm vdo block-map: fix a few small nits

Rename 'pages' to 'num_pages' in distribute_page_over_waitq().
Update assert message in validate_completed_page() to model others.
Tweak line-wrapping on a comment that was needlessly long.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: use a proper Makefile for dm-vdo
Mike Snitzer [Sat, 27 Jan 2024 02:18:33 +0000 (21:18 -0500)]
dm vdo: use a proper Makefile for dm-vdo

Requires moving dm-vdo-target.c into drivers/md/dm-vdo/

This change adds a proper drivers/md/dm-vdo/Makefile and eliminates
the abnormal use of patsubst in drivers/md/Makefile -- which was the
cause of at least one build failure that was reported by the upstream
build bot.

Also, split out VDO's drivers/md/dm-vdo/Kconfig and include it from
drivers/md/Kconfig

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: fix how dm_kcopyd_client_create() failure is checked
Mike Snitzer [Fri, 1 Dec 2023 00:54:56 +0000 (19:54 -0500)]
dm vdo: fix how dm_kcopyd_client_create() failure is checked

dm_kcopyd_client_create() returns an ERR_PTR so its return must be
checked with IS_ERR().

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Chung Chung <cchung@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo int-map: remove unused parameter from vdo_int_map_create
Bruce Johnston [Mon, 20 Nov 2023 22:29:56 +0000 (17:29 -0500)]
dm vdo int-map: remove unused parameter from vdo_int_map_create

Reviewed-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Bruce Johnston <bjohnsto@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo int-map: rename functions to use a common vdo_int_map preamble
Bruce Johnston [Mon, 20 Nov 2023 22:29:55 +0000 (17:29 -0500)]
dm vdo int-map: rename functions to use a common vdo_int_map preamble

Reviewed-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Bruce Johnston <bjohnsto@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo dedupe: switch to using int-map instead of pointer-map
Bruce Johnston [Mon, 20 Nov 2023 22:29:54 +0000 (17:29 -0500)]
dm vdo dedupe: switch to using int-map instead of pointer-map

Use get_unaligned_le64() on the hash lock's record name to serve as
the key to use with the int hash-map.

Switching to using int hash-map removes the only consumer of pointer
hash-map, as such it is removed.

Reviewed-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Bruce Johnston <bjohnsto@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo wait-queue: rename to vdo_waitq_dequeue_waiter
Mike Snitzer [Mon, 20 Nov 2023 22:29:20 +0000 (17:29 -0500)]
dm vdo wait-queue: rename to vdo_waitq_dequeue_waiter

Rename vdo_waitq_dequeue_next_waiter to vdo_waitq_dequeue_waiter.  The
"next" aspect of returned waiter is implied. "next" also isn't
informative ("oldest" would be). Removing "next_" adds symmetry to
vdo_waitq_enqueue_waiter().

Also fix whitespace and comments from previous waitq commit.

Reviewed-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo block-map: optimize enter_zone_read_only_mode
Mike Snitzer [Mon, 20 Nov 2023 22:29:19 +0000 (17:29 -0500)]
dm vdo block-map: optimize enter_zone_read_only_mode

Rather than incrementally dequeue from the zone->flush_waiters
vdo_wait_queue, simply re-initialize it.

Reviewed-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo wait-queue: optimize vdo_waitq_dequeue_matching_waiters
Mike Snitzer [Mon, 20 Nov 2023 22:29:18 +0000 (17:29 -0500)]
dm vdo wait-queue: optimize vdo_waitq_dequeue_matching_waiters

Remove temporary 'matched_waiters' waitq and just enqueue matched
waiters directly to the caller provided 'matched_waitq'.

Reviewed-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo wait-queue: remove unused debug function vdo_waitq_get_next_waiter
Mike Snitzer [Mon, 20 Nov 2023 22:29:17 +0000 (17:29 -0500)]
dm vdo wait-queue: remove unused debug function vdo_waitq_get_next_waiter

Reviewed-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo wait-queue: add proper namespace to interface
Mike Snitzer [Mon, 20 Nov 2023 22:29:16 +0000 (17:29 -0500)]
dm vdo wait-queue: add proper namespace to interface

Rename various interfaces and structs associated with vdo's wait-queue,
e.g.: s/wait_queue/vdo_wait_queue/, s/waiter/vdo_waiter/, etc.

Now all function names start with "vdo_waitq_" or "vdo_waiter_".

Reviewed-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo io-submitter: rename to vdo_submit_vio and submit_data_vio
Mike Snitzer [Fri, 25 Aug 2023 19:16:17 +0000 (15:16 -0400)]
dm vdo io-submitter: rename to vdo_submit_vio and submit_data_vio

Rename process_vio_io() to vdo_submit_vio(), and process_data_vio_io() to
submit_data_vio().

Reviewed-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo io-submitter: rename to vdo_submit_data_vio
Mike Snitzer [Fri, 25 Aug 2023 18:52:05 +0000 (14:52 -0400)]
dm vdo io-submitter: rename to vdo_submit_data_vio

Rename submit_data_vio_io() to vdo_submit_data_vio().

Reviewed-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo io-submitter: rename to vdo_submit_flush_vio
Mike Snitzer [Fri, 25 Aug 2023 18:43:30 +0000 (14:43 -0400)]
dm vdo io-submitter: rename to vdo_submit_flush_vio

Rename submit_flush_vio() to vdo_submit_flush_vio().

Reviewed-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo io-submitter: rename to vdo_submit_metadata_vio
Mike Snitzer [Fri, 25 Aug 2023 18:36:46 +0000 (14:36 -0400)]
dm vdo io-submitter: rename to vdo_submit_metadata_vio

Rename submit_metadata_vio() to vdo_submit_metadata_vio().

Reviewed-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo io-submitter: remove get_bio_sector
Mike Snitzer [Fri, 25 Aug 2023 16:42:25 +0000 (12:42 -0400)]
dm vdo io-submitter: remove get_bio_sector

Just open-code access to bio's sector.

Reviewed-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
7 months agodm vdo: add MAINTAINERS file entry
Matthew Sakai [Fri, 17 Nov 2023 02:32:39 +0000 (21:32 -0500)]
dm vdo: add MAINTAINERS file entry

Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: enable configuration and building of dm-vdo
Matthew Sakai [Fri, 17 Nov 2023 02:28:35 +0000 (21:28 -0500)]
dm vdo: enable configuration and building of dm-vdo

dm-vdo targets are not supported for 32-bit configurations. A vdo target
typically requires 1 to 1.5 GB of memory at any given time, which is likely
a large fraction of the addressable memory of a 32-bit system. At the same
time, the amount of addressable storage attached to a 32-bit system may not
be large enough for deduplication to provide much benefit. Because of these
concerns, 32-bit platforms are deemed unlikely to benefit from using a vdo
target, so dm-vdo is targeted only at 64-bit platforms.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: John Wiele <jwiele@redhat.com>
Signed-off-by: John Wiele <jwiele@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add the top-level DM target
Matthew Sakai [Fri, 17 Nov 2023 02:24:06 +0000 (21:24 -0500)]
dm vdo: add the top-level DM target

This adds the dm-vdo target.

The dm-vdo target provides inline deduplication, compression, and
zero-block elimination, allowing applications to consume less actual
storage than a normal target. By layering it with other device mapper
targets, it can add these features to any storage stack. It can also
provide a common deduplication pool for groups of targets. The vdo target
does not protect against data corruption, relying instead on integrity
protection of the storage below it.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Co-developed-by: Bruce Johnston <bjohnsto@redhat.com>
Signed-off-by: Bruce Johnston <bjohnsto@redhat.com>
Co-developed-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add debugging support
Matthew Sakai [Fri, 17 Nov 2023 02:12:14 +0000 (21:12 -0500)]
dm vdo: add debugging support

Add support for dumping detailed vdo state to the kernel log via a dmsetup
message. The dump code is not thread-safe and is generally intended for use
only when the vdo is hung.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Co-developed-by: Bruce Johnston <bjohnsto@redhat.com>
Signed-off-by: Bruce Johnston <bjohnsto@redhat.com>
Co-developed-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add sysfs support for setting parameters and fetching stats
Matthew Sakai [Fri, 17 Nov 2023 02:11:23 +0000 (21:11 -0500)]
dm vdo: add sysfs support for setting parameters and fetching stats

Add data and methods setting run time parameters via sysfs, and to
make state and statistics information available through sysfs.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Co-developed-by: Bruce Johnston <bjohnsto@redhat.com>
Signed-off-by: Bruce Johnston <bjohnsto@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add statistics reporting
Matthew Sakai [Fri, 17 Nov 2023 02:10:00 +0000 (21:10 -0500)]
dm vdo: add statistics reporting

Add data and methods to report statisics.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add the on-disk formats and marshalling of vdo structures
Matthew Sakai [Fri, 17 Nov 2023 02:09:25 +0000 (21:09 -0500)]
dm vdo: add the on-disk formats and marshalling of vdo structures

Add data and methods for marshalling and unmarshalling the persistent
metadata.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add the primary vdo structure
Matthew Sakai [Fri, 17 Nov 2023 02:08:47 +0000 (21:08 -0500)]
dm vdo: add the primary vdo structure

Add the data and methods that manage the dm-vdo target itself. This
includes the overall state of the target and its threads, the state of
the logical volumes, startup, shutdown, and statistics.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add repair of damaged vdo volumes
Matthew Sakai [Fri, 17 Nov 2023 02:08:05 +0000 (21:08 -0500)]
dm vdo: add repair of damaged vdo volumes

When a vdo is restarted after a crash, it will automatically attempt to
recover from its journals.

If a vdo encounters an unrecoverable error, it will enter read-only mode.
This mode indicates that some previously acknowledged data may have been
lost. The vdo may be instructed to rebuild as best it can in order to
return to a writable state. Although some data may be lost, this process
will ensure that the vdo's own metadata is self-consistent.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add the recovery journal
Matthew Sakai [Fri, 17 Nov 2023 02:07:26 +0000 (21:07 -0500)]
dm vdo: add the recovery journal

The recovery journal is used to amortize updates across the block map and
slab depot. Each write request causes an entry to be made in the journal.
Entries are either "data remappings" or "block map remappings." For a data
remapping, the journal records the logical address affected and its old and
new physical mappings. For a block map remapping, the journal records the
block map page number and the physical block allocated for it (block map
pages are never reclaimed, so the old mapping is always 0). Each journal
entry and the data write it represents must be stable on disk before the
other metadata structures may be updated to reflect the operation.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: implement the block map page cache
Matthew Sakai [Fri, 17 Nov 2023 02:06:33 +0000 (21:06 -0500)]
dm vdo: implement the block map page cache

The set of leaf pages of the block map tree is too large to fit in memory,
so each block map zone maintains a cache of leaf pages. This patch adds the
implementation of that cache.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add the block map
Matthew Sakai [Fri, 17 Nov 2023 02:05:22 +0000 (21:05 -0500)]
dm vdo: add the block map

The block map contains the logical to physical mapping. It can be thought
of as an array with one entry per logical address. Each entry is 5 bytes:
36 bits contain the physical block number which holds the data for the
given logical address, and the remaining 4 bits are used to indicate the
nature of the mapping. Of the 16 possible states, one represents a logical
address which is unmapped (i.e. it has never been written, or has been
discarded), one represents an uncompressed block, and the other 14 states
are used to indicate that the mapped data is compressed, and which of the
compression slots in the compressed block this logical address maps to.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add the slab depot
Matthew Sakai [Fri, 17 Nov 2023 02:00:27 +0000 (21:00 -0500)]
dm vdo: add the slab depot

Add the data and methods that implement the slab_depot that manages
the allocation of slabs of blocks added by the preceding patches.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add the block allocators and physical zones
Matthew Sakai [Fri, 17 Nov 2023 01:58:33 +0000 (20:58 -0500)]
dm vdo: add the block allocators and physical zones

Each slab is independent of every other. They are assigned to "physical
zones" in round-robin fashion. If there are P physical zones, then slab n
is assigned to zone n mod P. The set of slabs in each physical zone is
managed by a block allocator.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add the slab summary
Matthew Sakai [Fri, 17 Nov 2023 01:57:50 +0000 (20:57 -0500)]
dm vdo: add the slab summary

The slab depot maintains an additional small data structure, the "slab
summary," which is used to reduce the amount of work needed to come back
online after a crash. The slab summary maintains an entry for each slab
indicating whether or not the slab has ever been used, whether it is clean
(i.e. all of its reference count updates have been persisted to storage),
and approximately how full it is. During recovery, each physical zone will
attempt to recover at least one slab, stopping whenever it has recovered a
slab which has some free blocks. Once each zone has some space (or has
determined that none is available), the target can resume normal operation
in a degraded mode. Read and write requests can be serviced, perhaps with
degraded performance, while the remainder of the dirty slabs are recovered.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
7 months agodm vdo: add slab structure, slab journal and reference counters
Matthew Sakai [Fri, 17 Nov 2023 01:56:30 +0000 (20:56 -0500)]
dm vdo: add slab structure, slab journal and reference counters

Most of the vdo volume belongs to the slab depot. The depot contains a
collection of slabs. The slabs can be up to 32GB, and are divided into
three sections. Most of a slab consists of a linear sequence of 4K blocks.
These blocks are used either to store data, or to hold portions of the
block map (see subsequent patches). In addition to the data blocks, each
slab has a set of reference counters, using 1 byte for each data block.
Finally each slab has a journal. Reference updates are written to the slab
journal, which is written out one block at a time as each block fills. A
copy of the reference counters is kept in memory, and are written out a
block at a time, in oldest-dirtied-order whenever there is a need to
reclaim slab journal space. The journal is used both to ensure that the
main recovery journal (see subsequent patches) can regularly free up space,
and also to amortize the cost of updating individual reference blocks.

This patch adds the slab structure as well as the slab journal and
reference counters.

Co-developed-by: J. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: J. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: Michael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: Michael Sclafani <dm-devel@lists.linux.dev>
Co-developed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>