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

Commit e10a431b authored by John L. Hammond's avatar John L. Hammond Committed by Greg Kroah-Hartman
Browse files

staging: lustre: lov: move LSM to LOV layer



Move the definition of struct lov_stripe_md along with supporting
functions from obd.h to lov_internal.h. Remove the unused functions
obd_packmd() and obd_free_diskmd(). Simplify lov_obd_packmd()
according to the reduced use cases and rename it lov_packmd().

Signed-off-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Signed-off-by: default avatarJinshan Xiong <jinshan.xiong@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5814
Reviewed-on: http://review.whamcloud.com/13696


Reviewed-by: default avatarJames Simmons <uja.ornl@yahoo.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 48a2a12a
Loading
Loading
Loading
Loading
+1 −76
Original line number Diff line number Diff line
@@ -73,53 +73,7 @@ static inline void loi_init(struct lov_oinfo *loi)
{
}

/*
 * If we are unable to get the maximum object size from the OST in
 * ocd_maxbytes using OBD_CONNECT_MAXBYTES, then we fall back to using
 * the old maximum object size from ext3.
 */
#define LUSTRE_EXT3_STRIPE_MAXBYTES 0x1fffffff000ULL

struct lov_stripe_md {
	atomic_t     lsm_refc;
	spinlock_t	lsm_lock;
	pid_t	    lsm_lock_owner; /* debugging */

	/* maximum possible file size, might change as OSTs status changes,
	 * e.g. disconnected, deactivated
	 */
	loff_t		lsm_maxbytes;
	struct ost_id	lsm_oi;
	__u32		lsm_magic;
	__u32		lsm_stripe_size;
	__u32		lsm_pattern;	/* striping pattern (RAID0, RAID1) */
	__u16		lsm_stripe_count;
	__u16		lsm_layout_gen;
	char		lsm_pool_name[LOV_MAXPOOLNAME + 1];
	struct lov_oinfo *lsm_oinfo[0];
};

static inline bool lsm_is_released(struct lov_stripe_md *lsm)
{
	return !!(lsm->lsm_pattern & LOV_PATTERN_F_RELEASED);
}

static inline bool lsm_has_objects(struct lov_stripe_md *lsm)
{
	if (!lsm)
		return false;
	if (lsm_is_released(lsm))
		return false;
	return true;
}

static inline int lov_stripe_md_size(unsigned int stripe_count)
{
	struct lov_stripe_md lsm;

	return sizeof(lsm) + stripe_count * sizeof(lsm.lsm_oinfo[0]);
}

struct lov_stripe_md;
struct obd_info;

typedef int (*obd_enqueue_update_f)(void *cookie, int rc);
@@ -854,8 +808,6 @@ struct obd_ops {
		      struct obd_statfs *osfs, __u64 max_age, __u32 flags);
	int (*statfs_async)(struct obd_export *exp, struct obd_info *oinfo,
			    __u64 max_age, struct ptlrpc_request_set *set);
	int (*packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
		      struct lov_stripe_md *mem_src);
	int (*unpackmd)(struct obd_export *exp,
			struct lov_stripe_md **mem_tgt,
			struct lov_mds_md *disk_src, int disk_len);
@@ -1033,33 +985,6 @@ struct md_ops {
	 */
};

struct lsm_operations {
	void (*lsm_free)(struct lov_stripe_md *);
	void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, u64 *,
				    u64 *);
	void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, u64 *,
				     u64 *);
	int (*lsm_lmm_verify)(struct lov_mds_md *lmm, int lmm_bytes,
			      __u16 *stripe_count);
	int (*lsm_unpackmd)(struct lov_obd *lov, struct lov_stripe_md *lsm,
			    struct lov_mds_md *lmm);
};

extern const struct lsm_operations lsm_v1_ops;
extern const struct lsm_operations lsm_v3_ops;
static inline const struct lsm_operations *lsm_op_find(int magic)
{
	switch (magic) {
	case LOV_MAGIC_V1:
	       return &lsm_v1_ops;
	case LOV_MAGIC_V3:
	       return &lsm_v3_ops;
	default:
	       CERROR("Cannot recognize lsm_magic %08x\n", magic);
	       return NULL;
	}
}

static inline struct md_open_data *obd_mod_alloc(void)
{
	struct md_open_data *mod;
+0 −38
Original line number Diff line number Diff line
@@ -609,44 +609,6 @@ obd_process_config(struct obd_device *obd, int datalen, void *data)
	return rc;
}

/* Pack an in-memory MD struct for storage on disk.
 * Returns +ve size of packed MD (0 for free), or -ve error.
 *
 * If @disk_tgt == NULL, MD size is returned (max size if @mem_src == NULL).
 * If @*disk_tgt != NULL and @mem_src == NULL, @*disk_tgt will be freed.
 * If @*disk_tgt == NULL, it will be allocated
 */
static inline int obd_packmd(struct obd_export *exp,
			     struct lov_mds_md **disk_tgt,
			     struct lov_stripe_md *mem_src)
{
	int rc;

	EXP_CHECK_DT_OP(exp, packmd);
	EXP_COUNTER_INCREMENT(exp, packmd);

	rc = OBP(exp->exp_obd, packmd)(exp, disk_tgt, mem_src);
	return rc;
}

static inline int obd_free_diskmd(struct obd_export *exp,
				  struct lov_mds_md **disk_tgt)
{
	LASSERT(disk_tgt);
	LASSERT(*disk_tgt);
	/*
	 * LU-2590, for caller's convenience, *disk_tgt could be host
	 * endianness, it needs swab to LE if necessary, while just
	 * lov_mds_md header needs it for figuring out how much memory
	 * needs to be freed.
	 */
	if ((cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) &&
	    (((*disk_tgt)->lmm_magic == LOV_MAGIC_V1) ||
	     ((*disk_tgt)->lmm_magic == LOV_MAGIC_V3)))
		lustre_swab_lov_mds_md(*disk_tgt);
	return obd_packmd(exp, disk_tgt, NULL);
}

/* Unpack an MD struct from disk to in-memory format.
 * Returns +ve size of unpacked MD (0 for free), or -ve error.
 *
+0 −2
Original line number Diff line number Diff line
@@ -609,8 +609,6 @@ struct ll_file_data {
	struct list_head fd_lccs; /* list of ll_cl_context */
};

struct lov_stripe_md;

extern struct dentry *llite_root;
extern struct kset *llite_kset;

+0 −1
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@

enum obd_notify_event;
struct inode;
struct lov_stripe_md;
struct lustre_md;
struct obd_device;
struct obd_export;
+0 −105
Original line number Diff line number Diff line
@@ -2736,90 +2736,6 @@ static int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp,
	return -EINVAL;
}

static int lmv_pack_md_v1(const struct lmv_stripe_md *lsm,
			  struct lmv_mds_md_v1 *lmm1)
{
	int cplen;
	int i;

	lmm1->lmv_magic = cpu_to_le32(lsm->lsm_md_magic);
	lmm1->lmv_stripe_count = cpu_to_le32(lsm->lsm_md_stripe_count);
	lmm1->lmv_master_mdt_index = cpu_to_le32(lsm->lsm_md_master_mdt_index);
	lmm1->lmv_hash_type = cpu_to_le32(lsm->lsm_md_hash_type);
	cplen = strlcpy(lmm1->lmv_pool_name, lsm->lsm_md_pool_name,
			sizeof(lmm1->lmv_pool_name));
	if (cplen >= sizeof(lmm1->lmv_pool_name))
		return -E2BIG;

	for (i = 0; i < lsm->lsm_md_stripe_count; i++)
		fid_cpu_to_le(&lmm1->lmv_stripe_fids[i],
			      &lsm->lsm_md_oinfo[i].lmo_fid);
	return 0;
}

static int
lmv_pack_md(union lmv_mds_md **lmmp, const struct lmv_stripe_md *lsm,
	    int stripe_count)
{
	int lmm_size = 0, rc = 0;
	bool allocated = false;

	LASSERT(lmmp);

	/* Free lmm */
	if (*lmmp && !lsm) {
		int stripe_cnt;

		stripe_cnt = lmv_mds_md_stripe_count_get(*lmmp);
		lmm_size = lmv_mds_md_size(stripe_cnt,
					   le32_to_cpu((*lmmp)->lmv_magic));
		if (!lmm_size)
			return -EINVAL;
		kvfree(*lmmp);
		*lmmp = NULL;
		return 0;
	}

	/* Alloc lmm */
	if (!*lmmp && !lsm) {
		lmm_size = lmv_mds_md_size(stripe_count, LMV_MAGIC);
		LASSERT(lmm_size > 0);
		*lmmp = libcfs_kvzalloc(lmm_size, GFP_NOFS);
		if (!*lmmp)
			return -ENOMEM;
		lmv_mds_md_stripe_count_set(*lmmp, stripe_count);
		(*lmmp)->lmv_magic = cpu_to_le32(LMV_MAGIC);
		return lmm_size;
	}

	/* pack lmm */
	LASSERT(lsm);
	lmm_size = lmv_mds_md_size(lsm->lsm_md_stripe_count,
				   lsm->lsm_md_magic);
	if (!*lmmp) {
		*lmmp = libcfs_kvzalloc(lmm_size, GFP_NOFS);
		if (!*lmmp)
			return -ENOMEM;
		allocated = true;
	}

	switch (lsm->lsm_md_magic) {
	case LMV_MAGIC_V1:
		rc = lmv_pack_md_v1(lsm, &(*lmmp)->lmv_md_v1);
		break;
	default:
		rc = -EINVAL;
		break;
	}

	if (rc && allocated) {
		kvfree(*lmmp);
		*lmmp = NULL;
	}

	return lmm_size;
}

static int lmv_unpack_md_v1(struct obd_export *exp, struct lmv_stripe_md *lsm,
			    const struct lmv_mds_md_v1 *lmm1)
{
@@ -2959,26 +2875,6 @@ static int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
			     (union lmv_mds_md *)lmm, disk_len);
}

static int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
		      struct lov_stripe_md *lsm)
{
	const struct lmv_stripe_md *lmv = (struct lmv_stripe_md *)lsm;
	struct obd_device *obd = exp->exp_obd;
	struct lmv_obd *lmv_obd = &obd->u.lmv;
	int stripe_count;

	if (!lmmp) {
		if (lsm)
			stripe_count = lmv->lsm_md_stripe_count;
		else
			stripe_count = lmv_obd->desc.ld_tgt_count;

		return lmv_mds_md_size(stripe_count, LMV_MAGIC_V1);
	}

	return lmv_pack_md((union lmv_mds_md **)lmmp, lmv, 0);
}

static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
			     ldlm_policy_data_t *policy, enum ldlm_mode mode,
			     enum ldlm_cancel_flags flags, void *opaque)
@@ -3282,7 +3178,6 @@ static struct obd_ops lmv_obd_ops = {
	.statfs		= lmv_statfs,
	.get_info	= lmv_get_info,
	.set_info_async	= lmv_set_info_async,
	.packmd		= lmv_packmd,
	.unpackmd	= lmv_unpackmd,
	.notify		= lmv_notify,
	.get_uuid	= lmv_get_uuid,
Loading