From patchwork Wed May 1 11:09:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13650456 X-Patchwork-Delegate: snitzer@redhat.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EAB386AE9; Wed, 1 May 2024 11:09:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714561761; cv=none; b=nodOQjA+Kg+K1GcZqGvEACJKg/rrH3HTTrW8jKR+cx5RVl5UXRw1r0n3MR6b4y1F9ulh0tYiXLD/uYm3vCSas116pvY8F8PGpHHL7QRO7CcNfloPXd91PqWzUkSXd2ZL/rUyYmyPNXlkZSHLT1RMAU9h/XT8BvZ7EZNcYDq89Cc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714561761; c=relaxed/simple; bh=y3+WkSsCwjLGqujRlTas9TE+y/lYVxrLmSN7j8qYloY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B+/G+TPRPEM2if+S+x9DOsQOJqYqCmD7fwW55XU/tcxHPqrgLfHCs087QWIpihyF0pnC6OrShGWnYYPpKQY4x23YXieKV3h0sPC5d3damSETojibl7bPLoHUXda8GxP7QN0PZyWvxKvB6yybjszDo4D/yjhFrLBwnQ0ehlwLkuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RZSjL0Ec; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RZSjL0Ec" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 340B5C113CC; Wed, 1 May 2024 11:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714561761; bh=y3+WkSsCwjLGqujRlTas9TE+y/lYVxrLmSN7j8qYloY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RZSjL0EcAV5ay95awdpWiK5yB+xapVEkQKQeoBQfUEdcrnYnaP3oj6fREZYvSo5iy FtSMdG+kyO3AjGEfd66j8OtSilmItOVKg6m6BTo/4LSwVv6PUMC3rY+iYrDZTIJ2Rn AYeNijbhMV7jikFu/fClbpJoXBTBcH/d9J1qkZtNBzU10eIRfAxAtQYefWuPqQm2CD i5oJVBJf2ysnVJqFq0r4aR9g8kLm3xhWpF/8f+R0X2dX5rPI1f7USSejsKFPbWuW54 cIXGzzSB9Ju9tAudd4YJRiR6PbN5hfM2hgCYuxRLVUSeW5uPlM5HhtTU84NfYfoBgS b5AAc8vzuRrjA== From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , dm-devel@lists.linux.dev, Mike Snitzer Subject: [PATCH v3 10/14] block: Improve blk_zone_write_plug_bio_merged() Date: Wed, 1 May 2024 20:09:03 +0900 Message-ID: <20240501110907.96950-11-dlemoal@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240501110907.96950-1-dlemoal@kernel.org> References: <20240501110907.96950-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Improve blk_zone_write_plug_bio_merged() to check that we succefully get a reference on the zone write plug of the merged BIO, as expected since for a merge we already have at least one request and one BIO referencing the zone write plug. Comments in this function are also improved to better explain the references to the BIO zone write plug. Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke --- block/blk-zoned.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/block/blk-zoned.c b/block/blk-zoned.c index cd0049f5bf2f..1890b6d55d8b 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -885,11 +885,16 @@ void blk_zone_write_plug_bio_merged(struct bio *bio) bio_set_flag(bio, BIO_ZONE_WRITE_PLUGGING); /* - * Increase the plug reference count and advance the zone write - * pointer offset. + * Get a reference on the zone write plug of the target zone and advance + * the zone write pointer offset. Given that this is a merge, we already + * have at least one request and one BIO referencing the zone write + * plug. So this should not fail. */ zwplug = disk_get_zone_wplug(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector); + if (WARN_ON_ONCE(!zwplug)) + return; + spin_lock_irqsave(&zwplug->lock, flags); zwplug->wp_offset += bio_sectors(bio); spin_unlock_irqrestore(&zwplug->lock, flags);