Prakash-Surya/spl — comment on commit d5daa87bb21d731fd592c1e9f1fa39446b3290d7
File: module/spl/spl-taskq.c line 156
By Prakash-Surya:

This was moved from taskq_thread to here, although the comment is a little concerning.

If the ownership of the taskq_ent returns back to the caller, does this mean they can change the tqent_flags field? If so, I can see the following scenario being a problem:

1. Prealloc taskq_ent (so TQENT_FLAGS_PREALLOC is set)
2. tqent_func is executed, within this function the structure is deallocated or TQENT_FLAGS_PREALLOC is unset.
3. Now when the function returns and task_done is called, the structure will be freed when it really shouldn't be.

I'm not sure if that is a valid scenario, but if it is, I can see why the flag needs to be checked prior to executing tqent_func