Move more bgworker code to bgworker.c; also, some renaming.

Per discussion on pgsql-hackers.

Michael Paquier, slightly modified by me.  Original suggestion
from Amit Kapila.