All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: chris.mason@oracle.com
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: locking problems: Btrfs: be more selective in the defrag ioctl
Date: Sat, 20 Mar 2010 14:38:51 +0300	[thread overview]
Message-ID: <20100320113851.GB5331@bicker> (raw)

Hi Chris,

There is a locking problem in 
	940100a4a7b78 "Btrfs: be more selective in the defrag ioctl"

There are two places where we break out of the while loop under the 
lock.

fs/btrfs/ioctl.c +708 btrfs_defrag_file(159) error: double lock 'mutex:&inode->i_mutex'
   600                  mutex_lock(&inode->i_mutex);
   601                  if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)
   602                          BTRFS_I(inode)->force_compress = 1;
   603  
   604                  ret = btrfs_check_data_free_space(root, inode, PAGE_CACHE_SIZE);
   605                  if (ret) {
   606                          ret = -ENOSPC;
   607                          break;

	Here.

   608                  }
   609  
   610                  ret = btrfs_reserve_metadata_for_delalloc(root, inode, 1);
   611                  if (ret) {
   612                          btrfs_free_reserved_data_space(root, inode,
   613                                                         PAGE_CACHE_SIZE);
   614                          ret = -ENOSPC;
   615                          break;

	And here.

   616                  }

Maybe we should have "goto err_reservations;" instead of break?  I
don't know the code well enough to say.

regards,
dan carpenter

             reply	other threads:[~2010-03-20 11:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-20 11:38 Dan Carpenter [this message]
2010-03-22 13:47 ` locking problems: Btrfs: be more selective in the defrag ioctl Josef Bacik
2010-03-22 14:03   ` Dan Carpenter
2010-03-22 14:09     ` Josef Bacik

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=20100320113851.GB5331@bicker \
    --to=error27@gmail.com \
    --cc=chris.mason@oracle.com \
    --cc=linux-btrfs@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 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.