Thread (9 messages) 9 messages, 3 authors, 2019-08-27

Re: [PATCH] ext4: attempt to shrink directory on dentry removal

From: "Theodore Y. Ts'o" <tytso@mit.edu>
Date: 2019-08-26 03:19:35

On Sun, Aug 25, 2019 at 07:46:50PM -0700, harshad shirwadkar wrote:
If last is an intermediate dx node, is there a way to find out if it
actually is an intermediate dx node? Because an empty dirent block and
an intermediate dx block look the same. Unless we do dx_probe() there
is no way to know if a block is an intermediate dx block. Is that
right or am I missing something?
You can simply look at the first hash value in the intermediate
dx_node (remember, an empty intermediate node is not allowed), and
then do a dx_probe to search from the root and validate that we find
our way back to the last block.
Looking at your following comment, if metadata_csum feature is
enabled, then we can distinguish if a block is an empty dirent block
or an index block based on dentry->rec_len. If metadata csum is
enabled, then for index blocks, fake_dentry->rec_len is set to
blocksize while for a dirent not dentry->rec_len is set to blocksize -
sizeof(ext4_dir_entry_tail). Is my understanding correct?
Yes.  Although even if the metadata_csum feature is enabled, it's a
good idea to search from the root to make sure this really is the
intermediate dx node block that you are looking for.  You need to do
the dx_probe() to find its parent block anyway, in order to update it.
And if you don't find a pointer to that intermediate node, then it
must not be an a dx node --- or the htree pointers are corrupted.  In
the case of metadata_csum and a dx_tail, that sequence should never
occur normally, so if you don't find an entry for that block when
doing a dx_probe(), it's likely the directory structures have gotten
corrupted.

						- Ted
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help