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

Commit 1d5d5ec1 authored by Fan Yong's avatar Fan Yong Committed by Greg Kroah-Hartman
Browse files

staging: lustre: obdclass: unified flow control interfaces



Unify the flow control interfaces for MDC RPC and FLD RPC.
We allow to adjust the maximum inflight RPCs count via /sys
interface.

Signed-off-by: default avatarFan Yong <fan.yong@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4687
Reviewed-on: http://review.whamcloud.com/9562


Reviewed-by: default avatarNiu Yawei <yawei.niu@intel.com>
Reviewed-by: default avatarAlex Zhuravlev <alexey.zhuravlev@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 9ef3754c
Loading
Loading
Loading
Loading
+2 −53
Original line number Original line Diff line number Diff line
@@ -53,57 +53,6 @@
#include "../include/lustre_mdc.h"
#include "../include/lustre_mdc.h"
#include "fld_internal.h"
#include "fld_internal.h"


/* TODO: these 3 functions are copies of flow-control code from mdc_lib.c
 * It should be common thing. The same about mdc RPC lock
 */
static int fld_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw)
{
	int rc;

	spin_lock(&cli->cl_loi_list_lock);
	rc = list_empty(&mcw->mcw_entry);
	spin_unlock(&cli->cl_loi_list_lock);
	return rc;
};

static void fld_enter_request(struct client_obd *cli)
{
	struct mdc_cache_waiter mcw;
	struct l_wait_info lwi = { 0 };

	spin_lock(&cli->cl_loi_list_lock);
	if (cli->cl_r_in_flight >= cli->cl_max_rpcs_in_flight) {
		list_add_tail(&mcw.mcw_entry, &cli->cl_cache_waiters);
		init_waitqueue_head(&mcw.mcw_waitq);
		spin_unlock(&cli->cl_loi_list_lock);
		l_wait_event(mcw.mcw_waitq, fld_req_avail(cli, &mcw), &lwi);
	} else {
		cli->cl_r_in_flight++;
		spin_unlock(&cli->cl_loi_list_lock);
	}
}

static void fld_exit_request(struct client_obd *cli)
{
	struct list_head *l, *tmp;
	struct mdc_cache_waiter *mcw;

	spin_lock(&cli->cl_loi_list_lock);
	cli->cl_r_in_flight--;
	list_for_each_safe(l, tmp, &cli->cl_cache_waiters) {
		if (cli->cl_r_in_flight >= cli->cl_max_rpcs_in_flight) {
			/* No free request slots anymore */
			break;
		}

		mcw = list_entry(l, struct mdc_cache_waiter, mcw_entry);
		list_del_init(&mcw->mcw_entry);
		cli->cl_r_in_flight++;
		wake_up(&mcw->mcw_waitq);
	}
	spin_unlock(&cli->cl_loi_list_lock);
}

static int fld_rrb_hash(struct lu_client_fld *fld, u64 seq)
static int fld_rrb_hash(struct lu_client_fld *fld, u64 seq)
{
{
	LASSERT(fld->lcf_count > 0);
	LASSERT(fld->lcf_count > 0);
@@ -439,9 +388,9 @@ int fld_client_rpc(struct obd_export *exp,
	req->rq_reply_portal = MDC_REPLY_PORTAL;
	req->rq_reply_portal = MDC_REPLY_PORTAL;
	ptlrpc_at_set_req_timeout(req);
	ptlrpc_at_set_req_timeout(req);


	fld_enter_request(&exp->exp_obd->u.cli);
	obd_get_request_slot(&exp->exp_obd->u.cli);
	rc = ptlrpc_queue_wait(req);
	rc = ptlrpc_queue_wait(req);
	fld_exit_request(&exp->exp_obd->u.cli);
	obd_put_request_slot(&exp->exp_obd->u.cli);
	if (rc)
	if (rc)
		goto out_req;
		goto out_req;


+0 −5
Original line number Original line Diff line number Diff line
@@ -179,11 +179,6 @@ static inline void mdc_update_max_ea_from_body(struct obd_export *exp,
	}
	}
}
}


struct mdc_cache_waiter {
	struct list_head	      mcw_entry;
	wait_queue_head_t	     mcw_waitq;
};

/* mdc/mdc_locks.c */
/* mdc/mdc_locks.c */
int it_open_error(int phase, struct lookup_intent *it);
int it_open_error(int phase, struct lookup_intent *it);


+6 −8
Original line number Original line Diff line number Diff line
@@ -211,9 +211,10 @@ struct timeout_item {
	struct list_head	 ti_chain;
	struct list_head	 ti_chain;
};
};


#define OSC_MAX_RIF_DEFAULT       8
#define OBD_MAX_RIF_DEFAULT	8
#define OBD_MAX_RIF_MAX		512
#define OSC_MAX_RIF_MAX		256
#define OSC_MAX_RIF_MAX		256
#define OSC_MAX_DIRTY_DEFAULT  (OSC_MAX_RIF_DEFAULT * 4)
#define OSC_MAX_DIRTY_DEFAULT	(OBD_MAX_RIF_DEFAULT * 4)
#define OSC_MAX_DIRTY_MB_MAX	2048	/* arbitrary, but < MAX_LONG bytes */
#define OSC_MAX_DIRTY_MB_MAX	2048	/* arbitrary, but < MAX_LONG bytes */
#define OSC_DEFAULT_RESENDS	10
#define OSC_DEFAULT_RESENDS	10


@@ -225,9 +226,6 @@ enum {
	NUM_SYNC_ON_CANCEL_STATES
	NUM_SYNC_ON_CANCEL_STATES
};
};


#define MDC_MAX_RIF_DEFAULT       8
#define MDC_MAX_RIF_MAX	 512

enum obd_cl_sem_lock_class {
enum obd_cl_sem_lock_class {
	OBD_CLI_SEM_NORMAL,
	OBD_CLI_SEM_NORMAL,
	OBD_CLI_SEM_MGC,
	OBD_CLI_SEM_MGC,
+5 −0
Original line number Original line Diff line number Diff line
@@ -97,6 +97,11 @@ int obd_zombie_impexp_init(void);
void obd_zombie_impexp_stop(void);
void obd_zombie_impexp_stop(void);
void obd_zombie_barrier(void);
void obd_zombie_barrier(void);


int obd_get_request_slot(struct client_obd *cli);
void obd_put_request_slot(struct client_obd *cli);
__u32 obd_get_max_rpcs_in_flight(struct client_obd *cli);
int obd_set_max_rpcs_in_flight(struct client_obd *cli, __u32 max);

struct llog_handle;
struct llog_handle;
struct llog_rec_hdr;
struct llog_rec_hdr;
typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,
typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,
+2 −2
Original line number Original line Diff line number Diff line
@@ -360,7 +360,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
	cli->cl_chunkbits = PAGE_SHIFT;
	cli->cl_chunkbits = PAGE_SHIFT;


	if (!strcmp(name, LUSTRE_MDC_NAME)) {
	if (!strcmp(name, LUSTRE_MDC_NAME)) {
		cli->cl_max_rpcs_in_flight = MDC_MAX_RIF_DEFAULT;
		cli->cl_max_rpcs_in_flight = OBD_MAX_RIF_DEFAULT;
	} else if (totalram_pages >> (20 - PAGE_SHIFT) <= 128 /* MB */) {
	} else if (totalram_pages >> (20 - PAGE_SHIFT) <= 128 /* MB */) {
		cli->cl_max_rpcs_in_flight = 2;
		cli->cl_max_rpcs_in_flight = 2;
	} else if (totalram_pages >> (20 - PAGE_SHIFT) <= 256 /* MB */) {
	} else if (totalram_pages >> (20 - PAGE_SHIFT) <= 256 /* MB */) {
@@ -368,7 +368,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
	} else if (totalram_pages >> (20 - PAGE_SHIFT) <= 512 /* MB */) {
	} else if (totalram_pages >> (20 - PAGE_SHIFT) <= 512 /* MB */) {
		cli->cl_max_rpcs_in_flight = 4;
		cli->cl_max_rpcs_in_flight = 4;
	} else {
	} else {
		cli->cl_max_rpcs_in_flight = OSC_MAX_RIF_DEFAULT;
		cli->cl_max_rpcs_in_flight = OBD_MAX_RIF_DEFAULT;
	}
	}
	rc = ldlm_get_ref();
	rc = ldlm_get_ref();
	if (rc) {
	if (rc) {
Loading