Skip to content

Commit

Permalink
blk-crypto: pass a gendisk to blk_crypto_sysfs_{,un}register
Browse files Browse the repository at this point in the history
Prepare for changes to the block layer sysfs handling by passing the
readily available gendisk to blk_crypto_sysfs_{,un}register.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20221114042637.1009333-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Nov 30, 2022
1 parent c62256d commit 450deb9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
10 changes: 6 additions & 4 deletions block/blk-crypto-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ extern const struct blk_crypto_mode blk_crypto_modes[];

#ifdef CONFIG_BLK_INLINE_ENCRYPTION

int blk_crypto_sysfs_register(struct request_queue *q);
int blk_crypto_sysfs_register(struct gendisk *disk);

void blk_crypto_sysfs_unregister(struct request_queue *q);
void blk_crypto_sysfs_unregister(struct gendisk *disk);

void bio_crypt_dun_increment(u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE],
unsigned int inc);
Expand Down Expand Up @@ -79,12 +79,14 @@ bool __blk_crypto_cfg_supported(struct blk_crypto_profile *profile,

#else /* CONFIG_BLK_INLINE_ENCRYPTION */

static inline int blk_crypto_sysfs_register(struct request_queue *q)
static inline int blk_crypto_sysfs_register(struct gendisk *disk)
{
return 0;
}

static inline void blk_crypto_sysfs_unregister(struct request_queue *q) { }
static inline void blk_crypto_sysfs_unregister(struct gendisk *disk)
{
}

static inline bool bio_crypt_rq_ctx_compatible(struct request *rq,
struct bio *bio)
Expand Down
7 changes: 4 additions & 3 deletions block/blk-crypto-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ static struct kobj_type blk_crypto_ktype = {
* If the request_queue has a blk_crypto_profile, create the "crypto"
* subdirectory in sysfs (/sys/block/$disk/queue/crypto/).
*/
int blk_crypto_sysfs_register(struct request_queue *q)
int blk_crypto_sysfs_register(struct gendisk *disk)
{
struct request_queue *q = disk->queue;
struct blk_crypto_kobj *obj;
int err;

Expand All @@ -149,9 +150,9 @@ int blk_crypto_sysfs_register(struct request_queue *q)
return 0;
}

void blk_crypto_sysfs_unregister(struct request_queue *q)
void blk_crypto_sysfs_unregister(struct gendisk *disk)
{
kobject_put(q->crypto_kobject);
kobject_put(disk->queue->crypto_kobject);
}

static int __init blk_crypto_sysfs_init(void)
Expand Down
4 changes: 2 additions & 2 deletions block/blk-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ int blk_register_queue(struct gendisk *disk)
goto put_dev;
}

ret = blk_crypto_sysfs_register(q);
ret = blk_crypto_sysfs_register(disk);
if (ret)
goto put_dev;

Expand Down Expand Up @@ -913,7 +913,7 @@ void blk_unregister_queue(struct gendisk *disk)
*/
if (queue_is_mq(q))
blk_mq_sysfs_unregister(disk);
blk_crypto_sysfs_unregister(q);
blk_crypto_sysfs_unregister(disk);

mutex_lock(&q->sysfs_lock);
elv_unregister_queue(q);
Expand Down

0 comments on commit 450deb9

Please sign in to comment.