-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Support msync #13511
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
Support msync #13511
Conversation
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
d1a9151 to
beaa844
Compare
|
[Experimental Bot, please feedback here] The provided PR description does not fully meet the NuttX requirements. Here's a breakdown and suggestions for improvement: Strengths:
Areas for Improvement:
Revised Impact Section Example: Additional Tips:
By improving the PR description, you make it easier for reviewers to understand your changes and ensure a smoother review process. |
Summary: 1.Added msync callback in struct mm_map_entry_s 2.Added msync API in fs_msync.c 3.Added static msync_rammap for rammap. Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
Summary: Limitations of using fs putfile Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
Summary: In rammap: 1.0 - User 2.1 - Kernel 3.2 - XIP Therefore we need to use 2 bits to represent the type Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
77df38a to
a7c520e
Compare
mmap/fs_rammap.c:81:39: error: expected ‘)’ before ‘PRIdOFF’
81 | ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos);
| ^~~~~~~
mmap/fs_rammap.c:81:12: warning: spurious trailing ‘%’ in format [-Wformat=]
81 | ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
mmap/fs_rammap.c:81:37: note: format string is defined here
81 | ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos);
| ^
In file included from mmap/fs_rammap.c:30:
mmap/fs_rammap.c:98:51: error: expected ‘)’ before ‘PRIdOFF’
98 | ferr("ERROR: Write failed: offset=%"PRIdOFF" nwrite=%zd\n",
| ^~~~~~~
mmap/fs_rammap.c:98:20: warning: spurious trailing ‘%’ in format [-Wformat=]
98 | ferr("ERROR: Write failed: offset=%"PRIdOFF" nwrite=%zd\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mmap/fs_rammap.c:98:49: note: format string is defined here
98 | ferr("ERROR: Write failed: offset=%"PRIdOFF" nwrite=%zd\n",
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
a7c520e to
f0d9d38
Compare
|
@crafcat7 please include this testing example to apps/testing, maybe inside ostest or other place |
@acassis it's a standard api, let's reuse ltp test case: |
Summary
Why is this change necessary
In some external test cases (such as FIO), they use the msync interface provided by the system to ensure that the rammap data can actually be written to the file system. Currently, mmap in NuttX does not provide this interface, so msync is implemented.
Changes
This mainly adds fs_msync.c under fs/mmap. And makes some adjustments to rammap.c and anonmap.c
Implementation details
Each mmap corresponds to an mm_map entry. The priv.p of each entry is used to save filep + type (the lower three bits of each priv.p represent type).
At each msync, the lower three bits of type need to be restored to filep and the data written
Refer to #5997 and implement an msync based on the current mmap
Follow https://man7.org/linux/man-pages/man2/msync.2.html
Impact
msync()system call is now supported.msync()to synchronize memory-mapped files with their corresponding files on disk. This is essential for applications that require data consistency between memory and storage.msync()functionality and its usage. These updates are included in this PR.msync()itself doesn't introduce new security vulnerabilities, however, improper usage ofmsync()by application developers could potentially lead to data corruption or inconsistencies.Testing
Build Host(s): Linux x86
Target(s): sim/nsh
Based on anonymous mapping and rammap demo is OK.