s3: Add "g_lock_do" as a convenience wrapper function (cherry picked from commit...