Commit aff34e19 authored by Martin K. Petersen's avatar Martin K. Petersen Committed by Jens Axboe

block: Move integrity kobject to struct gendisk

The integrity kobject purely exists to support the integrity
subdirectory in sysfs and doesn't really have anything to do with the
blk_integrity data structure. Move the kobject to struct gendisk where
it belongs.
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Reported-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarSagi Grimberg <sagig@mellanox.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent ef658fc2
...@@ -249,8 +249,8 @@ struct integrity_sysfs_entry { ...@@ -249,8 +249,8 @@ struct integrity_sysfs_entry {
static ssize_t integrity_attr_show(struct kobject *kobj, struct attribute *attr, static ssize_t integrity_attr_show(struct kobject *kobj, struct attribute *attr,
char *page) char *page)
{ {
struct blk_integrity *bi = struct gendisk *disk = container_of(kobj, struct gendisk, integrity_kobj);
container_of(kobj, struct blk_integrity, kobj); struct blk_integrity *bi = blk_get_integrity(disk);
struct integrity_sysfs_entry *entry = struct integrity_sysfs_entry *entry =
container_of(attr, struct integrity_sysfs_entry, attr); container_of(attr, struct integrity_sysfs_entry, attr);
...@@ -261,8 +261,8 @@ static ssize_t integrity_attr_store(struct kobject *kobj, ...@@ -261,8 +261,8 @@ static ssize_t integrity_attr_store(struct kobject *kobj,
struct attribute *attr, const char *page, struct attribute *attr, const char *page,
size_t count) size_t count)
{ {
struct blk_integrity *bi = struct gendisk *disk = container_of(kobj, struct gendisk, integrity_kobj);
container_of(kobj, struct blk_integrity, kobj); struct blk_integrity *bi = blk_get_integrity(disk);
struct integrity_sysfs_entry *entry = struct integrity_sysfs_entry *entry =
container_of(attr, struct integrity_sysfs_entry, attr); container_of(attr, struct integrity_sysfs_entry, attr);
ssize_t ret = 0; ssize_t ret = 0;
...@@ -385,8 +385,8 @@ subsys_initcall(blk_dev_integrity_init); ...@@ -385,8 +385,8 @@ subsys_initcall(blk_dev_integrity_init);
static void blk_integrity_release(struct kobject *kobj) static void blk_integrity_release(struct kobject *kobj)
{ {
struct blk_integrity *bi = struct gendisk *disk = container_of(kobj, struct gendisk, integrity_kobj);
container_of(kobj, struct blk_integrity, kobj); struct blk_integrity *bi = blk_get_integrity(disk);
kmem_cache_free(integrity_cachep, bi); kmem_cache_free(integrity_cachep, bi);
} }
...@@ -429,14 +429,14 @@ int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template) ...@@ -429,14 +429,14 @@ int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template)
if (!bi) if (!bi)
return -1; return -1;
if (kobject_init_and_add(&bi->kobj, &integrity_ktype, if (kobject_init_and_add(&disk->integrity_kobj, &integrity_ktype,
&disk_to_dev(disk)->kobj, &disk_to_dev(disk)->kobj,
"%s", "integrity")) { "%s", "integrity")) {
kmem_cache_free(integrity_cachep, bi); kmem_cache_free(integrity_cachep, bi);
return -1; return -1;
} }
kobject_uevent(&bi->kobj, KOBJ_ADD); kobject_uevent(&disk->integrity_kobj, KOBJ_ADD);
bi->flags |= BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE; bi->flags |= BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE;
bi->interval = queue_logical_block_size(disk->queue); bi->interval = queue_logical_block_size(disk->queue);
...@@ -479,9 +479,9 @@ void blk_integrity_unregister(struct gendisk *disk) ...@@ -479,9 +479,9 @@ void blk_integrity_unregister(struct gendisk *disk)
bi = disk->integrity; bi = disk->integrity;
kobject_uevent(&bi->kobj, KOBJ_REMOVE); kobject_uevent(&disk->integrity_kobj, KOBJ_REMOVE);
kobject_del(&bi->kobj); kobject_del(&disk->integrity_kobj);
kobject_put(&bi->kobj); kobject_put(&disk->integrity_kobj);
disk->integrity = NULL; disk->integrity = NULL;
} }
EXPORT_SYMBOL(blk_integrity_unregister); EXPORT_SYMBOL(blk_integrity_unregister);
...@@ -1472,8 +1472,6 @@ struct blk_integrity { ...@@ -1472,8 +1472,6 @@ struct blk_integrity {
unsigned short tag_size; unsigned short tag_size;
const char *name; const char *name;
struct kobject kobj;
}; };
extern bool blk_integrity_is_initialized(struct gendisk *); extern bool blk_integrity_is_initialized(struct gendisk *);
......
...@@ -199,6 +199,7 @@ struct gendisk { ...@@ -199,6 +199,7 @@ struct gendisk {
struct disk_events *ev; struct disk_events *ev;
#ifdef CONFIG_BLK_DEV_INTEGRITY #ifdef CONFIG_BLK_DEV_INTEGRITY
struct blk_integrity *integrity; struct blk_integrity *integrity;
struct kobject integrity_kobj;
#endif #endif
int node_id; int node_id;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment