I think that the following assertion is already fixed by LU-3498:
That assertion is inside an if block which is only executed when do_statahead_enter() thinks that the thread creation failed.
Here is the relevant portion of do_statahead_enter() in version 2.5.1 (which has the LU-3498 bug):
rc = PTR_ERR(kthread_run(ll_statahead_thread, parent,
"ll_sa_%u", plli->lli_opendir_pid));
...
if (IS_ERR_VALUE(rc)) {
...
LASSERT(lli->lli_sai == NULL);
RETURN(-EAGAIN);
}
So with the fix for LU-3498, this code will not be executed unless the thread creation actually fails. If the thread creation fails, your patched code which does an extra ll_sai_put(sai) will not be executed anyway.
Unless I'm missing something, I don't think this patch belongs to this ticket. It probably is more appropriate to link that patch against LU-5274.
2.5.1 code has a glitch, kthread_run() returns thread id which could be a big value, and IS_ERR defines (-1000, -1) which is too narrow. 2.5.3 code does not has this issue.
# define IS_ERR_VALUE(x) ((x) >= (unsigned long)-4095)