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

Commit 0fbbced2 authored by Liang Zhen's avatar Liang Zhen Committed by Greg Kroah-Hartman
Browse files

staging: lustre: LNet drop rule implementation



This is implementation of LNet Drop Rule, which can randomly drop
LNet messages at specified rate.

LNet Drop Rule can only be applied to receive side of message. User
can add drop_rule either on end point of cluster (client/server) or
on LNet routers.

Here are lctl command to control LNet Drop Rules:
 - net_drop_add -s SRC_NID -d DEST_NID --rate VALUE
   drop 1/@VALUE of messages from @SRC_NID to @DEST_NID

 - net_drop_del -s SRC_NID -d DEST_NID
   remove all drop rules from @SRC_NID to @DEST_NID

 - net_drop_list
   list all drop rules on current node

 Examples:
 - lctl net_drop_add -s *@o2ib0 -d 192.168.1.102@tcp 1000
   add new drop rule, it will drop 1/1000 messages from network o2ib0
   to 192.168.1.102@tcp

 - lctl net_drop_add -s 10.8.6.123@o2ib1 -d * 500
   add new drop rule, it will drop 1/500 messages from 10.8.6.123@o2ib1
   to all nodes

Signed-off-by: default avatarLiang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435
Reviewed-on: http://review.whamcloud.com/11314


Reviewed-by: default avatarBobi Jam <bobijam@gmail.com>
Reviewed-by: default avatarAmir Shehata <amir.shehata@intel.com>
Reviewed-by: default avatarJohann Lombardi <johann.lombardi@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a921e9bd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ struct libcfs_ioctl_handler {
#define IOC_LIBCFS_PING		    _IOWR('e', 61, long)
/*	#define IOC_LIBCFS_DEBUG_PEER	      _IOWR('e', 62, long) */
#define IOC_LIBCFS_LNETST		  _IOWR('e', 63, long)
#define	IOC_LIBCFS_LNET_FAULT		_IOWR('e', 64, long)
/* lnd ioctls */
#define IOC_LIBCFS_REGISTER_MYNID	  _IOWR('e', 70, long)
#define IOC_LIBCFS_CLOSE_CONNECTION	_IOWR('e', 71, long)
+10 −0
Original line number Diff line number Diff line
@@ -578,6 +578,16 @@ char *lnet_msgtyp2str(int type);
void lnet_print_hdr(lnet_hdr_t *hdr);
int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold);

/** \addtogroup lnet_fault_simulation @{ */

int lnet_fault_ctl(int cmd, struct libcfs_ioctl_data *data);
int lnet_fault_init(void);
void lnet_fault_fini(void);

bool lnet_drop_rule_match(lnet_hdr_t *hdr);

/** @} lnet_fault_simulation */

void lnet_counters_get(lnet_counters_t *counters);
void lnet_counters_reset(void);

+2 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include <linux/types.h>

#include "types.h"
#include "lnetctl.h"

/* Max payload size */
#define LNET_MAX_PAYLOAD      CONFIG_LNET_MAX_PAYLOAD
@@ -572,6 +573,7 @@ typedef struct {
	struct lnet_peer_table		**ln_peer_tables;
	/* failure simulation */
	struct list_head		  ln_test_peers;
	struct list_head		  ln_drop_rules;

	struct list_head		  ln_nis;	/* LND instances */
	/* NIs bond on specific CPT(s) */
+83 −0
Original line number Diff line number Diff line
@@ -17,6 +17,89 @@

#include "types.h"

/** \addtogroup lnet_fault_simulation
 * @{
 */

enum {
	LNET_CTL_DROP_ADD,
	LNET_CTL_DROP_DEL,
	LNET_CTL_DROP_RESET,
	LNET_CTL_DROP_LIST,
};

#define LNET_ACK_BIT		BIT(0)
#define LNET_PUT_BIT		BIT(1)
#define LNET_GET_BIT		BIT(2)
#define LNET_REPLY_BIT		BIT(3)

/** ioctl parameter for LNet fault simulation */
struct lnet_fault_attr {
	/**
	 * source NID of drop rule
	 * LNET_NID_ANY is wildcard for all sources
	 * 255.255.255.255@net is wildcard for all addresses from @net
	 */
	lnet_nid_t			fa_src;
	/** destination NID of drop rule, see \a dr_src for details */
	lnet_nid_t			fa_dst;
	/**
	 * Portal mask to drop, -1 means all portals, for example:
	 * fa_ptl_mask = (1 << _LDLM_CB_REQUEST_PORTAL ) |
	 *		 (1 << LDLM_CANCEL_REQUEST_PORTAL)
	 *
	 * If it is non-zero then only PUT and GET will be filtered, otherwise
	 * there is no portal filter, all matched messages will be checked.
	 */
	__u64				fa_ptl_mask;
	/**
	 * message types to drop, for example:
	 * dra_type = LNET_DROP_ACK_BIT | LNET_DROP_PUT_BIT
	 *
	 * If it is non-zero then only specified message types are filtered,
	 * otherwise all message types will be checked.
	 */
	__u32				fa_msg_mask;
	union {
		/** message drop simulation */
		struct {
			/** drop rate of this rule */
			__u32			da_rate;
			/**
			 * time interval of message drop, it is exclusive
			 * with da_rate
			 */
			__u32			da_interval;
		} drop;
		/** TODO: add more */
		__u64			space[8];
	} u;
};

/** fault simluation stats */
struct lnet_fault_stat {
	/** total # matched messages */
	__u64				fs_count;
	/** # dropped LNET_MSG_PUT by this rule */
	__u64				fs_put;
	/** # dropped LNET_MSG_ACK by this rule */
	__u64				fs_ack;
	/** # dropped LNET_MSG_GET by this rule */
	__u64				fs_get;
	/** # dropped LNET_MSG_REPLY by this rule */
	__u64				fs_reply;
	union {
		struct {
			/** total # dropped messages */
			__u64			ds_dropped;
		} drop;
		/** TODO: add more */
		__u64			space[8];
	} u;
};

/** @} lnet_fault_simulation */

#define LNET_DEV_ID 0
#define LNET_DEV_PATH "/dev/lnet"
#define LNET_DEV_MAJOR 10
+1 −1
Original line number Diff line number Diff line
obj-$(CONFIG_LNET) += lnet.o

lnet-y := api-ni.o config.o nidstrings.o			\
lnet-y := api-ni.o config.o nidstrings.o net_fault.o		\
	  lib-me.o lib-msg.o lib-eq.o lib-md.o lib-ptl.o	\
	  lib-socket.o lib-move.o module.o lo.o			\
	  router.o router_proc.o acceptor.o peer.o
Loading