[09/15] btrfs: block incompatible optional features at scan
diff mbox

Message ID 1447066589-3835-10-git-send-email-anand.jain@oracle.com
State New
Headers show

Commit Message

Anand Jain Nov. 9, 2015, 10:56 a.m. UTC
For the matter of completeness we need to check if the device
being scanned has features that are known to the kernel. As of
now if it doesn't - the mount will fails, then what is the point
in having those devices added to the btrfs_fs_devices list at

So block those devices at scan. Which means the original block at
open_ctee() won't reach in case of device with unsupported feature.
But I am leaving that code as it is. without deleting.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
 fs/btrfs/volumes.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff mbox

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index b52197b..fcc9e57 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -976,6 +976,7 @@  int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
 	u64 transid;
 	u64 total_devices;
 	u64 bytenr;
+	u64 features;
 	 * we would like to check all the supers, but that would make
@@ -996,6 +997,15 @@  int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
 	if (btrfs_read_disk_super(bdev, bytenr, &page, &disk_super))
 		goto error_bdev_put;
+	features = btrfs_super_incompat_flags(disk_super) &
+	if (features) {
+		printk(KERN_ERR \
+			"BTRFS: couldn't scan, unsupported optional features (%Lx)\n",
+			features);
+		ret = -EOPNOTSUPP;
+		goto error_disk_super;
+	}
 	devid = btrfs_stack_device_id(&disk_super->dev_item);
 	transid = btrfs_super_generation(disk_super);
 	total_devices = btrfs_super_num_devices(disk_super);
@@ -1010,6 +1020,7 @@  int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
 	if (!ret && fs_devices_ret)
 		(*fs_devices_ret)->total_devices = total_devices;