I own, have carried on and off-duty and have shot numerous Glock pistols in 9mm, .40 and .45 calibers (models 17, 19, 21, 22, 23, 27 and 30). They are accurate, easy to shoot and safe. They have a safe action (kind of a hybrid between single and double action) where the first through the last round fired all have the same 5 pound trigger pull. It's hard to go wrong with a Glock.
The model you're considering (27) is normally viewed as a concealed carry or backup gun and is called a sub-compact. Many people who use that model get a magazine extender (adds 1 round) which also gives them a place for their little finger when gripping the gun.
You may want to check out how a Glock 23 feels in your hand as it's still considered a compact but gives a little more room for your grip. It's still quite concealable under a shirt or in a fannypack if needed.
I've shot a couple S&W autos (59 & 4006) and they are accurate. I've never shot the M&P model so couldn't tell you about that particular model. I see their specs state they have a double action only trigger set at 6.5 pounds for trigger pull.
If you are able to, you may want to check out the S&W trigger pull in a gun store just to see if it's something you're going to be comfortable with or not.
Personally, I prefer Glock, SIG and 1911 style pistols in that order. Given your current question, I would recommend the Glock but also suggest you handle both in a store so you have a better idea of what feels best to you. Good luck.