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

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

staging: lustre: lmv: separate master object with master stripe



Separate master stripe with master object, so
1. stripeEA only exists on master object.
2. sub-stripe object will be inserted into master object
as sub-directory, and it can get the master object by "..".

By this, it will remove those specilities for stripe0 in
LMV and LOD. And also simplify LFSCK, i.e. consistency check
would be easier.

When then master object becomes an orphan, we should
mark all of its sub-stripes as dead object as well,
otherwise client might still be able to create files
under these stripes.

A few fixes for striped directory layout lock:

 1. stripe 0 should be locked as EX, same as other stripes.
 2. Acquire the layout for directory, when it is being unliked.

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


Reviewed-by: default avatarAndreas Dilger <andreas.dilger@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 31c5e95e
Loading
Loading
Loading
Loading
+41 −23
Original line number Diff line number Diff line
@@ -2497,18 +2497,52 @@ struct lmv_desc {
	struct obd_uuid ld_uuid;
};

/* 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 */
/* LMV layout EA, and it will be stored both in master and slave object */
struct lmv_mds_md_v1 {
	__u32 lmv_magic;
	__u32 lmv_stripe_count;
	__u32 lmv_master_mdt_index;	/* On master object, it is master
					 * MDT index, on slave object, it
					 * is stripe index of the slave obj
					 */
	__u32 lmv_hash_type;		/* dir stripe policy, i.e. indicate
					 * which hash function to be used,
					 * Note: only lower 16 bits is being
					 * used for now. Higher 16 bits will
					 * be used to mark the object status,
					 * for example migrating or dead.
					 */
	__u32 lmv_layout_version;	/* Used for directory restriping */
	__u32 lmv_padding;
	struct lu_fid lmv_master_fid;	/* The FID of the master object, which
					 * is the namespace-visible dir FID
					 */
	char lmv_pool_name[LOV_MAXPOOLNAME];	/* pool name */
	struct lu_fid lmv_stripe_fids[0];	/* FIDs for each stripe */
};

#define LMV_MAGIC_V1	 0x0CD20CD0	/* normal stripe lmv magic */
#define LMV_MAGIC	 LMV_MAGIC_V1

/* #define LMV_USER_MAGIC 0x0CD30CD0 */
#define LMV_MAGIC_STRIPE 0x0CD40CD0	/* magic for dir sub_stripe */

/*
 *Right now only the lower part(0-16bits) of lmv_hash_type is being used,
 * and the higher part will be the flag to indicate the status of object,
 * for example the object is being migrated. And the hash function
 * might be interpreted differently with different flags.
 */
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_TYPE_MASK		0x0000ffff

#define LMV_HASH_FLAG_MIGRATION		0x80000000
#define LMV_HASH_FLAG_DEAD		0x40000000

#define LMV_HASH_NAME_ALL_CHARS		"all_char"
#define LMV_HASH_NAME_FNV_1A_64		"fnv_1a_64"

@@ -2540,19 +2574,6 @@ static inline __u64 lustre_hash_fnv_1a_64(const void *buf, size_t size)
	return hash;
}

struct lmv_mds_md_v1 {
	__u32 lmv_magic;
	__u32 lmv_stripe_count;		/* stripe count */
	__u32 lmv_master_mdt_index;	/* master MDT index */
	__u32 lmv_hash_type;		/* dir stripe policy, i.e. indicate
					 * which hash function to be used
					 */
	__u32 lmv_layout_version;	/* Used for directory restriping */
	__u32 lmv_padding;
	char lmv_pool_name[LOV_MAXPOOLNAME];	/* pool name */
	struct lu_fid lmv_stripe_fids[0];	/* FIDs for each stripe */
};

union lmv_mds_md {
	__u32			lmv_magic;
	struct lmv_mds_md_v1	lmv_md_v1;
@@ -2566,8 +2587,7 @@ 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_MIGRATE: {
	case LMV_MAGIC_V1: {
		struct lmv_mds_md_v1 *lmm1;

		len = sizeof(*lmm1);
@@ -2583,7 +2603,6 @@ 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);
@@ -2599,7 +2618,6 @@ 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 −2
Original line number Diff line number Diff line
@@ -269,8 +269,7 @@ struct ost_id {
#define LOV_USER_MAGIC_JOIN_V1 0x0BD20BD0
#define LOV_USER_MAGIC_V3 0x0BD30BD0

#define LMV_MAGIC_V1      0x0CD10CD0    /*normal stripe lmv magic */
#define LMV_USER_MAGIC    0x0CD20CD0    /*default lmv magic*/
#define LMV_USER_MAGIC    0x0CD30CD0    /*default lmv magic*/

#define LOV_PATTERN_RAID0 0x001
#define LOV_PATTERN_RAID1 0x002
+23 −2
Original line number Diff line number Diff line
@@ -48,10 +48,33 @@ struct lmv_stripe_md {
	__u32	lsm_md_layout_version;
	__u32	lsm_md_default_count;
	__u32	lsm_md_default_index;
	struct lu_fid lsm_md_master_fid;
	char	lsm_md_pool_name[LOV_MAXPOOLNAME];
	struct lmv_oinfo lsm_md_oinfo[0];
};

static inline bool
lsm_md_eq(const struct lmv_stripe_md *lsm1, const struct lmv_stripe_md *lsm2)
{
	int idx;

	if (lsm1->lsm_md_magic != lsm2->lsm_md_magic ||
	    lsm1->lsm_md_stripe_count != lsm2->lsm_md_stripe_count ||
	    lsm1->lsm_md_master_mdt_index != lsm2->lsm_md_master_mdt_index ||
	    lsm1->lsm_md_hash_type != lsm2->lsm_md_hash_type ||
	    lsm1->lsm_md_layout_version != lsm2->lsm_md_layout_version ||
	    !strcmp(lsm1->lsm_md_pool_name, lsm2->lsm_md_pool_name))
		return false;

	for (idx = 0; idx < lsm1->lsm_md_stripe_count; idx++) {
		if (!lu_fid_eq(&lsm1->lsm_md_oinfo[idx].lmo_fid,
			       &lsm2->lsm_md_oinfo[idx].lmo_fid))
			return false;
	}

	return true;
}

union lmv_mds_md;

int lmv_unpack_md(struct obd_export *exp, struct lmv_stripe_md **lsmp,
@@ -106,7 +129,6 @@ 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:
@@ -119,7 +141,6 @@ 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:
+2 −2
Original line number Diff line number Diff line
@@ -917,8 +917,8 @@ struct obd_ops {
	int (*fid_fini)(struct obd_device *obd);

	/* Allocate new fid according to passed @hint. */
	int (*fid_alloc)(struct obd_export *exp, struct lu_fid *fid,
			 struct md_op_data *op_data);
	int (*fid_alloc)(const struct lu_env *env, struct obd_export *exp,
			 struct lu_fid *fid, struct md_op_data *op_data);

	/*
	 * Object with @fid is getting deleted, we may want to do something
+3 −2
Original line number Diff line number Diff line
@@ -930,7 +930,8 @@ static inline int obd_fid_fini(struct obd_device *obd)
	return rc;
}

static inline int obd_fid_alloc(struct obd_export *exp,
static inline int obd_fid_alloc(const struct lu_env *env,
				struct obd_export *exp,
				struct lu_fid *fid,
				struct md_op_data *op_data)
{
@@ -939,7 +940,7 @@ static inline int obd_fid_alloc(struct obd_export *exp,
	EXP_CHECK_DT_OP(exp, fid_alloc);
	EXP_COUNTER_INCREMENT(exp, fid_alloc);

	rc = OBP(exp->exp_obd, fid_alloc)(exp, fid, op_data);
	rc = OBP(exp->exp_obd, fid_alloc)(env, exp, fid, op_data);
	return rc;
}

Loading