[PATCH 3/3] ext4: notify when device not supprt inlinecrypt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Notify when mount filesystem with -o inlinecrypt option, but the device
not support inlinecrypt.

Signed-off-by: Fengnan Chang <changfengnan@xxxxxxxx>
---
 fs/ext4/super.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 81749eaddf4c..f91454d3a877 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -48,6 +48,7 @@
 #include <linux/fsnotify.h>
 #include <linux/fs_context.h>
 #include <linux/fs_parser.h>
+#include <linux/blk-crypto.h>
 
 #include "ext4.h"
 #include "ext4_extents.h"	/* Needed for trace points definition */
@@ -5466,6 +5467,17 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 				 "the device does not support discard");
 	}
 
+#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT
+	if (sb->s_flags & SB_INLINECRYPT) {
+		struct request_queue *q = bdev_get_queue(sb->s_bdev);
+
+		if (!blk_crypto_supported(q)) {
+			ext4_msg(sb, KERN_WARNING,
+			 "mounting with \"inlinecrypt\" option, but the device does not support inlinecrypt");
+			sb->s_flags &= ~SB_INLINECRYPT;
+		}
+	}
+#endif
+
 	if (es->s_error_count)
 		mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */
 
-- 
2.32.0




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux