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

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

staging/lustre/obd: remove struct client_obd_lock



Remove the definition of struct client_obd_lock and the functions
client_obd_list_{init,lock,unlock,done}(). Use spinlock_t for the
cl_{loi,lru}_list_lock members of struct client_obd and call
spin_{lock,unlock}() directly.

Signed-off-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 019e9351
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -64,9 +64,9 @@ static int fld_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw)
{
	int rc;

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

@@ -75,15 +75,15 @@ static void fld_enter_request(struct client_obd *cli)
	struct mdc_cache_waiter mcw;
	struct l_wait_info lwi = { 0 };

	client_obd_list_lock(&cli->cl_loi_list_lock);
	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);
		client_obd_list_unlock(&cli->cl_loi_list_lock);
		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++;
		client_obd_list_unlock(&cli->cl_loi_list_lock);
		spin_unlock(&cli->cl_loi_list_lock);
	}
}

@@ -92,7 +92,7 @@ static void fld_exit_request(struct client_obd *cli)
	struct list_head *l, *tmp;
	struct mdc_cache_waiter *mcw;

	client_obd_list_lock(&cli->cl_loi_list_lock);
	spin_lock(&cli->cl_loi_list_lock);
	cli->cl_r_in_flight--;
	list_for_each_safe(l, tmp, &cli->cl_cache_waiters) {

@@ -106,7 +106,7 @@ static void fld_exit_request(struct client_obd *cli)
		cli->cl_r_in_flight++;
		wake_up(&mcw->mcw_waitq);
	}
	client_obd_list_unlock(&cli->cl_loi_list_lock);
	spin_unlock(&cli->cl_loi_list_lock);
}

static int fld_rrb_hash(struct lu_client_fld *fld, u64 seq)
+0 −67
Original line number Diff line number Diff line
@@ -55,71 +55,4 @@ struct ll_iattr {
	unsigned int	ia_attr_flags;
};

#define CLIENT_OBD_LIST_LOCK_DEBUG 1

struct client_obd_lock {
	spinlock_t		lock;

	unsigned long       time;
	struct task_struct *task;
	const char	 *func;
	int		 line;
};

static inline void __client_obd_list_lock(struct client_obd_lock *lock,
					  const char *func, int line)
{
	unsigned long cur = jiffies;

	while (1) {
		if (spin_trylock(&lock->lock)) {
			LASSERT(!lock->task);
			lock->task = current;
			lock->func = func;
			lock->line = line;
			lock->time = jiffies;
			break;
		}

		if (time_before(cur + 5 * HZ, jiffies) &&
		    time_before(lock->time + 5 * HZ, jiffies)) {
			struct task_struct *task = lock->task;

			if (!task)
				continue;

			LCONSOLE_WARN("%s:%d: lock %p was acquired by <%s:%d:%s:%d> for %lu seconds.\n",
				      current->comm, current->pid,
				      lock, task->comm, task->pid,
				      lock->func, lock->line,
				      (jiffies - lock->time) / HZ);
			LCONSOLE_WARN("====== for current process =====\n");
			dump_stack();
			LCONSOLE_WARN("====== end =======\n");
			set_current_state(TASK_UNINTERRUPTIBLE);
			schedule_timeout(1000 * HZ);
		}
		cpu_relax();
	}
}

#define client_obd_list_lock(lock) \
	__client_obd_list_lock(lock, __func__, __LINE__)

static inline void client_obd_list_unlock(struct client_obd_lock *lock)
{
	LASSERT(lock->task);
	lock->task = NULL;
	lock->time = jiffies;
	spin_unlock(&lock->lock);
}

static inline void client_obd_list_lock_init(struct client_obd_lock *lock)
{
	spin_lock_init(&lock->lock);
}

static inline void client_obd_list_lock_done(struct client_obd_lock *lock)
{}

#endif /* __LINUX_OBD_H */
+3 −6
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#ifndef __OBD_H
#define __OBD_H

#include <linux/spinlock.h>
#include "linux/obd.h"

#define IOC_OSC_TYPE	 'h'
@@ -293,14 +294,10 @@ struct client_obd {
	 * blocking everywhere, but we don't want to slow down fast-path of
	 * our main platform.)
	 *
	 * Exact type of ->cl_loi_list_lock is defined in arch/obd.h together
	 * with client_obd_list_{un,}lock() and
	 * client_obd_list_lock_{init,done}() functions.
	 *
	 * NB by Jinshan: though field names are still _loi_, but actually
	 * osc_object{}s are in the list.
	 */
	struct client_obd_lock	       cl_loi_list_lock;
	spinlock_t		       cl_loi_list_lock;
	struct list_head	       cl_loi_ready_list;
	struct list_head	       cl_loi_hp_ready_list;
	struct list_head	       cl_loi_write_list;
@@ -327,7 +324,7 @@ struct client_obd {
	atomic_t		 cl_lru_shrinkers;
	atomic_t		 cl_lru_in_list;
	struct list_head	 cl_lru_list; /* lru page list */
	struct client_obd_lock   cl_lru_list_lock; /* page list protector */
	spinlock_t		 cl_lru_list_lock; /* page list protector */

	/* number of in flight destroy rpcs is limited to max_rpcs_in_flight */
	atomic_t	     cl_destroy_in_flight;
+2 −2
Original line number Diff line number Diff line
@@ -314,7 +314,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
	INIT_LIST_HEAD(&cli->cl_loi_hp_ready_list);
	INIT_LIST_HEAD(&cli->cl_loi_write_list);
	INIT_LIST_HEAD(&cli->cl_loi_read_list);
	client_obd_list_lock_init(&cli->cl_loi_list_lock);
	spin_lock_init(&cli->cl_loi_list_lock);
	atomic_set(&cli->cl_pending_w_pages, 0);
	atomic_set(&cli->cl_pending_r_pages, 0);
	cli->cl_r_in_flight = 0;
@@ -333,7 +333,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
	atomic_set(&cli->cl_lru_busy, 0);
	atomic_set(&cli->cl_lru_in_list, 0);
	INIT_LIST_HEAD(&cli->cl_lru_list);
	client_obd_list_lock_init(&cli->cl_lru_list_lock);
	spin_lock_init(&cli->cl_lru_list_lock);

	init_waitqueue_head(&cli->cl_destroy_waitq);
	atomic_set(&cli->cl_destroy_in_flight, 0);
+4 −4
Original line number Diff line number Diff line
@@ -49,9 +49,9 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
					      obd_kobj);
	struct client_obd *cli = &dev->u.cli;

	client_obd_list_lock(&cli->cl_loi_list_lock);
	spin_lock(&cli->cl_loi_list_lock);
	len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight);
	client_obd_list_unlock(&cli->cl_loi_list_lock);
	spin_unlock(&cli->cl_loi_list_lock);

	return len;
}
@@ -74,9 +74,9 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
	if (val < 1 || val > MDC_MAX_RIF_MAX)
		return -ERANGE;

	client_obd_list_lock(&cli->cl_loi_list_lock);
	spin_lock(&cli->cl_loi_list_lock);
	cli->cl_max_rpcs_in_flight = val;
	client_obd_list_unlock(&cli->cl_loi_list_lock);
	spin_unlock(&cli->cl_loi_list_lock);

	return count;
}
Loading