Skip to content

Commit

Permalink
linux/zvol_os.c: Fix max_discard_sectors limit for 6.8+ kernel
Browse files Browse the repository at this point in the history
In the 6.8+ kernel, the zvol block device is allocated with qlimits
passed during initialization. The `max_hw_discard_sectors` is not set,
which is necessary to properly initialize `max_discard_sectors`. This
causes the `zvol_misc_trim` test to fail on the 6.8+ kernel as it
invokes the `blkdiscard` command, which then fails. To maintain
compatibility, `blk_queue_max_discard_sectors` is used to set the
discard sectors limits.

Signed-off-by: Ameer Hamza <[email protected]>
  • Loading branch information
ixhamza committed Aug 19, 2024
1 parent 816d2b2 commit 3af5c63
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions module/os/linux/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,8 @@ zvol_alloc_non_blk_mq(struct zvol_state_os *zso, zvol_queue_limits_t *limits)
zso->zvo_queue = zso->zvo_disk->queue;

#ifndef HAVE_BLKDEV_QUEUE_LIMITS_FEATURES
blk_queue_max_discard_sectors(zso->zvo_queue,
limits->zql_max_discard_sectors);
blk_queue_set_write_cache(zso->zvo_queue, B_TRUE);
#endif

Expand Down

0 comments on commit 3af5c63

Please sign in to comment.