Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79496845 authored by wang di's avatar wang di Committed by Greg Kroah-Hartman
Browse files

staging: lustre: add ability to migrate inodes.



Add client support to migrate the individual inodes
from one MDT to another MDT, and this functionality
will only migrate inode layout on MDT but not touch
data object on OST.

The directory will be migrated from top to the bottom,
i.e. migrating parent first, then migrating the child.

Signed-off-by: default avatarwang di <di.wang@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2430
Reviewed-on: http://review.whamcloud.com/6662


Reviewed-by: default avatarAlex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a8610297
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -1482,6 +1482,7 @@ enum obdo_flags {
#define LOV_MAGIC	 LOV_MAGIC_V1
#define LOV_MAGIC_JOIN_V1 0x0BD20BD0
#define LOV_MAGIC_V3      0x0BD30BD0
#define LOV_MAGIC_MIGRATE 0x0BD40BD0

/*
 * magic for fully defined striping
@@ -1987,7 +1988,7 @@ enum mdt_reint_cmd {
	REINT_OPEN     = 6,
	REINT_SETXATTR = 7,
	REINT_RMENTRY  = 8,
/*      REINT_WRITE    = 9, */
	REINT_MIGRATE  = 9,
	REINT_MAX
};

@@ -2280,6 +2281,7 @@ enum mds_op_bias {
	MDS_CREATE_VOLATILE	= 1 << 10,
	MDS_OWNEROVERRIDE	= 1 << 11,
	MDS_HSM_RELEASE		= 1 << 12,
	MDS_RENAME_MIGRATE	= BIT(13),
};

/* instance of mdt_reint_rec */
@@ -2488,11 +2490,13 @@ struct lmv_desc {
/* lmv structures */
#define LMV_MAGIC_V1	0x0CD10CD0	/* normal stripe lmv magic */
#define LMV_USER_MAGIC	0x0CD20CD0	/* default lmv magic*/
#define LMV_MAGIC_MIGRATE	0x0CD30CD0	/* migrate stripe lmv magic */
#define LMV_MAGIC	LMV_MAGIC_V1

enum lmv_hash_type {
	LMV_HASH_TYPE_ALL_CHARS = 1,
	LMV_HASH_TYPE_FNV_1A_64 = 2,
	LMV_HASH_TYPE_MIGRATION = 3,
};

#define LMV_HASH_NAME_ALL_CHARS		"all_char"
@@ -2552,7 +2556,8 @@ static inline ssize_t lmv_mds_md_size(int stripe_count, unsigned int lmm_magic)
	ssize_t len = -EINVAL;

	switch (lmm_magic) {
	case LMV_MAGIC_V1: {
	case LMV_MAGIC_V1:
	case LMV_MAGIC_MIGRATE: {
		struct lmv_mds_md_v1 *lmm1;

		len = sizeof(*lmm1);
@@ -2568,6 +2573,7 @@ static inline int lmv_mds_md_stripe_count_get(const union lmv_mds_md *lmm)
{
	switch (le32_to_cpu(lmm->lmv_magic)) {
	case LMV_MAGIC_V1:
	case LMV_MAGIC_MIGRATE:
		return le32_to_cpu(lmm->lmv_md_v1.lmv_stripe_count);
	case LMV_USER_MAGIC:
		return le32_to_cpu(lmm->lmv_user_md.lum_stripe_count);
@@ -2583,6 +2589,7 @@ static inline int lmv_mds_md_stripe_count_set(union lmv_mds_md *lmm,

	switch (le32_to_cpu(lmm->lmv_magic)) {
	case LMV_MAGIC_V1:
	case LMV_MAGIC_MIGRATE:
		lmm->lmv_md_v1.lmv_stripe_count = cpu_to_le32(stripe_count);
		break;
	case LMV_USER_MAGIC:
+1 −0
Original line number Diff line number Diff line
@@ -243,6 +243,7 @@ struct ost_id {
#define LL_IOC_GET_LEASE		_IO('f', 244)
#define LL_IOC_HSM_IMPORT		_IOWR('f', 245, struct hsm_user_import)
#define LL_IOC_LMV_SET_DEFAULT_STRIPE	_IOWR('f', 246, struct lmv_user_md)
#define LL_IOC_MIGRATE			_IOR('f', 247, int)

#define LL_STATFS_LMV	   1
#define LL_STATFS_LOV	   2
+2 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ static inline void lmv_cpu_to_le(union lmv_mds_md *lmv_dst,
{
	switch (lmv_src->lmv_magic) {
	case LMV_MAGIC_V1:
	case LMV_MAGIC_MIGRATE:
		lmv1_cpu_to_le(&lmv_dst->lmv_md_v1, &lmv_src->lmv_md_v1);
		break;
	default:
@@ -118,6 +119,7 @@ static inline void lmv_le_to_cpu(union lmv_mds_md *lmv_dst,
{
	switch (le32_to_cpu(lmv_src->lmv_magic)) {
	case LMV_MAGIC_V1:
	case LMV_MAGIC_MIGRATE:
		lmv1_le_to_cpu(&lmv_dst->lmv_md_v1, &lmv_src->lmv_md_v1);
		break;
	default:
+1 −11
Original line number Diff line number Diff line
@@ -847,9 +847,6 @@ struct md_op_data {
	/* Various operation flags. */
	enum mds_op_bias        op_bias;

	/* Operation type */
	__u32		   op_opc;

	/* Used by readdir */
	__u64		   op_offset;

@@ -871,6 +868,7 @@ enum op_cli_flags {
	CLI_RM_ENTRY	= 1 << 1,
	CLI_HASH64	= BIT(2),
	CLI_API32	= BIT(3),
	CLI_MIGRATE	= BIT(4),
};

struct md_enqueue_info;
@@ -1013,14 +1011,6 @@ struct obd_ops {
	 */
};

enum {
	LUSTRE_OPC_MKDIR    = (1 << 0),
	LUSTRE_OPC_SYMLINK  = (1 << 1),
	LUSTRE_OPC_MKNOD    = (1 << 2),
	LUSTRE_OPC_CREATE   = (1 << 3),
	LUSTRE_OPC_ANY      = (1 << 4)
};

/* lmv structures */
struct lustre_md {
	struct mdt_body	 *body;
+41 −2
Original line number Diff line number Diff line
@@ -883,6 +883,7 @@ int ll_dir_getstripe(struct inode *inode, void **plmm, int *plmm_size,
			lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)lmm);
		break;
	case LMV_USER_MAGIC:
	case LMV_MAGIC_MIGRATE:
		if (cpu_to_le32(LMV_USER_MAGIC) != LMV_USER_MAGIC)
			lustre_swab_lmv_user_md((struct lmv_user_md *)lmm);
		break;
@@ -897,8 +898,7 @@ int ll_dir_getstripe(struct inode *inode, void **plmm, int *plmm_size,
	return rc;
}

static int ll_get_mdt_idx_by_fid(struct ll_sb_info *sbi,
				 const struct lu_fid *fid)
int ll_get_mdt_idx_by_fid(struct ll_sb_info *sbi, const struct lu_fid *fid)
{
	struct md_op_data *op_data;
	int mdt_index, rc;
@@ -1960,6 +1960,45 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
		kfree(copy);
		return rc;
	}
	case LL_IOC_MIGRATE: {
		char *buf = NULL;
		const char *filename;
		int namelen = 0;
		int len;
		int rc;
		int mdtidx;

		rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg);
		if (rc < 0)
			return rc;

		data = (struct obd_ioctl_data *)buf;
		if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
		    !data->ioc_inllen1 || !data->ioc_inllen2) {
			rc = -EINVAL;
			goto migrate_free;
		}

		filename = data->ioc_inlbuf1;
		namelen = data->ioc_inllen1;
		if (namelen < 1) {
			rc = -EINVAL;
			goto migrate_free;
		}

		if (data->ioc_inllen2 != sizeof(mdtidx)) {
			rc = -EINVAL;
			goto migrate_free;
		}
		mdtidx = *(int *)data->ioc_inlbuf2;

		rc = ll_migrate(inode, file, mdtidx, filename, namelen);
migrate_free:
		obd_ioctl_freedata(buf, len);

		return rc;
	}

	default:
		return obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL,
				     (void __user *)arg);
Loading