mirror_zfs/include/os/linux/kernel/linux
Rob N 72e4996a54 bdev_discard_supported: understand discard_granularity=0
Kernel documentation for the discard_granularity property says:

    A discard_granularity of 0 means that the device does not support
    discard functionality.

Some older kernels had drivers (notably loop, but also some USB-SATA
adapters) that would set the QUEUE_FLAG_DISCARD capability flag, but
have discard_granularity=0. Since 5.10 (torvalds/linux@b35fd7422c) the
discard entry point blkdev_issue_discard() has had a check for this,
which would immediately reject the call with EOPNOTSUPP, and throw a
scary diagnostic message into the log. See #16068.

Since 6.8, the block layer sets a non-zero default for
discard_granularity (torvalds/linux@3c407dc723), and a future kernel
will remove the check entirely[1].

As such, there's no good reason for us to enable discard when
discard_granularity=0. The kernel will never let the request go in
anyway; better that we just disable it so we can report it properly to
the user.

1. https://patchwork.kernel.org/project/linux-block/patch/20240312144826.1045212-2-hch@lst.de/

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
(cherry picked from commit b181b2e604)
2024-04-19 10:19:53 -07:00
..
blkdev_compat.h bdev_discard_supported: understand discard_granularity=0 2024-04-19 10:19:53 -07:00
compiler_compat.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
dcache_compat.h compact: workaround for GPL-only symbols on riscv from Linux 6.2 2024-01-16 13:27:29 -08:00
kmap_compat.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
mm_compat.h linux 5.4 compat: page_size() 2024-03-28 13:29:46 -07:00
mod_compat.h vdev_disk: rewrite BIO filling machinery to avoid split pages 2024-03-28 13:29:46 -07:00
page_compat.h Linux 5.9 compat: NR_SLAB_RECLAIMABLE 2020-08-29 20:57:45 -07:00
percpu_compat.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
simd_aarch64.h Linux 6.2 compat: add check for kernel_neon_* availability 2024-01-12 12:38:27 -08:00
simd_arm.h Linux 6.2 compat: add check for kernel_neon_* availability 2024-01-12 12:38:27 -08:00
simd_powerpc.h Refactor CONFIG_SPE check on Linux/powerpc 2023-03-15 10:30:42 -07:00
simd_x86.h Avoid save/restoring AMX registers to avoid a SPR erratum 2023-08-27 08:25:42 -07:00
simd.h Add SHA2 SIMD feature tests for Linux 2023-03-02 13:52:04 -08:00
utsname_compat.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
vfs_compat.h Linux 6.6 compat: generic_fillattr has a new u32 request_mask added at arg2 2023-11-08 12:15:41 -08:00
xattr_compat.h Linux 6.3 compat: idmapped mount API changes 2023-04-10 14:15:36 -07:00