Re: [PATCH] remove sb->s_files and file_list_lock usage in dquot.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 6 Feb 2007 14:23:33 +0100
Christoph Hellwig <[email protected]> wrote:

>  static void add_dquot_ref(struct super_block *sb, int type)
>  {
> -	struct list_head *p;
> +	struct inode *inode;
>  
>  restart:
> -	file_list_lock();
> -	list_for_each(p, &sb->s_files) {
> -		struct file *filp = list_entry(p, struct file, f_u.fu_list);
> -		struct inode *inode = filp->f_path.dentry->d_inode;
> -		if (filp->f_mode & FMODE_WRITE && dqinit_needed(inode, type)) {
> -			struct dentry *dentry = dget(filp->f_path.dentry);
> -			file_list_unlock();
> -			sb->dq_op->initialize(inode, type);
> -			dput(dentry);
> -			/* As we may have blocked we had better restart... */
> -			goto restart;
> -		}
> +	spin_lock(&inode_lock);
> +	list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
> +		if (!atomic_read(&inode->i_writecount))
> +			continue;
> +		if (!dqinit_needed(inode, type))
> +			continue;
> +		if (inode->i_state & (I_FREEING|I_WILL_FREE))
> +			continue;
> +
> +		__iget(inode);
> +		spin_unlock(&inode_lock);
> +
> +		sb->dq_op->initialize(inode, type);
> +		iput(inode);
> +		/* As we may have blocked we had better restart... */
> +		goto restart;
>  	}
> -	file_list_unlock();
> +	spin_unlock(&inode_lock);
>  }

That loop has (and had) up to O(n^n) operations.  Is there something which
prevents this from going insane?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux