mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	get rid of timer in kern/acct.c
... and clean it up a bit, while we are at it Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
		
							parent
							
								
									84b92d39f9
								
							
						
					
					
						commit
						32dc730860
					
				
					 1 changed files with 10 additions and 30 deletions
				
			
		| 
						 | 
					@ -84,26 +84,16 @@ static void do_acct_process(struct bsd_acct_struct *acct,
 | 
				
			||||||
 * the cache line to have the data after getting the lock.
 | 
					 * the cache line to have the data after getting the lock.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct bsd_acct_struct {
 | 
					struct bsd_acct_struct {
 | 
				
			||||||
	volatile int		active;
 | 
						int			active;
 | 
				
			||||||
	volatile int		needcheck;
 | 
						unsigned long		needcheck;
 | 
				
			||||||
	struct file		*file;
 | 
						struct file		*file;
 | 
				
			||||||
	struct pid_namespace	*ns;
 | 
						struct pid_namespace	*ns;
 | 
				
			||||||
	struct timer_list	timer;
 | 
					 | 
				
			||||||
	struct list_head	list;
 | 
						struct list_head	list;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static DEFINE_SPINLOCK(acct_lock);
 | 
					static DEFINE_SPINLOCK(acct_lock);
 | 
				
			||||||
static LIST_HEAD(acct_list);
 | 
					static LIST_HEAD(acct_list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * Called whenever the timer says to check the free space.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
static void acct_timeout(unsigned long x)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct bsd_acct_struct *acct = (struct bsd_acct_struct *)x;
 | 
					 | 
				
			||||||
	acct->needcheck = 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Check the amount of free space and suspend/resume accordingly.
 | 
					 * Check the amount of free space and suspend/resume accordingly.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					@ -112,12 +102,12 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file)
 | 
				
			||||||
	struct kstatfs sbuf;
 | 
						struct kstatfs sbuf;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
	int act;
 | 
						int act;
 | 
				
			||||||
	sector_t resume;
 | 
						u64 resume;
 | 
				
			||||||
	sector_t suspend;
 | 
						u64 suspend;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spin_lock(&acct_lock);
 | 
						spin_lock(&acct_lock);
 | 
				
			||||||
	res = acct->active;
 | 
						res = acct->active;
 | 
				
			||||||
	if (!file || !acct->needcheck)
 | 
						if (!file || time_is_before_jiffies(acct->needcheck))
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
	spin_unlock(&acct_lock);
 | 
						spin_unlock(&acct_lock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -127,8 +117,8 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file)
 | 
				
			||||||
	suspend = sbuf.f_blocks * SUSPEND;
 | 
						suspend = sbuf.f_blocks * SUSPEND;
 | 
				
			||||||
	resume = sbuf.f_blocks * RESUME;
 | 
						resume = sbuf.f_blocks * RESUME;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sector_div(suspend, 100);
 | 
						do_div(suspend, 100);
 | 
				
			||||||
	sector_div(resume, 100);
 | 
						do_div(resume, 100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (sbuf.f_bavail <= suspend)
 | 
						if (sbuf.f_bavail <= suspend)
 | 
				
			||||||
		act = -1;
 | 
							act = -1;
 | 
				
			||||||
| 
						 | 
					@ -160,10 +150,7 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	del_timer(&acct->timer);
 | 
						acct->needcheck = jiffies + ACCT_TIMEOUT*HZ;
 | 
				
			||||||
	acct->needcheck = 0;
 | 
					 | 
				
			||||||
	acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ;
 | 
					 | 
				
			||||||
	add_timer(&acct->timer);
 | 
					 | 
				
			||||||
	res = acct->active;
 | 
						res = acct->active;
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
	spin_unlock(&acct_lock);
 | 
						spin_unlock(&acct_lock);
 | 
				
			||||||
| 
						 | 
					@ -185,9 +172,7 @@ static void acct_file_reopen(struct bsd_acct_struct *acct, struct file *file,
 | 
				
			||||||
	if (acct->file) {
 | 
						if (acct->file) {
 | 
				
			||||||
		old_acct = acct->file;
 | 
							old_acct = acct->file;
 | 
				
			||||||
		old_ns = acct->ns;
 | 
							old_ns = acct->ns;
 | 
				
			||||||
		del_timer(&acct->timer);
 | 
					 | 
				
			||||||
		acct->active = 0;
 | 
							acct->active = 0;
 | 
				
			||||||
		acct->needcheck = 0;
 | 
					 | 
				
			||||||
		acct->file = NULL;
 | 
							acct->file = NULL;
 | 
				
			||||||
		acct->ns = NULL;
 | 
							acct->ns = NULL;
 | 
				
			||||||
		list_del(&acct->list);
 | 
							list_del(&acct->list);
 | 
				
			||||||
| 
						 | 
					@ -195,13 +180,9 @@ static void acct_file_reopen(struct bsd_acct_struct *acct, struct file *file,
 | 
				
			||||||
	if (file) {
 | 
						if (file) {
 | 
				
			||||||
		acct->file = file;
 | 
							acct->file = file;
 | 
				
			||||||
		acct->ns = ns;
 | 
							acct->ns = ns;
 | 
				
			||||||
		acct->needcheck = 0;
 | 
							acct->needcheck = jiffies + ACCT_TIMEOUT*HZ;
 | 
				
			||||||
		acct->active = 1;
 | 
							acct->active = 1;
 | 
				
			||||||
		list_add(&acct->list, &acct_list);
 | 
							list_add(&acct->list, &acct_list);
 | 
				
			||||||
		/* It's been deleted if it was used before so this is safe */
 | 
					 | 
				
			||||||
		setup_timer(&acct->timer, acct_timeout, (unsigned long)acct);
 | 
					 | 
				
			||||||
		acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ;
 | 
					 | 
				
			||||||
		add_timer(&acct->timer);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (old_acct) {
 | 
						if (old_acct) {
 | 
				
			||||||
		mnt_unpin(old_acct->f_path.mnt);
 | 
							mnt_unpin(old_acct->f_path.mnt);
 | 
				
			||||||
| 
						 | 
					@ -348,7 +329,6 @@ void acct_exit_ns(struct pid_namespace *ns)
 | 
				
			||||||
	if (acct == NULL)
 | 
						if (acct == NULL)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	del_timer_sync(&acct->timer);
 | 
					 | 
				
			||||||
	spin_lock(&acct_lock);
 | 
						spin_lock(&acct_lock);
 | 
				
			||||||
	if (acct->file != NULL)
 | 
						if (acct->file != NULL)
 | 
				
			||||||
		acct_file_reopen(acct, NULL, NULL);
 | 
							acct_file_reopen(acct, NULL, NULL);
 | 
				
			||||||
| 
						 | 
					@ -498,7 +478,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
 | 
				
			||||||
	 * Fill the accounting struct with the needed info as recorded
 | 
						 * Fill the accounting struct with the needed info as recorded
 | 
				
			||||||
	 * by the different kernel functions.
 | 
						 * by the different kernel functions.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	memset((caddr_t)&ac, 0, sizeof(acct_t));
 | 
						memset(&ac, 0, sizeof(acct_t));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ac.ac_version = ACCT_VERSION | ACCT_BYTEORDER;
 | 
						ac.ac_version = ACCT_VERSION | ACCT_BYTEORDER;
 | 
				
			||||||
	strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm));
 | 
						strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue