From: Jan Kara <jack@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@lst.de>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] remove sb->s_files and file_list_lock usage in dquot.c
Date: Wed, 7 Feb 2007 09:35:57 +0100 [thread overview]
Message-ID: <20070207083557.GA5192@duck.suse.cz> (raw)
In-Reply-To: <20070206155001.22ab74f6.akpm@linux-foundation.org>
On Tue 06-02-07 15:50:01, Andrew Morton wrote:
> On Tue, 6 Feb 2007 14:23:33 +0100
> Christoph Hellwig <hch@lst.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?
Huh, I guess you meant O(n^2)... Yes, I know about this but as Christoph
pointed out, the loop runs only when quotaon is called on a filesystem and for
inodes somebody writes to. Usually, there are not so many such inodes. So
I'm not sure it's worth the trouble to fix this.
Honza
--
Jan Kara <jack@suse.cz>
SuSE CR Labs
next prev parent reply other threads:[~2007-02-07 8:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-06 13:23 [PATCH] remove sb->s_files and file_list_lock usage in dquot.c Christoph Hellwig
2007-02-06 13:46 ` Jan Kara
2007-02-06 23:50 ` Andrew Morton
2007-02-07 7:22 ` Christoph Hellwig
2007-02-07 18:03 ` Jan Engelhardt
2007-02-07 19:06 ` Christoph Hellwig
2007-02-08 12:22 ` Jan Engelhardt
2007-02-07 8:35 ` Jan Kara [this message]
2007-02-08 9:01 ` Bill Huey
2007-02-09 7:14 ` Bill Huey
2007-02-09 7:23 ` Bill Huey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070207083557.GA5192@duck.suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).