From patchwork Thu Apr 11 20:15:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 13626538 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B61A1865A for ; Thu, 11 Apr 2024 20:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712866548; cv=none; b=bxTkJfrE9uMwgbFhl3bw64rhaD/E94GJy5QwrsuJzUOFbiRA7TuRkoDWPuU7NtXkafJm+H1I2eUculPyOj4Ei+AWbCJah6W63Ty8xyzNoeF9BrRwyvOzuxLVrd7oYTOm/EVqpb+mPfvb8nHXZ5UdQCYtmV8Rek/2U9I8S6Rl++c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712866548; c=relaxed/simple; bh=NCmePHzNKfUHxeWZ/7p62pycueR+0yKWjQDJGF7HN2U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WL4oJMwRAi1eWir57XjHDiSuCLPxMYhQVvbpr8obKJxGQSDlW4BK1HBkjmHNc0Qm8BFEyG1z5P4jhW2HLsF4QdXsctc3znCJKPcBrgwub7zzQxuP/W1G7/smZO/6aoFnU7d7ijL6Fy25OdYelWLGdzgHuaCaZhO+COi7gb0biQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=redhat.com; arc=none smtp.client-ip=209.85.167.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-3c397193878so107612b6e.3 for ; Thu, 11 Apr 2024 13:15:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712866544; x=1713471344; 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=Sz075QmnPQTwVkv9vCOIw5mtXzBKUg3sK8QUXHUdUYU=; b=nOlwcmxLtFBAaqc7VuSC59zosgW3yx3cPX98N5dJ/ChVxJKz8VyH+RexFCHcAaF7wf OygN6bdWtEMmW2X7g6+8/cobSCCQckSwarWqRxyYjW5qh+v++S9ClRmdsS0rFz2h9LqE zrgIZD8hEOzm3pxqJC9T10e6vjXyeYwzfbyeY1GtRfZEGKcXi5d5ZPSlz+vdDbZqBOdZ N1jOWZkf2oglt8Q7wSlDc84ovQptNGS22RDb5jgRqSqO9/VuzBIYNw45niVXoza+37sC ZHOAI2zVNQ1/xThRnGy7/MbW+EHAFA0O61WwoozeDFF/1aGqxqGm19p7rxdmoITlj0yl MQ7w== X-Forwarded-Encrypted: i=1; AJvYcCUShmwSJZeRljl3lkzeyIJMqQ5vYU/vbpv8WFKjs6rAKuoyBHybfKEXa222IHGlX+ecqwBGyOQyuU9U2Q1uoF8DilXJ6JWGABWzr0A= X-Gm-Message-State: AOJu0Yx2+uEbPBh1RsrMPseckqdSe8CzmIJWUcD8aLsOYOyMCv/ovQPt A086jM593XFzyklJPtFnAdIvE2Gsx/Y7icfoURmHN/kvaN8J0u+79W8zvdhZxw== X-Google-Smtp-Source: AGHT+IHL6H9kovsai/jdp/4wUYtvJaa4EBLsSbF2gTIz+Lyj7LcB8K99xqE39taXcIN/P3p/doo3AQ== X-Received: by 2002:a54:4083:0:b0:3c5:fa38:c651 with SMTP id i3-20020a544083000000b003c5fa38c651mr671839oii.18.1712866544300; Thu, 11 Apr 2024 13:15:44 -0700 (PDT) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id jr13-20020a05622a800d00b00434c25cb61bsm1312751qtb.73.2024.04.11.13.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 13:15:42 -0700 (PDT) From: Mike Snitzer To: hch@lst.de Cc: axboe@kernel.dk, dm-devel@lists.linux.dev, linux-block@vger.kernel.org, mpatocka@redhat.com, Abelardo Ricart III , Brandon Smith , Linus Torvalds , Ming Lei , Mike Snitzer Subject: [PATCH for-6.10 1/2] dm-crypt: stop constraining max_segment_size to PAGE_SIZE Date: Thu, 11 Apr 2024 16:15:28 -0400 Message-Id: <20240411201529.44846-2-snitzer@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This change effectively reverts commit 586b286b110e ("dm crypt: constrain crypt device's max_segment_size to PAGE_SIZE") and relies on block core's late bio-splitting to ensure that dm-crypt's encryption bios are split accordingly if they exceed the underlying device's limits (e.g. max_segment_size). Commit 586b286b110e was applied as a 4.3 fix for the benefit of stable@ kernels 4.0+ just after block core's late bio-splitting was introduced in 4.3 with commit 54efd50bfd873 ("block: make generic_make_request handle arbitrarily sized bios"). Given block core's late bio-splitting it is past time that dm-crypt make use of it. Also, given the recent need to revert meaningful progress that was attempted during the 6.9 merge window (see commit bff4b74625fe Revert "dm: use queue_limits_set") this change allows DM core to safely make use of queue_limits_set() without risk of breaking dm-crypt on NVMe. Though it should be noted this commit isn't a prereq for reinstating DM core's use of queue_limits_set() because blk_validate_limits() was made less strict with commit b561ea56a264 ("block: allow device to have both virt_boundary_mask and max segment size"). Signed-off-by: Mike Snitzer Reviewed-by: Christoph Hellwig Reviewed-by: Mikulas Patocka Reviewed-by: Ming Lei --- drivers/md/dm-crypt.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 5bfa35760167..f43a2c0b3d77 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1656,8 +1656,8 @@ static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone); /* * Generate a new unfragmented bio with the given size - * This should never violate the device limitations (but only because - * max_segment_size is being constrained to PAGE_SIZE). + * This should never violate the device limitations (but if it did then block + * core should split the bio as needed). * * This function may be called concurrently. If we allocate from the mempool * concurrently, there is a possibility of deadlock. For example, if we have @@ -3717,14 +3717,6 @@ static void crypt_io_hints(struct dm_target *ti, struct queue_limits *limits) { struct crypt_config *cc = ti->private; - /* - * Unfortunate constraint that is required to avoid the potential - * for exceeding underlying device's max_segments limits -- due to - * crypt_alloc_buffer() possibly allocating pages for the encryption - * bio that are not as physically contiguous as the original bio. - */ - limits->max_segment_size = PAGE_SIZE; - limits->logical_block_size = max_t(unsigned int, limits->logical_block_size, cc->sector_size); limits->physical_block_size = From patchwork Thu Apr 11 20:15:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 13626539 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C526A1863B for ; Thu, 11 Apr 2024 20:15:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712866548; cv=none; b=Eoo4C9ixy0udPmcHouDLra6ahBYDPaQxluue1xaAK6MHsPwdXdC9QQTuofMf0BtIwSWMbNkQ+pmCPpp4PiznmHBIDky51uW91w0sU3eOrPKPV7woZr2ukgmk2lIpZMRq5dvDw1dvaqsXyBhDFYNvjWWJgKQiJE11goOk6ItdxC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712866548; c=relaxed/simple; bh=DF0z31XI1+xb0ikzM2l5oMRUQ/TAK8DEHHzwXdyf6LY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CdKEFmsS3V5v8PkcZ2Wly8JTdzrAhPQlDPDbY7PxDL5y2JjEJByP6K/+KkBujl5JeWYI79CoDTc+uv8Q9Dhgc42pnCBKfW1ngytd/1Mpvpw/WwiYtL58c+uzXv2fmgtc8wyirodNP1BAkIcSNODhO9stEFWnildOHf6yI+W4V0U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=redhat.com; arc=none smtp.client-ip=209.85.222.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-78ebc7e1586so127248985a.1 for ; Thu, 11 Apr 2024 13:15:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712866546; x=1713471346; 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=LpITuEe31p+a/qxo+70eR67S4eJD4GXO5prTh59KfsI=; b=PANjW6KnzjIyHgx7Jfq/+5nxQFHGH7XUWNErMnJEoo/Ats99HRNC6mnbiZHg+Z3qxT D54vWQxNzhgjsjTTcx5ecuQS/mN5sP33CdWLb4vkhKe/GPwXTciOoMSoB93pIFQbLwS6 PEng/soRaRaPJKQXg9UiwmmvSmFd1zprirk2qwG0/8Tau337CjXcZcZ58+ByZajdgu9p Erbm9Y8nseopp5zrbCLUTm8KU43lLuyaP9Hw7J3xS03NffN+aOCZK8gK55dSkcC8G1yl pYWo6hS2qI0AKskRPOt2MdSYPN9qk4tkNe2d9+XKG0rEpGZCh7X0NWhdWkegbpIto4UF 3n4g== X-Forwarded-Encrypted: i=1; AJvYcCXIWNRs3ad7q0C8quKnmpiL/FQB64WiFrybs3UVq2NlBt5vPlKiecKJvNW+sCog7tkxk6RXdlGPC/g22C5GZBcr5hGUlxm92asy+X0= X-Gm-Message-State: AOJu0Yxv78RNJew8TSoVWpjmKfT/+tbSgk+LbN3FGqXPgPf65K6kzCxd TG4Df9gY/Wv8OmtMdSOJqfFIZZ4YdsT4ilR5pd7UW0qo8NarZ3LYl0O7yFrR9TBEqdOPpsKLDFE = X-Google-Smtp-Source: AGHT+IFD6dL8mum13/FhxCLc737M/JKz4982DitzcuBRP2vPJobFwxJmSUBGIFfWCnAAGImVzkjbdg== X-Received: by 2002:a05:620a:1a22:b0:78e:bd2f:1088 with SMTP id bk34-20020a05620a1a2200b0078ebd2f1088mr1327700qkb.4.1712866545769; Thu, 11 Apr 2024 13:15:45 -0700 (PDT) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id d4-20020a37c404000000b0078d761e7b50sm1440968qki.106.2024.04.11.13.15.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 13:15:45 -0700 (PDT) From: Mike Snitzer To: hch@lst.de Cc: axboe@kernel.dk, dm-devel@lists.linux.dev, linux-block@vger.kernel.org, mpatocka@redhat.com, Abelardo Ricart III , Brandon Smith , Linus Torvalds , Ming Lei , Mike Snitzer Subject: [PATCH for-6.10 2/2] dm: use queue_limits_set Date: Thu, 11 Apr 2024 16:15:29 -0400 Message-Id: <20240411201529.44846-3-snitzer@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Use queue_limits_set which validates the limits and takes care of updating the readahead settings instead of directly assigning them to the queue. For that make sure all limits are actually updated before the assignment. Signed-off-by: Christoph Hellwig Signed-off-by: Mike Snitzer Reviewed-by: Ming Lei --- drivers/md/dm-table.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 41f1d731ae5a..88114719fe18 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1963,26 +1963,27 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, bool wc = false, fua = false; int r; - /* - * Copy table's limits to the DM device's request_queue - */ - q->limits = *limits; - if (dm_table_supports_nowait(t)) blk_queue_flag_set(QUEUE_FLAG_NOWAIT, q); else blk_queue_flag_clear(QUEUE_FLAG_NOWAIT, q); if (!dm_table_supports_discards(t)) { - q->limits.max_discard_sectors = 0; - q->limits.max_hw_discard_sectors = 0; - q->limits.discard_granularity = 0; - q->limits.discard_alignment = 0; - q->limits.discard_misaligned = 0; + limits->max_hw_discard_sectors = 0; + limits->discard_granularity = 0; + limits->discard_alignment = 0; + limits->discard_misaligned = 0; } + if (!dm_table_supports_write_zeroes(t)) + limits->max_write_zeroes_sectors = 0; + if (!dm_table_supports_secure_erase(t)) - q->limits.max_secure_erase_sectors = 0; + limits->max_secure_erase_sectors = 0; + + r = queue_limits_set(q, limits); + if (r) + return r; if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_WC))) { wc = true; @@ -2007,9 +2008,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, else blk_queue_flag_set(QUEUE_FLAG_NONROT, q); - if (!dm_table_supports_write_zeroes(t)) - q->limits.max_write_zeroes_sectors = 0; - dm_table_verify_integrity(t); /* @@ -2047,7 +2045,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, } dm_update_crypto_profile(q, t); - disk_update_readahead(t->md->disk); /* * Check for request-based device is left to