VDO COMPLETIONS.(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ vdo completions.(9) πŸŽ€

Kernel API Manual β€” okay bestie, this is the vdo completions.(9) page, and it's literally all about how completions vibe in vdo. Let's get into it πŸ’…

Most of vdo's data structures are lock free, each either belonging to a single "zone," or divided into a number of zones whose accesses to the structure do not overlap. During normal operation, at most one thread will be operating in any given zone. Each zone has a vdo_work_queue which holds vdo_completions that are to be run in that zone. A completion may only be enqueued on one queue or operating in a single zone at a time.

At each step of a multi-threaded operation, the completion performing the operation is given a callback, error handler, and thread id for the next step. A completion is "run" when it is operating on the correct thread (as specified by its callback_thread_id). If the value of its result field is an error (i.e. not VDO_SUCCESS), the function in its error_handler will be invoked. If the error_handler is NULL, or there is no error, the function set as its callback will be invoked.

Generally, a completion will not be run directly, but rather will be "launched." In this case, it will check whether it is operating on the correct thread. If it is, it will run immediately. Otherwise, it will be enqueued on the vdo_work_queue associated with the completion's callback_thread_id. When it is dequeued, it will be on the correct thread, and will get run.

In some cases, the completion should get queued instead of running immediately, even if it is being launched from the correct thread. This is usually in cases where there is a long chain of callbacks, all on the same thread, which could overflow the stack. In such cases, the completion's requeue field should be set to true. Doing so will skip the current thread check and simply enqueue the completion. slay, no stack overflow era πŸ¦‹

A completion may be "finished," in which case its complete field will be set to true before it is next run.

🚨 It is a bug to attempt to set the result or re-finish a finished completion. Like, genuinely a bug β€” don't do it.

Because a completion's fields are not safe to examine from any thread other than the one on which the completion is currently operating, this field is used only to aid in detecting programming errors. It can not be used for cross-thread checking on the status of an operation.

A completion must be "reset" before it can be reused after it has been finished. Resetting will also clear any error from the result field. iconic cleanup behavior, honestly ✨


🌈 SEE ALSO 🌈

xoxo, your kernel bestie πŸ’– β€” source: ./drivers/md/dm-vdo, date: October 2026.

πŸ“¦ where this page comes from