All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zach Brown <zab@redhat.com>
To: Stefan Behrens <sbehrens@giantdisaster.de>
Cc: Anand Jain <Anand.Jain@oracle.com>,
	linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [bug] label cli hangs until balance is completed
Date: Wed, 17 Jul 2013 10:49:00 -0700	[thread overview]
Message-ID: <20130717174900.GD13965@lenny.home.zabbo.net> (raw)
In-Reply-To: <51E65F5A.6050501@giantdisaster.de>

On Wed, Jul 17, 2013 at 11:09:46AM +0200, Stefan Behrens wrote:
> On Wed, 17 Jul 2013 16:29:05 +0800, Anand Jain wrote:
> >  'btrfs fi label /btrfs' will hang until balance is completed.
> >  (and probably even set label would hang). This is because we
> >  are trying to hold volume_mutex lock which balance will hold
> >  during its tenure.
> > 
> > -------
> > static int btrfs_ioctl_get_fslabel(struct file *file, void __user *arg)
> > ::
> >         mutex_lock(&root->fs_info->volume_mutex);
> >         ret = copy_to_user(arg, label, len);
> >         mutex_unlock(&root->fs_info->volume_mutex);
> > --------
> > 
> >  I doubt if get label would need such a heavy weight lock?
> >  Do we have any other lock which could fit better here ?
> >  Any comments ?
> 
> Just use the uuid_mutex instead of the volume_mutex.

I wouldn't copy_to_user() with the lock held.  That nests all of readpage
and mkwrite under the mutex creating more possibilities for deadlocks.

Whatever lock is chosen, I'd have get copy the label onto the kernel
stack before sending it to user space.

- z

  reply	other threads:[~2013-07-17 17:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17  8:29 [bug] label cli hangs until balance is completed Anand Jain
2013-07-17  9:09 ` Stefan Behrens
2013-07-17 17:49   ` Zach Brown [this message]
2013-07-18 11:18 ` [PATCH] btrfs: fix get set label blocking against balance Anand Jain
2013-07-18 12:47   ` Stefan Behrens
2013-07-19  9:31     ` Anand Jain
2013-07-19  9:39   ` [PATCH v2] " Anand Jain

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=20130717174900.GD13965@lenny.home.zabbo.net \
    --to=zab@redhat.com \
    --cc=Anand.Jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sbehrens@giantdisaster.de \
    /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.