Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Create.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@
return 0;
}

static void check_logical_block_size_compatibility(struct mdinfo *info)
{
char buf[10] = {0};

/*
* The logical block size feature is only used with metadata 1.x,
* so the metadata version also needs to be checked.
*/
if (sysfs_attribute_available(info, NULL, "logical_block_size") &&
sysfs_get_str(info, NULL, "metadata_version", buf, sizeof(buf)) > 0 &&
!memcmp(buf, "1.", 2)) {
pr_info("Arrays created by newer kernels have the logical block size feature enabled "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning here is not really valuable. I don't think people will remember, the array creation and kernel downgrade are usually not corelated,

If you see a risk, and risk is big enough to protect user then you should verify metadata and block mdadm from assembling such array with wrong kernel.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm of course open for discussion, please share you point of view.
For sure there are reasons you implemented it this way.

"by default. Such arrays can only be used on kernel versions later than 6.18\n");

Check failure on line 63 in Create.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING:SPLIT_STRING: quoted string split across lines
}

}

/**
* default_layout() - Get default layout for level.
* @st: metadata requested, could be NULL.
Expand Down Expand Up @@ -1303,6 +1320,14 @@
ioctl(mdfd, STOP_ARRAY, NULL);
goto abort;
}

/* After the kernel started supporting the logical block size feature,
* it modified the array metadata, which may lead to compatibility issues.
* As a result, arrays created on newer kernels cannot be used on older
* kernel versions, so users need to warned.
*/
check_logical_block_size_compatibility(&info);

/* if start_ro module parameter is set, array is
* auto-read-only, which is bad as the resync won't
* start. So lets make it read-write now.
Expand Down