f2fs: disable the discard option when device doesn't support
authorChenxi Mao <chenxi.mao2013@gmail.com>
Sat, 30 May 2015 14:56:46 +0000 (22:56 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 1 Jun 2015 23:21:32 +0000 (16:21 -0700)
Current f2fs check the whether the blk device can support discard.
However, the code will cause the discard option cannot be enabled.
Because the clear_opt(sbi, DISCARD) will be invoked forever.

This patch can fix this issue.

Jaegeuk Kim:
 The original patch was intended to disable the discard option when device
 does not support trim command.
 Rather than remaining the buggy patch, let's replace with this patch as
 an integrated one.

Signed-off-by: Chenxi Mao <chenxi.mao2013@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/super.c

index 8b5f5fb8f5cb4e1d0e7c3487e90396b7ac08a558..f0be6a62120ac392f9af341d27f1fcdf2651f544 100644 (file)
@@ -1237,10 +1237,12 @@ try_onemore:
 
        if (test_opt(sbi, DISCARD)) {
                struct request_queue *q = bdev_get_queue(sb->s_bdev);
-               if (!blk_queue_discard(q))
+               if (!blk_queue_discard(q)) {
                        f2fs_msg(sb, KERN_WARNING,
                                        "mounting with \"discard\" option, but "
                                        "the device does not support discard");
+                       clear_opt(sbi, DISCARD);
+               }
        }
 
        sbi->s_kobj.kset = f2fs_kset;