Commit Graph
635 Commits
Author SHA1 Message Date
Gleb Chesnokov a7f1f95a70 scripts: Preserve kernel patch conditions across whitespace changes
In-tree CI builds report compatibility errors after whitespace cleanup:

  Linux 7.3:
    conflicting types for 'wr'; have 'struct ib_rdma_wr'
    'sgv_shrinker' is a pointer; did you mean to use '->'?

  Linux 6.18.57, dev_handlers/scst_vdisk_main.c:330:
    too many arguments to function 'blkdev_issue_flush'

Two assumptions in specialize-patch change branch selection when only
whitespace changes in otherwise equivalent preprocessor expressions.

The dispatch expression accepts only spaces before '#'. A tab-indented
opening directive is copied as ordinary text, while its closing directive
still changes the conditional nesting state. Accept all horizontal
whitespace as the expression evaluator already does, including when an
indented #elif becomes #if after discarding its original opening branch.

The evaluator also substitutes an empty string for absent RHEL_MAJOR,
RHEL_RELEASE_CODE and MOFED version macros. Thus 'RHEL_MAJOR - 0' becomes
'- 0', which its signed-number patterns cannot reduce correctly. This
leaves the two-argument blkdev_issue_flush() call in a modern upstream
patch. Substitute zero for these absent numeric macros, matching C
preprocessor semantics and the existing RHEL_MINOR handling. Keep their
defined() results false and preserve supplied vendor version values.

Add isolated regressions for spaces and tabs around '#', nested unknown
guards, promoted #elif branches and absent vendor versions. Cover all
three flush signatures at the upstream 5.8/5.12 and RHEL 8.4/8.6 boundaries,
plus EL7, RHEL 9, upstream 6.18.57 and 7.3, with both '-0' and '- 0'. Apply
each resulting patch in a temporary directory in removal and blank-
preserving modes, checking selected branches, surviving guards and hunk
lengths without compiling or loading SCST.

Install patch in the CI build stage used by these generator tests. Without
this dependency, all 98 specialization subcases abort before applying the
patches, with the following error in the minimal Fedora build image:

  FileNotFoundError: [Errno 2] No such file or directory: 'patch'
2026-10-22 14:30:26 +03:00
Gleb Chesnokov 60ff16ef4f scst/include/backport.h: Allow resurrection with active references
Found by manual code inspection, not by an analyzer or a runtime test.
When scst_suspend_activity() times out with commands still active,
__scst_resume_activity() revives the command and management counters.
The old wrapper calls percpu_ref_reinit(), whose zero-count requirement
is enforced by this kernel assertion:

    WARN_ON_ONCE(!percpu_ref_is_zero(ref));

Upstream 3.18-4.19 and the retained EL7/UEK4/UEK5 implementations preserve
the per-CPU allocation and use long counters, but reinit still rejects
this legitimate nonzero resurrection. Restore the initial reference
additively, retain outstanding references, and restore per-CPU operation
with the kernel's bias, counter clearing and release-store ordering.
Keep explicitly forced atomic mode unchanged.

SCST serializes kill and resurrection with scst_suspend_mutex and keeps
both counters alive even when their release callbacks run. Require the
same external serialization for mode changes and exit. Concurrent gets
and puts remain allowed.

Kill confirmation can wake the caller before confirm_switch is cleared.
Drain a pending switch callback with rcu_barrier_sched() before reusing
the counters. The kernel switch waitqueue is private, and older kernels
do not export percpu_ref_switch_to_percpu(). This conditional barrier
can also wait for unrelated RCU callbacks; it is skipped once the switch
has completed. Native resurrection on 4.20+ and EL8+ remains unchanged.

Add scst-LIB-percpu-ref to scst.ko with private, real kernel counters.
Keep the backport helper available to KUnit on modern kernels, using
their counter layout and unified RCU API. Cover immediate resurrection
with active refs, resurrection after draining, forced atomic mode, and
repeated suspend cancellations with commands completing while dead.

Also fix the fake Kbuild cleaner used by the Python tooling tests.
CI reported test_cleanup_without_packaged_tooling failing with
"find: cannot delete .../isert-scst.ko: No such file or directory".
iSCSI cleans kernel/ and kernel/isert-scst/ concurrently, so one fixture
find can remove an artifact after the other has enumerated it. Use
-ignore_readdir_race to tolerate only vanished files, matching Kbuild's
idempotent rm -f behavior. Keep other find errors and the injected
FAIL_CLEAN failure fatal; retain parallel cleanup and artifact checks.

Tests, builds and VM validation were not run, as requested.
2026-10-21 19:48:40 +03:00
Gleb Chesnokov b1d1f7819e .github/workflows: Keep PR Ginkgo checks within a 30-minute budget
The basic-or-smoke PR filter selects 67 specs. Recent successful PR
runs spent more than 41 minutes executing their VM tests, in addition
to image preparation. Broad functional labels keep growing this set
whenever a new basic or smoke regression is added.

Select explicit pr-labelled specs instead: 11 local and 8 iSCSI cases.
Keep representative device, target, LUN and group management, repeated
configuration application, failed fileio creation, discovery and login,
MD5/SHA256 CHAP, portal validation, READ CAPACITY, read-only rejection,
and verified fileio/blockio I/O. Preserve each test's workload, assertions
and cleanup. Exclude manual, race and stress scenarios from the PR set.
The master and manual selections remain 103 and 106 specs respectively.

Limit the complete PR job to 30 minutes, its image build to 10 minutes
and VM execution to 18 minutes. Preserve the longer push/manual limits.
The intended end-to-end PR duration is 15-20 minutes; confirm it on CI
rather than treating dry-run counts as runtime evidence.

Validate selection in the Go runner and Python VM supervisor tests.
Framework checks, all 59 CI tests, actionlint and selection dry runs pass.
2026-10-21 13:20:12 +03:00
Gleb Chesnokov b74e00e63b scst_main: Terminate trace output for an empty CDB
The saved Cppcheck report warns about the formatter output:

  scst/src/scst_main.c:637: warning: Uninitialized variable: buf
  [uninitvar]

scst_dump_cdb does not write anything when cdb_len is zero, but
scst_trace_cmds prints its stack buffer as a string. Unknown opcode
groups can produce an empty CDB, so termination must not depend on
valid command contents.

Initialize nonempty output buffers and leave zero-capacity buffers
untouched. Add KUnit coverage for empty, ordinary, truncated, one-byte
and zero-size output. Include the new private test header in generated
kernel patches.
2026-10-21 13:20:12 +03:00
Gleb Chesnokov f0547f16e6 scst_dlm: Preserve membership when directory enumeration fails
The saved Cppcheck report identifies the lost directory-read result:

  scst/src/scst_dlm.c:784: style: Variable 'ret' is reassigned a value
  before the old one has been used. [redundantAssignment]

scst_dlm_update_nodeids overwrites the result of iterate_dir or
vfs_readdir with -ENOMEM. An empty or partial listing after a read error
can therefore replace the existing membership and report success.

Check the initial allocation and return directory errors before changing
node IDs, participant count or the local node ID. Isolate directory
access behind a task-scoped KUnit stub while retaining both kernel APIs.

Cover EIO, EACCES and ENOMEM with an existing membership and verify its
array ownership and contents survive. Include the private test header
in generated kernel patches as well as out-of-tree builds.
2026-10-21 13:20:12 +03:00
Gleb Chesnokov e4a191c109 isert-scst: Stop polling before indexing a failed CQ result
Manual review found that isert_poll_cq forms &cq->wc[err] when
ib_poll_cq returns a negative errno. This pointer formation already
indexes outside the completion array, even if the following loop does
not dereference it. No saved analyzer diagnostic directly reports it.

Stop on nonpositive results before forming the end pointer and preserve
the result for the caller. Keep the loop exit next to the poll result.

Add the scst-ISER-cq KUnit suite to isert-scst.ko. Call the production
polling function with a private ib_device poll callback and task-local
stubs for the success and error completion handlers. Cover initial
-EIO and -EINVAL results, an empty queue, full and short batches, and
an error after completions. Check poll termination, completion order
and dispatch to the correct handler. Negative-result cases also exercise
kernel UBSAN bounds checking when CONFIG_UBSAN_BOUNDS is enabled.

Include iSER in the existing KUnit module inventory and build it after
iscsi-scst with the RDMA compatibility probes. Propagate the common
KUnit flags through ordinary iSER builds as well, so analyzer builds
include the suite. Extend tooling checks for module selection, dependency
order, cleanup, private headers and in-tree source export.
2026-10-21 13:20:12 +03:00
Gleb Chesnokov 82b024984c .github/workflows: Update analyzer and VM test CI
Enable Cppcheck alongside the other analyzers on master pushes and
manual dispatch, using the existing container and KUnit-enabled runner.
Keep failures for source findings and incomplete analysis, and list the
enabled job in the tooling guide. Use only analyzer names for job titles;
KUnit source coverage remains mandatory.

The Ginkgo VM job reports this runner warning:

  Node.js 20 is deprecated. The following actions target Node.js 20
  but are being forced to run on Node.js 24: actions/checkout@v4,
  actions/upload-artifact@v4.

KUnit uses the same action versions. Update checkout and upload-artifact
to v7 in both VM workflows so they explicitly select Node.js 24, matching
the analyzer workflow. Retain checkout and artifact collection settings.
2026-10-21 13:20:12 +03:00
Gleb Chesnokov 6c51eb5b64 qla2x00t-32gbit: Release target command and tag resources
Manual review of the allocation path flagged by Coccinelle's
null/kmerr.cocci rule found two resource leaks. No separate analyzer
diagnostic is recorded for these leaks. Failed SCST target registration
frees only sqa_tgt, and normal target release also leaves its command
map and tag pool behind. Repeated registration failures or target
recreation retain those allocations indefinitely.

Move allocation and cleanup into SCST-owned resource helpers. Unwind the
command map if tag initialization fails, and destroy both resources if
registration fails or the target is released. Preserve the bitmap,
percpu_ida and sbitmap backends selected by the existing kernel guards.

Target stop phase 1 uses bounded session waits. Before dropping lport
callbacks and releasing command storage, wait for the SCST session list
to drain. SCST removes each session after its commands and unregistration
callback have completed, so late command releases can still return tags.

Keep the helpers in scst_qla2xxx.c and link the QLA KUnit suite into
qla2x00tgt.ko, following the existing SCST module layout. Expose private
helpers only in test builds and use task-scoped registration and
allocation stubs. Cover map allocation failure, tag initialization
failure, registration failure and normal resource destruction.

Build and record the matching qla2xxx_scst.ko dependency for the runner,
and clean both module builds together. Extend the build and cleanup
fixtures to check this dependency and failure propagation.

The dependency has no tests of its own. Requiring every supplied module
to have a KUnit manifest made the runner abort before loading any module:

  Module has no KUnit label manifest; rebuild with kunit-build

Accept modules without suites only when they are dependencies of supplied
test owners. Keep rejecting missing or malformed test manifests and
unrelated modules. Exercise native metadata parsing, label selection,
dependency load order and reverse cleanup in isolated runner fixtures.

The fixtures need no real target, but loading their owner still
initializes the QLogic drivers. Run them in a disposable VM without an
HBA; hardware session teardown requires separate integration validation.
2026-10-21 09:23:02 +03:00
Gleb Chesnokov 3646315a84 .github/workflows: Enable Coccinelle in analyzer CI
The analyzer image and runner already support Coccinelle, but its matrix
entry is commented out. Pushes to master and manual workflow runs
therefore skip semantic-patch analysis entirely.

Enable coccicheck as a parallel matrix job, using the existing runner to
invoke make coccicheck with KUnit sources included. Remaining source
findings fail the job, and parser/tool failures retain the separate
incomplete-analysis status. Existing diagnostics remain visible without
adding exclusions or changing analyzer models.

Update the CI guide to list the enabled target. Cppcheck remains disabled,
and workflow triggers remain push to master and manual dispatch.
2026-10-20 18:02:29 +03:00
Gleb Chesnokov f175f5408f scst_mem: Acquire shared pool references only while alive
Coccinelle api/atomic_as_refcounter.cocci reports:

  scst/src/scst_mem.c:1642:5-24:
  WARNING: atomic_dec_and_test variation before object free at line 1643.

Auditing this ownership counter exposes two bugs in shared pool lookup.
A lookup with a different owner mm returns the existing pool without
taking a reference. Its caller can then release another device's
ownership. Reject that lookup with NULL.

The last put can also reach zero before the destructor acquires
sgv_pools_mutex to unlink the pool. A concurrent lookup can still find
that pool. Use kref_get_unless_zero under the lookup mutex to reject a
pool whose destruction has already started.

Convert sgv_pool_ref to kref, retaining the existing nullable cleanup for
initialization failures separately from the last-reference callback.
The kref API also works on supported kernels predating refcount_t.

Add KUnit cases for same-mm acquisition, different-mm rejection and the
zero-reference state before unlinking. Export the private test header
in generated in-tree patches as well as the out-of-tree build.
2026-10-20 18:02:29 +03:00
Gleb Chesnokov f12687b530 scst_lib: Initialize WRITE SAME emulation CDBs and DIF tags
The internal WRITE(32) generated for DIF type 2 has three defects:
put_unaligned() infers a one-byte store from its destination pointer,
reserved/control bytes retain stack data, and the application-tag mask
is copied from bytes 26 and 27 even for a 16-byte input CDB. This can
corrupt the protection information or make the backend reject the write.

Clear the complete output buffer, use a sized big-endian application-tag
store and obtain the mask through scst_cmd_get_dif_app_tag_mask(). That
helper reads an explicit WRITE SAME(32) mask or derives the short-command
mask from the application's tag-check setting.

Extract the existing CDB builder behind the private KUnit interface. Add
regression cases for distinct tag bytes, full output images, short and
long commands, both short-command mask modes and buffer boundaries.
Nonzero poison patterns expose missing stores and reads beyond the short
CDB. Include the private header in generated in-tree kernel patches.

Fixes: 906f4dfefb ("Merge t10-pi branch back")
2026-10-20 15:48:45 +03:00
Gleb Chesnokov dfcd25997e scripts: Keep analyzer stdin flowing during progress updates
A progress timeout can occur before the child consumes all supplied
input. On Python 3.12, retrying communicate() without input stops
scheduling writes to stdin. The child waits for EOF while the driver
keeps waiting for output, which can hang the analyzer script tests
until the CI job timeout.

Run communicate() once in an I/O worker while the main thread waits
for its result and updates progress. On interruption, stop the owned
process group before joining the worker so blocked pipes cannot
prevent cleanup.

Make the regression wait for two progress updates before reading stdin
to force the pending-input case. Bound the entire child with an alarm
so a regression reports a failure instead of hanging the suite.

Validation: reproduce both check modes failing on Python 3.12.14
before the fix; all 75 lint-test fixtures pass on chesnokov-vm2
afterwards. All 11 process/log fixtures also pass locally on Python
3.14.8.

Fixes: c8648f9410 ("scripts: Share analyzer process and raw-log handling")
2026-10-20 15:48:45 +03:00
Gleb Chesnokov 78d97a1c30 .github/workflows: Run Checkpatch and SCST style analysis
Add a parallel make checkpatch job for pushes to master and manual
runs. Fail analyzer jobs on remaining source findings with status 1;
keep tool, build and coverage failures separate with status 2.
Validate the current report, Make status and native coverage before
classifying results. Checkpatch needs its script and data, not a
prepared KUnit kernel. Update the isolated CI report fixtures.

Run SCST style fixtures and make scs_lint in a separate job without a
kernel build, alongside the native analyzers. Pin uv and its setup
action; the linter supplies its pinned parser dependencies.

Retain the pull-request Checkpatch workflow for patch and commit
checks. Remove the standalone push Checkpatch workflow, whose role
is now covered by the common static-analyzer workflow.

Rename Tooling to Analyzer script tests and clarify that analyzer
jobs include KUnit sources without executing KUnit. Update Checkout
and Upload Artifact to v7 to replace their deprecated Node.js 20
runtimes, and align the CI documentation with the actual jobs.
2026-10-20 14:16:08 +03:00
Gleb Chesnokov 74a2e4bac3 scripts: Add the SCST code style linter
Document SCS.1 and expose make scs_lint for the common C source/header
scope, including userspace and KUnit. Adapt engine's OCS.7.5 check to
SCST_KUNIT_VISIBLE, SCST_KUNIT_VISIBLE_INLINE and VISIBLE_IF_KUNIT.
Require each annotation to occupy its own line; leave other function
attributes and source warnings unchanged.

Use Tree-sitter to distinguish code from comments, literals and
preprocessor directive contents while checking every conditional
branch. Pin the parser dependencies and run them through uv.

Support whole-tree, DIFFBR and explicit-file selection without new
exclusions or diagnostic exceptions. Retain findings and checked-file
records even when a later input fails. Add isolated rule, diff-mode,
coverage and read-failure fixtures with a separate test target.
2026-10-20 14:16:08 +03:00
Gleb Chesnokov 704c44dabe scripts: Add whole-file Checkpatch analysis
Expose make checkpatch through the common C source/header policy,
including userspace and KUnit sources. DIFFBR selects whole changed
files. Use the kernel's Checkpatch and companion data with --strict,
without adding diagnostic exceptions or loading local configuration.

Retain raw output and require native totals and a completion record
for every selected file. Distinguish source findings from unreadable
inputs, inconsistent reports and tool failures, with isolated fixtures.
Keep native caches in a temporary directory and serialize only this
analyzer's reports so it can run alongside the Kbuild analyzers.

Make checkpatch_scan use this target's implementation and exit status
instead of suppressing errors. Preserve the separate existing policy
of patch/commit helpers and the kernel regression runner.
2026-10-20 14:16:08 +03:00
Gleb Chesnokov 46208a5ba0 .github/workflows: Keep scst_user fork coverage manual
Reserve the legacy-kernel fork checks for manual runs instead of adding
two VM jobs and extra kernel builds to the regular CI selection. Remove
the Linux 5.8/5.9 Ginkgo jobs and regression matrix entries, retaining the
kernel pins and local-only VM runner for reproduction.

Label the fork spec manual and exclude that label from both ci-pr and
ci-push. Move smoke to the READ CAPACITY entries so their existing CI
coverage remains intact. Keep full manual runs inclusive, update the
selection checks, and document focused manual execution.
2026-10-20 08:49:25 +03:00
wenlxieandGleb Chesnokov 359dfbf11c ci: Run the scst_user Ginkgo specs on Linux 5.8 and 5.9
scst_user pins its data buffers from Linux 5.9, the first release in
which fork() gives the child a copy of a pinned page (commit
70e806e4e645, "mm: Do early cow for pinned pages during fork() for
ptes"). The Ginkgo "handler forks" spec checks this, but CI boots only
the current Fedora kernel, so the boundary itself is never tested.

Add a Ginkgo job matrix that runs the local "user" specs on Fedora 33's
Linux 5.8.18 and 5.9.16, on both sides of the boundary. On 5.9.16 the
fork spec relies on the pin alone; on 5.8.18 the handler protects its
buffers with MADV_DONTFORK, as required there. Both must keep correct
geometry and data. The jobs are named after their kernels, like the
regression jobs.

- kernel-5.8.env, kernel-5.9.env and their SHA256SUMS pin those kernels'
  rpms from Fedora's koji, like kernel.env and kernel.SHA256SUMS.
  Fedora's only 5.9.0 build is a rawhide kernel that defines RHEL_MAJOR 8
  and RHEL_MINOR 99, so SCST's backports treat it as RHEL and the build
  fails; 5.9.16 has the same fork() behavior.
- build-image takes an optional pin name, such as "kernel-5.9", for
  Ginkgo images. The image is otherwise built the same way.
- The Dockerfile downloads exactly the rpms listed in the selected
  checksum file, since 5.9 has no kernel-modules-core package.
- vm.py --local-only boots only the target guest, without the iSCSI
  initiator or the private network, and expects only the local report.
  The guest then writes a config without an iscsi section. The label
  filter is restricted to local specs: "local && (<filter>)", or "local"
  without one.
2026-10-20 08:43:01 +03:00
Gleb Chesnokov 0c5a41bba8 .github/workflows: Run Sparse and Smatch with KUnit
Run isolated tooling checks and separate Sparse and Smatch Make targets
on pushes to master and manual dispatch. Use the pinned kernel with
KUnit enabled and preserve full logs, policy and tool provenance.

During the source-fix rollout, completed source findings are advisory.
Tool, build, parser and coverage failures remain blocking, including an
empty scan or missing KUnit inputs. Local Make targets stay strict.
Validate the current run's report together with Make's exit status,
since Make maps both findings and incomplete analysis to status 2.

Prepare the runner and container for Coccinelle and Cppcheck as well,
but leave their matrix entries commented out. Cover all four report
formats and GNU Make exit mapping with isolated tooling fixtures.
2026-10-19 21:38:56 +03:00
Gleb Chesnokov 6c3405f5fe scripts: Add Cppcheck with native build contexts
Expose make cppcheck using freshly captured kernel CHECK commands and
real userspace compiler invocations. Keep their include paths and
definitions unchanged and analyze kernel and userspace contexts
separately.

Use the shared source scope without additional input exclusions, project
models or diagnostic suppressions. Relevant diffs trigger full
configured analysis; KUnit coverage follows the actual build
configuration.

Retain build logs, compilation databases, native XML and checker
coverage. Separate source findings from parser failures, missing inputs
and incomplete builds, with isolated report and capture fixtures.
2026-10-19 21:38:56 +03:00
Gleb Chesnokov 4b56975115 scripts: Add native Coccinelle report analysis
Expose make coccicheck using report rules from the selected kernel and
the shared source policy, including userspace and KUnit sources. Diff
mode selects whole changed sources and headers.

Preserve full native output and record rule initialization, per-input
handling and finalization. Treat parser errors and missing coverage as
incomplete analysis even if spatch returns zero; report source findings
separately.

Add isolated log and policy fixtures. Do not introduce project macro
models, diagnostic exceptions or CI execution.
2026-10-19 21:38:56 +03:00
Gleb Chesnokov 1c2365291a scripts: Pin the Sparse and Smatch container environment
Build standalone Sparse and Smatch from recorded revisions, applying the
reviewed SCST Smatch frontend correction. Install matching native Smatch
data without replacing standalone Sparse or adding project models.

Reuse the existing checksum-pinned kernel headers. Record source
commits, patch and binary hashes, and installed model contents for CI
evidence. Fail preparation instead of silently falling back to different
tools; no SCST modules are built or loaded while preparing this image.
2026-10-19 21:38:56 +03:00
Gleb Chesnokov 791f5e6e2d scripts: Retire legacy Sparse and Smatch regression wrappers
Use the dedicated native analyzer targets instead of regression wrappers
that return success after tool failures and summarize filtered output.

Remove their suffix switches and the analyzer-only IBM VIO option.
Update the regression caller and kernel-option parser together; the
maintained kernel list and compilation matrix are unchanged. Keep legacy
Checkpatch until its own integration series.
2026-10-19 21:38:56 +03:00
Gleb Chesnokov 2f8ff7ea63 scripts: Integrate Sparse and Smatch with reviewed policy
Run the native checkers through the ordered SCST module build with C=2.
Preserve Kbuild flags, full raw output and every attempted CHECK record.
Keep full, diff and explicit input selection on the shared scope; diff
selection triggers the complete configured module analysis.

Read exact diagnostic exceptions from policy/sparse.json and
smatch.json: two reviewed Smatch IRQ reports and the external FC
flexible-array warning. Keep the existing SCST matching boundaries and
reasons. Smatch uses its matching installed kernel data without
engine-specific additions.

Reject build, checker, frontend and truncation failures even when Kbuild
returns success. Retain per-invocation records and a machine-readable
run summary, and detect printed CHECK steps without a record. Require
selected C inputs to occur in the build. Keep findings distinct from
incompleteness.

Check native compatibility before compilation, and forward external
kernel capability probes to the real checker instead of skipping them as
inputs outside SCST. Include the pinned Smatch typeof frontend
correction and isolated fixtures for failure propagation and exact
exception boundaries.
2026-10-19 21:38:56 +03:00
Gleb Chesnokov df16b2e697 scripts: Expose analyzer policy without running tools
Add show, files and validate commands to analyzer_policy.py and expose
policy inspection through make analyzer-policy. Support text and JSON
reports without installing or invoking an analyzer or preparing a build.

Show the configured roots, input exclusions and their reasons. The file
inventory uses the shared selector and reports eligible tracked inputs,
not completed analysis or build coverage. Configuration and Git failures
return an error instead of a successful empty report.

Expose only the common input policy at this stage. Individual analyzer
policies belong with their drivers. Keep the existing checkpatch and
kernel regression filtering separate and document that boundary.

Add isolated CLI fixtures for policy reporting, repository-relative input
inventory and visible failures. Document the inspection entry points.
2026-10-19 21:38:56 +03:00
Gleb Chesnokov c1e2f41a49 scripts: Store shared analyzer scope as reviewed policy
Move the source roots, file types and input exclusions from lint_scope.py
into policy/common.json. Keep the existing scope, including KUnit sources,
the newer QLogic target and the exclusions for the legacy QLogic tree,
upstream QLogic sources, compiler probes and generated module metadata.

Adapt engine's reviewed-data and strict-loader approach to SCST. Require
reasons for input exclusions and reject malformed, missing or ambiguous
policy before selecting files. Do not import engine's exclusions or add
environment-based filtering or diagnostic suppression.

Use this policy for full, diff and explicit-file selection. Preserve both
lexical and resolved path checks, single-commit diff bases and index-based
selection. Treat policy paths literally in Git pathspecs as well as Python.
Add isolated fixtures for schema failures and policy-driven selection.
2026-10-19 21:38:56 +03:00
Gleb Chesnokov 05502f10b2 scripts: Share the analyzer build lock
Extract the per-worktree build lock ahead of the Sparse/Smatch and
Cppcheck drivers. Keep one advisory lock file for analyzer builds that
share generated state; release the descriptor on success or exception
without unlinking the file.

Document that callers must hold the lock around build-state changes and
log reset, and that ordinary builds are not covered by this advisory lock.
Add isolated fixtures checking cross-process contention, lock reuse and
release after an exception. Kbuild collection and analyzer-specific build
targets remain with their respective integration series.
2026-10-19 19:18:14 +03:00
Gleb Chesnokov c8648f9410 scripts: Share analyzer process and raw-log handling
Provide common process, progress and report helpers for the upcoming
analyzer drivers. Preserve raw output bytes and command failure statuses,
keep progress separate from captured diagnostics, and terminate the owned
process group when an invocation is interrupted.

Forward valid inherited Make jobserver pipes without taking their tokens.
Document named-log truncation explicitly: a later run replaces that named
report unless the caller requests preservation.

Import the process and terminal fixtures and add raw-log coverage. No
analyzer-specific filtering or diagnostic exclusions are introduced.
2026-10-19 19:18:14 +03:00
Gleb Chesnokov 1c455d4785 scripts: Validate analyzer diff bases as single commits
Passing the base directly to git diff allows an option such as --quiet to
be interpreted as a flag. On a clean worktree it can succeed without
selecting any sources, instead of rejecting the invalid revision.

Resolve the base with rev-parse --verify --end-of-options and require a
commit before building the diff command. Reuse the resulting object ID so
options, ranges, tree objects and unknown revisions cannot turn an invalid
request into an empty selection.

Add a fixture covering rejected bases on a clean tree and a valid tag
before and after a source change. Expose the resolver for future patch
consumers as well.
2026-10-19 19:18:14 +03:00
Gleb Chesnokov fce9b872b0 scripts: Define shared analyzer source selection
Give the upcoming analyzer drivers one source-selection policy for full,
working-tree diff and explicit-file checks. Include product C sources and
headers, including KUnit, and keep both lexical and resolved paths within
the allowed directories.

Select only the newer QLogic SCST target directory. Exclude the legacy
QLogic tree, the upstream part of the newer driver, the two conftest trees
and generated .mod.c files. Document these input exclusions separately
from diagnostic filtering, which this helper does not perform.

Add temporary-repository fixtures and a make lint-test entry point. Keep
the existing checkpatch and kernel regression consumers unchanged until
their replacement drivers are introduced.
2026-10-19 19:18:14 +03:00
Gleb Chesnokov cb1bcedc2a scripts: Add qla2xxx upstream maintenance tooling
Track upstream imports, compare driver snapshots, audit remaining
source differences and export patches mapped to the SCST tree. Keep
review artifacts outside Git and expose unresolved changes for review.

Move the newer QLogic kernel patch helpers into scripts/kernel with
their callers and tests. Add the update skill and guide, preserving
separate commits for upstream imports and SCST adaptations.
2026-10-19 17:36:43 +03:00
Gleb Chesnokov dc506a0474 .github/workflows: Select PR checks by changed paths
Pull requests that only change development guides or independent tooling
still compile kernels and run the VM suites. Select Ginkgo, KUnit, Clang
and kernel regression through one shared path policy before expensive
work. Compare the whole PR against its merge base, retaining deleted
paths and both sides of renames. Run checks for unclassified inputs.

Keep path rules in .github/ci-checks.toml and validate their structure,
check names, literal paths and conflicting entries before selection.
Provide a validation-only command. Changes to the config or selector
exercise every check.

Select kernel regression once in the preparation job and gate the build
job before expanding its matrix. Unrelated PRs do not allocate a runner
for every kernel. Selection failures fail the workflow and successful
skips include a reason in the job summary.

Run the Packages workflow only after pushes to master, preserving its
DEB/RPM builds and publication. Keep the separate Clang DEB build on PRs.
Retain full master and manual checks and the existing Checkpatch runs.
Cover path ownership, config validation and Git histories with tests,
and shorten the CI guide around all workflows, selection and results.

Quote the CC environment key so Checkpatch does not interpret unchanged
YAML diff context as a Cc trailer.
2026-10-19 13:44:33 +03:00
Gleb Chesnokov fdf7f5790f docs: Describe script ownership and invocation boundaries
Add a directory map with Make entry points and explain the preserved
working-directory conventions. Identify the current checkpatch ignore and
scan policies and the separate kernel regression analyzer path.

Record the caller updates required when moving helpers and the scope of
make shellcheck. Describe the side effects of cleanup, release and runtime
tools.
2026-10-19 10:31:32 +03:00
Gleb Chesnokov 13839f3f6a scripts: Group runtime diagnostics and exercisers under runtime/
Place interrupt and memory monitors beside the block-device benchmark and
persistent-reservation exerciser. Update the SRPT maintainer instructions
and copyright paths with the move.

The four helpers are byte-for-byte unchanged, including their existing
privilege requirements and device or host side effects.
2026-10-19 10:31:32 +03:00
Gleb Chesnokov 49b4d9f3ef scripts: Group release and packaging helpers under release/
Keep RPM artifact creation, archive generation, package release preparation
and version updates in one directory. Switch all component archive targets,
the top-level RPM target and the RPM workflow to the relocated helpers.

Point archive generation at the shared source inventory in source/ while
preserving its caller-directory semantics and the existing package inputs.
2026-10-19 10:31:32 +03:00
Gleb Chesnokov 43e717c7f1 scripts: Group kernel maintenance helpers under kernel/
Move patch generation, specialization, regression, kernel selection and
module signing helpers together, with their shared shell libraries. Update
component Makefiles, CI, nightly jobs, packaging metadata, documentation
and KUnit tooling references alongside the move.

Adjust repository-root and source-inventory lookups for the deeper path.
Resolve rhel-rpm-functions relative to kernel-functions through
BASH_SOURCE, since it is also sourced by the QLogic extraction helpers.

Keep the regression runner behavior and the nightly kernel matrix intact,
including the existing checkpatch, sparse and smatch switches and policy.
2026-10-19 10:31:32 +03:00
Gleb Chesnokov 88b5653b06 scripts: Group source maintenance helpers under source/
Keep source inventory, cleanup and shell lint helpers together. Update the
Makefile, Debian packaging, scstadmin and the kernel, release and existing
checkpatch callers in the same commit so each consumer uses a valid path.

Keep run-shellcheck rooted at scripts/ after the move, preserving its
coverage of all tracked Bash helpers. Source selection and the existing
checkpatch exclusions are unchanged.
2026-10-19 10:31:32 +03:00
wenlxieandGleb Chesnokov a6167625b0 tests: Exercise invalid READ CAPACITY replies from an scst_user handler
Run usr/fileio/fileio_tgt over scst_local with an LD_PRELOAD hook that
replaces the block length of one READ CAPACITY(10) or (16) reply with
809052976, as a user space backend did in production. The invalid reply
must be rejected with INTERNAL TARGET FAILURE sense, and afterwards READ
CAPACITY(10) and (16), reads and writes must return the right geometry
and data.

The local suite now builds usr and loads scst_user, and the CI image
builds usr for the Ginkgo guest.
2026-10-18 13:12:41 +03:00
Gleb Chesnokov 3d4f88273b tests: Add named CI selections for Ginkgo
Keep CI selection policy in shared ci-pr and ci-push label sets. Resolve
them to ordinary Ginkgo expressions for local discovery and execution,
and before booting CI guests so report validation still checks the exact
filter. Preserve ordinary expressions and the full manual selection.

Mark both ACG teardown scenarios as race and exclude that category from
master push runs. Keep their strict overlap, recovery and cleanup checks
unchanged. PR runs retain basic/smoke coverage through ci-pr.

Document the named selections and check their filtering behavior and
propagation through the VM supervisor.
2026-10-16 23:41:25 +03:00
Gleb Chesnokov 7dc98f5b29 scst: Cache the session black-hole mode for task management
Task-management initialization reads sess->acg before acquiring activity
protection. A concurrent reassignment can clear this pointer and later
drop the old ACG reference, so the read can dereference NULL or freed
storage even while ordinary command processing is suspended.

Keep a session-owned copy of the black-hole mode and read it with
READ_ONCE() in the TM path. Initialize it before admitting session work,
retain the old mode while replacing LUNs, and publish the new mode when
installing the new ACG. Update existing sessions on sysfs writes as well.
All writers hold scst_mutex and use WRITE_ONCE(); the TM command already
owns a session reference, so no additional locking or ACG reference is
needed for this scalar policy read.

Read the previous sysfs value under the same mutex so concurrent stores
cannot mistake a real change for a no-op and leave session copies stale.
Extend the private TM tests with sysfs mode transitions, rejected writes,
and old/new drop-policy checks inside and after real reassignment.

Remove the dedicated Ginkgo opt-in and Skip path now that the fix is
in place, so both teardown scenarios run whenever their labels are
selected, including full CI runs.

Link: https://github.com/SCST-project/scst/issues/367
2026-10-16 14:46:19 +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 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 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 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 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