shailesh jain wrote:
> Here it is.
> Outcome is that Child gets deleted but parent does not get deleted.
> (Now you will say it's a filesystem issue ;) ....)

Let's start with the command you used here.
It must not have been rm -rf, because the ENOENT is not being ignored:

> fstatat64(AT_FDCWD, "parent", {st_mode=S_IFDIR|0755, st_size=72, ...},
> AT_SYMLINK_NOFOLLOW) = 0
> unlinkat(AT_FDCWD, "parent", 0)         = -1 EISDIR (Is a directory)
> openat(AT_FDCWD, "parent",
> O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE|O_NOFOLLOW)
> = 3
> fstat64(3, {st_mode=S_IFDIR|0755, st_size=72, ...}) = 0
> fstat64(3, {st_mode=S_IFDIR|0755, st_size=72, ...}) = 0
> fcntl64(3, F_GETFL)                     = 0x28800 (flags
> O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_NOFOLLOW)
> fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
> fstat64(3, {st_mode=S_IFDIR|0755, st_size=72, ...}) = 0
> getdents64(3, /* 3 entries */, 1024)    = 80
> openat(3, "Child", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE|O_NOFOLLOW) = 4
> fstat64(4, {st_mode=S_IFDIR|0755, st_size=48, ...}) = 0
> fstat64(4, {st_mode=S_IFDIR|0755, st_size=48, ...}) = 0
> fcntl64(4, F_GETFL)                     = 0x28800 (flags
> O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_NOFOLLOW)
> fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
> close(3)                                = 0
> fcntl64(4, F_GETFD)                     = 0x1 (flags FD_CLOEXEC)
> fstat64(4, {st_mode=S_IFDIR|0755, st_size=48, ...}) = 0
> getdents64(4, /* 2 entries */, 1024)    = 48
> getdents64(4, /* 0 entries */, 1024)    = 0
> fcntl64(4, F_GETFD)                     = 0x1 (flags FD_CLOEXEC)
> openat(4, "..", O_RDONLY|O_LARGEFILE)   = 3
> close(4)                                = 0
> fstat64(3, {st_mode=S_IFDIR|0755, st_size=72, ...}) = 0
> unlinkat(3, "Child", AT_REMOVEDIR)      = 0
> fstat64(3, {st_mode=S_IFDIR|0755, st_size=72, ...}) = 0
> fcntl64(3, F_GETFL)                     = 0x8000 (flags
> O_RDONLY|O_LARGEFILE)
> fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
> fstat64(3, {st_mode=S_IFDIR|0755, st_size=72, ...}) = 0
> getdents64(3, /* 3 entries */, 1024)    = 80
> openat(3, "Child", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE|O_NOFOLLOW) = -1
> ENOENT (No such file or directory)
> getdents64(3, /* 0 entries */, 1024)    = 0
> fcntl64(3, F_GETFD)                     = 0x1 (flags FD_CLOEXEC)

POSIX allows readdir to work that way.

I already suggested that making this change might help you:

-    CONSECUTIVE_READDIR_UNLINK_THRESHOLD = 10
+    CONSECUTIVE_READDIR_UNLINK_THRESHOLD = 1


Reply via email to