Skip to content

iSCSILogicalUnit: add block size override and backstore type selection#2148

Open
ryan-ronnander wants to merge 5 commits intoClusterLabs:mainfrom
ryan-ronnander:rr/iscsi-block-size
Open

iSCSILogicalUnit: add block size override and backstore type selection#2148
ryan-ronnander wants to merge 5 commits intoClusterLabs:mainfrom
ryan-ronnander:rr/iscsi-block-size

Conversation

@ryan-ronnander
Copy link
Copy Markdown
Contributor

@ryan-ronnander ryan-ronnander commented Apr 11, 2026

Summary

This PR adds block size override and backstore type selection to the iSCSILogicalUnit resource agent for the lio-t (targetcli) and scst implementations.

Commits

  • block_size parameter — Override the block size (512, 1024, 2048, or 4096) presented to iSCSI initiators. No-op when unset; the kernel default is preserved.

    • lio-t: writes to the LIO configfs block_size attribute after backstore creation, before LUN mapping
    • scst: passes blocksize in the scstadmin -open_dev attributes string at device creation time
  • scst_bstype parameter — Select the SCST device handler (vdisk_blockio or vdisk_fileio). The handler was previously hardcoded to vdisk_blockio. The vdisk_fileio handler routes I/O through the kernel page cache, which is required when presenting smaller block sizes on 4K-native backing devices (for example, block_size=512 on a 4K NVMe drive).

  • Unsupported parameter warnings — Wire scst_bstype into the unsupported parameter lists for non-scst implementations, and liot_bstype into the scst list, so users get a warning when setting parameters that do not apply to their implementation.

  • Fix lio-t configfs paths — The lio-t code path hardcoded iblock_* in configfs paths for scsi_sn, product_id, block_size, and emulate_* attribute writes. This only works for the default block backstore. When liot_bstype is fileio or pscsi, the configfs directory is fileio_* or pscsi_* respectively. Both start and monitor functions now resolve the correct path based on liot_bstype.

Allows these new parameters to be used in:

  • Pacemaker
  • DRBD Reactor - Reactor uses available resource agents from this repo.
  • LINSTOR Gateway - A development build successfully passes these parameters through to drbd-reactor promoter configs, which invoke the resource agent.

Testing

Tested on AlmaLinux 9, kernel 5.14.0-611.45.1.el9_7.x86_64, SCST master (5d74814).

  • lio-t block backstore with block_size=4096: start, monitor, stop, Pacemaker failover
  • lio-t fileio backstore with block_size=4096: start, monitor, stop via LINSTOR Gateway
  • scst vdisk_blockio with block_size=4096: full target and LU lifecycle
  • scst vdisk_fileio with block_size=512: full target and LU lifecycle
  • All four block sizes (512, 1024, 2048, 4096) verified on both lio-t and scst
  • Initiator verification via blockdev --getss and blockdev --getpbsz
  • Data integrity (64MB sha256 round-trip) on lio-t block backstore with block_size=4096

@knet-jenkins
Copy link
Copy Markdown

knet-jenkins bot commented Apr 11, 2026

Can one of the project admins check and authorise this run please: https://haci.fast.eng.rdu2.dc.redhat.com/job/resource-agents/job/resource-agents-pipeline/job/PR-2148/1/input

@ryan-ronnander ryan-ronnander marked this pull request as ready for review April 11, 2026 00:46
Add optional block_size parameter to override the logical block size
(512, 1024, 2048, or 4096) presented to initiators.

- lio-t: writes to configfs block_size attribute after backstore
  creation, before LUN mapping (must be set before LUN assignment)
- scst: passes blocksize in the -open_dev attributes string at
  device creation time (read-only after creation)

No-op when unset; kernel default (typically 512) is preserved.
@knet-jenkins
Copy link
Copy Markdown

knet-jenkins bot commented Apr 11, 2026

Can one of the project admins check and authorise this run please: https://haci.fast.eng.rdu2.dc.redhat.com/job/resource-agents/job/resource-agents-pipeline/job/PR-2148/2/input

The SCST handler was hardcoded to vdisk_blockio, which uses direct I/O.
Add scst_bstype parameter (default: vdisk_blockio) to allow selecting
vdisk_fileio, which routes I/O through the kernel page cache. The fileio
handler is needed when presenting smaller block sizes on 4K-native
backing devices (for example, block_size=512 on a 4K NVMe drive).
…m lists

Add scst_bstype to the unsupported parameter lists for iet, tgt, lio,
and lio-t implementations so users get a warning when setting it on a
non-scst target. Add liot_bstype to the scst list for the same reason.
@knet-jenkins
Copy link
Copy Markdown

knet-jenkins bot commented Apr 11, 2026

Can one of the project admins check and authorise this run please: https://haci.fast.eng.rdu2.dc.redhat.com/job/resource-agents/job/resource-agents-pipeline/job/PR-2148/3/input

@ryan-ronnander
Copy link
Copy Markdown
Contributor Author

ryan-ronnander commented Apr 11, 2026

While the original commit covers the typical use case of presenting 4K block sizes to initiators on 512-native storage (512 → 4K), doing the opposite (4K → 512) requires a fileio backstore. The liot_bstype parameter already exposed this for targetcli, but SCST had no equivalent (the handler was hardcoded to vdisk_blockio).

The second commit adds scst_bstype to allow selecting vdisk_fileio, and the third wires it into the unsupported parameter warnings for consistency.

Tested both directions on AlmaLinux 9 with targetcli and SCST. Happy with where this MR is.

EDIT: A few more tweaks were needed to targetcli fileio backend handling due to hardcoded configfs paths - 146da1e.

…tores

The lio-t code path hardcoded iblock_* in configfs paths for scsi_sn,
product_id, block_size, and emulate_* attribute writes. This only works
for the default block backstore. When liot_bstype is set to fileio or
pscsi, the configfs directory is fileio_* or pscsi_* respectively.

Map liot_bstype to the correct configfs core directory name in both
the start and monitor functions.
@knet-jenkins
Copy link
Copy Markdown

knet-jenkins bot commented Apr 11, 2026

Can one of the project admins check and authorise this run please: https://haci.fast.eng.rdu2.dc.redhat.com/job/resource-agents/job/resource-agents-pipeline/job/PR-2148/4/input

Expose the LIO configfs emulate_write_cache attribute as an RA
parameter. Fileio backstores default to write-back caching which
is unsafe for HA configurations. Setting emulate_write_cache=0
enables write-through mode. Follows the existing emulate_tpu,
emulate_3pc, emulate_caw pattern.
@knet-jenkins
Copy link
Copy Markdown

knet-jenkins bot commented Apr 11, 2026

Can one of the project admins check and authorise this run please: https://haci.fast.eng.rdu2.dc.redhat.com/job/resource-agents/job/resource-agents-pipeline/job/PR-2148/5/input

@ryan-ronnander
Copy link
Copy Markdown
Contributor Author

ryan-ronnander commented Apr 11, 2026

Needed to expose yet another parameter in 8f9f820 to ensure we can set the correct write-back/write-through caching when used in a DRBD context.

  • Added emulate_write_cache in the latest commit. The fileio backstore defaults to write-back caching (emulate_write_cache=1), which is unsafe for HA configurations where data must be flushed to disk before the iSCSI write is acknowledged. This follows the existing emulate_tpu, emulate_3pc, emulate_caw pattern.
  • LINSTOR Gateway uses these parameters to manage HA iSCSI targets over DRBD-replicated storage. When Gateway selects the fileio backstore (unreleased dev build, needed for presenting smaller block sizes on 4K-native backing devices), it automatically sets emulate_write_cache=0 to ensure write-through mode.
  • SCST is unaffected — its vdisk_fileio handler already uses write_through=1 at device creation time, which is hardcoded in the RA.

@ryan-ronnander ryan-ronnander changed the title iSCSILogicalUnit: add block_size parameter for lio-t and scst iSCSILogicalUnit: add block size override and backstore type selection Apr 13, 2026
@oalbrigt
Copy link
Copy Markdown
Contributor

Nice. I'll review it later this week or next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants