Bug 219285 - getdents() does not list entries created after opening the directory
Summary: getdents() does not list entries created after opening the directory
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: fs_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-16 19:13 UTC by Krzysztof Małysa
Modified: 2024-10-01 11:39 UTC (History)
1 user (show)

See Also:
Kernel Version: 6.10.10
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Krzysztof Małysa 2024-09-16 19:13:15 UTC
As in the title, the below program illustrates the problem. Expected output should include line "entry: after", actual output does not:
```
entry: .
entry: ..
entry: before
```
Program:

```c
#include <unistd.h>
#include <dirent.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>

int main() {
	system("rm -rf /tmp/dirent-problems-test-dir");
	if (mkdir("/tmp/dirent-problems-test-dir", 0755)) {
		abort();
	}

	int fd = creat("/tmp/dirent-problems-test-dir/before", 0644);
	if (fd < 0) {
		abort();
	}
	close(fd);

	DIR* dir = opendir("/tmp/dirent-problems-test-dir");

	fd = creat("/tmp/dirent-problems-test-dir/after", 0644);
	if (fd < 0) {
		abort();
	}
	close(fd);

	struct dirent* entry;
	while ((entry = readdir(dir))) {
		printf("entry: %s\n", entry->d_name);
	}

	closedir(dir);
	return 0;
}
```

Affected kernel version: 6.10.10.
Filesystem: ext4.
Distribution: Arch Linux.
Comment 1 Krzysztof Małysa 2024-09-16 19:36:15 UTC
On Linux 6.6.51 it works as expected.
Comment 2 The Linux kernel's regression tracker (Thorsten Leemhuis) 2024-09-25 13:38:25 UTC
Could you check if 6.11 is still affected and bisect https://docs.kernel.org/next/admin-guide/bug-bisect.html ?
Comment 3 Krzysztof Małysa 2024-09-27 21:04:52 UTC
Regression first appeared in 6.10.7, 6.10.6 was good. I will further bisect tomorrow.
Comment 4 Krzysztof Małysa 2024-09-27 21:05:19 UTC
6.11 is still affected.
Comment 5 Krzysztof Małysa 2024-09-28 15:13:26 UTC
308b4fc2403b335894592ee9dc212a5e58bb309f is the first bad commit.

Reverting it fixes the bug both on 6.10.11 and 6.11.
Comment 6 The Linux kernel's regression tracker (Thorsten Leemhuis) 2024-10-01 11:08:58 UTC
thx; can I CC you when forwarding this report by mail? this would expose your email address to the public
Comment 7 Krzysztof Małysa 2024-10-01 11:12:36 UTC
Ye, you can CC me.
Comment 8 The Linux kernel's regression tracker (Thorsten Leemhuis) 2024-10-01 11:39:33 UTC
TWIMC: forwarded https://lore.kernel.org/regressions/8196cf54-5783-4905-af00-45a869537f7c@leemhuis.info/

Note You need to log in before you can comment on or make changes to this bug.