From: "Stephen C. Tweedie" <sct@redhat.com>
To: Jan Kara <jack@suse.cz>
Cc: "Marcelo W. Tosatti" <marcelo@conectiva.com.br>,
linux-kernel <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@digeo.com>, Stephen Tweedie <sct@redhat.com>
Subject: Re: Deadlock fix for 2.4.20
Date: 18 Apr 2003 16:50:44 +0100 [thread overview]
Message-ID: <1050681044.3203.87.camel@sisko.scot.redhat.com> (raw)
In-Reply-To: <20030415151240.GA23547@atrey.karlin.mff.cuni.cz>
Hi,
On Tue, 2003-04-15 at 16:12, Jan Kara wrote:
> I'm sending you a patch which fixes the deadlock when quota is used on
> ext3. The problem is that in sync_dquots() first dqio_sem is acquired
> and then transaction is started while in the other paths the order is
> inverse... The patch introduces needed framework into quota to allow
> ext3 start transaction before the semaphore is acquired. Please apply.
Please don't, there is at least one major and one minor problem to be
resolved.
> +#define EXT3_OLD_QFMT_BLOCKS 2
> +
> +static int ext3_sync_dquot(struct dquot *dquot)
> +{
> + int ret;
> + handle_t *handle;
> + struct inode *qinode;
> +
> + lock_kernel();
> + qinode = dquot->dq_sb->s_dquot.files[dquot->dq_type]->f_dentry->d_inode;
> + handle = ext3_journal_start(qinode, EXT3_OLD_QFMT_BLOCKS);
> + if (IS_ERR(handle)) {
> + unlock_kernel();
> + return PTR_ERR(handle);
> + }
> + unlock_kernel();
> + ret = old_sync_dquot(dquot);
> + lock_kernel();
> + ret = ext3_journal_stop(handle, qinode);
> + unlock_kernel();
> + return ret;
> +}
> +#endif
First of all, EXT3_OLD_QFMT_BLOCKS is wrong. If you "chown" a file to a
new user, you'll potentially allocate new space for a new quota file
entry. That requires a ton of preallocation. At the minimum, you have
the inode update; the superblock update for the free block counts; the
group descriptor update, likewise; the bitmap update; possibly one or
more indirect block updates; and (finally) the quota block itself.
You _will_ get buffer-credit assert failures with this value.
Secondly, you're now effectively calling generic_file_write with a
transaction already open. That's _another_ lock ranking violation.
generic_file_write() takes i_sem, and then opens a transaction. With
this new quota code, you can now open a transaction and then take
i_sem. Boom.
However, most users don't ever take i_sem on the quota inode in any
other way. Directly writing to, or truncating, the quota file is a
highly non-recommended activity. :-)
btw, I'm away all next week, so further responses will be slow...
Cheers,
Stephen
prev parent reply other threads:[~2003-04-18 15:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-15 15:12 Jan Kara
2003-04-18 15:50 ` Stephen C. Tweedie [this message]
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=1050681044.3203.87.camel@sisko.scot.redhat.com \
--to=sct@redhat.com \
--cc=akpm@digeo.com \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
/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
all inboxes | Powered by JetHome®