From: Jan Kara <jack@suse.cz>
To: Jeff Mahoney <jeffm@suse.com>
Cc: Linux FS Maling List <linux-fsdevel@vger.kernel.org>,
Jan Kara <jack@suse.cz>,
reiserfs-devel <reiserfs-devel@vger.kernel.org>
Subject: Re: [PATCH] reiserfs: fix deadlocks with quotas
Date: Tue, 14 Aug 2012 19:20:32 +0200 [thread overview]
Message-ID: <20120814172032.GL7122@quack.suse.cz> (raw)
In-Reply-To: <501B2B04.2050706@suse.com>
On Thu 02-08-12 21:36:04, Jeff Mahoney wrote:
> The BKL push-down for reiserfs made lock recursion a special case that needs
> to be handled explicitly. One of the cases that was unhandled is dropping
> the quota during inode eviction. Both reiserfs_evict_inode and
> reiserfs_write_dquot take the write lock, but when the journal lock is
> taken it only drops one the references. The locking rules are that the journal
> lock be acquired before the write lock so leaving the reference open leads
> to a ABBA deadlock.
>
> This patch pushes the unlock up before clear_inode and avoids the recursive
> locking.
>
> Another ABBA situation can occur when the write lock is dropped while reading
> the bitmap buffer while in the quota code. When the lock is reacquired, it
> will deadlock against dquot->dq_lock and dqopt->dqio_mutex in the dquot_acquire
> path. It's safe to retain the lock across the read and should be cached under
> write load.
>
> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Yeah, the patch looks good. Since we don't have reiserfs maintainer, I
guess I'll push this through my tree.
Honza
> ---
> fs/reiserfs/bitmap.c | 2 --
> fs/reiserfs/inode.c | 2 +-
> 2 files changed, 1 insertion(+), 3 deletions(-)
>
> --- a/fs/reiserfs/bitmap.c
> +++ b/fs/reiserfs/bitmap.c
> @@ -1334,9 +1334,7 @@ struct buffer_head *reiserfs_read_bitmap
> else if (bitmap == 0)
> block = (REISERFS_DISK_OFFSET_IN_BYTES >> sb->s_blocksize_bits) + 1;
>
> - reiserfs_write_unlock(sb);
> bh = sb_bread(sb, block);
> - reiserfs_write_lock(sb);
> if (bh == NULL)
> reiserfs_warning(sb, "sh-2029: %s: bitmap block (#%u) "
> "reading failed", __func__, block);
> --- a/fs/reiserfs/inode.c
> +++ b/fs/reiserfs/inode.c
> @@ -76,10 +76,10 @@ void reiserfs_evict_inode(struct inode *
> ;
> }
> out:
> + reiserfs_write_unlock_once(inode->i_sb, depth);
> clear_inode(inode); /* note this must go after the journal_end to prevent deadlock */
> dquot_drop(inode);
> inode->i_blocks = 0;
> - reiserfs_write_unlock_once(inode->i_sb, depth);
> return;
>
> no_delete:
>
> --
> Jeff Mahoney
> SUSE Labs
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
prev parent reply other threads:[~2012-08-14 17:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-03 1:36 [PATCH] reiserfs: fix deadlocks with quotas Jeff Mahoney
2012-08-14 17:20 ` Jan Kara [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=20120814172032.GL7122@quack.suse.cz \
--to=jack@suse.cz \
--cc=jeffm@suse.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=reiserfs-devel@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).