On Tue 07-04-20 11:21:01, Andreas Dilger wrote: > While looking at this code, I noticed that ext4_empty_dir() considers a > directory without a "." or ".." entry to be empty. I see this was changed > in 64d4ce8923 ("ext4: fix ext4_empty_dir() for directories with holes"). > I can understand that we want to not die on corrupted leaf blocks, but it > isn't clear to me that it is a good idea to allow deleting an entire > directory tree if the first block has an error (missing "." or ".." as the > first and second entries) but is otherwise valid. There were definitely > bugs in the past that made "." or ".." not be the first and second entries. That's a good question. I'd just say that ext4_empty_dir() generally returns true when there's some problem with the directory. In commit 64d4ce8923 I just followed that convention. This behavior of ext4_empty_dir() (and empty_dir() before in ext3) dates back at least to the beginning of git history... I guess we could err on the safer side and disallow directory deletion if there is any problem with it but I guess there was some motivation for this behavior in the past? Maybe somebody remembers? Honza -- Jan Kara <jack@xxxxxxxx> SUSE Labs, CR