]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
f2fs: Always enable discard for zoned blocks devices
authorDamien Le Moal <damien.lemoal@wdc.com>
Fri, 28 Oct 2016 08:45:03 +0000 (17:45 +0900)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 23 Nov 2016 20:11:19 +0000 (12:11 -0800)
Zone write pointer reset acts as discard for zoned block
devices. So if the zoned block device feature is enabled,
always declare that discard is enabled, even if the device
does not actually support the command.
For the same reason, prevent the use the "nodicard" mount
option.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/super.c

index 47e7a97bdc6c165643d9be28096080bee8af581c..707beab1afec79b05adba40d6aa46395fd9fe4c1 100644 (file)
@@ -1111,13 +1111,6 @@ static inline void clear_ckpt_flags(struct f2fs_sb_info *sbi, unsigned int f)
        spin_unlock(&sbi->cp_lock);
 }
 
-static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi)
-{
-       struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev);
-
-       return blk_queue_discard(q);
-}
-
 static inline void f2fs_lock_op(struct f2fs_sb_info *sbi)
 {
        down_read(&sbi->cp_rwsem);
@@ -2423,6 +2416,13 @@ static inline int f2fs_sb_mounted_blkzoned(struct super_block *sb)
        return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED);
 }
 
+static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi)
+{
+       struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev);
+
+       return blk_queue_discard(q) || f2fs_sb_mounted_blkzoned(sbi->sb);
+}
+
 static inline void set_opt_mode(struct f2fs_sb_info *sbi, unsigned int mt)
 {
        clear_opt(sbi, ADAPTIVE);
index 56b0d2a5a590bbe3f954dfa29383b559d7464ae3..7bb0b36ae5e6246f93c79df7d907e29eaf16c846 100644 (file)
@@ -419,6 +419,11 @@ static int parse_options(struct super_block *sb, char *options)
                        }
                        break;
                case Opt_nodiscard:
+                       if (f2fs_sb_mounted_blkzoned(sb)) {
+                               f2fs_msg(sb, KERN_WARNING,
+                                       "discard is required for zoned block devices");
+                               return -EINVAL;
+                       }
                        clear_opt(sbi, DISCARD);
                        break;
                case Opt_noheap: