This is a note to let you know that I've just added the patch titled s390/dasd: put block allocation in separate function to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: s390-dasd-put-block-allocation-in-separate-function.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 6dca41f5bf941263d40b5b8f7c988860c39bbba8 Author: Stefan Haberland <sth@xxxxxxxxxxxxx> Date: Tue Sep 20 21:26:10 2022 +0200 s390/dasd: put block allocation in separate function [ Upstream commit 2b43bf061b2e1b67561cbb1f6f305421f5fc86af ] Put block allocation into a separate function to put some copy pair logic in it in a later patch. Signed-off-by: Stefan Haberland <sth@xxxxxxxxxxxxx> Reviewed-by: Jan Hoeppner <hoeppner@xxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20220920192616.808070-2-sth@xxxxxxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Stable-dep-of: c3116e62ddef ("s390/dasd: fix double module refcount decrement") Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index 56ab74aa07f42..cf80db7a74a3d 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c @@ -2028,6 +2028,25 @@ static void dasd_eckd_kick_validate_server(struct dasd_device *device) dasd_put_device(device); } +static int dasd_eckd_alloc_block(struct dasd_device *device) +{ + struct dasd_block *block; + struct dasd_uid temp_uid; + + dasd_eckd_get_uid(device, &temp_uid); + if (temp_uid.type == UA_BASE_DEVICE) { + block = dasd_alloc_block(); + if (IS_ERR(block)) { + DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s", + "could not allocate dasd block structure"); + return PTR_ERR(block); + } + device->block = block; + block->base = device; + } + return 0; +} + /* * Check device characteristics. * If the device is accessible using ECKD discipline, the device is enabled. @@ -2036,8 +2055,6 @@ static int dasd_eckd_check_characteristics(struct dasd_device *device) { struct dasd_eckd_private *private = device->private; - struct dasd_block *block; - struct dasd_uid temp_uid; int rc, i; int readonly; unsigned long value; @@ -2095,19 +2112,10 @@ dasd_eckd_check_characteristics(struct dasd_device *device) device->default_expires = value; } - dasd_eckd_get_uid(device, &temp_uid); - if (temp_uid.type == UA_BASE_DEVICE) { - block = dasd_alloc_block(); - if (IS_ERR(block)) { - DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s", - "could not allocate dasd " - "block structure"); - rc = PTR_ERR(block); - goto out_err1; - } - device->block = block; - block->base = device; - } + /* check if block device is needed and allocate in case */ + rc = dasd_eckd_alloc_block(device); + if (rc) + goto out_err1; /* register lcu with alias handling, enable PAV */ rc = dasd_alias_make_device_known_to_lcu(device);