Skip to content

Commit

Permalink
Merge pull request #1574 from robertbaldyga/exp-obj-serial
Browse files Browse the repository at this point in the history
Introduce exp_obj serial
  • Loading branch information
robertbaldyga authored Oct 25, 2024
2 parents 7a3b067 + b6f604d commit 588b775
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions modules/cas_cache/exp_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,29 @@ static int _cas_exp_obj_check_path(const char *dev_name)
return result;
}

static ssize_t device_attr_serial_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gendisk *gd = dev_to_disk(dev);
struct cas_disk *dsk = gd->private_data;
struct cas_exp_obj *exp_obj = dsk->exp_obj;

return sysfs_emit(buf, "opencas-%s", exp_obj->dev_name);
}

static struct device_attribute device_attr_serial =
__ATTR(serial, 0444, device_attr_serial_show, NULL);

static struct attribute *device_attrs[] = {
&device_attr_serial.attr,
NULL,
};

static const struct attribute_group device_attr_group = {
.attrs = device_attrs,
.name = "device",
};

int cas_exp_obj_create(struct cas_disk *dsk, const char *dev_name,
struct module *owner, struct cas_exp_obj_ops *ops, void *priv)
{
Expand Down Expand Up @@ -476,13 +499,19 @@ int cas_exp_obj_create(struct cas_disk *dsk, const char *dev_name,
if (cas_add_disk(gd))
goto error_add_disk;

result = sysfs_create_group(&disk_to_dev(gd)->kobj, &device_attr_group);
if (result)
goto error_sysfs;

result = bd_claim_by_disk(cas_disk_get_blkdev(dsk), dsk, gd);
if (result)
goto error_bd_claim;

return 0;

error_bd_claim:
sysfs_remove_group(&disk_to_dev(gd)->kobj, &device_attr_group);
error_sysfs:
del_gendisk(dsk->exp_obj->gd);
error_add_disk:
error_set_geometry:
Expand Down

0 comments on commit 588b775

Please sign in to comment.