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)) { \
* 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;
}
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
len++;
inc = 5*sizeof(u32) + len;
-#if CONFIG_TUX_EXTENDED_LOG
+#ifdef CONFIG_TUX_EXTENDED_LOG
inc += 7*sizeof(u32);
#endif
* 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;
str += sizeof(u32);
CHECK_LOGPTR(str);
-#if CONFIG_TUX_EXTENDED_LOG
+#ifdef CONFIG_TUX_EXTENDED_LOG
/*
* Log the client port number:
*/
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);
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;
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);
}
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;
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);
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;
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;
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;
int fd = req->fd, ret;
if (fd != -1) {
+ Dprintk("closing req->fd: %d\n", fd);
req->fd = -1;
ret = tux_close(fd);
if (ret)
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;
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);
/*
* 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:
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);
}
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 (;;) {