Skip to content

Commit

Permalink
scst_vdisk: Add active attributes support to vdisk_fileio
Browse files Browse the repository at this point in the history
vdisk_blockio already supports the active attribute to facilitate
deferring opening au underlying block device.  Add a similar feature
to vdisk_fileio.
  • Loading branch information
bmeagherix committed Feb 2, 2024
1 parent 36e06a0 commit 3f3231f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions scst/src/dev_handlers/scst_vdisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,12 @@ static void vdisk_blockio_check_flush_support(struct scst_vdisk_dev *virt_dev)
return;
}

static bool vdisk_supports_active(const struct scst_vdisk_dev *virt_dev)
{
/* Both blockio and fileio support active attribute */
return !virt_dev->nullio;
}

static void vdisk_check_tp_support(struct scst_vdisk_dev *virt_dev)
{
struct block_device *bdev = NULL;
Expand All @@ -550,7 +556,7 @@ static void vdisk_check_tp_support(struct scst_vdisk_dev *virt_dev)
res = PTR_ERR_OR_ZERO(fd);
}
if (res) {
if (res == -EMEDIUMTYPE && virt_dev->blockio)
if (res == -EMEDIUMTYPE && vdisk_supports_active(virt_dev))
TRACE(TRACE_MINOR,
"Unable to open %s with EMEDIUMTYPE, DRBD passive?",
virt_dev->filename);
Expand Down Expand Up @@ -666,7 +672,7 @@ static int vdisk_get_file_size(const struct scst_vdisk_dev *virt_dev,
}

res = scst_file_or_bdev_size(virt_dev->filename);
if (res == -EMEDIUMTYPE && virt_dev->blockio) {
if (res == -EMEDIUMTYPE && vdisk_supports_active(virt_dev)) {
TRACE(TRACE_MINOR,
"Unable to open %s with EMEDIUMTYPE, DRBD passive?",
virt_dev->filename);
Expand Down Expand Up @@ -1070,7 +1076,7 @@ static int vdisk_reexamine(struct scst_vdisk_dev *virt_dev)

res = vdisk_get_file_size(virt_dev, &file_size);
if (res < 0) {
if ((res == -EMEDIUMTYPE) && virt_dev->blockio) {
if ((res == -EMEDIUMTYPE) && vdisk_supports_active(virt_dev)) {
TRACE_DBG("Reexam pending (dev %s)", virt_dev->name);
virt_dev->reexam_pending = 1;
res = 0;
Expand Down Expand Up @@ -1442,7 +1448,7 @@ static int vdisk_attach_tgt(struct scst_tgt_dev *tgt_dev)
if (!virt_dev->nullio && !virt_dev->cdrom_empty) {
res = vdisk_open_fd(virt_dev, tgt_dev->dev->dev_rd_only);
if (res != 0) {
if ((res == -EMEDIUMTYPE) && virt_dev->blockio) {
if ((res == -EMEDIUMTYPE) && vdisk_supports_active(virt_dev)) {
/* It's OK, it will be reopen on exec */
res = 0;
} else {
Expand Down Expand Up @@ -9577,6 +9583,7 @@ static struct scst_trace_log vdisk_local_trace_tbl[] = {
#endif

static const struct attribute *vdisk_fileio_attrs[] = {
&vdev_active_attr.attr,
&vdev_size_ro_attr.attr,
&vdev_size_mb_ro_attr.attr,
&vdisk_blocksize_attr.attr,
Expand Down Expand Up @@ -9610,6 +9617,7 @@ static const struct attribute *vdisk_fileio_attrs[] = {
};

static const char *const fileio_add_dev_params[] = {
"active",
"async",
"blocksize",
"cluster_mode",
Expand Down

0 comments on commit 3f3231f

Please sign in to comment.