The purpose of this check is to prevent avail from going out of bounds, but I think it may not be necessary.
/* Validate avail index is within bounds */
if (avail >= SIMPLEFS_MAX_EXTENTS) {
ret = -EMLINK;
goto iput;
}
Whenever functions like "simplefs_create" are called, we already validate the maximum number of files with:
if (eblock->nr_files == SIMPLEFS_MAX_SUBFILES)
If this check passes, it means there is guaranteed to be space for creating a new object under this directory. Therefore, simplefs_get_available_ext_idx() should never return an out-of-bound value, and this boundary check appears redundant.