Reverted LFS_O_SYNC implicit noop sync broadcasting
Reading more into POSIX, it seems that most of the write functions do have special behavior built into what would implicitly be a noop. It's difficult to find, since it usually doesn't matter, but consider the m_time field. The following operations do _not_ update m_time: - write when size=0 - truncate when size does not change - fruncate when size does not change I think it's safe to extend these to sync broadcasts in littlefs, and only guarantee sync broadcasts when the file state has changed (even though that may mean other file handles may remain out-of-date!). In this interpretation, the "write operations" described in POSIX more mean the implicit write operations effected by write/truncate/fruncate. That being said, it's not clear what the best approach is, desync files make this all a bit more muddled... This may also be reverted.
This commit is contained in:
@@ -10520,9 +10520,8 @@ lfs_ssize_t lfsr_file_write(lfs_t *lfs, lfsr_file_t *file,
|
||||
// underlying file, this means no updating file pos or file size
|
||||
//
|
||||
// since we need to test for this, just return early
|
||||
lfs_size_t written = 0;
|
||||
if (size == 0) {
|
||||
goto noop;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// checkpoint the allocator
|
||||
@@ -10549,6 +10548,7 @@ lfs_ssize_t lfsr_file_write(lfs_t *lfs, lfsr_file_t *file,
|
||||
}
|
||||
|
||||
const uint8_t *buffer_ = buffer;
|
||||
lfs_size_t written = 0;
|
||||
while (size > 0) {
|
||||
// bypass buffer?
|
||||
//
|
||||
@@ -10631,7 +10631,6 @@ lfs_ssize_t lfsr_file_write(lfs_t *lfs, lfsr_file_t *file,
|
||||
// update our pos
|
||||
file->pos = pos;
|
||||
|
||||
noop:;
|
||||
// flush if requested
|
||||
//
|
||||
// this seems unreachable, but it's possible if we transition from
|
||||
@@ -10874,7 +10873,7 @@ int lfsr_file_truncate(lfs_t *lfs, lfsr_file_t *file, lfs_off_t size_) {
|
||||
// do nothing if our size does not change
|
||||
lfs_off_t size = lfsr_file_size_(file);
|
||||
if (lfsr_file_size_(file) == size_) {
|
||||
goto noop;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// checkpoint the allocator
|
||||
@@ -10943,7 +10942,6 @@ int lfsr_file_truncate(lfs_t *lfs, lfsr_file_t *file, lfs_off_t size_) {
|
||||
// mark as unsynced
|
||||
file->flags |= LFS_F_UNSYNCED;
|
||||
|
||||
noop:;
|
||||
// flush if requested
|
||||
//
|
||||
// this seems unreachable, but it's possible if we transition from
|
||||
@@ -10980,7 +10978,7 @@ int lfsr_file_fruncate(lfs_t *lfs, lfsr_file_t *file, lfs_off_t size_) {
|
||||
// do nothing if our size does not change
|
||||
lfs_off_t size = lfsr_file_size_(file);
|
||||
if (size == size_) {
|
||||
goto noop;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// checkpoint the allocator
|
||||
@@ -11077,7 +11075,6 @@ int lfsr_file_fruncate(lfs_t *lfs, lfsr_file_t *file, lfs_off_t size_) {
|
||||
// mark as unsynced
|
||||
file->flags |= LFS_F_UNSYNCED;
|
||||
|
||||
noop:;
|
||||
// flush if requested
|
||||
//
|
||||
// this seems unreachable, but it's possible if we transition from
|
||||
|
||||
Reference in New Issue
Block a user