1
0
mirror of https://github.com/schoebel/mars synced 2025-03-25 04:26:49 +00:00

all: replace msleep() by brick_msleep()

This commit is contained in:
Thomas Schoebel-Theuer 2012-09-17 12:11:25 +02:00 committed by Thomas Schoebel-Theuer
parent a24d18d620
commit 11c7900acb
14 changed files with 59 additions and 59 deletions

10
brick.c
View File

@ -12,7 +12,7 @@
#include "brick.h"
#include "brick_mem.h"
int brick_msleep(int msecs, bool shorten)
int _brick_msleep(int msecs, bool shorten)
{
unsigned long timeout;
if (msecs <= 0) {
@ -29,7 +29,7 @@ int brick_msleep(int msecs, bool shorten)
return jiffies_to_msecs(timeout);
}
EXPORT_SYMBOL_GPL(brick_msleep);
EXPORT_SYMBOL_GPL(_brick_msleep);
//////////////////////////////////////////////////////////////
@ -708,7 +708,7 @@ int set_recursive_button(struct generic_brick *orig_brick, brick_switch_t mode,
struct generic_output *output;
struct generic_brick *next;
BRICK_DBG("---> i = %d\n", i);
//msleep(1000);
//brick_msleep(1000);
if (!input)
continue;
output = input->connect;
@ -727,14 +727,14 @@ int set_recursive_button(struct generic_brick *orig_brick, brick_switch_t mode,
struct generic_output *output = brick->outputs[i];
struct list_head *tmp;
BRICK_DBG("---> i = %d output = %p\n", i, output);
//msleep(1000);
//brick_msleep(1000);
if (!output)
continue;
for (tmp = output->output_head.next; tmp && tmp != &output->output_head; tmp = tmp->next) {
struct generic_input *input = container_of(tmp, struct generic_input, input_head);
struct generic_brick *next = input->brick;
BRICK_DBG("----> tmp = %p input = %p next = %p\n", tmp, input, next);
//msleep(1000);
//brick_msleep(1000);
if (unlikely(!next)) {
BRICK_ERR("oops, bad brick pointer\n");
status = -EINVAL;

View File

@ -13,8 +13,8 @@
#define MAX_BRICK_TYPES 64
#define msleep(msecs) brick_msleep(msecs, false)
extern int brick_msleep(int msecs, bool shorten);
#define brick_msleep(msecs) _brick_msleep(msecs, false)
extern int _brick_msleep(int msecs, bool shorten);
/////////////////////////////////////////////////////////////////////////

View File

@ -57,7 +57,7 @@ void mars_limit_sleep(struct mars_limiter *lim, int amount)
if (sleep > 0) {
if (sleep > 1000)
sleep = 1000;
msleep(sleep);
brick_msleep(sleep);
}
}

View File

@ -17,7 +17,7 @@ void exit_logst(struct log_status *logst)
while (atomic_read(&logst->mref_flying) > 0) {
if (!count++)
MARS_DBG("waiting for IO terminating...");
msleep(500);
brick_msleep(500);
}
if (logst->read_mref) {
MARS_DBG("putting read_mref\n");
@ -232,7 +232,7 @@ void *log_reserve(struct log_status *logst, struct log_header *lh)
MARS_ERR("mref_get() failed, status = %d\n", status);
goto err_free;
}
msleep(100);
brick_msleep(100);
}
mars_trace(mref, "log_start");

View File

@ -799,7 +799,7 @@ static int aio_submit_thread(void *data)
if ((long long)jiffies - mref_a->start_jiffies <= mref->ref_timeout) {
if (!_dequeue(tinfo, false)) {
atomic_inc(&output->total_msleep_count);
msleep(1000 * 4 / HZ);
brick_msleep(1000 * 4 / HZ);
}
_enqueue(tinfo, mref_a, MARS_PRIO_LOW, true);
continue;
@ -834,7 +834,7 @@ static int aio_submit_thread(void *data)
break;
}
atomic_inc(&output->total_delay_count);
msleep(sleeptime);
brick_msleep(sleeptime);
if (sleeptime < 100) {
sleeptime += 1000 / HZ;
}

View File

@ -93,7 +93,7 @@ static void check_endio(struct generic_callback *cb)
return;
fatal:
msleep(60000);
brick_msleep(60000);
return;
}
@ -132,7 +132,7 @@ static int check_watchdog(void *data)
unsigned long flags;
unsigned long now;
msleep(5000);
brick_msleep(5000);
traced_lock(&output->check_lock, flags);

View File

@ -212,9 +212,9 @@ static void client_ref_io(struct client_output *output, struct mref_object *mref
while (output->brick->max_flying > 0 && atomic_read(&output->fly_count) > output->brick->max_flying) {
MARS_IO("sleeping request pos = %lld len = %d rw = %d (flying = %d)\n", mref->ref_pos, mref->ref_len, mref->ref_rw, atomic_read(&output->fly_count));
#ifdef IO_DEBUGGING
msleep(3000);
brick_msleep(3000);
#else
msleep(1000 * 2 / HZ);
brick_msleep(1000 * 2 / HZ);
#endif
}
@ -439,13 +439,13 @@ static int sender_thread(void *data)
if (do_kill) {
do_kill = false;
_kill_socket(output);
msleep(3000);
brick_msleep(3000);
}
status = _connect(output, brick->brick_name);
MARS_IO("connect status = %d\n", status);
if (unlikely(status < 0)) {
msleep(3000);
brick_msleep(3000);
_do_timeout(output, &output->wait_list, false);
_do_timeout(output, &output->mref_list, false);
continue;
@ -472,7 +472,7 @@ static int sender_thread(void *data)
output->get_info = false;
} else {
MARS_WRN("cannot get info, status = %d\n", status);
msleep(1000);
brick_msleep(1000);
}
}
@ -505,7 +505,7 @@ static int sender_thread(void *data)
do_kill = false;
_kill_socket(output);
}
msleep(3000);
brick_msleep(3000);
continue;
}

View File

@ -512,7 +512,7 @@ int _run_copy(struct copy_brick *brick)
*/
_clash(brick);
MARS_DBG("re-clash\n");
msleep(100);
brick_msleep(100);
return 0;
}
_clear_all_mref(brick);

View File

@ -334,7 +334,7 @@ static int if_make_request(struct request_queue *q, struct bio *bio)
/* FIXME: THIS IS PROVISIONARY (use event instead)
*/
while (unlikely(!brick->power.led_on)) {
msleep(100);
brick_msleep(100);
}
down(&input->kick_sem);
@ -767,7 +767,7 @@ static int if_release(struct gendisk *gd, fmode_t mode)
while ((nr = atomic_read(&input->flying_count)) > 0) {
MARS_INF("%d IO requests not yet completed\n", nr);
msleep(3000);
brick_msleep(3000);
}
if (atomic_dec_and_test(&input->open_count)) {

View File

@ -355,7 +355,7 @@ int _mars_send_raw(struct mars_socket *msock, void *buf, int len)
#endif
if (status == -EAGAIN) {
msleep(sleeptime);
brick_msleep(sleeptime);
// linearly increasing backoff
if (sleeptime < 100) {
sleeptime += 1000 / HZ;
@ -365,12 +365,12 @@ int _mars_send_raw(struct mars_socket *msock, void *buf, int len)
if (unlikely(status == -EINTR)) { // ignore it
flush_signals(current);
MARS_IO("#%d got signal\n", msock->s_debug_nr);
msleep(50);
brick_msleep(50);
continue;
}
if (unlikely(!status)) {
MARS_WRN("#%d EOF from socket upon send_page()\n", msock->s_debug_nr);
msleep(50);
brick_msleep(50);
status = -ECOMM;
break;
}
@ -408,7 +408,7 @@ restart:
msock->s_pos = 0;
msock->s_buffer = brick_block_alloc(0, PAGE_SIZE);
if (unlikely(!msock->s_buffer))
msleep(100);
brick_msleep(100);
}
if (msock->s_pos + rest < PAGE_SIZE) {
@ -508,7 +508,7 @@ int mars_recv_raw(struct mars_socket *msock, void *buf, int minlen, int maxlen)
}
if (status == -EAGAIN) {
msleep(sleeptime);
brick_msleep(sleeptime);
// linearly increasing backoff
if (sleeptime < 100) {
sleeptime += 1000 / HZ;
@ -574,7 +574,7 @@ int _mars_send_struct(struct mars_socket *msock, void *data, const struct meta *
#if 1
if (len > 16 * PAGE_SIZE) {
MARS_WRN("#%d implausible len=%d, \n", msock->s_debug_nr, len);
msleep(30000);
brick_msleep(30000);
status = -EINVAL;
break;
}
@ -687,7 +687,7 @@ int _mars_recv_struct(struct mars_socket *msock, void *data, const struct meta *
void *mem;
status = mars_recv_raw(msock, &header, sizeof(header), sizeof(header));
if (status == -EAGAIN) {
msleep(50);
brick_msleep(50);
continue;
}
if (status < 0) {
@ -787,7 +787,7 @@ int _mars_recv_struct(struct mars_socket *msock, void *data, const struct meta *
MARS_IO("#%d called from line %d reading extra %d\n", msock->s_debug_nr, line, header.h_len);
status = mars_recv_raw(msock, item, header.h_len, header.h_len);
while (status == -EAGAIN) {
msleep(50);
brick_msleep(50);
status = mars_recv_raw(msock, item, header.h_len, header.h_len);
}
if (status >= 0) {

View File

@ -63,7 +63,7 @@ int cb_thread(void *data)
tmp = brick->cb_read_list.next;
if (tmp == &brick->cb_read_list) {
traced_unlock(&brick->cb_lock, flags);
msleep(1000 / HZ);
brick_msleep(1000 / HZ);
continue;
}
}
@ -670,7 +670,7 @@ static int _server_thread(void *data)
while (!kthread_should_stop() &&
(!mars_global || !mars_global->global_power.button)) {
MARS_DBG("system did not start up\n");
msleep(5000);
brick_msleep(5000);
}
MARS_INF("-------- server now working on host '%s' ----------\n", id);
@ -681,18 +681,18 @@ static int _server_thread(void *data)
brick = (void*)mars_make_brick(mars_global, NULL, true, &server_brick_type, "server", "server");
if (!brick) {
MARS_ERR("cannot create server instance\n");
msleep(5000);
brick_msleep(5000);
continue;
}
}
status = mars_accept_socket(&brick->handler_socket, &server_socket);
if (unlikely(status < 0)) {
msleep(500);
brick_msleep(500);
if (status == -EAGAIN)
continue; // without error message
MARS_WRN("accept status = %d\n", status);
msleep(2000);
brick_msleep(2000);
continue;
}
brick->handler_socket.s_shutdown_on_err = true;
@ -715,7 +715,7 @@ static int _server_thread(void *data)
}
brick = NULL;
msleep(1000);
brick_msleep(1000);
continue;
err:
@ -727,7 +727,7 @@ static int _server_thread(void *data)
}
brick = NULL;
}
msleep(3000);
brick_msleep(3000);
}
MARS_INF("-------- cleaning up ----------\n");

View File

@ -632,7 +632,7 @@ int trans_logger_ref_get(struct trans_logger_output *output, struct mref_object
/* FIXME: THIS IS PROVISIONARY (use event instead)
*/
while (unlikely(!brick->power.led_on)) {
msleep(HZ / 10);
brick_msleep(HZ / 10);
}
return _write_ref_get(output, mref_a);
@ -918,7 +918,7 @@ void free_writeback(struct writeback_info *wb)
#ifdef LATE_COMPLETE
while (!orig_mref_a->is_completed) {
MARS_ERR("request %lld (len = %d) was not completed\n", orig_mref->ref_pos, orig_mref->ref_len);
msleep(3000);
brick_msleep(3000);
}
#endif
#ifdef OLD_POSCOMPLETE
@ -1484,7 +1484,7 @@ bool prep_phase_startio(struct trans_logger_mref_aspect *mref_a)
err:
MARS_ERR("cannot work\n");
msleep(1000);
brick_msleep(1000);
return false;
}
@ -2371,7 +2371,7 @@ void trans_logger_replay(struct trans_logger_brick *brick)
status = log_read(&input->logst, &lh, &buf, &len);
if (status == -EAGAIN) {
MARS_DBG("got -EAGAIN\n");
msleep(backoff);
brick_msleep(backoff);
if (backoff < 3000) {
backoff += 100;
} else {
@ -2396,7 +2396,7 @@ void trans_logger_replay(struct trans_logger_brick *brick)
brick->replay_end_pos = finished_pos;
break;
}
msleep(1000);
brick_msleep(1000);
continue;
}
@ -2449,7 +2449,7 @@ void trans_logger_replay(struct trans_logger_brick *brick)
mars_trigger();
while (!kthread_should_stop()) {
msleep(500);
brick_msleep(500);
}
}

View File

@ -1042,23 +1042,23 @@ int peer_thread(void *data)
if (!mars_socket_is_alive(&peer->socket)) {
if (peer->socket.s_socket) {
_peer_cleanup(peer);
msleep(5000);
brick_msleep(5000);
continue;
}
if (!mars_net_is_alive) {
msleep(1000);
brick_msleep(1000);
continue;
}
status = mars_create_socket(&peer->socket, &sockaddr, false);
if (unlikely(status < 0)) {
MARS_INF("no connection to '%s'\n", real_peer);
msleep(5000);
brick_msleep(5000);
continue;
}
peer->socket.s_shutdown_on_err = true;
MARS_DBG("successfully opened socket to '%s'\n", real_peer);
msleep(100);
brick_msleep(100);
continue;
}
@ -1077,13 +1077,13 @@ int peer_thread(void *data)
if (unlikely(status < 0)) {
MARS_WRN("communication error on send, status = %d\n", status);
_peer_cleanup(peer);
msleep(2000);
brick_msleep(2000);
continue;
}
if (cmd.cmd_code == CMD_NOTIFY) {
flip = false;
pause_time = 0;
msleep(1000);
brick_msleep(1000);
continue;
}
@ -1092,7 +1092,7 @@ int peer_thread(void *data)
if (unlikely(status < 0)) {
MARS_WRN("communication error on receive, status = %d\n", status);
_peer_cleanup(peer);
msleep(5000);
brick_msleep(5000);
continue;
}
@ -1109,7 +1109,7 @@ int peer_thread(void *data)
mars_free_dent_all(NULL, &old_list);
}
msleep(1000);
brick_msleep(1000);
if (!kthread_should_stop()) {
if (pause_time < CONFIG_MARS_PROPAGATE_INTERVAL)
pause_time++;
@ -3794,7 +3794,7 @@ static int light_thread(void *data)
mars_mem_percent = 70;
brick_global_memlimit = brick_global_memavail * mars_mem_percent / 100;
msleep(100);
brick_msleep(100);
if (kthread_should_stop()) {
_global.global_power.button = false;
@ -3853,7 +3853,7 @@ static int light_thread(void *data)
_show_statist(&_global);
#endif
msleep(500);
brick_msleep(500);
wait_event_interruptible_timeout(_global.main_event, _global.main_trigger, CONFIG_MARS_SCAN_INTERVAL * HZ);
_global.main_trigger = false;
@ -3862,7 +3862,7 @@ static int light_thread(void *data)
done:
MARS_INF("-------- cleaning up ----------\n");
mars_remote_trigger();
msleep(2000);
brick_msleep(2000);
mars_kill_brick_all(&_global, &_global.server_anchor, false);
mars_free_dent_all(&_global, &_global.dent_anchor);

View File

@ -587,7 +587,7 @@ restart:
dent->d_version = version;
#ifdef CONFIG_MARS_USE_SYSLOG
msleep(10); // yield
brick_msleep(10); // yield
#endif
//MARS_IO("reading inode '%s'\n", dent->d_path);
@ -627,7 +627,7 @@ restart:
for (tmp = global->dent_anchor.next, next = tmp->next; tmp != &global->dent_anchor; tmp = next, next = next->next) {
struct mars_dent *dent = container_of(tmp, struct mars_dent, dent_link);
#ifdef CONFIG_MARS_USE_SYSLOG
msleep(10); // yield
brick_msleep(10); // yield
#else
schedule();
#endif
@ -661,7 +661,7 @@ restart:
struct mars_dent *dent = container_of(tmp, struct mars_dent, dent_link);
up_read(&global->dent_mutex);
#ifdef CONFIG_MARS_USE_SYSLOG
msleep(10); // yield
brick_msleep(10); // yield
#else
schedule();
#endif
@ -681,7 +681,7 @@ restart:
struct mars_dent *dent = container_of(tmp, struct mars_dent, dent_link);
up_read(&global->dent_mutex);
#ifdef CONFIG_MARS_USE_SYSLOG
msleep(10); // yield
brick_msleep(10); // yield
#else
schedule();
#endif