Throttle logging so that it's not so bloody easy to accidentally take out a machine with a zombified daemon.
git-svn-id: http://svn.xiph.org/trunk/fusd@12351 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
parent
55b0389911
commit
41185bd56b
@ -130,7 +130,6 @@ struct fusd_dev_t_s {
|
|||||||
void *private_data; /* User's private data */
|
void *private_data; /* User's private data */
|
||||||
struct cdev* handle;
|
struct cdev* handle;
|
||||||
dev_t dev_id;
|
dev_t dev_id;
|
||||||
// devfs_handle_t handle; /* The devfs-provided handle */
|
|
||||||
|
|
||||||
fusd_file_t **files; /* Array of this device's open files */
|
fusd_file_t **files; /* Array of this device's open files */
|
||||||
int array_size; /* Size of the array pointed to by 'files' */
|
int array_size; /* Size of the array pointed to by 'files' */
|
||||||
|
|||||||
@ -103,11 +103,6 @@
|
|||||||
* __wake_up. */
|
* __wake_up. */
|
||||||
/* #define CONFIG_FUSD_USE_WAKEUPSYNC */
|
/* #define CONFIG_FUSD_USE_WAKEUPSYNC */
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,9)
|
|
||||||
# define vsnprintf(str, size, format, ap) vsprintf(str, format, ap)
|
|
||||||
# define snprintf(str, len, args...) sprintf(str, args)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
|
||||||
|
|
||||||
#define CLASS class_simple
|
#define CLASS class_simple
|
||||||
@ -138,8 +133,8 @@
|
|||||||
#include "fusd_msg.h"
|
#include "fusd_msg.h"
|
||||||
#include "kfusd.h"
|
#include "kfusd.h"
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
|
||||||
# error "***FUSD doesn't work before Linux Kernel v2.4.0"
|
# error "***FUSD doesn't work before Linux Kernel v2.6.0"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC struct cdev* fusd_control_device;
|
STATIC struct cdev* fusd_control_device;
|
||||||
@ -181,6 +176,10 @@ STATIC int fusd_debug_level = CONFIG_FUSD_DEBUGLEVEL;
|
|||||||
module_param(fusd_debug_level, int, S_IRUGO);
|
module_param(fusd_debug_level, int, S_IRUGO);
|
||||||
|
|
||||||
#define BUFSIZE 1000 /* kernel's kmalloc pool has a 1012-sized bucket */
|
#define BUFSIZE 1000 /* kernel's kmalloc pool has a 1012-sized bucket */
|
||||||
|
static int debug_throttle = 0; /* emit a maximum number of debug
|
||||||
|
messages, else it's possible to take
|
||||||
|
out the machine accidentally if a
|
||||||
|
daemon disappears with open files */
|
||||||
|
|
||||||
STATIC void rdebug_real(char *fmt, ...)
|
STATIC void rdebug_real(char *fmt, ...)
|
||||||
{
|
{
|
||||||
@ -188,6 +187,9 @@ STATIC void rdebug_real(char *fmt, ...)
|
|||||||
int len;
|
int len;
|
||||||
char *message;
|
char *message;
|
||||||
|
|
||||||
|
if(debug_throttle > 100) return;
|
||||||
|
debug_throttle++;
|
||||||
|
|
||||||
/* I'm kmallocing since you don't really want 1k on the stack. I've
|
/* I'm kmallocing since you don't really want 1k on the stack. I've
|
||||||
* had stack overflow problems before; the kernel stack is quite
|
* had stack overflow problems before; the kernel stack is quite
|
||||||
* small... */
|
* small... */
|
||||||
@ -1195,6 +1197,10 @@ STATIC ssize_t fusd_client_read(struct file *file , char *buf,
|
|||||||
int retval = -EPIPE;
|
int retval = -EPIPE;
|
||||||
|
|
||||||
GET_FUSD_FILE_AND_DEV(file->private_data, fusd_file, fusd_dev);
|
GET_FUSD_FILE_AND_DEV(file->private_data, fusd_file, fusd_dev);
|
||||||
|
|
||||||
|
if(ZOMBIE(fusd_dev))
|
||||||
|
goto zombie_dev;
|
||||||
|
|
||||||
LOCK_FUSD_FILE(fusd_file);
|
LOCK_FUSD_FILE(fusd_file);
|
||||||
|
|
||||||
RDEBUG(3, "got a read on /dev/%s (owned by pid %d) from pid %d",
|
RDEBUG(3, "got a read on /dev/%s (owned by pid %d) from pid %d",
|
||||||
@ -1203,7 +1209,7 @@ STATIC ssize_t fusd_client_read(struct file *file , char *buf,
|
|||||||
transaction = fusd_find_incomplete_transaction(fusd_file, FUSD_READ);
|
transaction = fusd_find_incomplete_transaction(fusd_file, FUSD_READ);
|
||||||
if (transaction && transaction->size > count)
|
if (transaction && transaction->size > count)
|
||||||
{
|
{
|
||||||
RDEBUG(3, "Incomplete I/O transaction %ld thrown out, as the transaction's size of %d bytes was greater than "
|
RDEBUG(2, "Incomplete I/O transaction %ld thrown out, as the transaction's size of %d bytes was greater than "
|
||||||
"the retry's size of %d bytes", transaction->transid, transaction->size, (int)count);
|
"the retry's size of %d bytes", transaction->transid, transaction->size, (int)count);
|
||||||
|
|
||||||
fusd_cleanup_transaction(fusd_file, transaction);
|
fusd_cleanup_transaction(fusd_file, transaction);
|
||||||
@ -1273,6 +1279,7 @@ STATIC ssize_t fusd_client_read(struct file *file , char *buf,
|
|||||||
|
|
||||||
invalid_file:
|
invalid_file:
|
||||||
invalid_dev:
|
invalid_dev:
|
||||||
|
zombie_dev:
|
||||||
RDEBUG(3, "got a read on client file from pid %d, driver has disappeared",
|
RDEBUG(3, "got a read on client file from pid %d, driver has disappeared",
|
||||||
current->pid);
|
current->pid);
|
||||||
return -EPIPE;
|
return -EPIPE;
|
||||||
@ -1362,6 +1369,10 @@ STATIC ssize_t fusd_client_write(struct file *file,
|
|||||||
struct fusd_transaction* transaction;
|
struct fusd_transaction* transaction;
|
||||||
|
|
||||||
GET_FUSD_FILE_AND_DEV(file->private_data, fusd_file, fusd_dev);
|
GET_FUSD_FILE_AND_DEV(file->private_data, fusd_file, fusd_dev);
|
||||||
|
|
||||||
|
if(ZOMBIE(fusd_dev))
|
||||||
|
goto zombie_dev;
|
||||||
|
|
||||||
LOCK_FUSD_FILE(fusd_file);
|
LOCK_FUSD_FILE(fusd_file);
|
||||||
|
|
||||||
RDEBUG(3, "got a write on /dev/%s (owned by pid %d) from pid %d",
|
RDEBUG(3, "got a write on /dev/%s (owned by pid %d) from pid %d",
|
||||||
@ -1437,7 +1448,8 @@ STATIC ssize_t fusd_client_write(struct file *file,
|
|||||||
|
|
||||||
invalid_file:
|
invalid_file:
|
||||||
invalid_dev:
|
invalid_dev:
|
||||||
RDEBUG(3, "got a read on client file from pid %d, driver has disappeared",
|
zombie_dev:
|
||||||
|
RDEBUG(3, "got a write on client file from pid %d, driver has disappeared",
|
||||||
current->pid);
|
current->pid);
|
||||||
return -EPIPE;
|
return -EPIPE;
|
||||||
}
|
}
|
||||||
@ -1453,6 +1465,10 @@ STATIC int fusd_client_ioctl(struct inode *inode, struct file *file,
|
|||||||
struct fusd_transaction* transaction;
|
struct fusd_transaction* transaction;
|
||||||
|
|
||||||
GET_FUSD_FILE_AND_DEV(file->private_data, fusd_file, fusd_dev);
|
GET_FUSD_FILE_AND_DEV(file->private_data, fusd_file, fusd_dev);
|
||||||
|
|
||||||
|
if(ZOMBIE(fusd_dev))
|
||||||
|
goto zombie_dev;
|
||||||
|
|
||||||
LOCK_FUSD_FILE(fusd_file);
|
LOCK_FUSD_FILE(fusd_file);
|
||||||
|
|
||||||
RDEBUG(3, "got an ioctl on /dev/%s (owned by pid %d) from pid %d",
|
RDEBUG(3, "got an ioctl on /dev/%s (owned by pid %d) from pid %d",
|
||||||
@ -1527,7 +1543,8 @@ STATIC int fusd_client_ioctl(struct inode *inode, struct file *file,
|
|||||||
|
|
||||||
invalid_file:
|
invalid_file:
|
||||||
invalid_dev:
|
invalid_dev:
|
||||||
RDEBUG(3, "got a read on client file from pid %d, driver has disappeared",
|
zombie_dev:
|
||||||
|
RDEBUG(3, "got an ioctl on client file from pid %d, driver has disappeared",
|
||||||
current->pid);
|
current->pid);
|
||||||
return -EPIPE;
|
return -EPIPE;
|
||||||
}
|
}
|
||||||
@ -1576,6 +1593,10 @@ static int fusd_client_mmap(struct file *file, struct vm_area_struct * vma)
|
|||||||
struct fusd_mmap_instance* mmap_instance;
|
struct fusd_mmap_instance* mmap_instance;
|
||||||
|
|
||||||
GET_FUSD_FILE_AND_DEV(file->private_data, fusd_file, fusd_dev);
|
GET_FUSD_FILE_AND_DEV(file->private_data, fusd_file, fusd_dev);
|
||||||
|
|
||||||
|
if(ZOMBIE(fusd_dev))
|
||||||
|
goto zombie_dev;
|
||||||
|
|
||||||
LOCK_FUSD_FILE(fusd_file);
|
LOCK_FUSD_FILE(fusd_file);
|
||||||
|
|
||||||
RDEBUG(3, "got a mmap on /dev/%s (owned by pid %d) from pid %d",
|
RDEBUG(3, "got a mmap on /dev/%s (owned by pid %d) from pid %d",
|
||||||
@ -1626,6 +1647,7 @@ static int fusd_client_mmap(struct file *file, struct vm_area_struct * vma)
|
|||||||
|
|
||||||
invalid_file:
|
invalid_file:
|
||||||
invalid_dev:
|
invalid_dev:
|
||||||
|
zombie_dev:
|
||||||
RDEBUG(3, "got a mmap on client file from pid %d, driver has disappeared",
|
RDEBUG(3, "got a mmap on client file from pid %d, driver has disappeared",
|
||||||
current->pid);
|
current->pid);
|
||||||
return -EPIPE;
|
return -EPIPE;
|
||||||
@ -2654,7 +2676,7 @@ STATIC void fusd_status_build_text(fusd_statcontext_t *fs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
len += snprintf(buf + len, buf_size - len,
|
len += snprintf(buf + len, buf_size - len,
|
||||||
"\nFUSD $Revision: 1.97-kor-hacked-11 $ - %d devices used by %d clients\n",
|
"\nFUSD $Revision$ - %d devices used by %d clients\n",
|
||||||
total_files, total_clients);
|
total_files, total_clients);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
@ -2803,7 +2825,7 @@ STATIC int init_fusd(void)
|
|||||||
|
|
||||||
|
|
||||||
printk(KERN_INFO
|
printk(KERN_INFO
|
||||||
"fusd: starting, $Revision: 1.97-kor-hacked-11 $, $Date: 2003/07/11 22:29:39 $");
|
"fusd: starting, $Revision$, $Date$");
|
||||||
#ifdef CVSTAG
|
#ifdef CVSTAG
|
||||||
printk(", release %s", CVSTAG);
|
printk(", release %s", CVSTAG);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user