Skip to content

scst_vdisk: Refresh thin provisioning after backend changes - #391

Merged
lnocturno merged 1 commit into
masterfrom
3.11/gleb/vdisk-tp-recheck
Sep 28, 2026
Merged

lnocturno merged 1 commit into
masterfrom
3.11/gleb/vdisk-tp-recheck

Conversation

@lnocturno

Copy link
Copy Markdown
Contributor

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.
  • Preserve the existing manual-setting policy, including an explicit thin_provisioned=0. A backend swap does not unconditionally enable TP.
  • 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: #389

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: #389
@lnocturno
lnocturno force-pushed the 3.11/gleb/vdisk-tp-recheck branch from 5786a4a to 7df258d Compare September 17, 2026 12:29
@lnocturno
lnocturno merged commit 5908a8d into master Sep 28, 2026
73 of 76 checks passed
@lnocturno
lnocturno deleted the 3.11/gleb/vdisk-tp-recheck branch September 28, 2026 09:32
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.

1 participant