Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbd: Use assume_storage_prezeroed when formatting #4996

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

black-dragon74
Copy link
Member

@black-dragon74 black-dragon74 commented Dec 3, 2024

Describe what this PR does

Instead of passing lazy_itable_init=1 and lazy_journal_init=1 to
mkfs.ext4, pass assume_storage_prezeroed=1 which is
stronger and allows the filesystem to skip inode table zeroing
completely instead of simply doing it lazily.

The support for this flag is checked by trying to format a fake
temporary image with mkfs.ext4 and checking its STDERR.

Closes: #4948

@black-dragon74 black-dragon74 added the DNM DO NOT MERGE label Dec 3, 2024
@mergify mergify bot added the component/rbd Issues related to RBD label Dec 3, 2024
@@ -101,7 +101,7 @@ var (
xfsHasReflink = xfsReflinkUnset

mkfsDefaultArgs = map[string][]string{
"ext4": {"-m0", "-Enodiscard,lazy_itable_init=1,lazy_journal_init=1"},
"ext4": {"-m0", "-Enodiscard,assume_storage_prezeroed=1"},
Copy link
Member

Choose a reason for hiding this comment

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

make sure that you only do this when mkfs.ext4 supports the option, you'll need to add some form of detection, ideally with something like sync.Once.

Copy link
Contributor

Choose a reason for hiding this comment

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

assume_storage_prezeroed option became available in e2fsprogs 1.47.0 last year, so it should probably be "discovered" similar to xfsSupportsReflink().

My suggestion to do it similar to xfsSupportsReflink() isn't viable because mkfs.ext4 doesn't include extended options in its help output, but trying with assume_storage_prezeroed=1 and falling back to lazy_itable_init=1,lazy_journal_init=1 upon parsing out Bad option(s) specified: assume_storage_prezeroed error should work.

Copy link
Member Author

@black-dragon74 black-dragon74 Dec 27, 2024

Choose a reason for hiding this comment

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

I and Madhu had a discussion on this. Since this flag is part of e2fsprogs >= 1.47 and we have control over which version of it we bundle in the container, do we really need this check?

Sidenote: Detection is possible by parsing the semver of e2fsprogs. It is standard flag so it must be there?

Copy link
Contributor

Choose a reason for hiding this comment

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

The check for the version isn't always reliable in the face of downstream backports.

Copy link
Collaborator

Choose a reason for hiding this comment

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

as @idryomov mentioned we cannot depend on the version check, as the base image includes the required version, we could say what is supported by this version but that could be a problem if someone wants to build/test custom images. let's depend on the error check and fall back that works for all the cases.

@black-dragon74 black-dragon74 marked this pull request as ready for review January 6, 2025 11:58
@black-dragon74 black-dragon74 removed the DNM DO NOT MERGE label Jan 6, 2025
@black-dragon74 black-dragon74 force-pushed the stor-prezeroed branch 2 times, most recently from 2699bc7 to 6b52f64 Compare January 6, 2025 12:25
@@ -67,6 +67,10 @@ const (
xfsReflinkNoSupport
xfsReflinkSupport

ext4PrezeroedUnset
Copy link
Member

Choose a reason for hiding this comment

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

restart counting again, use ext4PrezeroedUnset = itoa

Copy link
Member Author

Choose a reason for hiding this comment

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

go doesn't consider iota twice in the same const block :(

internal/rbd/nodeserver.go Outdated Show resolved Hide resolved
internal/rbd/nodeserver.go Outdated Show resolved Hide resolved
internal/rbd/nodeserver.go Outdated Show resolved Hide resolved
internal/rbd/nodeserver.go Outdated Show resolved Hide resolved
@black-dragon74 black-dragon74 force-pushed the stor-prezeroed branch 2 times, most recently from 3d4e46b to ed5b89a Compare January 8, 2025 09:33
Copy link
Member

@nixpanic nixpanic 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, just a few nits and potential improvements

internal/rbd/nodeserver.go Outdated Show resolved Hide resolved
internal/rbd/nodeserver.go Outdated Show resolved Hide resolved
internal/rbd/nodeserver.go Outdated Show resolved Hide resolved
// "assume_storage_prezeroed" option. It does this by creating a temporary
// image file, attempting to format it with the ext4 filesystem using the
// "assume_storage_prezeroed" option, and checking the output for errors.
func (ns *NodeServer) ext4SupportsPrezeroed() bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about if we check if this is supported or not in the driver.go(if we are stating it as nodeplugin) before starting the node plugin and store it in the Nodeserver struct like its suggested here https://github.com/ceph/ceph-csi/pull/4996/files#r1910308642?

Copy link
Member Author

Choose a reason for hiding this comment

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

As the result for this is cached, let's check it when we need it instead of doing it preemptively? This way also has the added benefit of keeping driver.go simple. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

I think this is sufficient for now. It could be placed in some internal/util/... package, and keep a single initialization with sync.Once there. That could be an improvement, but I don't think it is really needed at the moment.

@black-dragon74 black-dragon74 force-pushed the stor-prezeroed branch 2 times, most recently from 288c82e to d782438 Compare January 17, 2025 10:44
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

file, err := os.CreateTemp("", "test-sparse-")
Copy link
Member

Choose a reason for hiding this comment

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

place this in the t.TempDir() directory for automatic cleanup, no need to have to remove the file in a defer.

Copy link
Member

Choose a reason for hiding this comment

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

Rebased and fixed this nit for you :-)

@nixpanic nixpanic requested a review from a team January 22, 2025 13:15
@nixpanic
Copy link
Member

@Mergifyio queue

Copy link
Contributor

mergify bot commented Jan 24, 2025

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at c308e09

Instead of passing lazy_itable_init=1 and lazy_journal_init=1 to
mkfs.ext4, pass assume_storage_prezeroed=1 which is
stronger and allows the filesystem to skip inode table zeroing
completely instead of simply doing it lazily.

The support for this flag is checked by trying to format a fake
temporary image with mkfs.ext4 and checking its STDERR.

Closes: ceph#4948
Signed-off-by: Niraj Yadav <[email protected]>
@mergify mergify bot added the ok-to-test Label to trigger E2E tests label Jan 24, 2025
@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/upgrade-tests-cephfs

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.30

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/upgrade-tests-rbd

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.30

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.32

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.31

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.30

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.31

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.32

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.31

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.32

@ceph-csi-bot ceph-csi-bot removed the ok-to-test Label to trigger E2E tests label Jan 24, 2025
@mergify mergify bot merged commit c308e09 into ceph:devel Jan 24, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/rbd Issues related to RBD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass assume_storage_prezeroed option when formatting ext4 if possible
5 participants