Beispiel #1
0
static int osd_zap_it_rec(const struct lu_env *env, const struct dt_it *di,
			  struct dt_rec *dtrec, __u32 attr)
{
	struct luz_direntry *zde = &osd_oti_get(env)->oti_zde;
	zap_attribute_t     *za = &osd_oti_get(env)->oti_za;
	struct osd_zap_it   *it = (struct osd_zap_it *)di;
	struct lu_dirent    *lde = (struct lu_dirent *)dtrec;
	int                  rc, namelen;
	ENTRY;

	it->ozi_reset = 0;
	LASSERT(lde);

	lde->lde_hash = cpu_to_le64(udmu_zap_cursor_serialize(it->ozi_zc));

	if ((rc = -zap_cursor_retrieve(it->ozi_zc, za)))
		GOTO(out, rc);

	namelen = strlen(za->za_name);
	if (namelen > NAME_MAX)
		GOTO(out, rc = -EOVERFLOW);
	strcpy(lde->lde_name, za->za_name);
	lde->lde_namelen = cpu_to_le16(namelen);

	if (za->za_integer_length != 8 || za->za_num_integers < 3) {
		CERROR("%s: unsupported direntry format: %d %d\n",
		       osd_obj2dev(it->ozi_obj)->od_svname,
		       za->za_integer_length, (int)za->za_num_integers);

		GOTO(out, rc = -EIO);
	}

	rc = -zap_lookup(it->ozi_zc->zc_objset, it->ozi_zc->zc_zapobj,
			 za->za_name, za->za_integer_length, 3, zde);
	if (rc)
		GOTO(out, rc);

	lde->lde_fid = zde->lzd_fid;
	lde->lde_attrs = LUDA_FID;

	/* append lustre attributes */
	osd_it_append_attrs(lde, attr, namelen, zde->lzd_reg.zde_type);

	lde->lde_reclen = cpu_to_le16(lu_dirent_calc_size(namelen, attr));

out:
	RETURN(rc);
}
Beispiel #2
0
static int osd_dir_it_rec(const struct lu_env *env, const struct dt_it *di,
			  struct dt_rec *dtrec, __u32 attr)
{
	struct osd_zap_it   *it = (struct osd_zap_it *)di;
	struct lu_dirent    *lde = (struct lu_dirent *)dtrec;
	struct luz_direntry *zde = &osd_oti_get(env)->oti_zde;
	zap_attribute_t     *za = &osd_oti_get(env)->oti_za;
	int		     rc, namelen;
	ENTRY;

	if (it->ozi_pos <= 1) {
		lde->lde_hash = cpu_to_le64(1);
		strcpy(lde->lde_name, ".");
		lde->lde_namelen = cpu_to_le16(1);
		lde->lde_fid = *lu_object_fid(&it->ozi_obj->oo_dt.do_lu);
		lde->lde_attrs = LUDA_FID;
		/* append lustre attributes */
		osd_it_append_attrs(lde, attr, 1, IFTODT(S_IFDIR));
		lde->lde_reclen = cpu_to_le16(lu_dirent_calc_size(1, attr));
		it->ozi_pos = 1;
		GOTO(out, rc = 0);

	} else if (it->ozi_pos == 2) {
		lde->lde_hash = cpu_to_le64(2);
		strcpy(lde->lde_name, "..");
		lde->lde_namelen = cpu_to_le16(2);
		lde->lde_attrs = LUDA_FID;
		/* append lustre attributes */
		osd_it_append_attrs(lde, attr, 2, IFTODT(S_IFDIR));
		lde->lde_reclen = cpu_to_le16(lu_dirent_calc_size(2, attr));
		rc = osd_find_parent_fid(env, &it->ozi_obj->oo_dt, &lde->lde_fid);
		/*
		 * early Orion code was not setting LinkEA, so it's possible
		 * some setups still have objects with no LinkEA set.
		 * but at that time .. was a real record in the directory
		 * so we should try to lookup .. in ZAP
		 */
		if (rc != -ENOENT)
			GOTO(out, rc);
	}

	LASSERT(lde);

	rc = -zap_cursor_retrieve(it->ozi_zc, za);
	if (unlikely(rc != 0))
		GOTO(out, rc);

	lde->lde_hash = cpu_to_le64(udmu_zap_cursor_serialize(it->ozi_zc));
	namelen = strlen(za->za_name);
	if (namelen > NAME_MAX)
		GOTO(out, rc = -EOVERFLOW);
	strcpy(lde->lde_name, za->za_name);
	lde->lde_namelen = cpu_to_le16(namelen);

	if (za->za_integer_length != 8 || za->za_num_integers < 3) {
		CERROR("%s: unsupported direntry format: %d %d\n",
		       osd_obj2dev(it->ozi_obj)->od_svname,
		       za->za_integer_length, (int)za->za_num_integers);

		GOTO(out, rc = -EIO);
	}

	rc = -zap_lookup(it->ozi_zc->zc_objset, it->ozi_zc->zc_zapobj,
			 za->za_name, za->za_integer_length, 3, zde);
	if (rc)
		GOTO(out, rc);

	lde->lde_fid = zde->lzd_fid;
	lde->lde_attrs = LUDA_FID;

	/* append lustre attributes */
	osd_it_append_attrs(lde, attr, namelen, zde->lzd_reg.zde_type);

	lde->lde_reclen = cpu_to_le16(lu_dirent_calc_size(namelen, attr));

out:
	RETURN(rc);
}