Commit Graph
9444 Commits
Author SHA1 Message Date
Gleb Chesnokov e467b375e3 kunit: Cover task management across ACG reassignment
Issue #367 reports a TM thread dereferencing sess->acg while the session
reassignment path temporarily clears it. Add private fixtures covering
all black_hole modes for teardown TM functions, mode changes after real
reassignment, and the unchanged-group path.

Invoke the TM reader from the allocation stub during reassignment and
check command state, drop policy and event delivery for all five modes.
Keep the old and new modes equal in this case so that its expected policy
is unambiguous. The regression runs without SKIP and may crash the test
VM before a production fix; document this execution requirement.

Expose only private test entry points and task-scoped redirects; normal
build behavior is unchanged.

Link: https://github.com/SCST-project/scst/issues/367
2026-10-16 14:46:19 +03:00
Gleb Chesnokov 21567d8ce6 .github/workflows: Limit RPM builds and cancel outdated PR runs
Build RPM packages only on pushes to master and remove the manual package
workflow trigger. Keep DEB checks on pull requests and retain the rolling
master publication with its current-head checks and release serialization.

Cancel outdated runs of the same pull request within each CI workflow.
Give other events a separate group per run so master package builds and
publication are not interrupted by newer pushes. Keep the full regression
matrix and all build and test steps unchanged.
2026-10-15 20:00:26 +03:00
Gleb Chesnokov 555826aaa5 .github/workflows: Run KUnit and Ginkgo in disposable VMs
Build kernel-matched images on GitHub-hosted runners and execute tests
under an external QEMU supervisor. Run KUnit and Ginkgo in independent
jobs that each build and test SCST. Keep guest images local to each job
and upload build logs and test reports.

Capture serial logs outside the guests, require complete matching
reports, and bound guest execution independently of kernel health.
Exercise guest panic and timeout handling before KUnit. Give Ginkgo an
isolated iSCSI peer and disposable block storage.

Print native test output and summaries in the job log. On failure, include
supervisor errors, kernel diagnostics and bounded serial tails while
retaining complete artifacts and the original test command exit status.

Select basic management and smoke SCSI/I/O tests on both transports for
pull requests. Run every Ginkgo spec after pushes to master and on manual
runs. Pass the label filter into the guest and require both transport
reports to confirm the requested selection.
2026-10-15 20:00:26 +03:00
Gleb Chesnokov b39d5ecb94 scst_lib: Bound UNMAP parsing by the parameter transfer
The UNMAP parser reads the descriptor length before checking that the
parameter header is present, and bounds descriptor reads by the CDB
length without checking the available SG data. A nonzero CDB length with
no buffer also succeeds silently. Reject short headers and transfers with
PARAMETER LIST LENGTH ERROR before reading any parameter data, while
preserving the zero-length command as a no-op.

SBC-3 section 5.26.2 requires an incomplete final UNMAP descriptor to be
ignored. The current multiple-of-16 check instead rejects the entire
command. Parse only complete descriptors within both the advertised
descriptor length and the CDB parameter length, as Linux target does.
Bound allocation and traversal by that same descriptor count.

Keep the existing KUnit expectations and enable the six short-transfer
cases previously skipped to avoid out-of-bounds reads. Add coverage for
zero-length CDBs with extra SG data, truncated headers across SG entries,
partial final descriptors and oversized descriptor-length fields. Fill
input descriptors independently of the expected output count.

Add shared Ginkgo cases over scst_local and TCP iSCSI using temporary
thin-provisioned fileio LUNs. Check target sense for short headers and
read back seeded ranges and guards to detect ignored valid descriptors,
unwanted discards and incomplete descriptors processed as complete ones.
Probe hole punching before export because fileio does not promise LBPRZ.
Keep SG_IO and CDB transfer lengths equal in these integration cases;
missing or split SG data remains covered by KUnit.

Fixes: 3b57904da6 ("Unify parsing of descriptors-based and internal commands")
2026-10-14 21:54:52 +03:00
Gleb Chesnokov 57b5a80a59 scst_event: Count delivered events only once
GET_NEXT_EVENT removes a delivered event from queued_events_cnt when it
moves the event to processing_events_list. If the consumer does not
acknowledge that event before its timeout, scst_event_timeout_fn()
decrements the same counter again. This can make the count negative or
undercount other queued events, weakening the queue admission limit.

Clear the queued-counter pointer when delivery moves the event, under
scst_event_mutex, and decrement it on timeout only while it is present.
Keep the existing delivered-timeout expectations. Extend KUnit coverage
to expire an undelivered event after a copy fault, drain the remaining
queue, and acknowledge another processing event after a timeout.

Fixes: 297d268a7a ("SCST events infrastructure")
2026-10-14 21:54:52 +03:00
Gleb Chesnokov 520017bdec scstadmin: Omit dynamic attribute values from update messages
Dynamic attributes can contain CHAP secrets. Administrative update,
duplicate, removal and debug messages currently print their values,
exposing them in captured command output.

Report the operation and attribute name without the value in both
the CLI and Perl library. Keep metadata-driven discovery and explicit
privileged queries unchanged.

Add a Ginkgo case that checks add, duplicate, remove, missing-value
and debug output through the real scstadmin. Query the newly created
attribute explicitly to confirm that the synthetic secret was stored
before checking that the update output omits it.

Link: https://github.com/SCST-project/scst/issues/91
2026-10-14 21:54:52 +03:00
Gleb Chesnokov e5e7f3a004 scstadmin: Restrict saved configurations to the effective user
Saved configurations contain CHAP secrets. Opening a new output with
the caller's umask can make those secrets readable by other users.
Truncating an existing readable file also leaves its access mode
unchanged while the new contents are written.

Create outputs with mode 0600 and restrict existing files before
truncating them. Require an owned regular file, reject symbolic links
and report preparation, flush, sync and close failures. Keep the
original secret in the configuration because CHAP needs it.

Add Ginkgo coverage through the real scstadmin for new and existing
0644, 0640 and 0600 outputs and for symlink rejection. Run the writer
with umask 022 and probe access after dropping to UID/GID 65534, using
public and private control files to validate the probe itself.

Link: https://github.com/SCST-project/scst/issues/91
2026-10-14 21:54:52 +03:00
Gleb Chesnokov 9d43596c2b scst_user: Remove obsolete licensing contact from rejection message
The unsupported-license diagnostic directs users to an obsolete
mailbox. Remove that invitation without inventing a replacement
contact or changing the licensing policy.

Keep the accepted license strings and the EPERM result unchanged.
This changes only the diagnostic text.

Link: https://github.com/SCST-project/scst/issues/240
2026-10-14 21:54:52 +03:00
Gleb Chesnokov 9b56cadc3e scst_targ: Accept direction flags for zero-length REWIND
A tape REWIND transfers no data, but its transport can supply Read or
Write flags with zero expected lengths. RFC 7143 section 11.3.1 permits
either or both flags in this case. The parser rejects the mismatch
before the command reaches the device handler.

Allow the mismatch only for tape REWIND with no decoded or expected
input or output data. Preserve the rejection of nonzero transfers and
the existing TEST UNIT READY exception.

Update the CDB KUnit cases to accept READ, WRITE and BIDI flags with
zero lengths. Cover nonzero input and output lengths as rejection
cases through the real command parser.

Link: https://github.com/SCST-project/scst/issues/278
2026-10-14 21:54:52 +03:00
Gleb Chesnokov 8bcebe6361 scst_targ: Bound UNMAP overlap by the descriptor count
The UNMAP parser allocates a counted descriptor array without a
terminating entry. Walking until a zero-block descriptor can read
beyond that array or miss valid ranges after a zero-block entry.

Bound the overlap walk by cmd_data_descriptors_cnt and skip each
zero-block entry individually. This keeps all valid ranges in the
atomic-command exclusion check without examining unpublished entries.

The existing UNMAP KUnit cases cover the count boundary, zero-block
entries and both command argument orders using allocated guard storage.

Link: https://github.com/SCST-project/scst/issues/328
2026-10-14 21:54:52 +03:00
Gleb Chesnokov 3f3dd3b57f tests: Exercise fileio FUA and cache commands across transports
The fio profile uses a final explicit synchronization, which can hide
an ignored FUA from issue #395. Send WRITE(10/16) FUA commands followed
by readback before any later cache command instead.

Share the protocol cases between local and iSCSI fixtures. Cover explicit
SYNCHRONIZE CACHE(10/16) ranges, zero-length-to-end and IMMED, using
nonzero offsets and one-block/cross-page transfers on sparse owned files.
Cover buffered synchronous/asynchronous I/O and asynchronous direct I/O
with 512/4096-byte sectors. Reject direct synchronous profiles before
creating a backing file: vdisk_fileio does not support that combination.
Add write-through and nonvolatile-cache FUA controls, keeping them out
of the separate unfixed commandless cache-bypass path.

Unit-test literal CDB bytes, range overflow, command order, data phases,
failed commands, corrupt readback and backend profile attributes without
storage access. These tests check the command contract and payload;
persistence after a crash remains a separate test-harness task.

Link: https://github.com/SCST-project/scst/issues/395
2026-10-14 17:39:14 +03:00
Gleb Chesnokov edb1a66d64 kunit: Check queued VDISK sync ownership and failure paths
The issue #394 fix moves sync into sysfs work. A timed-out store may
return while that work still owns a device reference, so the handler can
disappear before backend lookup.

Exercise the real store and callback with a task-local executor, real
work allocation and device krefs. Cover allocation, suspend and backend
failures, successful and delayed completion, and handler removal
before delayed work runs. Check reference balance, suspend/resume
pairing and lockdep assertions at backend entry.

Use native task-scoped stubs at the core queue and suspension
boundaries; normal builds compile them out. Acquire scst_mutex directly
through the production callback. No synthetic device enters a real SCST
queue, and a delayed kobject release is joined before its independent
allocation and module reference are released; incomplete release is
retained. These deterministic ordering tests do not simulate concurrent
teardown or power loss.

Link: https://github.com/SCST-project/scst/issues/394
2026-10-14 17:39:14 +03:00
Gleb Chesnokov 8c4e44fca9 kunit: Cover VDISK FUA decoding and cache command completion
Issue #395 combined an advanced write offset, an incorrect flush end,
missing asynchronous FUA propagation and an explicit-flush bypass for
direct I/O. The existing backend tests supplied parsed parameters and
covered only successful queued completion.

Decode WRITE(10/12/16/32) through the core and handler parsers, including
large LBAs, FUA controls and both sector sizes. Check SYNCHRONIZE CACHE
range coverage, zero-length-to-end semantics, errors and IMMED ordering
with its temporary command reference. Also exercise commandless direct
flushes, queued FUA errors and residuals, and short-write-before-flush
ordering. Add the detached-handler guard case for issue #394.

Use a zero-length data buffer for cache commands. Their core parser leaves
data_len zero and vdisk flushes to the end of the device, so require the
flush to cover the CDB range without rejecting that wider flush.

The private fixture records filesystem calls and completion ordering;
it does not claim persistence across a crash. Keep the existing skips
for the separate commandless cache-bypass defect.

Link: https://github.com/SCST-project/scst/issues/394
Link: https://github.com/SCST-project/scst/issues/395
2026-10-14 17:39:14 +03:00
Gleb Chesnokov 3d069d3ee0 tests: Cover fileio sync across backend detach and reactivation
The sysfs sync regression in issue #394 originates in
commit 530af782ed ("scst_vdisk: Add 'sync' sysfs attribute").
It dereferenced a closed file. Require a management rejection for inactive
devices, the last detach and ALUA states that close the backend, then
verify recovery.

Remove only the fixture device's internal copy-manager mappings when
checking the last attachment: an external LUN count alone does not prove
that the backend is closed. Use an explicit local session for successful
sync and preserve unrelated devices. Put session LUNs in an explicit
initiator group because scstadmin does not report the default group map
in its session listing.

Drop the temporary known-crash label, opt-in setting and example filter.
The inactive-sync regression now belongs to the default basic selection.

Link: https://github.com/SCST-project/scst/issues/394
2026-10-14 17:39:14 +03:00
Gleb Chesnokov d2a269a9f7 scst_vdisk: Do not skip explicit flushes for direct I/O
Setting o_direct causes vdisk_fsync() to skip FUA and SYNCHRONIZE CACHE.
Bypassing the page cache does not make data persistent in the backing
device's volatile cache. Direct I/O still needs explicit synchronization.
Moreover, fileio uses o_direct only in its asynchronous path: synchronous
writes, including the DIF fallback, remain buffered despite the flag.

The o_direct flush bypass was added by the 2007 cleanup of vdisk_fsync().
Remove it so that an explicit flush reaches the backend regardless of the
I/O mode. Preserve the write-through, non-volatile cache and nullio cases.

Fixes: 6e1cb95cce ("Minor cleanups")
Link: https://github.com/SCST-project/scst/issues/395
2026-10-14 17:39:14 +03:00
Gleb Chesnokov cceb3b7197 scst_vdisk: Honor FUA in asynchronous fileio writes
With async=1, fileio_exec_write() returns through fileio_exec_async()
before reaching its FUA flush. The asynchronous path only requests
IOCB_DSYNC for write-through devices and ignores the command's FUA bit.
A write-back device can consequently report a successful FUA write before
the data is persistent, for both buffered and direct I/O.

This has been the case since asynchronous fileio support was introduced
in 2018. Request IOCB_DSYNC for FUA writes as well as write-through writes
so that the filesystem performs the synchronization before completing
the I/O. Preserve the explicit nv_cache override and leave reads and
ordinary write-back writes unchanged.

Fixes: d84fc0783d ("vdisk_fileio: Add support for asynchronous I/O processing")
Link: https://github.com/SCST-project/scst/issues/395
2026-10-14 17:39:14 +03:00
Gleb Chesnokov 6d4751538b scst_vdisk: Use filesystem synchronization for fileio flushes
Writing and waiting for dirty pages does not guarantee that the data can
be recovered after a crash. For example, a write into a sparse backing
file can also require an allocation or journal update, and the backing
device can still hold the data in a volatile write cache. A successful
FUA or SYNCHRONIZE CACHE must not acknowledge only page writeback.

The 2009 Linux 2.6.32 port replaced sync_page_range(), which also performed
metadata synchronization, with filemap_write_and_wait_range(). The
alternative generic_write_sync() was left disabled; it would also be
insufficient for an ordinary write-back file because it checks O_DSYNC.

Use vfs_fsync_range() with datasync enabled to let the filesystem persist
the data and the metadata needed to retrieve it, including any required
backend flush. Keep the existing range, DIF-tag handling and SCSI error
reporting. The API is available in all kernels in the nightly matrix.

Remove the unused writeback test boundary and its stub. The private file
operations now record filesystem synchronization directly, so a missing
fsync still fails the existing flush-count assertions.

Fixes: 2b5833d90e ("Update for 2.6.32 + fix context of vdisk_t10_dev_id_rwlock")
Link: https://github.com/SCST-project/scst/issues/395
2026-10-14 17:39:14 +03:00
Gleb Chesnokov ce9819b847 scst_vdisk: Convert the flush length to an inclusive end offset
__vdisk_fsync_fileio() receives an offset and a length but passes the
length as the last byte to filemap_write_and_wait_range(). At nonzero
LBAs this can truncate or invert the range and report success without
writing the requested pages. This affects FUA, SYNCHRONIZE CACHE and
file-backed DIF tags even when the starting offset is correct.

The Linux 2.6.32 update in 2009 replaced sync_page_range(), which took a
length, with filemap_write_and_wait_range(), which takes an inclusive end
offset, without converting the argument.

Calculate the last byte as loff + len - 1. Treat an empty range as a no-op
so that a zero-length flush cannot turn into an end offset of -1.

Fixes: 2b5833d90e ("Update for 2.6.32 + fix context of vdisk_t10_dev_id_rwlock")
Link: https://github.com/SCST-project/scst/issues/395
2026-10-14 17:39:14 +03:00
Gleb Chesnokov 01bdcc047d scst_vdisk: Flush FUA writes from the original offset
fileio_exec_write() passes its local loff to scst_writev(), which advances
it by the number of bytes written. Using that offset for the subsequent
FUA flush starts the range after the data instead of at its beginning.
The command can therefore complete without synchronizing its writes.

The 2011 opcode dispatch refactoring moved the flush into the write
function, where loff was already advanced between I/O batches. The 2012
zero-copy change then passed &loff instead of &fd->f_pos to vfs_writev(),
making the offset wrong even for a write completed in one call.

Use the unchanged command offset for the flush, including after short
writes and errors. Keep the working offset for advancing through the I/O.

Fixes: 63a6094cad ("Eliminate the blockio / fileio / nullio if-statements in vdisk_do_job() and the READ/WRITE functions called from that function. Convert the opcode switch in vdisk_*do_job() to an array with function pointers.")
Fixes: f742ae018e ("scst_vdisk: Add zero-copy file I/O readsupport")
Link: https://github.com/SCST-project/scst/issues/395
2026-10-14 17:39:14 +03:00
Gleb Chesnokov 6a4f85e6eb scst_vdisk: Protect the backend during sysfs sync
Writing to the sync attribute after the last target device has detached,
or while the virtual device is inactive, dereferences a NULL file pointer.
The blockio branch likewise passes a missing block device to the flush
helper. The sync attribute was introduced in 2015 without checking whether
the backend was open or serializing against its release.

Run the operation through the SCST sysfs work mechanism and keep a device
reference until it finishes. Suspend command and task management activity
to exclude backend reopen from MODE SELECT and resets. Hold scst_mutex and
the ALUA lock across the open check and flush to exclude detach, explicit
activation and ALUA transitions. This also closes the race that a NULL
check alone would leave behind.

Activity remains globally suspended until the flush completes, so a slow
backend can delay commands to other devices as well.

Return -ENOMEDIUM for a closed backend instead of opening an inactive
device. Preserve the nullio no-op and the existing fileio/blockio flush
selection. The sysfs work mechanism avoids taking scst_mutex directly in
a sysfs callback and provides the usual -EAGAIN completion protocol.

A device kobject reference does not keep the handler attached after the
sysfs store returns. Check dh_priv under scst_mutex as well and return
-ENODEV if handler teardown won the race with the queued work.

Keep backend dispatch in a private helper so KUnit can exercise it with
task-scoped stubs on an unregistered device. Enable the existing closed-
backend cases without queueing a synthetic device to the sysfs thread.

Fixes: 530af782ed ("scst_vdisk: Add 'sync' sysfs attribute")
Link: https://github.com/SCST-project/scst/issues/394
2026-10-14 17:39:14 +03:00
Gleb Chesnokov a246e3fd2a kunit: Add composite runtime labels
Allow named sets of base labels and exact suite names in one TOML file.
Keep KUNIT_LABEL as the selection interface and combine overlapping sets
without running a suite twice. Include an IO set for CDB, UNMAP and VDISK.

Share expansion between source listing and runtime module selection.
Validate requested sets against the supplied module manifests before any
module operation, then load their owners and dependencies as before.
Reject namespace conflicts, nested sets and incomplete selections.

List descriptions and expanded suites without a build or loaded modules.
Allow an alternate file through --label-config, record selected definitions
in reports, and cover source listing, configuration and module ordering.
2026-10-14 16:30:27 +03:00
Gleb Chesnokov 5144a3c3e2 kunit: Read suite results from debugfs
Read and preserve the native KTAP document for each suite after its run
write completes, under the same operation timeout. Validate the document
identity, plan and completeness independently of the kernel log.

Keep kernel log capture for diagnostics, retained fixtures and unexpected
execution. Preserve the stop and module ownership rules, and cover result
read failures, parameter diagnostics and complete results with an Oops.
2026-10-14 16:30:27 +03:00
Gleb Chesnokov 95781cb18f scst/include/backport.h: Fix Ubuntu 24.04 allocation helper backports
Ubuntu 24.04 kernel 6.8.0-147 includes default_gfp() and the typed
allocation helpers. The version checks only account for mainline and
selected stable releases, so backport.h redefines __default_gfp(),
default_gfp() and __alloc_flex(). The package build fails while compiling
scst_copy_mgr.o with -Werror.

Add an explicit Ubuntu 6.8 ABI boundary to the existing version checks.
The helpers are absent from 6.8.0-146 and present in 6.8.0-147. Apply the
same boundary to __alloc_objs() and document the Ubuntu backport commits.

Limit the exception to ABIs 147 through 998. Ubuntu recommends ABI 999
for custom builds, which may use older sources without these helpers.
Derivative kernels start at ABI 1000 and use independent ABI sequences;
for example, 6.8.0-1047-aws does not contain these helpers. Preserve the
existing fallback for these kernels rather than infer API availability
from their ABI numbers.

Keep the upstream and stable version checks and the existing object
wrappers. API availability remains a versioned compatibility decision.

Fixes: 77c1efbc1e ("scst/include/backport.h: Add kmalloc_obj() helper family")
Link: https://ubuntu.com/kernel/docs/how-to/develop-customise/build-kernel/#modify-abi-number
Link: https://discourse.ubuntu.com/t/73765
Link: https://github.com/SCST-project/scst/actions/runs/38561552270/job/115843592684
2026-10-14 16:08:46 +03:00
Gleb Chesnokov 606376a3c0 docs: Centralize contributor checks and test navigation
Keep local validation commands in CONTRIBUTING so developers and agents
follow the same checks. Link to them from AGENTS instead of maintaining
separate instructions, and distinguish static checks from builds and tests.

Add concise README navigation and contributor links to the KUnit and
Ginkgo guides without duplicating their commands and configuration
reference.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov 714bfca753 kunit: Test iSCSI transmit progress and completion
Integrate iSCSI test objects in out-of-tree module builds.
Move transmit state names to a private header and link a separate
suite with task-scoped socket and completion boundaries.

Exercise data, padding and digest progress, retries, short sends and
TX_END completion. Preserve socket arguments and completion order
without creating a socket or initiator session.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov d41d195c4f kunit: Test scst_user cleanup and reply ownership
Link a USER suite with private cleanup access and a task-scoped
pool-flush boundary. Check existing cleanup-yield behavior, post-unjam
flush ordering and session reply ownership without changing logic or
destroying real SGV pools.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov 50eb95a451 kunit: Add VDISK write and synchronization regressions
Link separate I/O and synchronization suites with shared fixtures. Use
private file operations and native task-scoped block-flush and writeback
stubs. Distinguish page writeback from filesystem synchronization and
accept either fsync or fdatasync. The writeback boundary retains the
original API and arguments.

Assert FUA offsets, inclusive ranges, filesystem synchronization,
asynchronous flags, errors and completion counts. Check failed writes
for status and progress without requiring full-range FUA synchronization.
Allow empty-range and empty-file requests to omit backend synchronization
or perform it.
Exercise the original sysfs store on a private device. Explicitly skip
unsafe closed-backend and commandless-bypass cases pending separate
production fixes.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov 4029d4f008 kunit: Integrate handler tests and cover VDISK capacity
Include all handler suites through the shared KUnit switch in external
module builds. Link the capacity suite as a separate object with private
access to the command dispatcher. Keep the access declarations available
to ordinary in-tree builds.

Check READ CAPACITY response bytes, queue geometry, short and split
buffers, and invalid CDBs using private fileio and nullio fixtures.
Bind the command CDB to its inline buffer and provide a private session
for allocation-failure status handling.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov 45d3123fe4 build: Prepare device handlers for separate test objects
Make scst_vdisk and scst_user composite modules so KUnit can link
additional objects without including test sources. Rename the
implementation files while preserving the module names and update
source-path consumers.

Move existing private command and device layouts into local headers
without changing their fields, constants or logic. No installed
interface is expanded.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov e284f3299a kunit: Test LUN rollback, teardown and external blockers
Add private access declarations and task-scoped boundaries for sysfs,
copy-manager admission, grace periods and blocking waits. Preserve
their original operations outside the current test task.

Share the existing ACG release-work layout through the private core
header so the worker and its separate test object use one definition.

Link separate lifecycle and blocker suites covering rollback, mapping
detach order, ACG worker locking and reference ownership. Cleanup
tolerates failed initialization and assertions.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov 593023ba41 kunit: Test copy-manager updates and read-only admission
Expose private functions to a separate test object and stub discovery,
registration and default-group lookup. Keep the actual update and
admission paths unchanged.

Check coalescing, failed inquiry, removal before retry and read-only
LUN rejection using private state.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov bc20ee1ca1 kunit: Test event import, delivery and timeout accounting
Move the existing client layout into a private header and link
separate suites with shared fixtures. Add task-scoped usercopy and
allocation boundaries around the actual ioctl and timeout paths.

Use private clients without scheduling work or accessing userspace
memory. Preserve payload validation and counter behavior; the
delivered-timeout assertion exposes the existing double decrement.

Include the private event headers needed by ordinary in-tree builds
in generated kernel patches.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov bd6671cdda kunit: Test command ordering with bounded worker teardown
Exercise queue policy, barriers, sequence wrap, slot ownership and
concurrent producers through a private declaration of the existing
ordering function.

Keep worker memory outside KUnit-managed resources and pin the module
until completion. Bound teardown waits and report retained state when
a worker cannot finish.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov 82d9a42ec5 kunit: Test CDB decoding and direction contracts
Link a separate CDB test object with private access to command
parsing. Exercise tape and disk transfer decoding, REWIND and
initiator direction checks on private commands without altering
production behavior.

Provide private device, target-device and session state required by
command parsing, and optional logs of decoded direction expectations.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov de6f96695f kunit: Test UNMAP parsing and atomic overlap boundaries
Give the separate UNMAP suite private access to the actual overlap
function. Check parser and consumer contracts without changing
validation or descriptor traversal.

Bind each command's CDB pointer to its private buffer and provide a
private session for allocation-failure status handling.

Use allocated guard descriptors to expose count violations safely.
Expect incomplete final descriptors to be ignored while preserving
complete descriptors, including when the CDB truncates the list. Stop
sense and descriptor checks if the parser returns an unexpected status.
Keep correct-result assertions for existing failures and explicitly skip
short-transfer cases that could read beyond the baseline buffer.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov 0ebd6c3328 kunit: Test ALUA callback delivery with private groups
Exercise state transitions with unregistered groups, devices and
mappings. Check per-device callback delivery, ordering, optional
callbacks and unchanged or invalid states without changing ALUA
behavior.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov d89f53368b kunit: Add full test builds and label-based execution
Provide kunit-build for all test-owning modules and their dependencies,
kunit-run for existing artifacts, and kunit-test for a sequential build
and run even under make -j. Allow root builds and run every command with
the caller's privileges. Require root for module execution.

Map KUNIT_TEST and KUNIT_LOG to private Kbuild switches. Default
KUNIT_LABEL to ALL and use KUNIT_ARGS for other runner options and
module paths. Resolve artifacts from explicit arguments, configuration
or the recorded build, preserving spaces. Group and align the Makefile
help for component tests, KUnit and ordinary build targets.

Read label-to-suite mappings and dependency order from module metadata,
without a separate Python owner registry. Reject dependency cycles and
missing SCST core artifacts. Load external kernel dependencies with
modprobe before preparing KUnit; keep shared system
modules loaded. Load only selected SCST owners and their dependencies
from the supplied build and trigger suites through native KUnit debugfs.

Support built-in and modular KUnit with autorun disabled. Load modular
KUnit with known parameters when absent and release it after SCST
cleanup or a clean initial load failure. Reuse an existing instance only
after validating its effective parameters in sysfs; reject invalid or
unreadable values without changing the module. Never unload preloaded
KUnit. Check global filters before loading SCST.

Capture fresh kernel records and parse suites with the upstream KTAP
parser. Preserve logs and skip reasons, associating first-parameter
diagnostics with their case without changing plans or results. Stop
module operations on incomplete evidence, diagnostics or retained
fixtures. Continue after ordinary assertion failures. Finish capturing
output after command exit. Distinguish suites not started from missing
results, and count each Oops as one event. Print concise errors and
colored terminal statuses as suites finish. Group failure details after
progress. Normalize each assertion block independently of printk
messages while retaining value indentation. Follow with explicit stop
reasons and a compact SCST build summary. Reserve module headings,
author, license, source checksums, vermagic and other modules for
verbose output. Keep full case logs, module metadata and kernel
diagnostics in plain-text and JSON reports.

Cover build ordering, selection, kernel setup, dependency preparation,
runner lifecycle and reporting with mocked operations. Document VM
setup, build, execution and extension in the KUnit guide.

Add kunit-clean for test-owning component builds. Invalidate the recorded
module list and clear tooling caches on ordinary and component clean
paths too, including failed cleanup. Preserve reports and user settings.

Check all tooling, kunit-build and cleanup in one CI job. Pin the
Fedora container by digest and fetch a fixed kernel-devel package from
Koji with a SHA-256 check, independently of the regression matrix.
Save build evidence without building a kernel or loading modules.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov 6a3bef807b kunit: Import the public Linux KTAP parser
Vendor the unmodified public Linux master parser and printer with
provenance and checksums. Keep SCST module execution policy outside
these files.

Pin upstream commit 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov c3070172c7 kunit: Add a shared test switch and a core library suite
Integrate optional native KUnit suites with out-of-tree SCST modules.
A single CONFIG_SCST_KUNIT_TEST switch includes all test objects of
each owner. Declare each suite name and label once and discover source
registrations for kunit-list without a build or loaded modules.
Preserve ordinary builds without KUnit.

Start with a fixed-wire LUN regression. Centralize private visibility
and task-scoped static-stub switches, and define retained-fixture
reporting for asynchronous tests. Use current native KUnit APIs
without compatibility shims. Keep optional execution messages behind
CONFIG_SCST_KUNIT_LOG while leaving failure diagnostics unconditional.

Add Makefile/Kbuild regression checks and document the shared switch.

Keep compatibility builds free of KUnit, including inherited test
options and allmodconfig. Generate ordinary in-tree SCST patches with
private declarations but without test suites or KUnit build options.
Check this boundary and preserve kernels without an unwinder option.
2026-10-14 15:08:03 +03:00
Gleb Chesnokov c0e118e739 docs: Define contribution rules and local static checks
Document SCST additions to the Linux kernel coding and commit style,
including a prefix registry and optional sign-off. Configure Conform for
kernel-style subjects and list applicable pre-handoff checks in AGENTS.md.

Use the existing checkpatch and ShellCheck entry points. Document direct
Conform invocations for commit ranges and message files in linked
worktrees, without introducing another checking script.

Keep the existing CI workflows and checkpatch exclusions unchanged.
2026-10-13 13:56:16 +03:00
Gleb Chesnokov af9ecd7a07 docs: Simplify repository guidance for agents
Trim repeated source-of-truth guidance and route documentation by topic.
Preserve the architecture map, cross-component contracts, build context,
compatibility policy, generated-state rules and live-host boundaries.
2026-10-13 12:42:36 +03:00
Gleb Chesnokov fad988d842 .gitignore: Ignore Codegraph generated files
Ignore the Codegraph cache directory, database and database sidecars so
local indexing artifacts do not appear as source changes.
2026-10-13 12:42:36 +03:00
Gleb Chesnokov e69138598e tests: Verify local and iSCSI I/O with fio
Run one fio profile with concurrent 4K, 64K and 128K jobs in disjoint
regions. Cover buffered fileio with 512-byte sectors and direct blockio
with 4K sectors. Verify CRC32C data and completed byte counts, and follow
buffered I/O with direct verification to bypass the initiator page cache.

Reuse the SCSI fixtures and exported-device checks for both transports.
Require an explicit target block device and check its use and signatures
before exporting it. Configure the per-job region size and I/O timeout,
and retain rendered job files, JSON reports and stderr.

Cover job rendering and report validation with framework tests. Document
fio prerequisites, destructive scope and label selection through the
common Make targets.
2026-10-13 12:42:36 +03:00
Gleb Chesnokov 1f48a4f400 tests: Cover SCSI commands on local and iSCSI targets
Add shared sg3_utils scenarios for scst_local and iSCSI exports: inquiry
and VPD identity, capacity, LUN visibility, write protection and invalid
LBA handling. Require the expected SCSI status and raw sense for rejected
commands, then verify that valid reads still work.

Use temporary fileio backends with 512-byte sectors. Keep fixture
identifiers within vdisk's 20-character USN limit. Match each exported
device to its fixture by identity and geometry before submitting commands.
Carry binary responses over the existing supervised command transports
and retain fixture ownership through successful cleanup.

Add framework checks for response parsing, device selection and command
interruption. Document tool prerequisites and the scsi label for both
transports through the common Make targets.
2026-10-13 12:42:36 +03:00
Gleb Chesnokov 41e6caeebc tests: Add two-host iSCSI component tests
Run Ginkgo on the target and drive a separate Open-iSCSI initiator over
SSH. Keep host locks, bounded command logs and failure latches on both
sides. Load checkout modules, own the foreground target daemon, and
remove sessions and node records before tearing down target resources.

Add discovery, login/logout, repeated login, portal filtering and CHAP
scenarios. Offer each CHAP algorithm separately and verify recovery after
an authentication rejection. Use dummy LUNs and per-run initiator IQNs
without changing the initiator's global configuration.

Register the iSCSI group with the shared runner and validate every
selected host before starting the first suite. Finish local teardown
before starting iSCSI tests and stop after any suite failure. Extend the
configuration examples and guide with initiator setup and cleanup limits.
2026-10-13 12:42:36 +03:00
Gleb Chesnokov 40c3ead2db tests: Extend single-host SCST component coverage
Cover fileio activation and configuration persistence, local ALUA state
changes, relative target IDs, live-session group changes and copy-manager
rollback through scstadmin. Manage temporary backing files with device
cleanup and assert the session LUN maps exposed by the CLI.

Add configurable group/device churn and many-LUN teardown scenarios.
Keep the inactive-fileio sync reproducer behind an explicit opt-in
because it can crash affected kernels. Document the new configuration
options and test labels.
2026-10-13 12:42:36 +03:00
Gleb Chesnokov feab01b85b tests: Add SCST component tests with Ginkgo
Add component tests for the scstadmin management interface, including
state preservation after rejected commands. Use scst_local and
vdisk_nullio to cover devices, targets, LUN mappings, initiator groups,
ALUA and configuration save/restore without physical storage.

Provide a shared runner with explicit configuration, host locking,
bounded command logs and JSON/JUnit reports. Select specs through labels
and focus before preparing the host, and reject empty selections. Parse
scstadmin output, including session attributes and LUN mappings, through
common helpers covered by framework tests.

Load checkout modules in suite setup, optionally build them first, and
unload them after successful cleanup. Add common Make targets for
framework checks, test selection and live runs, with setup documentation.
2026-10-13 12:42:36 +03:00
Gleb Chesnokov 9041f8518d scstadmin: Fix status when target creation attributes are absent
Drivers such as iSCSI do not advertise target creation attributes.
-list_drv_attr still prints their attributes but returns failure when
that optional list is empty, aborting callers that check its exit status.

Return success for an empty list after checking for retrieval errors.
2026-10-13 12:42:36 +03:00
wenlxieandGleb Chesnokov 6ddf82829e scst_user: yield cleanup while shared SGV remains checked out
With SGV sharing, device B can reuse a buffer whose allocation owner is
a command from device A. If A's user handle closes while B still has the
SGV checked out, A's command remains in its hash. The unjam pass sees
that command, but there is no ready A command, so get_next_cmd() returns
-EAGAIN. Once cleanup_done is set, the old inner loop keeps retrying A
and prevents the single cleanup worker from reaching B.

The post-unjam pool flush added by PR #378 frees SGV objects that have
already returned to the recycling lists. It cannot free the object
still checked out by B, so it cannot resolve this dependency.

Yield A to the outer cleanup loop when no ready command exists but the
unjam pass still reports commands. The worker can process B and retry A
after its normal sleep. Signal A's cleanup completion only when its
release is done and no commands remain.

Link: https://github.com/SCST-project/scst/issues/279
2026-10-02 09:40:21 +03:00
Gleb Chesnokov 5908a8da46 scst_vdisk: Refresh thin provisioning after backend changes
Changing filename while a vdisk is inactive leaves the old backend's
thin-provisioning capabilities cached. For example, switching between a
plain device and a discard-capable cache can leave automatic thin
provisioning disabled or enabled for the wrong backend.

Mark only a TP recheck as pending after a successful filename write.
Consume it in the common activation path used by active=1 and ALUA.
Do not request a full backend reexamination for an existing device:
that would also overwrite the exported size and recheck cache mode.
The initial deferred reexamination still performs its normal work; if
it completes the TP check, activation does not repeat that check.

Make the TP probe safe to call repeatedly:
- Track successful creation of gen_tp_soft_threshold_reached_UA with
  tp_ua_attr_created. This avoids duplicate sysfs creation for both
  thin-to-thin switches and thin-to-non-thin-to-thin round trips.
  Keep the attribute until device removal; its existing store callback
  rejects requests while TP is disabled. Failed creation leaves the
  flag clear so a later probe can retry.
- Compare the previous effective TP state and advertised UNMAP limits
  with vdisk_tp_changed(). Notify on TP enable/disable and on changed
  granularity, alignment, maximum LBA count or discard-zeroes behavior
  while TP remains enabled. Ignore stale limits while TP is disabled.
- Keep the requested manual TP setting separate from the effective
  backend capability. An explicit thin_provisioned=0 stays disabled.
  An explicit thin_provisioned=1 is temporarily disabled on a backend
  without TP and restored when a later backend supports it. Reusing
  the effective value as the request would lose that setting on a
  thin-to-non-thin-to-thin round trip.
- On a probe-open error, leave the previous capabilities and pending
  flag intact. Activation closes any reopened descriptors and returns
  the device to inactive state so a subsequent activation can retry.

Filename replacement, explicit activation and ALUA activation already
serialize through scst_alua_lock(). Use that same lock for the new
state so another filename write cannot race with consuming the pending
check. Keep the new bool fields outside the command-side bitfields to
avoid sharing their read-modify-write storage with command callbacks.

Queue INQUIRY DATA HAS CHANGED through vdev_inq_changed_work. Calling
scst_dev_inquiry_data_changed() directly from activation could recurse
on scst_mutex. The existing device-free callback cancels this work
before releasing the device. Ordinary ALUA or active cycles without a
filename write do not request another TP probe or notification.

Link: https://github.com/SCST-project/scst/pull/389
2026-09-28 12:32:17 +03:00