Skip to content

bcachefs: Remove BCACHEFS_SB_MAX_SIZE & check#3001

Merged
karelzak merged 1 commit intoutil-linux:masterfrom
tasleson:bcachefs_correct_max_size_constant
May 1, 2024
Merged

bcachefs: Remove BCACHEFS_SB_MAX_SIZE & check#3001
karelzak merged 1 commit intoutil-linux:masterfrom
tasleson:bcachefs_correct_max_size_constant

Conversation

@tasleson
Copy link
Contributor

@tasleson tasleson commented Apr 29, 2024

The size of the super block as stated in the kernel:

  sb_max_size_bits; /* base 2 of 512 byte sectors */

So the existing constant is off by a factor of 512. This was discovered as some existing bcachefs FS have super blocks which exceed (1 << 0x010) or 65536.

This constant had an incorrect value. However, the code already
does a max. size check which is correct.

Note: bcachefs can theoretically have a superblock of 32MiB, but
this is very unlikely to happen.

@t-8ch
Copy link
Member

t-8ch commented Apr 30, 2024

In this case BCACHEFS_MAX_SIZE itself can be dropped.
The size is validated against sb_max_size_bits which itself is already validated against BCACHEFS_SB_MAX_SIZE_SHIFT.

@t-8ch
Copy link
Member

t-8ch commented Apr 30, 2024

These superblocks will also run into the global limit of 8MiB in blkid_probe_get_buffer().
So this fix is probably not enough.

@tasleson
Copy link
Contributor Author

These superblocks will also run into the global limit of 8MiB in blkid_probe_get_buffer(). So this fix is probably not enough.

I'm wondering if people would take issue with increasing this to 32MiB?

	if (len > 8388608 /* 8 Mib */ ) {
		DBG(BUFFER, ul_debug("\t  too large read request (ignore)"));
		return NULL;
	}

@t-8ch
Copy link
Member

t-8ch commented Apr 30, 2024

Or we provide a second function that is able to bypass that limit.
This way we don't have to weaken the failsafe globally.

This constant had an incorrect value.  However, the code already
does a max. size check which is correct.

Note: bcachefs can theoretically have a superblock of 32MiB, but
this is very unlikely to happen.

Signed-off-by: Tony Asleson <[email protected]>
@tasleson tasleson force-pushed the bcachefs_correct_max_size_constant branch from 5a3099f to 63ffa1c Compare April 30, 2024 18:46
@tasleson
Copy link
Contributor Author

@t-8ch I updated the PR to remove the max size constant and check. I spoke with Kent about the max size and realistically it should never get that big with most being significantly < 1 MiB. The user who was failing to find bcachefs super block with blkid had 1 that was ~70KB. It should be fine to leave the current max of 8MiB.

@tasleson tasleson changed the title bcachefs: Correct BCACHEFS_SB_MAX_SIZE bcachefs: Remove BCACHEFS_SB_MAX_SIZE & check Apr 30, 2024
Copy link
Member

@t-8ch t-8ch left a comment

Choose a reason for hiding this comment

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

Looks good and should also go to the maintenance branches.

@karelzak karelzak merged commit f4975bf into util-linux:master May 1, 2024
@karelzak
Copy link
Collaborator

karelzak commented May 1, 2024

Cherry-picked to stable/v2.40 too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants