X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Ftux%2Flogger.c;h=c0c2cc3f4c1475ead12409a1e64759cfcccabe02;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=5ce80c17eebb32f0d55b9425be60f0631cbbc232;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/net/tux/logger.c b/net/tux/logger.c index 5ce80c17e..c0c2cc3f4 100644 --- a/net/tux/logger.c +++ b/net/tux/logger.c @@ -127,7 +127,7 @@ static void __throttle_logging (void) remove_wait_queue(&log_full, &wait); } -#if CONFIG_TUX_DEBUG +#ifdef CONFIG_TUX_DEBUG #define CHECK_LOGPTR(ptr) \ do { \ if ((ptr < log_buffer) || (ptr > log_buffer + LOG_LEN)) { \ @@ -153,7 +153,7 @@ void __log_request (tux_req_t *req) * Log the reply status (success, or type of failure) */ if (!tux_log_incomplete && (!req->status || (req->bytes_sent == -1))) { - + Dprintk("not logging req %p: {%s} [%d/%d]\n", req, req->uri_str, req->status, req->bytes_sent); return; } @@ -184,7 +184,7 @@ void __log_request (tux_req_t *req) Dprintk("version_str: {%s} [%d]\n", req->version_str, req->version_len); len += req->version_len + 1; -#if CONFIG_TUX_EXTENDED_LOG +#ifdef CONFIG_TUX_EXTENDED_LOG Dprintk("user_agent_str: {%s} [%d]\n", req->user_agent_str, req->user_agent_len); len += req->user_agent_len + 1; #endif @@ -195,7 +195,7 @@ void __log_request (tux_req_t *req) len++; inc = 5*sizeof(u32) + len; -#if CONFIG_TUX_EXTENDED_LOG +#ifdef CONFIG_TUX_EXTENDED_LOG inc += 7*sizeof(u32); #endif @@ -225,7 +225,7 @@ void __log_request (tux_req_t *req) * and other damage. The signature also servers as a log format * version identifier. */ -#if CONFIG_TUX_EXTENDED_LOG +#ifdef CONFIG_TUX_EXTENDED_LOG *(u32 *)str = 0x2223beef; #else *(u32 *)str = 0x1112beef; @@ -242,7 +242,7 @@ void __log_request (tux_req_t *req) str += sizeof(u32); CHECK_LOGPTR(str); -#if CONFIG_TUX_EXTENDED_LOG +#ifdef CONFIG_TUX_EXTENDED_LOG /* * Log the client port number: */ @@ -260,7 +260,7 @@ void __log_request (tux_req_t *req) str += sizeof(u32); CHECK_LOGPTR(str); -#if CONFIG_TUX_EXTENDED_LOG +#ifdef CONFIG_TUX_EXTENDED_LOG *(u32 *)str = req->accept_timestamp; str += sizeof(u32); *(u32 *)str = req->parse_timestamp; str += sizeof(u32); *(u32 *)str = req->output_timestamp; str += sizeof(u32); @@ -312,7 +312,7 @@ void __log_request (tux_req_t *req) CHECK_LOGPTR(str); } *str++ = 0; -#if CONFIG_TUX_EXTENDED_LOG +#ifdef CONFIG_TUX_EXTENDED_LOG if (req->user_agent_len) { memcpy(str, req->user_agent_str, req->user_agent_len); str += req->user_agent_len; @@ -353,12 +353,13 @@ void __log_request (tux_req_t *req) void tux_push_pending (struct sock *sk) { - struct tcp_opt *tp = tcp_sk(sk); + struct tcp_sock *tp = tcp_sk(sk); + struct inet_connection_sock *icsk = inet_csk(sk); Dprintk("pushing pending frames on sock %p.\n", sk); lock_sock(sk); if ((sk->sk_state == TCP_ESTABLISHED) && !sk->sk_err) { - tp->ack.pingpong = tux_ack_pingpong; + icsk->icsk_ack.pingpong = tux_ack_pingpong; tp->nonagle = 1; __tcp_push_pending_frames(sk, tp, tcp_current_mss(sk, 0), TCP_NAGLE_OFF); } @@ -383,33 +384,6 @@ void __put_data_sock (tux_req_t *req) req->data_sock = NULL; } -/* open-coded sys_close */ - -long tux_close(unsigned int fd) -{ - struct file * filp; - struct files_struct *files = current->files; - - spin_lock(&files->file_lock); - if (fd >= files->max_fds) - goto out_unlock; - filp = files->fd[fd]; - if (!filp) - goto out_unlock; - files->fd[fd] = NULL; - FD_CLR(fd, files->close_on_exec); - /* __put_unused_fd(files, fd); */ - __FD_CLR(fd, files->open_fds); - if (fd < files->next_fd) - files->next_fd = fd; - spin_unlock(&files->file_lock); - return filp_close(filp, files); - -out_unlock: - spin_unlock(&files->file_lock); - return -EBADF; -} - void flush_request (tux_req_t *req, int cachemiss) { struct socket *sock; @@ -424,7 +398,7 @@ void flush_request (tux_req_t *req, int cachemiss) TUX_BUG(); if (req->ti->thread != current) TUX_BUG(); -#if CONFIG_TUX_DEBUG +#ifdef CONFIG_TUX_DEBUG if (req->bytes_expected && (req->bytes_sent != req->bytes_expected)) { printk("hm, bytes_expected: %d != bytes_sent: %d!\n", req->bytes_expected, req->bytes_sent); @@ -439,7 +413,7 @@ void flush_request (tux_req_t *req, int cachemiss) if (sock) sk = sock->sk; Dprintk("FLUSHING req %p <%p> (sock %p, sk %p) (keepalive: %d, status: %d)\n", req, __builtin_return_address(0), sock, sk, req->keep_alive, req->status); - if (req->in_file.f_pos) + if (req->in_file->f_pos) /*TUX_BUG()*/; release_req_dentry(req); req->private = 0; @@ -558,7 +532,7 @@ void flush_request (tux_req_t *req, int cachemiss) req->post_data_len = 0; SET_TIMESTAMP(req->accept_timestamp); -#if CONFIG_TUX_EXTENDED_LOG +#ifdef CONFIG_TUX_EXTENDED_LOG req->parse_timestamp = 0; req->output_timestamp = 0; req->flush_timestamp = 0; @@ -567,7 +541,7 @@ void flush_request (tux_req_t *req, int cachemiss) req->total_bytes += req->bytes_sent; req->bytes_sent = 0; -#if CONFIG_TUX_DEBUG +#ifdef CONFIG_TUX_DEBUG req->bytes_expected = 0; #endif req->body_len = 0; @@ -659,6 +633,7 @@ void flush_request (tux_req_t *req, int cachemiss) int fd = req->fd, ret; if (fd != -1) { + Dprintk("closing req->fd: %d\n", fd); req->fd = -1; ret = tux_close(fd); if (ret) @@ -674,6 +649,8 @@ out: static int warn_once = 1; +static loff_t log_filp_last_index; + static unsigned int writeout_log (void) { unsigned int len, pending, next_log_tail; @@ -681,6 +658,8 @@ static unsigned int writeout_log (void) struct file *log_filp; char * str; unsigned int ret; + struct inode *inode; + struct address_space *mapping; if (tux_logging) Dprintk("TUX logger: opening log file {%s}.\n", tux_logfile); @@ -725,18 +704,22 @@ static unsigned int writeout_log (void) /* * Sync log data to disk: */ - if (log_filp->f_op && log_filp->f_op->fsync) { - down(&log_filp->f_dentry->d_inode->i_sem); - log_filp->f_op->fsync(log_filp, log_filp->f_dentry, 1); - up(&log_filp->f_dentry->d_inode->i_sem); + inode = log_filp->f_dentry->d_inode; + mapping = inode->i_mapping; + if (mapping->nrpages > 256) { /* batch stuff up */ + mutex_lock(&inode->i_mutex); + filemap_fdatawrite(inode->i_mapping); + + /* + * Now nuke old pagecache up to the place where we just + * started the I/O. There's no point in trying to invalidate + * pages after that, because they're currently in-flight. + */ + invalidate_mapping_pages(mapping, 0, log_filp_last_index); + log_filp_last_index = log_filp->f_pos >> PAGE_CACHE_SHIFT; + mutex_unlock(&inode->i_mutex); } - /* - * Reduce the cache footprint of the logger file - it's - * typically write-once. - */ - invalidate_inode_pages(log_filp->f_dentry->d_inode->i_mapping); - out_lock: spin_lock(&log_lock); out: @@ -764,13 +747,12 @@ static int logger_thread (void *data) oldmm = get_fs(); set_fs(KERNEL_DS); printk(KERN_NOTICE "TUX: logger thread started.\n"); -#if CONFIG_SMP +#ifdef CONFIG_SMP { - cpumask_t log_mask, map; + cpumask_t map; - mask_to_cpumask(log_cpu_mask, &log_mask); - cpus_and(map, cpu_online_map, log_mask); - if(!(cpus_empty(map))) + cpus_and(map, cpu_online_map, tux_log_cpu_mask); + if (!(cpus_empty(map))) set_cpus_allowed(current, map); } @@ -788,7 +770,7 @@ static int logger_thread (void *data) memset(log_buffer, 0, LOG_LEN); log_head = log_tail = 0; - current->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; + current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; add_wait_queue(&log_wait, &wait); for (;;) {