JAGNYA DATTA TRIPATHY has uploaded this change for review.

View Change

MDCACHE: keep chunk num_entries exact and guard the split

unchunk_dirent() removes a dirent from its chunk's dirent list but does
not decrement chunk->num_entries. place_new_dirent() increments it on
every insert, so on a cached directory each rename (remove plus insert)
drives the counter one above the real list length.

place_new_dirent() splits a chunk when num_entries reaches
avl_chunk_split (192 with the default Dir_Chunk of 128). If the list is
really shorter than avl_chunk_split / 2, the scan for the split point
finds nothing, "here" stays NULL, and the following LogFullDebugAlt
dereferences here->name. Release builds crash; debug builds hit the
assert. With 3 entries in a cached directory the crash comes after 189
alternating renames of one file (seen in the cthon04 basic rename test).

Decrement num_entries in unchunk_dirent() so it always equals the list
length; every removal goes through it, and mdcache_clean_dirent_chunk()
resets the count to 0 afterwards as before. In place_new_dirent(), scan
for the split point before allocating the new chunk, and if there is
none, log LogCrit, resync the counter and skip the split instead of
dereferencing NULL.

Change-Id: Ie1dee6417b331dcb33c849a8920a65d5110b14d4
Signed-off-by: Jagnya Datta Tripathy <jagnya.tripathy@gmail.com>
---
M src/FSAL/Stackable_FSALs/FSAL_MDCACHE/mdcache_avl.c
M src/FSAL/Stackable_FSALs/FSAL_MDCACHE/mdcache_helpers.c
2 files changed, 31 insertions(+), 11 deletions(-)

git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha refs/changes/47/1258747/1

To view, visit change 1258747. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: ffilz/nfs-ganesha
Gerrit-Branch: next
Gerrit-Change-Id: Ie1dee6417b331dcb33c849a8920a65d5110b14d4
Gerrit-Change-Number: 1258747
Gerrit-PatchSet: 1
Gerrit-Owner: JAGNYA DATTA TRIPATHY <jagnya.tripathy@gmail.com>