lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070207072259.GA22083@lst.de>
Date:	Wed, 7 Feb 2007 08:22:59 +0100
From:	Christoph Hellwig <hch@....de>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Christoph Hellwig <hch@....de>, jack@...e.cz,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] remove sb->s_files and file_list_lock usage in dquot.c

On Tue, Feb 06, 2007 at 03:50:01PM -0800, Andrew Morton wrote:
> On Tue, 6 Feb 2007 14:23:33 +0100
> Christoph Hellwig <hch@....de> 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?

I don't think so.  Then again it's only called when you call quotaon on
a mounted filesystem, and normally you don't have that many inodes
instanciated at that time.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ