All of lore.kernel.org
 help / color / mirror / Atom feed
From: Itai Handler <itai.handler@gmail.com>
To: dm-devel@redhat.com
Cc: snitzer@redhat.com, agk@redhat.com
Subject: [dm-devel] [RFC PATCH 1/1] dm crypt: change maximum sector size to PAGE_SIZE
Date: Wed, 10 Nov 2021 19:43:23 +0200	[thread overview]
Message-ID: <CAFpOueRBb9y_Fgb3-c6_eFTKZR9DoAXZmxqqx0UH1Yb2rbV0RQ@mail.gmail.com> (raw)

Maximum sector size of dm-crypt is currently limited to 4096 bytes.

On systems where PAGE_SIZE is larger than 4096 bytes, using larger
sectors can be beneficial for performance reasons.

This patch changes maximum sector size from 4096 bytes to PAGE_SIZE,
and in addition it changes the type of sector_size in
struct crypt_config from 'unsigned short int' to 'unsigned int', in
order to be able to represent larger values.

On a prototype system which has PAGE_SIZE of 65536 bytes, I saw about
x2 performance improvement in sequential read throughput benchmark
while using only about half of the CPU usage, after simply increasing
sector size from 4096 to 65536 bytes.
I used ext4 filesystem for that benchmark, which supports 64KiB
sectors.

Note: A small change should be made in cryptsetup in order to add
support for sectors larger than 4096 bytes.

Signed-off-by: Itai Handler <itai.handler@gmail.com>
---
 drivers/md/dm-crypt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 916b7da16de2..78c239443bd5 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -168,7 +168,7 @@ struct crypt_config {
        } iv_gen_private;
        u64 iv_offset;
        unsigned int iv_size;
-       unsigned short int sector_size;
+       unsigned int sector_size;
        unsigned char sector_shift;

        union {
@@ -3115,9 +3115,9 @@ static int crypt_ctr_optional(struct dm_target
*ti, unsigned int argc, char **ar
                        cc->cipher_auth = kstrdup(sval, GFP_KERNEL);
                        if (!cc->cipher_auth)
                                return -ENOMEM;
-               } else if (sscanf(opt_string, "sector_size:%hu%c",
&cc->sector_size, &dummy) == 1) {
+               } else if (sscanf(opt_string, "sector_size:%u%c",
&cc->sector_size, &dummy) == 1) {
                        if (cc->sector_size < (1 << SECTOR_SHIFT) ||
-                           cc->sector_size > 4096 ||
+                           cc->sector_size > PAGE_SIZE ||
                            (cc->sector_size & (cc->sector_size - 1))) {
                                ti->error = "Invalid feature value for
sector_size";
                                return -EINVAL;
-- 
2.17.1

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


             reply	other threads:[~2021-11-10 17:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10 17:43 Itai Handler [this message]
2021-11-11 13:07 ` [dm-devel] [RFC PATCH 1/1] dm crypt: change maximum sector size to PAGE_SIZE Milan Broz
2021-11-12 15:32   ` Mike Snitzer
2021-11-14 11:56   ` Itai Handler
2021-11-25 16:28     ` Itai Handler
2021-11-27 11:19       ` Milan Broz
2021-11-28 15:33         ` Itai Handler
2022-03-13 14:53           ` Itai Handler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFpOueRBb9y_Fgb3-c6_eFTKZR9DoAXZmxqqx0UH1Yb2rbV0RQ@mail.gmail.com \
    --to=itai.handler@gmail.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=snitzer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.