Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: stop issuing discards if not supported by device

Turn off issuance of discard requests if the device does
not support it - similar to the action we take for barriers.
This will save a little computation time if a non-discardable
device is mounted with -o discard, and also makes it obvious
that it's not doing what was asked at mount time ...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

authored by

Eric Sandeen and committed by
Theodore Ts'o
a30eec2a 6b0310fb

+7 -1
+7 -1
fs/ext4/mballoc.c
··· 2534 2534 entry->count, entry->group, entry); 2535 2535 2536 2536 if (test_opt(sb, DISCARD)) { 2537 + int ret; 2537 2538 ext4_fsblk_t discard_block; 2538 2539 2539 2540 discard_block = entry->start_blk + ··· 2542 2541 trace_ext4_discard_blocks(sb, 2543 2542 (unsigned long long)discard_block, 2544 2543 entry->count); 2545 - sb_issue_discard(sb, discard_block, entry->count); 2544 + ret = sb_issue_discard(sb, discard_block, entry->count); 2545 + if (ret == EOPNOTSUPP) { 2546 + ext4_warning(sb, 2547 + "discard not supported, disabling"); 2548 + clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); 2549 + } 2546 2550 } 2547 2551 2548 2552 err = ext4_mb_load_buddy(sb, entry->group, &e4b);