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

fix(devinfo): add consistent read for kernel bug #65

Merged
merged 1 commit into from
Feb 16, 2024
Merged

Conversation

niladrih
Copy link
Member

@niladrih niladrih commented Feb 12, 2024

Fixes openebs/mayastor#1274

On the linux kernel versions below v5.8, there's a bug which behaves like so:
Whenever a read(2) syscall is issued (and this one takes an argument for how many bytes to read off of a file) to the /proc/mounts virtual file, few of the mount entries are read off of it. The kernel maintains the seek position of the file so that it can serve subsequent read(2)s from that position. But, in between the first and the second read(2), a device might be unmounted and one/few mount entries might be removed from the already-read portion of the file. This moves the mount entries after the deleted entries further up the file. However, the seek position has not changed. So, subsequent read(2)s will miss one or more read entries, as the seek position now points to a mount entry further down the list.
Ref: torvalds/linux@9f6c61f

Changes:
This PR adds a consistent_read() implementation for the interface MountIter for kernel versions less than 5.8.0. consistent_read() reads the whole file twice start to end, and compares the two byte buffers. If both of the subsequent reads resulted in the same byte-sequence, then we can say we have not lost mount entries when traversing /proc/mounts, as then the comparison would fail on the second read from start to end. This is configured to default to 2 comparison retries if the first comparison fails. However that may not be enough if there are very many mount entries and the host has very frequent unmounts. Use higher retries for those cases.

@niladrih
Copy link
Member Author

@tiagolobocastro and others -- should I remove the MountIter::new() API as I intend to refactor control-plane and mayastor to use SafeMountIter instead?

@niladrih
Copy link
Member Author

Is the linter CI issue because of std::sync::OnceLock?

@tiagolobocastro
Copy link
Contributor

Is the linter CI issue because of std::sync::OnceLock?

Non-related, @datacore-vvarakantham is fixing this

@tiagolobocastro
Copy link
Contributor

@tiagolobocastro and others -- should I remove the MountIter::new() API as I intend to refactor control-plane and mayastor to use SafeMountIter instead?

We need to keep I think, otherwise you can't merge this PR independently to the other repos?

@niladrih
Copy link
Member Author

@tiagolobocastro and others -- should I remove the MountIter::new() API as I intend to refactor control-plane and mayastor to use SafeMountIter instead?

We need to keep I think, otherwise you can't merge this PR independently to the other repos?

Yeah, it's fine to keep it.

Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
@pchandra19 pchandra19 merged commit 6b39a25 into develop Feb 16, 2024
3 checks passed
@pchandra19 pchandra19 deleted the fix-1274 branch February 16, 2024 09:17
niladrih added a commit to openebs/mayastor-control-plane that referenced this pull request Feb 18, 2024
Ref: openebs/mayastor-dependencies#65

Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
niladrih added a commit to openebs/mayastor-control-plane that referenced this pull request Feb 19, 2024
Ref: openebs/mayastor-dependencies#65

Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
niladrih added a commit to openebs/mayastor-control-plane that referenced this pull request Feb 19, 2024
Ref: openebs/mayastor-dependencies#65

Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
niladrih added a commit to openebs/mayastor-control-plane that referenced this pull request Feb 19, 2024
Ref: openebs/mayastor-dependencies#65

Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
niladrih added a commit to openebs/mayastor-control-plane that referenced this pull request Feb 19, 2024
Ref: openebs/mayastor-dependencies#65

Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
niladrih added a commit to openebs/mayastor that referenced this pull request Feb 19, 2024
niladrih added a commit to openebs/mayastor that referenced this pull request Feb 19, 2024
niladrih added a commit to openebs/mayastor-control-plane that referenced this pull request Feb 20, 2024
Ref: openebs/mayastor-dependencies#65

Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
bors-openebs-mayastor bot pushed a commit to openebs/mayastor-control-plane that referenced this pull request Feb 20, 2024
749: refactor(csi-driver): replace MountIters with SafeMountIters r=niladrih a=niladrih

Changes:
- Replaces MountIters with SafeMountIters.

Ref:
- openebs/mayastor-dependencies#65
- openebs/mayastor#1591

Co-authored-by: Niladri Halder <niladri.halder26@gmail.com>
niladrih added a commit to openebs/mayastor that referenced this pull request Feb 20, 2024
niladrih added a commit to openebs/mayastor that referenced this pull request Feb 21, 2024
niladrih added a commit to openebs/mayastor that referenced this pull request Feb 21, 2024
niladrih added a commit to openebs/mayastor that referenced this pull request Feb 21, 2024
niladrih added a commit to openebs/mayastor that referenced this pull request Feb 21, 2024
niladrih added a commit to openebs/mayastor that referenced this pull request Feb 21, 2024
bors-openebs-mayastor bot pushed a commit to openebs/mayastor that referenced this pull request Feb 21, 2024
1591: refactor(io-engine): use SafeMountIter instead of proc_mounts::MountIter r=niladrih a=niladrih

Changes:
- Removes proc_mounts as a dependency.
- Adds utils/dependencies/devinfo as a depdency
- Uses devinfo::mountinfo::SafeMountIter in place of proc_mounts::MountIter

Ref:
- openebs/mayastor-dependencies#65
- openebs/mayastor-control-plane#749

Co-authored-by: Niladri Halder <niladri.halder26@gmail.com>
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.

csi-node is unable to find mount during statefulset scale in
4 participants