From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [PATCH] remove sb->s_files and file_list_lock usage in dquot.c Date: Tue, 6 Feb 2007 15:50:01 -0800 Message-ID: <20070206155001.22ab74f6.akpm@linux-foundation.org> References: <20070206132333.GA9919@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Christoph Hellwig Return-path: Received: from smtp.osdl.org ([65.172.181.24]:55657 "EHLO smtp.osdl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965592AbXBFXuM (ORCPT ); Tue, 6 Feb 2007 18:50:12 -0500 In-Reply-To: <20070206132333.GA9919@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Tue, 6 Feb 2007 14:23:33 +0100 Christoph Hellwig 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?