Commit 6ea510c1 authored by Lisa Nguyen's avatar Lisa Nguyen Committed by Greg Kroah-Hartman
Browse files

staging: lustre: Remove typedef and update cfs_hash_bd struct



Remove typedef keyword and rename the cfs_hash_bd_t struct to
cfs_hash_bd in libcfs_hash.h. These changes resolve the
"Do not add new typedefs" warning generated by checkpatch.pl
and meet kernel coding style.

Struct variables in other header and source files that depend
on libcfs_hash.h are updated as well.

Signed-off-by: default avatarLisa Nguyen <lisa@xenapiadmin.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a3ea59e0
Loading
Loading
Loading
Loading
+38 −38
Original line number Diff line number Diff line
@@ -109,10 +109,10 @@ struct cfs_hash_bucket {
/**
 * cfs_hash bucket descriptor, it's normally in stack of caller
 */
typedef struct cfs_hash_bd {
struct cfs_hash_bd {
	struct cfs_hash_bucket	*bd_bucket;      /**< address of bucket */
	unsigned int		bd_offset;      /**< offset in bucket */
} cfs_hash_bd_t;
};

#define CFS_HASH_NAME_LEN	   16      /**< default name length */
#define CFS_HASH_BIGNAME_LEN	64      /**< bigname for param tree */
@@ -287,15 +287,15 @@ typedef struct cfs_hash_lock_ops {

typedef struct cfs_hash_hlist_ops {
	/** return hlist_head of hash-head of @bd */
	struct hlist_head *(*hop_hhead)(cfs_hash_t *hs, cfs_hash_bd_t *bd);
	struct hlist_head *(*hop_hhead)(cfs_hash_t *hs, struct cfs_hash_bd *bd);
	/** return hash-head size */
	int (*hop_hhead_size)(cfs_hash_t *hs);
	/** add @hnode to hash-head of @bd */
	int (*hop_hnode_add)(cfs_hash_t *hs,
			     cfs_hash_bd_t *bd, struct hlist_node *hnode);
			     struct cfs_hash_bd *bd, struct hlist_node *hnode);
	/** remove @hnode from hash-head of @bd */
	int (*hop_hnode_del)(cfs_hash_t *hs,
			     cfs_hash_bd_t *bd, struct hlist_node *hnode);
			     struct cfs_hash_bd *bd, struct hlist_node *hnode);
} cfs_hash_hlist_ops_t;

typedef struct cfs_hash_ops {
@@ -539,13 +539,13 @@ static inline int cfs_hash_dec_and_lock(cfs_hash_t *hs,
}

static inline void cfs_hash_bd_lock(cfs_hash_t *hs,
				    cfs_hash_bd_t *bd, int excl)
				    struct cfs_hash_bd *bd, int excl)
{
	hs->hs_lops->hs_bkt_lock(&bd->bd_bucket->hsb_lock, excl);
}

static inline void cfs_hash_bd_unlock(cfs_hash_t *hs,
				      cfs_hash_bd_t *bd, int excl)
				      struct cfs_hash_bd *bd, int excl)
{
	hs->hs_lops->hs_bkt_unlock(&bd->bd_bucket->hsb_lock, excl);
}
@@ -554,56 +554,56 @@ static inline void cfs_hash_bd_unlock(cfs_hash_t *hs,
 * operations on cfs_hash bucket (bd: bucket descriptor),
 * they are normally for hash-table without rehash
 */
void cfs_hash_bd_get(cfs_hash_t *hs, const void *key, cfs_hash_bd_t *bd);
void cfs_hash_bd_get(cfs_hash_t *hs, const void *key, struct cfs_hash_bd *bd);

static inline void cfs_hash_bd_get_and_lock(cfs_hash_t *hs, const void *key,
					    cfs_hash_bd_t *bd, int excl)
					    struct cfs_hash_bd *bd, int excl)
{
	cfs_hash_bd_get(hs, key, bd);
	cfs_hash_bd_lock(hs, bd, excl);
}

static inline unsigned cfs_hash_bd_index_get(cfs_hash_t *hs, cfs_hash_bd_t *bd)
static inline unsigned cfs_hash_bd_index_get(cfs_hash_t *hs, struct cfs_hash_bd *bd)
{
	return bd->bd_offset | (bd->bd_bucket->hsb_index << hs->hs_bkt_bits);
}

static inline void cfs_hash_bd_index_set(cfs_hash_t *hs,
					 unsigned index, cfs_hash_bd_t *bd)
					 unsigned index, struct cfs_hash_bd *bd)
{
	bd->bd_bucket = hs->hs_buckets[index >> hs->hs_bkt_bits];
	bd->bd_offset = index & (CFS_HASH_BKT_NHLIST(hs) - 1U);
}

static inline void *
cfs_hash_bd_extra_get(cfs_hash_t *hs, cfs_hash_bd_t *bd)
cfs_hash_bd_extra_get(cfs_hash_t *hs, struct cfs_hash_bd *bd)
{
	return (void *)bd->bd_bucket +
	       cfs_hash_bkt_size(hs) - hs->hs_extra_bytes;
}

static inline __u32
cfs_hash_bd_version_get(cfs_hash_bd_t *bd)
cfs_hash_bd_version_get(struct cfs_hash_bd *bd)
{
	/* need hold cfs_hash_bd_lock */
	return bd->bd_bucket->hsb_version;
}

static inline __u32
cfs_hash_bd_count_get(cfs_hash_bd_t *bd)
cfs_hash_bd_count_get(struct cfs_hash_bd *bd)
{
	/* need hold cfs_hash_bd_lock */
	return bd->bd_bucket->hsb_count;
}

static inline int
cfs_hash_bd_depmax_get(cfs_hash_bd_t *bd)
cfs_hash_bd_depmax_get(struct cfs_hash_bd *bd)
{
	return bd->bd_bucket->hsb_depmax;
}

static inline int
cfs_hash_bd_compare(cfs_hash_bd_t *bd1, cfs_hash_bd_t *bd2)
cfs_hash_bd_compare(struct cfs_hash_bd *bd1, struct cfs_hash_bd *bd2)
{
	if (bd1->bd_bucket->hsb_index != bd2->bd_bucket->hsb_index)
		return bd1->bd_bucket->hsb_index - bd2->bd_bucket->hsb_index;
@@ -614,14 +614,14 @@ cfs_hash_bd_compare(cfs_hash_bd_t *bd1, cfs_hash_bd_t *bd2)
	return 0;
}

void cfs_hash_bd_add_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd,
void cfs_hash_bd_add_locked(cfs_hash_t *hs, struct cfs_hash_bd *bd,
			    struct hlist_node *hnode);
void cfs_hash_bd_del_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd,
void cfs_hash_bd_del_locked(cfs_hash_t *hs, struct cfs_hash_bd *bd,
			    struct hlist_node *hnode);
void cfs_hash_bd_move_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd_old,
			     cfs_hash_bd_t *bd_new, struct hlist_node *hnode);
void cfs_hash_bd_move_locked(cfs_hash_t *hs, struct cfs_hash_bd *bd_old,
			     struct cfs_hash_bd *bd_new, struct hlist_node *hnode);

static inline int cfs_hash_bd_dec_and_lock(cfs_hash_t *hs, cfs_hash_bd_t *bd,
static inline int cfs_hash_bd_dec_and_lock(cfs_hash_t *hs, struct cfs_hash_bd *bd,
					   atomic_t *condition)
{
	LASSERT(cfs_hash_with_spin_bktlock(hs));
@@ -630,48 +630,48 @@ static inline int cfs_hash_bd_dec_and_lock(cfs_hash_t *hs, cfs_hash_bd_t *bd,
}

static inline struct hlist_head *cfs_hash_bd_hhead(cfs_hash_t *hs,
						  cfs_hash_bd_t *bd)
						  struct cfs_hash_bd *bd)
{
	return hs->hs_hops->hop_hhead(hs, bd);
}

struct hlist_node *cfs_hash_bd_lookup_locked(cfs_hash_t *hs,
					    cfs_hash_bd_t *bd, const void *key);
					    struct cfs_hash_bd *bd, const void *key);
struct hlist_node *cfs_hash_bd_peek_locked(cfs_hash_t *hs,
					  cfs_hash_bd_t *bd, const void *key);
					  struct cfs_hash_bd *bd, const void *key);
struct hlist_node *cfs_hash_bd_findadd_locked(cfs_hash_t *hs,
					     cfs_hash_bd_t *bd, const void *key,
					     struct cfs_hash_bd *bd, const void *key,
					     struct hlist_node *hnode,
					     int insist_add);
struct hlist_node *cfs_hash_bd_finddel_locked(cfs_hash_t *hs,
					     cfs_hash_bd_t *bd, const void *key,
					     struct cfs_hash_bd *bd, const void *key,
					     struct hlist_node *hnode);

/**
 * operations on cfs_hash bucket (bd: bucket descriptor),
 * they are safe for hash-table with rehash
 */
void cfs_hash_dual_bd_get(cfs_hash_t *hs, const void *key, cfs_hash_bd_t *bds);
void cfs_hash_dual_bd_lock(cfs_hash_t *hs, cfs_hash_bd_t *bds, int excl);
void cfs_hash_dual_bd_unlock(cfs_hash_t *hs, cfs_hash_bd_t *bds, int excl);
void cfs_hash_dual_bd_get(cfs_hash_t *hs, const void *key, struct cfs_hash_bd *bds);
void cfs_hash_dual_bd_lock(cfs_hash_t *hs, struct cfs_hash_bd *bds, int excl);
void cfs_hash_dual_bd_unlock(cfs_hash_t *hs, struct cfs_hash_bd *bds, int excl);

static inline void cfs_hash_dual_bd_get_and_lock(cfs_hash_t *hs, const void *key,
						 cfs_hash_bd_t *bds, int excl)
						 struct cfs_hash_bd *bds, int excl)
{
	cfs_hash_dual_bd_get(hs, key, bds);
	cfs_hash_dual_bd_lock(hs, bds, excl);
}

struct hlist_node *cfs_hash_dual_bd_lookup_locked(cfs_hash_t *hs,
						 cfs_hash_bd_t *bds,
						 struct cfs_hash_bd *bds,
						 const void *key);
struct hlist_node *cfs_hash_dual_bd_findadd_locked(cfs_hash_t *hs,
						  cfs_hash_bd_t *bds,
						  struct cfs_hash_bd *bds,
						  const void *key,
						  struct hlist_node *hnode,
						  int insist_add);
struct hlist_node *cfs_hash_dual_bd_finddel_locked(cfs_hash_t *hs,
						  cfs_hash_bd_t *bds,
						  struct cfs_hash_bd *bds,
						  const void *key,
						  struct hlist_node *hnode);

@@ -699,7 +699,7 @@ void *cfs_hash_del_key(cfs_hash_t *hs, const void *key);
/* Hash lookup/for_each functions */
#define CFS_HASH_LOOP_HOG       1024

typedef int (*cfs_hash_for_each_cb_t)(cfs_hash_t *hs, cfs_hash_bd_t *bd,
typedef int (*cfs_hash_for_each_cb_t)(cfs_hash_t *hs, struct cfs_hash_bd *bd,
				      struct hlist_node *node, void *data);
void *cfs_hash_lookup(cfs_hash_t *hs, const void *key);
void cfs_hash_for_each(cfs_hash_t *hs, cfs_hash_for_each_cb_t, void *data);
@@ -739,10 +739,10 @@ cfs_hash_key_validate(cfs_hash_t *hs, const void *key,

/* Validate hnode is in the correct bucket */
static inline void
cfs_hash_bucket_validate(cfs_hash_t *hs, cfs_hash_bd_t *bd,
cfs_hash_bucket_validate(cfs_hash_t *hs, struct cfs_hash_bd *bd,
			 struct hlist_node *hnode)
{
	cfs_hash_bd_t   bds[2];
	struct cfs_hash_bd   bds[2];

	cfs_hash_dual_bd_get(hs, cfs_hash_key(hs, hnode), bds);
	LASSERT(bds[0].bd_bucket == bd->bd_bucket ||
@@ -756,7 +756,7 @@ cfs_hash_key_validate(cfs_hash_t *hs, const void *key,
		      struct hlist_node *hnode) {}

static inline void
cfs_hash_bucket_validate(cfs_hash_t *hs, cfs_hash_bd_t *bd,
cfs_hash_bucket_validate(cfs_hash_t *hs, struct cfs_hash_bd *bd,
			 struct hlist_node *hnode) {}

#endif /* CFS_HASH_DEBUG_LEVEL */
@@ -830,7 +830,7 @@ cfs_hash_u64_hash(const __u64 key, unsigned mask)
	return ((unsigned)(key * CFS_GOLDEN_RATIO_PRIME_64) & mask);
}

/** iterate over all buckets in @bds (array of cfs_hash_bd_t) */
/** iterate over all buckets in @bds (array of struct cfs_hash_bd) */
#define cfs_hash_for_each_bd(bds, n, i) \
	for (i = 0; i < n && (bds)[i].bd_bucket != NULL; i++)

+1 −1
Original line number Diff line number Diff line
@@ -659,7 +659,7 @@ struct lu_site {
static inline struct lu_site_bkt_data *
lu_site_bkt_from_fid(struct lu_site *site, struct lu_fid *fid)
{
	cfs_hash_bd_t bd;
	struct cfs_hash_bd bd;

	cfs_hash_bd_get(site->ls_obj_hash, fid, &bd);
	return cfs_hash_bd_extra_get(site->ls_obj_hash, &bd);
+2 −2
Original line number Diff line number Diff line
@@ -1891,7 +1891,7 @@ static int reprocess_one_queue(struct ldlm_resource *res, void *closure)
	return LDLM_ITER_CONTINUE;
}

static int ldlm_reprocess_res(cfs_hash_t *hs, cfs_hash_bd_t *bd,
static int ldlm_reprocess_res(cfs_hash_t *hs, struct cfs_hash_bd *bd,
			      struct hlist_node *hnode, void *arg)
{
	struct ldlm_resource *res = cfs_hash_object(hs, hnode);
@@ -2040,7 +2040,7 @@ struct export_cl_data {
 * Iterator function for ldlm_cancel_locks_for_export.
 * Cancels passed locks.
 */
int ldlm_cancel_locks_for_export_cb(cfs_hash_t *hs, cfs_hash_bd_t *bd,
int ldlm_cancel_locks_for_export_cb(cfs_hash_t *hs, struct cfs_hash_bd *bd,
				    struct hlist_node *hnode, void *data)

{
+2 −2
Original line number Diff line number Diff line
@@ -1925,7 +1925,7 @@ struct ldlm_cli_cancel_arg {
	void   *lc_opaque;
};

static int ldlm_cli_hash_cancel_unused(cfs_hash_t *hs, cfs_hash_bd_t *bd,
static int ldlm_cli_hash_cancel_unused(cfs_hash_t *hs, struct cfs_hash_bd *bd,
				       struct hlist_node *hnode, void *arg)
{
	struct ldlm_resource	   *res = cfs_hash_object(hs, hnode);
@@ -2023,7 +2023,7 @@ static int ldlm_iter_helper(struct ldlm_lock *lock, void *closure)
	return helper->iter(lock, helper->closure);
}

static int ldlm_res_iter_helper(cfs_hash_t *hs, cfs_hash_bd_t *bd,
static int ldlm_res_iter_helper(cfs_hash_t *hs, struct cfs_hash_bd *bd,
				struct hlist_node *hnode, void *arg)

{
+9 −9
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v)
{
	struct ldlm_namespace *ns  = m->private;
	__u64		  res = 0;
	cfs_hash_bd_t	  bd;
	struct cfs_hash_bd	  bd;
	int		    i;

	/* result is not strictly consistant */
@@ -564,7 +564,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
	struct ldlm_namespace *ns = NULL;
	struct ldlm_ns_bucket *nsb;
	ldlm_ns_hash_def_t    *nsd;
	cfs_hash_bd_t	  bd;
	struct cfs_hash_bd	  bd;
	int		    idx;
	int		    rc;

@@ -743,7 +743,7 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
	} while (1);
}

static int ldlm_resource_clean(cfs_hash_t *hs, cfs_hash_bd_t *bd,
static int ldlm_resource_clean(cfs_hash_t *hs, struct cfs_hash_bd *bd,
			       struct hlist_node *hnode, void *arg)
{
	struct ldlm_resource *res = cfs_hash_object(hs, hnode);
@@ -756,7 +756,7 @@ static int ldlm_resource_clean(cfs_hash_t *hs, cfs_hash_bd_t *bd,
	return 0;
}

static int ldlm_resource_complain(cfs_hash_t *hs, cfs_hash_bd_t *bd,
static int ldlm_resource_complain(cfs_hash_t *hs, struct cfs_hash_bd *bd,
				  struct hlist_node *hnode, void *arg)
{
	struct ldlm_resource  *res = cfs_hash_object(hs, hnode);
@@ -1060,7 +1060,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
{
	struct hlist_node     *hnode;
	struct ldlm_resource *res;
	cfs_hash_bd_t	 bd;
	struct cfs_hash_bd	 bd;
	__u64		 version;
	int		      ns_refcount = 0;

@@ -1183,7 +1183,7 @@ struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res)
	return res;
}

static void __ldlm_resource_putref_final(cfs_hash_bd_t *bd,
static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
					 struct ldlm_resource *res)
{
	struct ldlm_ns_bucket *nsb = res->lr_ns_bucket;
@@ -1214,7 +1214,7 @@ static void __ldlm_resource_putref_final(cfs_hash_bd_t *bd,
int ldlm_resource_putref(struct ldlm_resource *res)
{
	struct ldlm_namespace *ns = ldlm_res_to_ns(res);
	cfs_hash_bd_t   bd;
	struct cfs_hash_bd   bd;

	LASSERT_ATOMIC_GT_LT(&res->lr_refcount, 0, LI_POISON);
	CDEBUG(D_INFO, "putref res: %p count: %d\n",
@@ -1243,7 +1243,7 @@ int ldlm_resource_putref_locked(struct ldlm_resource *res)
	       res, atomic_read(&res->lr_refcount) - 1);

	if (atomic_dec_and_test(&res->lr_refcount)) {
		cfs_hash_bd_t bd;
		struct cfs_hash_bd bd;

		cfs_hash_bd_get(ldlm_res_to_ns(res)->ns_rs_hash,
				&res->lr_name, &bd);
@@ -1352,7 +1352,7 @@ void ldlm_dump_all_namespaces(ldlm_side_t client, int level)
}
EXPORT_SYMBOL(ldlm_dump_all_namespaces);

static int ldlm_res_hash_dump(cfs_hash_t *hs, cfs_hash_bd_t *bd,
static int ldlm_res_hash_dump(cfs_hash_t *hs, struct cfs_hash_bd *bd,
			      struct hlist_node *hnode, void *arg)
{
	struct ldlm_resource *res = cfs_hash_object(hs, hnode);
Loading