@@ -480,6 +480,7 @@ struct btrfs_super_block {
#define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7)
#define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8)
#define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9)
+#define BTRFS_FEATURE_INCOMPAT_TEST (1ULL << 10)
#define BTRFS_FEATURE_COMPAT_SUPP 0ULL
@@ -495,7 +496,8 @@ struct btrfs_super_block {
BTRFS_FEATURE_INCOMPAT_RAID56 | \
BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA | \
- BTRFS_FEATURE_INCOMPAT_NO_HOLES)
+ BTRFS_FEATURE_INCOMPAT_NO_HOLES | \
+ BTRFS_FEATURE_INCOMPAT_TEST)
/*
* A leaf is full of items. offset and size tell us where to find
@@ -1368,7 +1368,7 @@ int main(int ac, char **av)
int dev_cnt = 0;
int saved_optind;
char fs_uuid[BTRFS_UUID_UNPARSED_SIZE] = { 0 };
- u64 features = BTRFS_MKFS_DEFAULT_FEATURES;
+ u64 features = BTRFS_MKFS_DEFAULT_FEATURES | BTRFS_FEATURE_INCOMPAT_TEST;
struct mkfs_allocation allocation = { 0 };
struct btrfs_mkfs_config mkfs_cfg;
------------------------------------------------------------
Results..
btrfs dev scan /dev/sdc
Scanning for Btrfs filesystems in '/dev/sdc'
ERROR: device scan failed '/dev/sdc' - Protocol family not supported
btrfs dev ready /dev/sdc
ERROR: unable to determine if device '/dev/sdc' is ready for mount: Protocol family not supported
mount /dev/sdc /btrfs
mount: mount /dev/sdc on /btrfs failed: Protocol family not supported
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2: Commit update with unit test case and its results.
Remove the printk the error to system log, thats not required.
Return -EPFNOSUPPORT instead of -ENOSUPPORT, thats more appropriate
when device with incompatible feature is found during device scan.
fs/btrfs/volumes.c | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -1071,6 +1071,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
@@ -1091,6 +1092,12 @@ 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) &
+ ~BTRFS_FEATURE_INCOMPAT_SUPP;
+ if (features) {
+ ret = -EPFNOSUPPORT;
+ 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);
@@ -1105,6 +1112,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;
+error_disk_super:
btrfs_release_disk_super(page);
error_bdev_put: