From: Frederic Weisbecker <fweisbec@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: reiserfs-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Al Viro <viro@ZenIV.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] reiserfs: Fix locking in reiserfs_quota_on()
Date: Thu, 28 Oct 2010 03:36:07 +0200 [thread overview]
Message-ID: <20101028013604.GB6233@nowhere> (raw)
In-Reply-To: <1288225703-8170-1-git-send-email-jack@suse.cz>
On Thu, Oct 28, 2010 at 02:28:23AM +0200, Jan Kara wrote:
> reiserfs_quota_on() unpacks a tail of quota file in case it has one. But after
> BKL conversion, reiserfs_unpack() expects to be called with write_lock held.
> So acquire the lock before calling reiserfs_unpack() to avoid assertion
> failures.
>
> Reported-by: markus.gapp@gmx.net
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/reiserfs/super.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> Frederic, would you merge this patch or should I merge it?
>
> diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
> index 6e85cfd..73c000f 100644
> --- a/fs/reiserfs/super.c
> +++ b/fs/reiserfs/super.c
> @@ -2059,7 +2059,9 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
> inode = path->dentry->d_inode;
> /* We must not pack tails for quota files on reiserfs for quota IO to work */
> if (!(REISERFS_I(inode)->i_flags & i_nopack_mask)) {
> + reiserfs_write_lock(sb);
> err = reiserfs_unpack(inode, NULL);
> + reiserfs_write_unlock(sb);
> if (err) {
> reiserfs_warning(sb, "super-6520",
> "Unpacking tail of quota file failed"
> --
> 1.7.1
>
Yeah. This is due to a recent fix in reiserfs_unpack().
And in this fix I assumed reiserfs_unpack() was always called under the
reiserfs lock.
I was wrong, I thought that reiserfs_quota_on() was ok because it can
call joural_begin() which appears to have the same requirements.
But no that's probably another bug, journal_begin() should also
be called under the reiserfs lock.
Anyway that must be another patch.
For this specific problem, it might be slightly more proper to do the
below. It lowers a bit the reiserfs lock coverage and also fixes
a weird lock-unlock ordering in reiserfs_unpack() that was doing:
Lock A - Lock B - Unlock A - Unlock B
Hmm?
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
index 5cbb81e..af2a58f 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
@@ -189,8 +189,8 @@ int reiserfs_unpack(struct inode *inode, struct file *filp)
/* we need to make sure nobody is changing the file size beneath
** us
*/
- reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb);
depth = reiserfs_write_lock_once(inode->i_sb);
+ reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb);
write_from = inode->i_size & (blocksize - 1);
/* if we are on a block boundary, we are already unpacked. */
next prev parent reply other threads:[~2010-10-28 1:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-28 0:28 [PATCH] reiserfs: Fix locking in reiserfs_quota_on() Jan Kara
2010-10-28 0:47 ` Al Viro
2010-10-28 1:36 ` Frederic Weisbecker [this message]
2010-11-09 15:37 ` Jan Kara
2010-11-09 15:40 ` Frederic Weisbecker
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=20101028013604.GB6233@nowhere \
--to=fweisbec@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=reiserfs-devel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.