drivers/quota.makeBackingFsDev(): use mknod+rename#1280
Merged
vrothberg merged 1 commit intocontainers:mainfrom Jul 8, 2022
Merged
drivers/quota.makeBackingFsDev(): use mknod+rename#1280vrothberg merged 1 commit intocontainers:mainfrom
vrothberg merged 1 commit intocontainers:mainfrom
Conversation
Use mknod() followed by rename() to create the "backingFsBlockDev" device, instead of unlink() followed by mknod(), to remove the window where the node won't exist if we're just going to end up replacing it with an identical device node. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Member
Author
|
May be applicable to https://bugzilla.redhat.com/show_bug.cgi?id=2091214, but without knowing what removed /var/lib/containers/storage/overlay/backingFsBlockDev, we can't be sure. |
rhatdan
reviewed
Jul 7, 2022
| if err := unix.Mknod(backingFsBlockDevTmp, unix.S_IFBLK|0600, int(stat.Dev)); err != nil { | ||
| return "", fmt.Errorf("Failed to mknod %s: %v", backingFsBlockDevTmp, err) | ||
| } | ||
| if err := unix.Rename(backingFsBlockDevTmp, backingFsBlockDev); err != nil { |
Member
There was a problem hiding this comment.
Rename is allowed over an existing device?
Member
Author
There was a problem hiding this comment.
Per rename(2), yes. We'll get EEXIST back if we're using renameat2() and with a RENAME_NOREPLACE flag.
rhatdan
approved these changes
Jul 7, 2022
Member
|
LGTM |
| if err := unix.Mknod(backingFsBlockDev, unix.S_IFBLK|0600, int(stat.Dev)); err != nil { | ||
| return "", fmt.Errorf("Failed to mknod %s: %v", backingFsBlockDev, err) | ||
| if err := unix.Mknod(backingFsBlockDevTmp, unix.S_IFBLK|0600, int(stat.Dev)); err != nil { | ||
| return "", fmt.Errorf("Failed to mknod %s: %v", backingFsBlockDevTmp, err) |
Member
There was a problem hiding this comment.
Suggested change
| return "", fmt.Errorf("Failed to mknod %s: %v", backingFsBlockDevTmp, err) | |
| return "", fmt.Errorf("failed to mknod %s: %w", backingFsBlockDevTmp, err) |
| return "", fmt.Errorf("Failed to mknod %s: %v", backingFsBlockDevTmp, err) | ||
| } | ||
| if err := unix.Rename(backingFsBlockDevTmp, backingFsBlockDev); err != nil { | ||
| return "", fmt.Errorf("Failed to rename %s to %s: %v", backingFsBlockDevTmp, backingFsBlockDev, err) |
Member
There was a problem hiding this comment.
Suggested change
| return "", fmt.Errorf("Failed to rename %s to %s: %v", backingFsBlockDevTmp, backingFsBlockDev, err) | |
| return "", fmt.Errorf("failed to rename %s to %s: %w", backingFsBlockDevTmp, backingFsBlockDev, err) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use mknod() followed by rename() to create the "backingFsBlockDev" device, instead of unlink() followed by mknod(), to remove the window where the node won't exist if we're just going to end up replacing it with an identical device node.