From patchwork Thu Jun 1 09:40:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 1788898 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=IjgHkEVl; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QX1Mn4CM1z20Py for ; Thu, 1 Jun 2023 19:40:36 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1q4enD-0001EM-GY; Thu, 01 Jun 2023 09:40:27 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1q4enC-0001Dr-9w for kernel-team@lists.ubuntu.com; Thu, 01 Jun 2023 09:40:26 +0000 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 0AAC73F234 for ; Thu, 1 Jun 2023 09:40:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1685612426; bh=iJkYR3H7n1qqvA5VuDpGdt4l6CajwalhMQyVUki7CiI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IjgHkEVlCXLnNnY5GxpIunnXQwhbN8Zgdt4LFB59piYubTJ8rxFMON/D14cqkHTqT If41EL2mwH7FM+RTh8KTEnGADFNDjytDSNkLabXX23i4OHxydN5nVkP/mpiH30aNQ+ 9hMzjnSpO4EwFK4FVRv3WkidFFjhL1a8a0mrGTritgs00S9Mg2O/WqDZDMk3PfZ7P4 CsD4HEOsF9xZT0zJ0FNazDUdc48PG3bM8baD6KKP4cCTJbnzudYq7A7ddS5JFnl5iG 7TZW04/Tj5lj3z6tn/WzedBrNF6+KKAhN74Onm153nY5/lMbyTDGkK+SU2JLD4Qo8Y 5WnM//rk+2N9w== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-51496307313so543985a12.1 for ; Thu, 01 Jun 2023 02:40:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685612425; x=1688204425; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iJkYR3H7n1qqvA5VuDpGdt4l6CajwalhMQyVUki7CiI=; b=J1rsKPGLW9x7QqFx6ckpZdvnB51PiK7lRsxlOiZPKaNryNtk1AndaK5jI2DnJEACfW laEz/J/8fFK9eQbImP19e1yT9ksdOAWqAAD/Ll1sU0h8lGRkOdKCwI4Ytx2RuAGh1Qk/ C6JYzog8qcdqwSOYMLnaYWwU9rEaZvbYzMq7IG8j+R9uZPOQsrmo7uK4cq0lDK91f4Xc XjJOp0032YKUWaADAxKIxZpixyP7KMeerzzaqgyKq+HZBD058GrAZD2CXvFm5z9lBmc7 X8FvAGwEz4EYNnvG7QGtLGM0CgvU4Mn3rzY690MjJzf/2PpxZ02nFDL575AyvTwVSDIO yyzw== X-Gm-Message-State: AC+VfDw+DwOoB6CGYPYzrx8+eC/zTFNBqbSlNC8QVTVUffnHGL6TNM95 Dd0dhTn3nKAhnW4AYZ8iRDBK5veMaoUvRfGLzhCqAwUrlr5+N2PG96u20ydKKaXp2UToxj1RSIO TKLZ8Z0hb0FfZ1BOhYC3r22npDjfw9NMr/fk70YUns0DFWET3Qg== X-Received: by 2002:aa7:c902:0:b0:514:95ce:fb24 with SMTP id b2-20020aa7c902000000b0051495cefb24mr5317446edt.40.1685612425313; Thu, 01 Jun 2023 02:40:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WoEH7VNvCJ22meLaAp5FCNJiveh5L/Fx2xZclrPQgPra8CvVdkjNOo1pPxPBsh/DO3+7RsQ== X-Received: by 2002:aa7:c902:0:b0:514:95ce:fb24 with SMTP id b2-20020aa7c902000000b0051495cefb24mr5317437edt.40.1685612425122; Thu, 01 Jun 2023 02:40:25 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-068-085.002.205.pools.vodafone-ip.de. [2.205.68.85]) by smtp.gmail.com with ESMTPSA id r16-20020a056402019000b00514b3a2008esm2733758edv.2.2023.06.01.02.40.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 02:40:24 -0700 (PDT) From: Alexander Mikhalitsyn To: kernel-team@lists.ubuntu.com Subject: [SRU][K:master-next][PATCH v3 1/2] block: handle bio_split_to_limits() NULL return Date: Thu, 1 Jun 2023 11:40:05 +0200 Message-Id: <20230601094006.171590-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230601094006.171590-1-aleksandr.mikhalitsyn@canonical.com> References: <20230601094006.171590-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kamal.mostafa@canonical.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jens Axboe BugLink: https://bugs.launchpad.net/bugs/2020901 This can't happen right now, but in preparation for allowing bio_split_to_limits() returning NULL if it ended the bio, check for it in all the callers. Signed-off-by: Jens Axboe (backported from 613b14884b8595e20b9fac4126bf627313827fbe) [amikhalitsyn: context adjustments] Signed-off-by: Alexander Mikhalitsyn --- block/blk-merge.c | 4 +++- block/blk-mq.c | 5 ++++- drivers/block/drbd/drbd_req.c | 2 ++ drivers/block/ps3vram.c | 2 ++ drivers/md/dm.c | 2 ++ drivers/md/md.c | 2 ++ drivers/nvme/host/multipath.c | 2 ++ drivers/s390/block/dcssblk.c | 2 ++ 8 files changed, 19 insertions(+), 2 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 88e39b955bd6..1af8043900f4 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -348,11 +348,13 @@ void __blk_queue_split(struct request_queue *q, struct bio **bio, break; default: split = blk_bio_segment_split(q, *bio, &q->bio_split, nr_segs); + if (IS_ERR(split)) + *bio = split = NULL; break; } if (split) { - /* there isn't chance to merge the splitted bio */ + /* there isn't chance to merge the split bio */ split->bi_opf |= REQ_NOMERGE; blkcg_bio_issue_init(split); diff --git a/block/blk-mq.c b/block/blk-mq.c index 7c7e632871e7..fc6a5b003780 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2815,8 +2815,11 @@ void blk_mq_submit_bio(struct bio *bio) blk_status_t ret; blk_queue_bounce(q, &bio); - if (blk_may_split(q, bio)) + if (blk_may_split(q, bio)) { __blk_queue_split(q, &bio, &nr_segs); + if (!bio) + return; + } if (!bio_integrity_prep(bio)) return; diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index e60d3c6314c6..f323a4714f6a 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -1609,6 +1609,8 @@ void drbd_submit_bio(struct bio *bio) struct drbd_device *device = bio->bi_bdev->bd_disk->private_data; blk_queue_split(&bio); + if (!bio) + return; /* * what we "blindly" assume: diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index 4f90819e245e..2a431178dc7e 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -587,6 +587,8 @@ static void ps3vram_submit_bio(struct bio *bio) dev_dbg(&dev->core, "%s\n", __func__); blk_queue_split(&bio); + if (!bio) + return; spin_lock_irq(&priv->lock); busy = !bio_list_empty(&priv->list); diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 5acee96b5a7b..bf904c153d41 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1674,6 +1674,8 @@ static void dm_split_and_process_bio(struct mapped_device *md, * otherwise associated queue_limits won't be imposed. */ blk_queue_split(&bio); + if (!bio) + return; } init_clone_info(&ci, md, map, bio, is_abnormal); diff --git a/drivers/md/md.c b/drivers/md/md.c index 946434ced070..772a89843226 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -465,6 +465,8 @@ static void md_submit_bio(struct bio *bio) } blk_queue_split(&bio); + if (!bio) + return; if (mddev->ro == 1 && unlikely(rw == WRITE)) { if (bio_sectors(bio) != 0) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index d62c4a0f89ab..571c4791faa8 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -351,6 +351,8 @@ static void nvme_ns_head_submit_bio(struct bio *bio) * pool from the original queue to allocate the bvecs from. */ blk_queue_split(&bio); + if (!bio) + return; srcu_idx = srcu_read_lock(&head->srcu); ns = nvme_find_path(head); diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index f4401b2d30e0..18506cc222ba 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -865,6 +865,8 @@ dcssblk_submit_bio(struct bio *bio) unsigned long bytes_done; blk_queue_split(&bio); + if (!bio) + return; bytes_done = 0; dev_info = bio->bi_bdev->bd_disk->private_data; From patchwork Thu Jun 1 09:40:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 1788899 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=ixPWkNoM; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QX1Mq3V6xz20Py for ; Thu, 1 Jun 2023 19:40:39 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1q4enJ-0001I3-PI; Thu, 01 Jun 2023 09:40:33 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1q4enH-0001Gs-Tf for kernel-team@lists.ubuntu.com; Thu, 01 Jun 2023 09:40:31 +0000 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 81E3C3F452 for ; Thu, 1 Jun 2023 09:40:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1685612431; bh=MInKnttFcng1O/WkDaJ4oZQ3IcwI2pG8e0BvGlRLFII=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ixPWkNoM9xFXPcwtQzSy+Ti4OhgG7ngs51c320wlr+Hy/6XuPTdG77OC9nMapAsWu 5Tb+d5ObylY/1f5WKpXpKdREOj73o7c99pCH8eH73uv0E/A5icYWS/tMqUmPCpOm09 V4o6P7AUSduIhO+kvdLl3+5R7wexLSSCQUEyDEoOGs1QuZvDKi00tdt7eQUvRu2JUX 8lK3aGS+W/Wrg6r/8PQY1T7qpz0J/NqQYY42rCQFxanKGbEiToTff9nSnWknMX0Ts7 RbxTqwFMmVCG2mnLTC28Coz9aQmKM+pTMfeGrYCuOh3cY5uXSmOaPO9YD92f2uYbcj nj+5ndJG+8SqA== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-51496307313so544035a12.1 for ; Thu, 01 Jun 2023 02:40:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685612431; x=1688204431; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MInKnttFcng1O/WkDaJ4oZQ3IcwI2pG8e0BvGlRLFII=; b=eUuZZnSxLG94rGTUdg0yWy+potZOWDjPAFThoDjdWuAhFzE4+FvZysv1TeIJFxJWNo lceX9jMKxiX5199FzvjVGEeZ9By79ie1AAooObGk1sKoS3A2XVhU7xXzZW0upkGsRE3O KcbJU5ISyoxQWkafN1o4S6t65eJo/Eb0C95BtKKYOExg5rW43BclRfzTFIfLpeDEBbVx 0xCQfeFf1MBFeW3d5kIDZm2CgPuh03SRPaVvwv7AoRVpvwZ8B1HWRrJav1NCofxLlkjV 9jF2qtVzffHu6s1N+8TN0IW1b9T7SXjR5wQfdrFsZ52b8dvstau1JXTlrQUrc3/SsVB/ nBXQ== X-Gm-Message-State: AC+VfDyd1IldLJt451+m8AP49D9nCajHD0GD1bfj/aOwLSC3RqZzTIxl E2aR4xygNSUEsnmRRLvQukfY+AC8A9gNYImbWR3906hxVdmSUF65FBng+omeFo3qbIEnq8OraRX omMeVqgg4IkkJ9jVgxapbt9YMyo9tE8+Gqz1luy/in7kugeWyVQ== X-Received: by 2002:a50:ee04:0:b0:514:90de:423e with SMTP id g4-20020a50ee04000000b0051490de423emr6032705eds.36.1685612431051; Thu, 01 Jun 2023 02:40:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ52c2+OLzNgcJNeVvxar6LlsB1deeZx4bt8byt/FQnog4T0WuvKq8O1yLYlVCNzBEyggiciDQ== X-Received: by 2002:a50:ee04:0:b0:514:90de:423e with SMTP id g4-20020a50ee04000000b0051490de423emr6032694eds.36.1685612430897; Thu, 01 Jun 2023 02:40:30 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-068-085.002.205.pools.vodafone-ip.de. [2.205.68.85]) by smtp.gmail.com with ESMTPSA id r16-20020a056402019000b00514b3a2008esm2733758edv.2.2023.06.01.02.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 02:40:30 -0700 (PDT) From: Alexander Mikhalitsyn To: kernel-team@lists.ubuntu.com Subject: [SRU][K:master-next][PATCH v3 2/2] pktcdvd: check for NULL returna fter calling bio_split_to_limits() Date: Thu, 1 Jun 2023 11:40:06 +0200 Message-Id: <20230601094006.171590-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230601094006.171590-1-aleksandr.mikhalitsyn@canonical.com> References: <20230601094006.171590-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kamal.mostafa@canonical.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jens Axboe BugLink: https://bugs.launchpad.net/bugs/2020901 The revert of the removal of this driver happened after we fixed up the split limits for NOWAIT issue, hence it got missed. Ensure that we check for a NULL bio after splitting, in case it should be retried. Marking this as fixing both commits, so that stable backport will do this correctly. Cc: stable@vger.kernel.org Fixes: 9cea62b2cbab ("block: don't allow splitting of a REQ_NOWAIT bio") Fixes: 4b83e99ee709 ("Revert "pktcdvd: remove driver."") Signed-off-by: Jens Axboe (backported from 3e9900f3bd7ba30d60f82b162b70a1dffe4e8e24) [amikhalitsyn: adjust context bio_split_to_limits -> blk_queue_split] Signed-off-by: Alexander Mikhalitsyn --- drivers/block/pktcdvd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 789093375344..1988bb05c0c7 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2400,6 +2400,8 @@ static void pkt_submit_bio(struct bio *bio) struct bio *split; blk_queue_split(&bio); + if (!bio) + return; pkt_dbg(2, pd, "start = %6llx stop = %6llx\n", (unsigned long long)bio->bi_iter.bi_sector,