Exemplo n.º 1
0
static int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj,
		    u64 offset, void *p, unsigned length)
{
	struct osd_request *or = osd_start_request(od, GFP_KERNEL);
/*	struct osd_sense_info osi = {.key = 0};*/
	int ret;

	if (unlikely(!or)) {
		EXOFS_DBGMSG("%s: osd_start_request failed.\n", __func__);
		return -ENOMEM;
	}
	ret = osd_req_read_kern(or, obj, offset, p, length);
	if (unlikely(ret)) {
		EXOFS_DBGMSG("%s: osd_req_read_kern failed.\n", __func__);
		goto out;
	}

	ret = osd_finalize_request(or, 0, cred, NULL);
	if (unlikely(ret)) {
		EXOFS_DBGMSG("Failed to osd_finalize_request() => %d\n", ret);
		goto out;
	}

	ret = osd_execute_request(or);
	if (unlikely(ret))
		EXOFS_DBGMSG("osd_execute_request() => %d\n", ret);
	/* osd_req_decode_sense(or, ret); */

out:
	osd_end_request(or);
	EXOFS_DBGMSG2("read_kern(0x%llx) offset=0x%llx "
		      "length=0x%llx dev=%p ret=>%d\n",
		      _LLU(obj->id), _LLU(offset), _LLU(length), od, ret);
	return ret;
}
Exemplo n.º 2
0
/*
 * Write the superblock to the OSD
 */
int exofs_sync_fs(struct super_block *sb, int wait)
{
	struct exofs_sb_info *sbi;
	struct exofs_fscb *fscb;
	struct exofs_io_state *ios;
	int ret = -ENOMEM;

	lock_super(sb);
	sbi = sb->s_fs_info;
	fscb = &sbi->s_fscb;

	ret = exofs_get_io_state(sbi, &ios);
	if (ret)
		goto out;

	/* Note: We only write the changing part of the fscb. .i.e upto the
	 *       the fscb->s_dev_table_oid member. There is no read-modify-write
	 *       here.
	 */
	ios->length = offsetof(struct exofs_fscb, s_dev_table_oid);
	memset(fscb, 0, ios->length);
	fscb->s_nextid = cpu_to_le64(sbi->s_nextid);
	fscb->s_numfiles = cpu_to_le32(sbi->s_numfiles);
	fscb->s_magic = cpu_to_le16(sb->s_magic);
	fscb->s_newfs = 0;
	fscb->s_version = EXOFS_FSCB_VER;

	ios->obj.id = EXOFS_SUPER_ID;
	ios->offset = 0;
	ios->kern_buff = fscb;
	ios->cred = sbi->s_cred;

	ret = exofs_sbi_write(ios);
	if (unlikely(ret)) {
		EXOFS_ERR("%s: exofs_sbi_write failed.\n", __func__);
		goto out;
	}
	sb->s_dirt = 0;

out:
	EXOFS_DBGMSG("s_nextid=0x%llx ret=%d\n", _LLU(sbi->s_nextid), ret);
	exofs_put_io_state(ios);
	unlock_super(sb);
	return ret;
}
Exemplo n.º 3
0
static int _osd_print_system_info(struct osd_dev *od, void *caps)
{
	struct osd_request *or;
	struct osd_attr get_attrs[] = {
		ATTR_DEF_RI(OSD_ATTR_RI_VENDOR_IDENTIFICATION, 8),
		ATTR_DEF_RI(OSD_ATTR_RI_PRODUCT_IDENTIFICATION, 16),
		ATTR_DEF_RI(OSD_ATTR_RI_PRODUCT_MODEL, 32),
		ATTR_DEF_RI(OSD_ATTR_RI_PRODUCT_REVISION_LEVEL, 4),
		ATTR_DEF_RI(OSD_ATTR_RI_PRODUCT_SERIAL_NUMBER, 64 /*variable*/),
		ATTR_DEF_RI(OSD_ATTR_RI_OSD_NAME, 64 /*variable*/),
		ATTR_DEF_RI(OSD_ATTR_RI_TOTAL_CAPACITY, 8),
		ATTR_DEF_RI(OSD_ATTR_RI_USED_CAPACITY, 8),
		ATTR_DEF_RI(OSD_ATTR_RI_NUMBER_OF_PARTITIONS, 8),
		ATTR_DEF_RI(OSD_ATTR_RI_CLOCK, 6),
		/* IBM-OSD-SIM Has a bug with this one put it last */
		ATTR_DEF_RI(OSD_ATTR_RI_OSD_SYSTEM_ID, 20),
	};
	void *iter = NULL, *pFirst;
	int nelem = ARRAY_SIZE(get_attrs), a = 0;
	int ret;

	or = osd_start_request(od, GFP_KERNEL);
	if (!or)
		return -ENOMEM;

	/* get attrs */
	osd_req_get_attributes(or, &osd_root_object);
	osd_req_add_get_attr_list(or, get_attrs, ARRAY_SIZE(get_attrs));

	ret = osd_finalize_request(or, 0, caps, NULL);
	if (ret)
		goto out;

	ret = osd_execute_request(or);
	if (ret) {
		OSD_ERR("Failed to detect %s => %d\n", _osd_ver_desc(or), ret);
		goto out;
	}

	osd_req_decode_get_attr_list(or, get_attrs, &nelem, &iter);

	OSD_INFO("Detected %s device\n",
		_osd_ver_desc(or));

	pFirst = get_attrs[a++].val_ptr;
	OSD_INFO("VENDOR_IDENTIFICATION  [%s]\n",
		(char *)pFirst);

	pFirst = get_attrs[a++].val_ptr;
	OSD_INFO("PRODUCT_IDENTIFICATION [%s]\n",
		(char *)pFirst);

	pFirst = get_attrs[a++].val_ptr;
	OSD_INFO("PRODUCT_MODEL          [%s]\n",
		(char *)pFirst);

	pFirst = get_attrs[a++].val_ptr;
	OSD_INFO("PRODUCT_REVISION_LEVEL [%u]\n",
		pFirst ? get_unaligned_be32(pFirst) : ~0U);

	pFirst = get_attrs[a++].val_ptr;
	OSD_INFO("PRODUCT_SERIAL_NUMBER  [%s]\n",
		(char *)pFirst);

	pFirst = get_attrs[a].val_ptr;
	OSD_INFO("OSD_NAME               [%s]\n", (char *)pFirst);
	a++;

	pFirst = get_attrs[a++].val_ptr;
	OSD_INFO("TOTAL_CAPACITY         [0x%llx]\n",
		pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL);

	pFirst = get_attrs[a++].val_ptr;
	OSD_INFO("USED_CAPACITY          [0x%llx]\n",
		pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL);

	pFirst = get_attrs[a++].val_ptr;
	OSD_INFO("NUMBER_OF_PARTITIONS   [%llu]\n",
		pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL);

	if (a >= nelem)
		goto out;

	/* FIXME: Where are the time utilities */
	pFirst = get_attrs[a++].val_ptr;
	OSD_INFO("CLOCK                  [0x%02x%02x%02x%02x%02x%02x]\n",
		((char *)pFirst)[0], ((char *)pFirst)[1],
		((char *)pFirst)[2], ((char *)pFirst)[3],
		((char *)pFirst)[4], ((char *)pFirst)[5]);

	if (a < nelem) { /* IBM-OSD-SIM bug, Might not have it */
		unsigned len = get_attrs[a].len;
		char sid_dump[32*4 + 2]; /* 2nibbles+space+ASCII */

		hex_dump_to_buffer(get_attrs[a].val_ptr, len, 32, 1,
				   sid_dump, sizeof(sid_dump), true);
		OSD_INFO("OSD_SYSTEM_ID(%d)\n"
			 "        [%s]\n", len, sid_dump);
		a++;
	}
out:
	osd_end_request(or);
	return ret;
}
Exemplo n.º 4
0
static int _read_and_match_data_map(struct exofs_sb_info *sbi, unsigned numdevs,
				    struct exofs_device_table *dt)
{
	u64 stripe_length;

	sbi->data_map.odm_num_comps   =
				le32_to_cpu(dt->dt_data_map.cb_num_comps);
	sbi->data_map.odm_stripe_unit =
				le64_to_cpu(dt->dt_data_map.cb_stripe_unit);
	sbi->data_map.odm_group_width =
				le32_to_cpu(dt->dt_data_map.cb_group_width);
	sbi->data_map.odm_group_depth =
				le32_to_cpu(dt->dt_data_map.cb_group_depth);
	sbi->data_map.odm_mirror_cnt  =
				le32_to_cpu(dt->dt_data_map.cb_mirror_cnt);
	sbi->data_map.odm_raid_algorithm  =
				le32_to_cpu(dt->dt_data_map.cb_raid_algorithm);

/* FIXME: Only raid0 for now. if not so, do not mount */
	if (sbi->data_map.odm_num_comps != numdevs) {
		EXOFS_ERR("odm_num_comps(%u) != numdevs(%u)\n",
			  sbi->data_map.odm_num_comps, numdevs);
		return -EINVAL;
	}
	if (sbi->data_map.odm_raid_algorithm != PNFS_OSD_RAID_0) {
		EXOFS_ERR("Only RAID_0 for now\n");
		return -EINVAL;
	}
	if (0 != (numdevs % (sbi->data_map.odm_mirror_cnt + 1))) {
		EXOFS_ERR("Data Map wrong, numdevs=%d mirrors=%d\n",
			  numdevs, sbi->data_map.odm_mirror_cnt);
		return -EINVAL;
	}

	if (0 != (sbi->data_map.odm_stripe_unit & ~PAGE_MASK)) {
		EXOFS_ERR("Stripe Unit(0x%llx)"
			  " must be Multples of PAGE_SIZE(0x%lx)\n",
			  _LLU(sbi->data_map.odm_stripe_unit), PAGE_SIZE);
		return -EINVAL;
	}

	sbi->layout.stripe_unit = sbi->data_map.odm_stripe_unit;
	sbi->layout.mirrors_p1 = sbi->data_map.odm_mirror_cnt + 1;

	if (sbi->data_map.odm_group_width) {
		sbi->layout.group_width = sbi->data_map.odm_group_width;
		sbi->layout.group_depth = sbi->data_map.odm_group_depth;
		if (!sbi->layout.group_depth) {
			EXOFS_ERR("group_depth == 0 && group_width != 0\n");
			return -EINVAL;
		}
		sbi->layout.group_count = sbi->data_map.odm_num_comps /
						sbi->layout.mirrors_p1 /
						sbi->data_map.odm_group_width;
	} else {
		if (sbi->data_map.odm_group_depth) {
			printk(KERN_NOTICE "Warning: group_depth ignored "
				"group_width == 0 && group_depth == %d\n",
				sbi->data_map.odm_group_depth);
			sbi->data_map.odm_group_depth = 0;
		}
		sbi->layout.group_width = sbi->data_map.odm_num_comps /
							sbi->layout.mirrors_p1;
		sbi->layout.group_depth = -1;
		sbi->layout.group_count = 1;
	}

	stripe_length = (u64)sbi->layout.group_width * sbi->layout.stripe_unit;
	if (stripe_length >= (1ULL << 32)) {
		EXOFS_ERR("Total Stripe length(0x%llx)"
			  " >= 32bit is not supported\n", _LLU(stripe_length));
		return -EINVAL;
	}

	return 0;
}