/* Returns: 0 on success (all glocks acquired), errno on failure (no glocks acquired)  */
static int nq_m_sync(unsigned int num_gh, struct gfs2_holder *ghs, struct gfs2_holder **p)
/* Returns: 0 on success (all glocks acquired), errno on failure (no glocks acquired)  */
static int nq_m_sync(unsigned int num_gh, struct gfs2_holder *ghs, struct gfs2_holder **p)
{
	unsigned int x;
	int error = 0;
	for (x = 0; x < num_gh; x++)
		p[x] = &ghs[x];
	sort(p, num_gh, sizeof(struct gfs2_holder *), glock_compare, NULL);
	for (x = 0; x < num_gh; x++) {
		p[x]->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC);
		error = gfs2_glock_nq(p[x]);
		if (error) {
			while (x--)
				gfs2_glock_dq(p[x]);
			break;
		}
	}
	return error;
}