SERVER-14186 map/reduce check for ismaster under write lock

We need to check master-ness under a write lock before doing a logOp() or else
the server might shut down.

(PARTIAL cherry pick from commit f65ef0b5c272d94f500ea615e36023b45cdf088e)

Conflicts:
	src/mongo/db/commands/mr.cpp
	src/mongo/db/dbcommands.cpp