コード例 #1
0
ファイル: fld_handler.c プロジェクト: Zealsathish/lustre
/**
 * Lookup sequece in local cache/fldb.
 **/
int fld_local_lookup(const struct lu_env *env, struct lu_server_fld *fld,
		     u64 seq, struct lu_seq_range *range)
{
	struct lu_seq_range *erange;
	struct fld_thread_info *info;
	int rc;
	ENTRY;

	info = lu_context_key_get(&env->le_ctx, &fld_thread_key);
	LASSERT(info != NULL);
	erange = &info->fti_lrange;

	/* Lookup it in the cache. */
	rc = fld_cache_lookup(fld->lsf_cache, seq, erange);
	if (rc == 0) {
		if (unlikely(fld_range_type(erange) != fld_range_type(range) &&
			     !fld_range_is_any(range))) {
			CERROR("%s: FLD cache range "DRANGE" does not match"
			       "requested flag %x: rc = %d\n", fld->lsf_name,
			       PRANGE(erange), range->lsr_flags, -EIO);
			RETURN(-EIO);
		}
		*range = *erange;
		RETURN(0);
	}
	RETURN(rc);
}
コード例 #2
0
ファイル: fld_index.c プロジェクト: hfeeki/lustre
/**
 * lookup range for a seq passed. note here we only care about the start/end,
 * caller should handle the attached location data (flags, index).
 *
 * \param  seq     seq for lookup.
 * \param  range   result of lookup.
 *
 * \retval  0           found, \a range is the matched range;
 * \retval -ENOENT      not found, \a range is the left-side range;
 * \retval  -ve         other error;
 */
int fld_index_lookup(const struct lu_env *env, struct lu_server_fld *fld,
		     seqno_t seq, struct lu_seq_range *range)
{
        struct lu_seq_range     *fld_rec;
        struct fld_thread_info  *info;
        int rc;

        ENTRY;

	info = lu_context_key_get(&env->le_ctx, &fld_thread_key);
	fld_rec = &info->fti_rec;

	rc = fld_cache_lookup(fld->lsf_cache, seq, fld_rec);
	if (rc == 0) {
                *range = *fld_rec;
                if (range_within(range, seq))
                        rc = 0;
                else
                        rc = -ENOENT;
        }

        CDEBUG(D_INFO, "%s: lookup seq = "LPX64" range : "DRANGE" rc = %d\n",
               fld->lsf_name, seq, PRANGE(range), rc);

        RETURN(rc);
}
コード例 #3
0
ファイル: fld_handler.c プロジェクト: Zealsathish/lustre
/*
 * Returns true, if fid is local to this server node.
 *
 * WARNING: this function is *not* guaranteed to return false if fid is
 * remote: it makes an educated conservative guess only.
 *
 * fid_is_local() is supposed to be used in assertion checks only.
 */
int fid_is_local(const struct lu_env *env,
                 struct lu_site *site, const struct lu_fid *fid)
{
	int result;
	struct seq_server_site *ss_site;
	struct lu_seq_range *range;
	struct fld_thread_info *info;
	ENTRY;

	info = lu_context_key_get(&env->le_ctx, &fld_thread_key);
	range = &info->fti_lrange;

	result = 1; /* conservatively assume fid is local */
	ss_site = lu_site2seq(site);
	if (ss_site->ss_client_fld != NULL) {
		int rc;

		rc = fld_cache_lookup(ss_site->ss_client_fld->lcf_cache,
				      fid_seq(fid), range);
		if (rc == 0)
			result = (range->lsr_index == ss_site->ss_node_id);
	}
	return result;
}