Skip to content

Commit

Permalink
block: return errors from disk_alloc_events
Browse files Browse the repository at this point in the history
Prepare for proper error handling in add_disk.

Signed-off-by: Luis Chamberlain <[email protected]>
[hch: split from a larger patch]
Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
mcgrof authored and axboe committed Aug 23, 2021
1 parent 614310c commit 92e7755
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion block/blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio,

struct request_queue *blk_alloc_queue(int node_id);

void disk_alloc_events(struct gendisk *disk);
int disk_alloc_events(struct gendisk *disk);
void disk_add_events(struct gendisk *disk);
void disk_del_events(struct gendisk *disk);
void disk_release_events(struct gendisk *disk);
Expand Down
7 changes: 4 additions & 3 deletions block/disk-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,17 +444,17 @@ module_param_cb(events_dfl_poll_msecs, &disk_events_dfl_poll_msecs_param_ops,
/*
* disk_{alloc|add|del|release}_events - initialize and destroy disk_events.
*/
void disk_alloc_events(struct gendisk *disk)
int disk_alloc_events(struct gendisk *disk)
{
struct disk_events *ev;

if (!disk->fops->check_events || !disk->events)
return;
return 0;

ev = kzalloc(sizeof(*ev), GFP_KERNEL);
if (!ev) {
pr_warn("%s: failed to initialize events\n", disk->disk_name);
return;
return -ENOMEM;
}

INIT_LIST_HEAD(&ev->node);
Expand All @@ -466,6 +466,7 @@ void disk_alloc_events(struct gendisk *disk)
INIT_DELAYED_WORK(&ev->dwork, disk_events_workfn);

disk->ev = ev;
return 0;
}

void disk_add_events(struct gendisk *disk)
Expand Down

0 comments on commit 92e7755

Please sign in to comment.