All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Mamedov <rm@romanrm.net>
To: linux-raid@vger.kernel.org
Subject: Slow discard on RAID1 with --write-mostly: split into 1MB requests
Date: Tue, 7 Feb 2023 03:01:40 +0500	[thread overview]
Message-ID: <20230207030140.138f5f75@nvm> (raw)

Hello,

I found that if an mdadm RAID1 is created with a write-mostly device, each
discard request to the array ends up being split into 1MB pieces. My SSD is
capable of processing at most 200 of these per second, so as a result
discarding a 512GB array takes 42 minutes.

The kernel is 6.1.9.

In both cases:

# grep . /sys/block/md0/queue/discard_*
/sys/block/md0/queue/discard_granularity:512
/sys/block/md0/queue/discard_max_bytes:2199023255040
/sys/block/md0/queue/discard_max_hw_bytes:2199023255040
/sys/block/md0/queue/discard_zeroes_data:0

Steps to reproduce:

# wipefs -a /dev/nvme1n1p2 /dev/nvme2n1p2
/dev/nvme1n1p2: 4 bytes were erased at offset 0x00001000 (linux_raid_member): fc 4e 2b a9
/dev/nvme2n1p2: 4 bytes were erased at offset 0x00001000 (linux_raid_member): fc 4e 2b a9

# mdadm --create --level 1 -n2 --assume-clean --metadata=1.2 /dev/md0 /dev/nvme1n1p2 /dev/nvme2n1p2
mdadm: array /dev/md0 started.

# mdadm --grow --array-size 10G /dev/md0 # (so that the test doesn't take forever)

# time blkdiscard -f /dev/md0

real	0m0.335s
user	0m0.000s
sys	0m0.003s

# mdadm --stop /dev/md0 
mdadm: stopped /dev/md0

# wipefs -a /dev/nvme1n1p2 /dev/nvme2n1p2
/dev/nvme1n1p2: 4 bytes were erased at offset 0x00001000 (linux_raid_member): fc 4e 2b a9
/dev/nvme2n1p2: 4 bytes were erased at offset 0x00001000 (linux_raid_member): fc 4e 2b a9

# mdadm --create --level 1 -n2 --assume-clean --metadata=1.2 /dev/md0 /dev/nvme1n1p2 --write-mostly /dev/nvme2n1p2
mdadm: array /dev/md0 started.

# mdadm --grow --array-size 10G /dev/md0

# time blkdiscard -f /dev/md0

real	0m48.744s
user	0m0.000s
sys	0m0.019s

-- 
With respect,
Roman

                 reply	other threads:[~2023-02-06 22:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230207030140.138f5f75@nvm \
    --to=rm@romanrm.net \
    --cc=linux-raid@vger.kernel.org \
    /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.