[PATCH v2 0/4] mtd: block2mtd: convert to folios

Tal Zussman tz2294 at columbia.edu
Fri Oct 16 12:11:06 PDT 2026


block2mtd still goes through the page wrappers around the folio page
cache API, each of which hides a compound_head() call. Convert the read,
write and erase paths to use folios directly. This removes a
compound_head() call per page in the read path and four per page in the
write and erase paths, and leaves the driver with no struct page usage.

The first patch fixes a pre-existing race in the write and erase paths,
which could modify a page that invalidate_bdev() had already dropped
from the page cache.

Tested on KVM with the MTD test modules and fsx/fsstress on UBIFS with
no errors.

The numbers below are the time in ms for one pass over a 256 MiB
device, by folio size, from mtd_speedtest except the last row, which
is from the MEMERASE ioctl:

+------------------------------+-------+--------+---------+---------+
| Test                         | Folio |   Base | Patched |  Change |
+------------------------------+-------+--------+---------+---------+
| Eraseblock read (128 KiB)    |   4K  |  20.25 |   19.55 |   -3.4% |
|                              |  16K  |  20.19 |   14.55 |  -27.9% |
|                              |  64K  |  20.21 |   13.24 |  -34.5% |
+------------------------------+-------+--------+---------+---------+
| Eraseblock write (128 KiB)   |   4K  |  26.37 |   25.01 |   -5.1% |
|                              |  16K  |  26.10 |   17.62 |  -32.5% |
|                              |  64K  |  25.69 |   15.45 |  -39.8% |
+------------------------------+-------+--------+---------+---------+
| Page read (512 B)            |   4K  |  75.70 |   72.02 |   -4.9% |
|                              |  16K  |  76.50 |   73.00 |   -4.6% |
|                              |  64K  |  76.44 |   72.96 |   -4.5% |
+------------------------------+-------+--------+---------+---------+
| Page write (512 B)           |   4K  | 113.57 |  109.59 |   -3.5% |
|                              |  16K  | 114.42 |  109.73 |   -4.1% |
|                              |  64K  | 114.39 |  109.57 |   -4.2% |
+------------------------------+-------+--------+---------+---------+
| 2-page read (1 KiB)          |   4K  |  48.42 |   46.40 |   -4.2% |
|                              |  16K  |  48.96 |   47.07 |   -3.9% |
|                              |  64K  |  48.59 |   47.07 |   -3.1% |
+------------------------------+-------+--------+---------+---------+
| 2-page write (1 KiB)         |   4K  |  63.61 |   61.28 |   -3.7% |
|                              |  16K  |  63.96 |   61.20 |   -4.3% |
|                              |  64K  |  63.82 |   60.85 |   -4.6% |
+------------------------------+-------+--------+---------+---------+
| Erase, blocks hold data      |   4K  |  15.40 |   14.13 |   -8.3% |
| (mtd_speedtest)              |  16K  |  15.28 |   10.48 |  -31.4% |
|                              |  64K  |  15.22 |   10.13 |  -33.4% |
+------------------------------+-------+--------+---------+---------+
| Erase, already erased        |   4K  |  26.60 |   18.30 |  -31.2% |
| (MEMERASE ioctl)             |  16K  |  26.70 |   15.10 |  -43.4% |
|                              |  64K  |  26.50 |   14.40 |  -45.7% |
+------------------------------+-------+--------+---------+---------+

---
Changes in v2:
- Patch 1 (new): Retry if the page was dropped from the page cache
  between the lookup and the lock, per Sashiko.
- Patches 3 and 4: Carry that retry over to the folio loops.
- Cover: Report the benchmark as time per pass over a 256 MiB device
  instead of throughput.
- Link to v1: https://patch.msgid.link/20261014-block2mtd-folio-v1-0-19d24ae676ee@columbia.edu

---
Tal Zussman (4):
      mtd: block2mtd: retry if the page was dropped from the page cache
      mtd: block2mtd: convert block2mtd_read() to folios
      mtd: block2mtd: convert _block2mtd_write() to folios
      mtd: block2mtd: convert _block2mtd_erase() to folios

 drivers/mtd/devices/block2mtd.c | 128 +++++++++++++++++++---------------------
 1 file changed, 60 insertions(+), 68 deletions(-)
---
base-commit: 2f7fa8d90694d21dce68ceabd8383252b111cfea
change-id: 20261012-block2mtd-folio-9ccb6639c05a

Best regards,
--  
Tal Zussman <tz2294 at columbia.edu>




More information about the linux-mtd mailing list