/* Returns: 0 on success (all glocks acquired), errno on failure (no glocks acquired)  */
int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs)
/* Returns: 0 on success (all glocks acquired), errno on failure (no glocks acquired)  */
int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs)
{
	struct gfs2_holder *tmp[4];
	struct gfs2_holder **pph = tmp;
	int error = 0;
	switch(num_gh) {
	case 0:
		return 0;
	case 1:
		ghs->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC);
		return gfs2_glock_nq(ghs);
	default:
		if (num_gh <= 4)
			break;
		pph = kmalloc(num_gh * sizeof(struct gfs2_holder *), GFP_NOFS);
		if (!pph)
			return -ENOMEM;
	}
	error = nq_m_sync(num_gh, ghs, pph);
	if (pph != tmp)
		kfree(pph);
	return error;
}