/* Callers must hold ih->mutex. This function can sleep.  */
static int inotify_handle_get_wd(struct inotify_handle *ih, struct inotify_watch *watch)
/* Callers must hold ih->mutex. This function can sleep.  */
static int inotify_handle_get_wd(struct inotify_handle *ih, struct inotify_watch *watch)
{
	int ret;
	do {
		if (unlikely(!idr_pre_get(&ih->idr, GFP_NOFS)))
			return -ENOSPC;
		ret = idr_get_new_above(&ih->idr, watch, ih->last_wd+1, &watch->wd);
	} while (ret == -EAGAIN);
	if (likely(!ret))
		ih->last_wd = watch->wd;
	return ret;
}