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

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

staging: lustre: create striped directory



1. client send create request to the master MDT, which
  will allocate FIDs and create slaves. for all of slaves.

2. Client needs to revalidate slaves during intent getattr
   and open request.

3. lmv_stripe_md will include attributes(size, nlink etc)
   from all of stripe, which will be protected by UPDATE lock.
   client needs to merge these attributes when update inode.

4. send create request to the MDT where the file is located,
   which can help creating master stripe of striped directory.

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


Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Reviewed-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5ce536b3
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -191,6 +191,9 @@ struct cl_attr {
	 * Group identifier for quota purposes.
	 */
	gid_t  cat_gid;

	/* nlink of the directory */
	__u64  cat_nlink;
};

/**
+39 −1
Original line number Diff line number Diff line
@@ -1610,6 +1610,7 @@ static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi,
#define XATTR_NAME_LOV	  "trusted.lov"
#define XATTR_NAME_LMA	  "trusted.lma"
#define XATTR_NAME_LMV	  "trusted.lmv"
#define XATTR_NAME_DEFAULT_LMV	"trusted.dmv"
#define XATTR_NAME_LINK	 "trusted.link"
#define XATTR_NAME_FID	  "trusted.fid"
#define XATTR_NAME_VERSION      "trusted.version"
@@ -2472,7 +2473,7 @@ struct lmv_desc {
	__u32 ld_tgt_count;		/* how many MDS's */
	__u32 ld_active_tgt_count;	 /* how many active */
	__u32 ld_default_stripe_count;     /* how many objects are used */
	__u32 ld_pattern;		  /* default MEA_MAGIC_* */
	__u32 ld_pattern;		  /* default hash pattern */
	__u64 ld_default_hash_size;
	__u64 ld_padding_1;		/* also fix lustre_swab_lmv_desc */
	__u32 ld_padding_2;		/* also fix lustre_swab_lmv_desc */
@@ -2486,6 +2487,43 @@ struct lmv_desc {
#define LMV_MAGIC_V1	0x0CD10CD0	/* normal stripe lmv magic */
#define LMV_USER_MAGIC	0x0CD20CD0	/* default 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,
};

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

/**
 * The FNV-1a hash algorithm is as follows:
 *     hash = FNV_offset_basis
 *     for each octet_of_data to be hashed
 *             hash = hash XOR octet_of_data
 *             hash = hash × FNV_prime
 *     return hash
 * http://en.wikipedia.org/wiki/Fowler–Noll–Vo_hash_function#FNV-1a_hash
 *
 * http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-reference-source
 * FNV_prime is 2^40 + 2^8 + 0xb3 = 0x100000001b3ULL
 **/
#define LUSTRE_FNV_1A_64_PRIME		0x100000001b3ULL
#define LUSTRE_FNV_1A_64_OFFSET_BIAS	0xcbf29ce484222325ULL
static inline __u64 lustre_hash_fnv_1a_64(const void *buf, size_t size)
{
	__u64 hash = LUSTRE_FNV_1A_64_OFFSET_BIAS;
	const unsigned char *p = buf;
	size_t i;

	for (i = 0; i < size; i++) {
		hash ^= p[i];
		hash *= LUSTRE_FNV_1A_64_PRIME;
	}

	return hash;
}

struct lmv_mds_md_v1 {
	__u32 lmv_magic;
	__u32 lmv_stripe_count;		/* stripe count */
+8 −8
Original line number Diff line number Diff line
@@ -374,19 +374,17 @@ struct lov_user_mds_data_v3 {
} __packed;
#endif

/* keep this to be the same size as lov_user_ost_data_v1 */
struct lmv_user_mds_data {
	struct lu_fid	lum_fid;
	__u32		lum_padding;
	__u32		lum_mds;
};

/* lum_type */
enum {
	LMV_STRIPE_TYPE = 0,
	LMV_DEFAULT_TYPE = 1,
};

/*
 * Got this according to how get LOV_MAX_STRIPE_COUNT, see above,
 * (max buffer size - lmv+rpc header) / sizeof(struct lmv_user_mds_data)
 */
#define LMV_MAX_STRIPE_COUNT 2000  /* ((12 * 4096 - 256) / 24) */
#define lmv_user_md lmv_user_md_v1
struct lmv_user_md_v1 {
	__u32	lum_magic;	 /* must be the first field */
@@ -399,7 +397,7 @@ struct lmv_user_md_v1 {
	__u32	lum_padding3;
	char	lum_pool_name[LOV_MAXPOOLNAME];
	struct	lmv_user_mds_data  lum_objects[0];
};
} __packed;

static inline int lmv_user_md_size(int stripes, int lmm_magic)
{
@@ -407,6 +405,8 @@ static inline int lmv_user_md_size(int stripes, int lmm_magic)
		      stripes * sizeof(struct lmv_user_mds_data);
}

void lustre_swab_lmv_user_md(struct lmv_user_md *lum);

struct ll_recreate_obj {
	__u64 lrc_id;
	__u32 lrc_ost_idx;
+2 −0
Original line number Diff line number Diff line
@@ -391,6 +391,8 @@ static inline void obd_ioctl_freedata(char *buf, int len)
#define LOVEA_DELETE_VALUES(size, count, offset) (size == 0 && count == 0 && \
						 offset == (typeof(offset))(-1))

#define LMVEA_DELETE_VALUES(count, offset) ((count) == 0 && \
					    (offset) == (typeof(offset))(-1))
/* #define POISON_BULK 0 */

/*
+59 −0
Original line number Diff line number Diff line
@@ -66,4 +66,63 @@ static inline void lmv_free_memmd(struct lmv_stripe_md *lsm)
{
	lmv_unpack_md(NULL, &lsm, NULL, 0);
}

static inline void lmv1_cpu_to_le(struct lmv_mds_md_v1 *lmv_dst,
				  const struct lmv_mds_md_v1 *lmv_src)
{
	int i;

	lmv_dst->lmv_magic = cpu_to_le32(lmv_src->lmv_magic);
	lmv_dst->lmv_stripe_count = cpu_to_le32(lmv_src->lmv_stripe_count);
	lmv_dst->lmv_master_mdt_index =
		cpu_to_le32(lmv_src->lmv_master_mdt_index);
	lmv_dst->lmv_hash_type = cpu_to_le32(lmv_src->lmv_hash_type);
	lmv_dst->lmv_layout_version = cpu_to_le32(lmv_src->lmv_layout_version);

	for (i = 0; i < lmv_src->lmv_stripe_count; i++)
		fid_cpu_to_le(&lmv_dst->lmv_stripe_fids[i],
			      &lmv_src->lmv_stripe_fids[i]);
}

static inline void lmv1_le_to_cpu(struct lmv_mds_md_v1 *lmv_dst,
				  const struct lmv_mds_md_v1 *lmv_src)
{
	int i;

	lmv_dst->lmv_magic = le32_to_cpu(lmv_src->lmv_magic);
	lmv_dst->lmv_stripe_count = le32_to_cpu(lmv_src->lmv_stripe_count);
	lmv_dst->lmv_master_mdt_index =
		le32_to_cpu(lmv_src->lmv_master_mdt_index);
	lmv_dst->lmv_hash_type = le32_to_cpu(lmv_src->lmv_hash_type);
	lmv_dst->lmv_layout_version = le32_to_cpu(lmv_src->lmv_layout_version);

	for (i = 0; i < lmv_src->lmv_stripe_count; i++)
		fid_le_to_cpu(&lmv_dst->lmv_stripe_fids[i],
			      &lmv_src->lmv_stripe_fids[i]);
}

static inline void lmv_cpu_to_le(union lmv_mds_md *lmv_dst,
				 const union lmv_mds_md *lmv_src)
{
	switch (lmv_src->lmv_magic) {
	case LMV_MAGIC_V1:
		lmv1_cpu_to_le(&lmv_dst->lmv_md_v1, &lmv_src->lmv_md_v1);
		break;
	default:
		break;
	}
}

static inline void lmv_le_to_cpu(union lmv_mds_md *lmv_dst,
				 const union lmv_mds_md *lmv_src)
{
	switch (le32_to_cpu(lmv_src->lmv_magic)) {
	case LMV_MAGIC_V1:
		lmv1_le_to_cpu(&lmv_dst->lmv_md_v1, &lmv_src->lmv_md_v1);
		break;
	default:
		break;
	}
}

#endif
Loading