Comment 5 for bug 1920821

Revision history for this message
Juerg Haefliger (juergh) wrote :

Hmm.. The referenced commit [1] is in 5.11.0-11 (which is based on stable 5.11.7).

[1]
commit 73dfbeb7fdb1c9f1f1dc991e3ea10f4c3fd8a7fb
Author: Jan Kara <email address hidden>
Date: Mon Feb 22 10:48:09 2021 +0100

    block: Try to handle busy underlying device on discard

    BugLink: https://bugs.launchpad.net/bugs/1919492

    commit 56887cffe946bb0a90c74429fa94d6110a73119d upstream.

    Commit 384d87ef2c95 ("block: Do not discard buffers under a mounted
    filesystem") made paths issuing discard or zeroout requests to the
    underlying device try to grab block device in exclusive mode. If that
    failed we returned EBUSY to userspace. This however caused unexpected
    fallout in userspace where e.g. FUSE filesystems issue discard requests
    from userspace daemons although the device is open exclusively by the
    kernel. Also shrinking of logical volume by LVM issues discard requests
    to a device which may be claimed exclusively because there's another LV
    on the same PV. So to avoid these userspace regressions, fall back to
    invalidate_inode_pages2_range() instead of returning EBUSY to userspace
    and return EBUSY only of that call fails as well (meaning that there's
    indeed someone using the particular device range we are trying to
    discard).