[PATCH 7/7] nonblocking aio: btrfs

2017-02-13 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues 

Return EAGAIN if any of the following checks fail
 + i_rwsem is lockable
 + NODATACOW or PREALLOC is set
 + Can nocow at the desired location
 + Writing beyond end of file

Signed-off-by: Goldwyn Rodrigues 
---
 fs/btrfs/file.c  | 25 -
 fs/btrfs/inode.c |  3 +++
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 3a14c87..f4dcc7a 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1804,12 +1804,29 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
ssize_t num_written = 0;
bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host);
ssize_t err;
-   loff_t pos;
-   size_t count;
+   loff_t pos = iocb->ki_pos;
+   size_t count = iov_iter_count(from);
loff_t oldsize;
int clean_page = 0;
 
-   inode_lock(inode);
+   if ((iocb->ki_flags & IOCB_NONBLOCKING) &&
+   (iocb->ki_flags & IOCB_DIRECT)) {
+   /* Don't sleep on inode rwsem */
+   if (!inode_trylock(inode))
+   return -EAGAIN;
+   /*
+* We will allocate space in case nodatacow is not set,
+* so bail
+*/
+   if (!(BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW |
+ BTRFS_INODE_PREALLOC)) ||
+   check_can_nocow(inode, pos, ) <= 0) {
+   inode_unlock(inode);
+   return -EAGAIN;
+   }
+   } else
+   inode_lock(inode);
+
err = generic_write_checks(iocb, from);
if (err <= 0) {
inode_unlock(inode);
@@ -1843,8 +1860,6 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
 */
update_time_for_write(inode);
 
-   pos = iocb->ki_pos;
-   count = iov_iter_count(from);
start_pos = round_down(pos, root->sectorsize);
oldsize = i_size_read(inode);
if (start_pos > oldsize) {
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index be4da91..9911ebd 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8690,6 +8690,9 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct 
iov_iter *iter)
if (offset + count <= inode->i_size) {
inode_unlock(inode);
relock = true;
+   } else if (iocb->ki_flags & IOCB_NONBLOCKING) {
+   ret = -EAGAIN;
+   goto out;
}
ret = btrfs_delalloc_reserve_space(inode, offset, count);
if (ret)
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 11/29] btrfs: remove unused parameter from btrfs_check_super_valid

2017-02-13 Thread Liu Bo
On Mon, Feb 13, 2017 at 10:33:55AM +0100, David Sterba wrote:
> None of the checks need to know the RO/RW status.
>

OK...there was a readonly check, which lets us skip all checks,
it was removed by the below commit, should we add the check back?

commit 1104a8855109a4051d74977f819a13b4516aa11e
Author: David Sterba 
Date:   Wed Mar 6 15:57:46 2013 +0100

btrfs: enhance superblock checks

The superblock checksum is not verified upon mount. 

Add that check and also reorder existing checks to a more logical
order.

Current mkfs.btrfs does not calculate the correct checksum of
super_block and thus a freshly created filesytem will fail to mount when
this patch is applied.

First transaction commit calculates correct superblock checksum and
saves it to disk.

Reproducer:
$ mfks.btrfs /dev/sda
$ mount /dev/sda /mnt
$ btrfs scrub start /mnt
$ sleep 5
$ btrfs scrub status /mnt
... super:2 ...

Signed-off-by: David Sterba 
Signed-off-by: Josef Bacik 
Signed-off-by: Chris Mason 

Thanks,

-liubo

> Signed-off-by: David Sterba 
> ---
>  fs/btrfs/disk-io.c | 8 +++-
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 441a62cd0351..2b06f557c176 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -64,8 +64,7 @@
>  static const struct extent_io_ops btree_extent_io_ops;
>  static void end_workqueue_fn(struct btrfs_work *work);
>  static void free_fs_root(struct btrfs_root *root);
> -static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
> - int read_only);
> +static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info);
>  static void btrfs_destroy_ordered_extents(struct btrfs_root *root);
>  static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
> struct btrfs_fs_info *fs_info);
> @@ -2801,7 +2800,7 @@ int open_ctree(struct super_block *sb,
>  
>   memcpy(fs_info->fsid, fs_info->super_copy->fsid, BTRFS_FSID_SIZE);
>  
> - ret = btrfs_check_super_valid(fs_info, sb->s_flags & MS_RDONLY);
> + ret = btrfs_check_super_valid(fs_info);
>   if (ret) {
>   btrfs_err(fs_info, "superblock contains fatal errors");
>   err = -EINVAL;
> @@ -4115,8 +4114,7 @@ int btrfs_read_buffer(struct extent_buffer *buf, u64 
> parent_transid)
>   return btree_read_extent_buffer_pages(fs_info, buf, parent_transid);
>  }
>  
> -static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
> -   int read_only)
> +static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info)
>  {
>   struct btrfs_super_block *sb = fs_info->super_copy;
>   u64 nodesize = btrfs_super_nodesize(sb);
> -- 
> 2.10.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 05/29] btrfs: remove unused parameter from write_dev_supers

2017-02-13 Thread Liu Bo
On Mon, Feb 13, 2017 at 10:33:36AM +0100, David Sterba wrote:
> The barriers are handled by the caller.
>

Reviewed-by: Liu Bo 

Thanks,

-liubo
> Signed-off-by: David Sterba 
> ---
>  fs/btrfs/disk-io.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 48846d215e97..43e71457c193 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3410,7 +3410,7 @@ struct buffer_head *btrfs_read_dev_super(struct 
> block_device *bdev)
>   */
>  static int write_dev_supers(struct btrfs_device *device,
>   struct btrfs_super_block *sb,
> - int do_barriers, int wait, int max_mirrors)
> + int wait, int max_mirrors)
>  {
>   struct buffer_head *bh;
>   int i;
> @@ -3752,7 +3752,7 @@ static int write_all_supers(struct btrfs_fs_info 
> *fs_info, int max_mirrors)
>   flags = btrfs_super_flags(sb);
>   btrfs_set_super_flags(sb, flags | BTRFS_HEADER_FLAG_WRITTEN);
>  
> - ret = write_dev_supers(dev, sb, do_barriers, 0, max_mirrors);
> + ret = write_dev_supers(dev, sb, 0, max_mirrors);
>   if (ret)
>   total_errors++;
>   }
> @@ -3775,7 +3775,7 @@ static int write_all_supers(struct btrfs_fs_info 
> *fs_info, int max_mirrors)
>   if (!dev->in_fs_metadata || !dev->writeable)
>   continue;
>  
> - ret = write_dev_supers(dev, sb, do_barriers, 1, max_mirrors);
> + ret = write_dev_supers(dev, sb, 1, max_mirrors);
>   if (ret)
>   total_errors++;
>   }
> -- 
> 2.10.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Is it possible to have metadata-only device with no data?

2017-02-13 Thread Alexander Tomokhov
Yeah, thank you for suggestion. Bcache is what I actually use right now. 
However it's concept is different, operating at block/bucket level and requires 
another (underlying!) layer.

06.02.2017, 01:27, "Kai Krakow" :
> Am Mon, 06 Feb 2017 00:42:01 +0300
> schrieb Alexander Tomokhov :
>
>>  Is it possible, having two drives to do raid1 for metadata but keep
>>  data on a single drive only? --
>
> No, but you could take a look into bcache which should get you
> something similar if used in write-around mode.
>
> Random access will become cached in bcache, which should most of the
> time be metadata, plus of course randomly accessed data from HDD. If
> you reduce the sequential cutoff trigger in bcache, it should cache
> mostly metadata only.
>
> --
> Regards,
> Kai
>
> Replies to list-only preferred.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Is it possible to have metadata-only device with no data?

2017-02-13 Thread Alexander Tomokhov
Thank you. Interesting.
At least it's possible to implement in theory.
Though, this way metadata-only device is still handled like a casual btrfs 
device and not distinguished separately from normal data+metadata devices.

06.02.2017, 02:54, "Roman Mamedov" :
> On Sun, 5 Feb 2017 22:55:42 +0100
> Hans van Kranenburg  wrote:
>
>>  On 02/05/2017 10:42 PM, Alexander Tomokhov wrote:
>>  > Is it possible, having two drives to do raid1 for metadata but keep data 
>> on a single drive only?
>>
>>  Nope.
>>
>>  Would be a really nice feature though... Putting metadata on SSD and
>>  bulk data on HDD...
>
> You can play around with this hack just to see how that would perform, but it
> comes with no warranty and untested even by me. I was going to try it, but put
> it on hold since you'd also need to make sure the SSD is being preferred for
> metadata reads (and not HDD), but so far have not figured out a simple way of
> ensuring that.
>
> --- linux-amd64-4.4/fs/btrfs/volumes.c.orig 2016-11-01 22:41:41.970978721 
> +0500
> +++ linux-amd64-4.4/fs/btrfs/volumes.c 2016-11-01 22:58:45.958977731 +0500
> @@ -4597,6 +4597,14 @@
>  if (total_avail == 0)
>  continue;
>
> + /* If we have two devices and one is less than 25% of the total FS size, 
> then
> + * presumably it's a small device just for metadata RAID1, don't use it
> + * for new data chunks. */
> + if ((fs_devices->num_devices == 2) &&
> + (device->total_bytes * 4 < fs_devices->total_rw_bytes) &&
> + (type & BTRFS_BLOCK_GROUP_DATA))
> + continue;
> +
>  ret = find_free_dev_extent(trans, device,
> max_stripe_size * dev_stripes,
> _offset, _avail);
>
> --
> With respect,
> Roman
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/29] btrfs: remove unused parameter from read_block_for_search

2017-02-13 Thread Liu Bo
On Tue, Feb 14, 2017 at 09:03:49AM +0800, Qu Wenruo wrote:
> 
> 
> At 02/14/2017 08:59 AM, Liu Bo wrote:
> > On Mon, Feb 13, 2017 at 10:33:24AM +0100, David Sterba wrote:
> > > Never used in that function.
> > 
> > There is already one,
> > https://patchwork.kernel.org/patch/9546079/
> 
> Hi Liu,
> 
> That patch seems to remove @trans, while this is to remove @time_seq.
> Or did I missed something?

Heh, my bad, thanks for spotting this.

Thanks,

-liubo
> 
> Thanks,
> Qu
> > 
> > Thanks,
> > 
> > -liubo
> > > 
> > > Signed-off-by: David Sterba 
> > > ---
> > >  fs/btrfs/ctree.c | 10 +-
> > >  1 file changed, 5 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> > > index fbeff20eb194..35e22349c139 100644
> > > --- a/fs/btrfs/ctree.c
> > > +++ b/fs/btrfs/ctree.c
> > > @@ -2440,7 +2440,7 @@ noinline void btrfs_unlock_up_safe(struct 
> > > btrfs_path *path, int level)
> > >  static int
> > >  read_block_for_search(struct btrfs_root *root, struct btrfs_path *p,
> > > struct extent_buffer **eb_ret, int level, int slot,
> > > -   const struct btrfs_key *key, u64 time_seq)
> > > +   const struct btrfs_key *key)
> > >  {
> > >   struct btrfs_fs_info *fs_info = root->fs_info;
> > >   u64 blocknr;
> > > @@ -2871,7 +2871,7 @@ int btrfs_search_slot(struct btrfs_trans_handle 
> > > *trans, struct btrfs_root *root,
> > >   }
> > > 
> > >   err = read_block_for_search(root, p, , level,
> > > - slot, key, 0);
> > > + slot, key);
> > >   if (err == -EAGAIN)
> > >   goto again;
> > >   if (err) {
> > > @@ -3015,7 +3015,7 @@ int btrfs_search_old_slot(struct btrfs_root *root, 
> > > const struct btrfs_key *key,
> > >   }
> > > 
> > >   err = read_block_for_search(root, p, , level,
> > > - slot, key, time_seq);
> > > + slot, key);
> > >   if (err == -EAGAIN)
> > >   goto again;
> > >   if (err) {
> > > @@ -5786,7 +5786,7 @@ int btrfs_next_old_leaf(struct btrfs_root *root, 
> > > struct btrfs_path *path,
> > >   next = c;
> > >   next_rw_lock = path->locks[level];
> > >   ret = read_block_for_search(root, path, , level,
> > > - slot, , 0);
> > > + slot, );
> > >   if (ret == -EAGAIN)
> > >   goto again;
> > > 
> > > @@ -5836,7 +5836,7 @@ int btrfs_next_old_leaf(struct btrfs_root *root, 
> > > struct btrfs_path *path,
> > >   break;
> > > 
> > >   ret = read_block_for_search(root, path, , level,
> > > - 0, , 0);
> > > + 0, );
> > >   if (ret == -EAGAIN)
> > >   goto again;
> > > 
> > > --
> > > 2.10.1
> > > 
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> > > the body of a message to majord...@vger.kernel.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> > the body of a message to majord...@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> > 
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/29] btrfs: remove unused parameter from read_block_for_search

2017-02-13 Thread Qu Wenruo



At 02/14/2017 08:59 AM, Liu Bo wrote:

On Mon, Feb 13, 2017 at 10:33:24AM +0100, David Sterba wrote:

Never used in that function.


There is already one,
https://patchwork.kernel.org/patch/9546079/


Hi Liu,

That patch seems to remove @trans, while this is to remove @time_seq.
Or did I missed something?

Thanks,
Qu


Thanks,

-liubo


Signed-off-by: David Sterba 
---
 fs/btrfs/ctree.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index fbeff20eb194..35e22349c139 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2440,7 +2440,7 @@ noinline void btrfs_unlock_up_safe(struct btrfs_path 
*path, int level)
 static int
 read_block_for_search(struct btrfs_root *root, struct btrfs_path *p,
  struct extent_buffer **eb_ret, int level, int slot,
- const struct btrfs_key *key, u64 time_seq)
+ const struct btrfs_key *key)
 {
struct btrfs_fs_info *fs_info = root->fs_info;
u64 blocknr;
@@ -2871,7 +2871,7 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
}

err = read_block_for_search(root, p, , level,
-   slot, key, 0);
+   slot, key);
if (err == -EAGAIN)
goto again;
if (err) {
@@ -3015,7 +3015,7 @@ int btrfs_search_old_slot(struct btrfs_root *root, const 
struct btrfs_key *key,
}

err = read_block_for_search(root, p, , level,
-   slot, key, time_seq);
+   slot, key);
if (err == -EAGAIN)
goto again;
if (err) {
@@ -5786,7 +5786,7 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct 
btrfs_path *path,
next = c;
next_rw_lock = path->locks[level];
ret = read_block_for_search(root, path, , level,
-   slot, , 0);
+   slot, );
if (ret == -EAGAIN)
goto again;

@@ -5836,7 +5836,7 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct 
btrfs_path *path,
break;

ret = read_block_for_search(root, path, , level,
-   0, , 0);
+   0, );
if (ret == -EAGAIN)
goto again;

--
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html





--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/29] btrfs: remove unused parameter from read_block_for_search

2017-02-13 Thread Liu Bo
On Mon, Feb 13, 2017 at 10:33:24AM +0100, David Sterba wrote:
> Never used in that function.

There is already one,
https://patchwork.kernel.org/patch/9546079/

Thanks,

-liubo
> 
> Signed-off-by: David Sterba 
> ---
>  fs/btrfs/ctree.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index fbeff20eb194..35e22349c139 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -2440,7 +2440,7 @@ noinline void btrfs_unlock_up_safe(struct btrfs_path 
> *path, int level)
>  static int
>  read_block_for_search(struct btrfs_root *root, struct btrfs_path *p,
> struct extent_buffer **eb_ret, int level, int slot,
> -   const struct btrfs_key *key, u64 time_seq)
> +   const struct btrfs_key *key)
>  {
>   struct btrfs_fs_info *fs_info = root->fs_info;
>   u64 blocknr;
> @@ -2871,7 +2871,7 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, 
> struct btrfs_root *root,
>   }
>  
>   err = read_block_for_search(root, p, , level,
> - slot, key, 0);
> + slot, key);
>   if (err == -EAGAIN)
>   goto again;
>   if (err) {
> @@ -3015,7 +3015,7 @@ int btrfs_search_old_slot(struct btrfs_root *root, 
> const struct btrfs_key *key,
>   }
>  
>   err = read_block_for_search(root, p, , level,
> - slot, key, time_seq);
> + slot, key);
>   if (err == -EAGAIN)
>   goto again;
>   if (err) {
> @@ -5786,7 +5786,7 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct 
> btrfs_path *path,
>   next = c;
>   next_rw_lock = path->locks[level];
>   ret = read_block_for_search(root, path, , level,
> - slot, , 0);
> + slot, );
>   if (ret == -EAGAIN)
>   goto again;
>  
> @@ -5836,7 +5836,7 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct 
> btrfs_path *path,
>   break;
>  
>   ret = read_block_for_search(root, path, , level,
> - 0, , 0);
> + 0, );
>   if (ret == -EAGAIN)
>   goto again;
>  
> -- 
> 2.10.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] btrfs: relocation: Enhance kernel error output for relocation

2017-02-13 Thread Qu Wenruo
When balance(relocation) fails, btrfs-progs will report like:

ERROR: error during balancing '/mnt/scratch': Input/output error
There may be more info in syslog - try dmesg | tail

However kernel can't provide may useful info in many cases to locate the
problem.

This patch will add error messages in relocation to help user and
developer to locate the problem.

Signed-off-by: Qu Wenruo 
---
v2:
  Fix typo where 'err' and 'ret' are used wrong.
---
 fs/btrfs/relocation.c | 60 +++
 1 file changed, 56 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 379711048fb0..d26809807c1b 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4011,6 +4011,8 @@ static noinline_for_stack int relocate_block_group(struct 
reloc_control *rc)
rc->block_rsv, rc->block_rsv->size,
BTRFS_RESERVE_FLUSH_ALL);
if (ret) {
+   btrfs_err(fs_info, "failed to reserve space: %d(%s)",
+ ret, btrfs_decode_error(ret));
err = ret;
break;
}
@@ -4019,6 +4021,9 @@ static noinline_for_stack int relocate_block_group(struct 
reloc_control *rc)
if (IS_ERR(trans)) {
err = PTR_ERR(trans);
trans = NULL;
+   btrfs_err(fs_info,
+ "failed to start transaction: %d(%s)",
+ err, btrfs_decode_error(err));
break;
}
 restart:
@@ -4028,8 +4033,11 @@ static noinline_for_stack int 
relocate_block_group(struct reloc_control *rc)
}
 
ret = find_next_extent(rc, path, );
-   if (ret < 0)
+   if (ret < 0) {
+   btrfs_err(fs_info, "failed to find next extent: %d(%s)",
+ ret, btrfs_decode_error(ret));
err = ret;
+   }
if (ret != 0)
break;
 
@@ -4081,9 +4089,17 @@ static noinline_for_stack int 
relocate_block_group(struct reloc_control *rc)
 
if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
ret = add_tree_block(rc, , path, );
+   if (ret < 0)
+   btrfs_err(fs_info,
+ "failed to record tree block: %d(%s)",
+ ret, btrfs_decode_error(ret));
} else if (rc->stage == UPDATE_DATA_PTRS &&
   (flags & BTRFS_EXTENT_FLAG_DATA)) {
ret = add_data_references(rc, , path, );
+   if (ret < 0)
+   btrfs_err(fs_info,
+ "failed to record data extent: 
%d(%s)",
+ ret, btrfs_decode_error(ret));
} else {
btrfs_release_path(path);
ret = 0;
@@ -4103,6 +4119,9 @@ static noinline_for_stack int relocate_block_group(struct 
reloc_control *rc)
rc->backref_cache.last_trans = trans->transid - 
1;
 
if (ret != -EAGAIN) {
+   btrfs_err(fs_info,
+   "faild to relocate tree blocks: %d(%s)",
+ ret, btrfs_decode_error(ret));
err = ret;
break;
}
@@ -4121,6 +4140,9 @@ static noinline_for_stack int relocate_block_group(struct 
reloc_control *rc)
ret = relocate_data_extent(rc->data_inode,
   , >cluster);
if (ret < 0) {
+   btrfs_err(fs_info,
+   "failed to relocate data extent: %d(%s)",
+ ret, btrfs_decode_error(ret));
err = ret;
break;
}
@@ -4147,8 +4169,12 @@ static noinline_for_stack int 
relocate_block_group(struct reloc_control *rc)
if (!err) {
ret = relocate_file_extent_cluster(rc->data_inode,
   >cluster);
-   if (ret < 0)
+   if (ret < 0) {
+   btrfs_err(fs_info,
+   "failed to relocate file extent cluster: %d(%s)",
+ ret, btrfs_decode_error(ret));
err = ret;
+   }
}
 
rc->create_reloc_tree = 0;
@@ -4158,6 

Re: [PATCH] btrfs: relocation: Enhance kernel error output for relocation

2017-02-13 Thread Liu Bo
On Mon, Feb 13, 2017 at 03:26:27PM +0800, Qu Wenruo wrote:
> When balance(relocation) fails, btrfs-progs will report like:
> 
> ERROR: error during balancing '/mnt/scratch': Input/output error
> There may be more info in syslog - try dmesg | tail
> 
> However in some case, for example debugging btrfs/125 with small file
> size, kernel only have some recoverable csum error message and nothing
> useful at all.
> 
> This patch will add error messages in relocation to help both end user to
> wipe out some obvious problems, like ENOSPC.
> And for developers, they can locate the problem to specific function just
> by kernel message.
> 
> Signed-off-by: Qu Wenruo 
> ---
>  fs/btrfs/relocation.c | 60 
> +++
>  1 file changed, 56 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 379711048fb0..c9474377a59c 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -4011,6 +4011,8 @@ static noinline_for_stack int 
> relocate_block_group(struct reloc_control *rc)
>   rc->block_rsv, rc->block_rsv->size,
>   BTRFS_RESERVE_FLUSH_ALL);
>   if (ret) {
> + btrfs_err(fs_info, "failed to reserve space: %d(%s)",
> +   ret, btrfs_decode_error(ret));
>   err = ret;
>   break;
>   }
> @@ -4019,6 +4021,9 @@ static noinline_for_stack int 
> relocate_block_group(struct reloc_control *rc)
>   if (IS_ERR(trans)) {
>   err = PTR_ERR(trans);
>   trans = NULL;
> + btrfs_err(fs_info,
> +   "failed to start transaction: %d(%s)",
> +   err, btrfs_decode_error(err));
>   break;
>   }
>  restart:
> @@ -4028,8 +4033,11 @@ static noinline_for_stack int 
> relocate_block_group(struct reloc_control *rc)
>   }
>  
>   ret = find_next_extent(rc, path, );
> - if (ret < 0)
> + if (ret < 0) {
> + btrfs_err(fs_info, "failed to find next extent: %d(%s)",
> +   ret, btrfs_decode_error(ret));
>   err = ret;
> + }
>   if (ret != 0)
>   break;
>  
> @@ -4081,9 +4089,17 @@ static noinline_for_stack int 
> relocate_block_group(struct reloc_control *rc)
>  
>   if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
>   ret = add_tree_block(rc, , path, );
> + if (ret < 0)
> + btrfs_err(fs_info,
> +   "failed to record tree block: %d(%s)",
> +   ret, btrfs_decode_error(ret));
>   } else if (rc->stage == UPDATE_DATA_PTRS &&
>  (flags & BTRFS_EXTENT_FLAG_DATA)) {
>   ret = add_data_references(rc, , path, );
> + if (ret < 0)
> + btrfs_err(fs_info,
> +   "failed to record data extent: 
> %d(%s)",
> +   ret, btrfs_decode_error(ret));
>   } else {
>   btrfs_release_path(path);
>   ret = 0;
> @@ -4103,6 +4119,9 @@ static noinline_for_stack int 
> relocate_block_group(struct reloc_control *rc)
>   rc->backref_cache.last_trans = trans->transid - 
> 1;
>  
>   if (ret != -EAGAIN) {
> + btrfs_err(fs_info,
> + "faild to relocate tree blocks: %d(%s)",
> +   ret, btrfs_decode_error(ret));
>   err = ret;
>   break;
>   }
> @@ -4121,6 +4140,9 @@ static noinline_for_stack int 
> relocate_block_group(struct reloc_control *rc)
>   ret = relocate_data_extent(rc->data_inode,
>  , >cluster);
>   if (ret < 0) {
> + btrfs_err(fs_info,
> + "failed to relocate data extent: %d(%s)",
> +   ret, btrfs_decode_error(ret));
>   err = ret;
>   break;
>   }
> @@ -4147,8 +4169,12 @@ static noinline_for_stack int 
> relocate_block_group(struct reloc_control *rc)
>   if (!err) {
>   ret = relocate_file_extent_cluster(rc->data_inode,
>  >cluster);
> - if (ret < 0)
> + if (ret < 0) {
> +  

Re: FS gives kernel UPS on attempt to create snapshot and after running balance it's unmountable.

2017-02-13 Thread Qu Wenruo



At 02/14/2017 08:23 AM, Tomasz Kusmierz wrote:

Forgot to mention:

btrfs inspect-internal dump-super -af /dev/sdc


Your btrfs-progs is somewhat old, which doesn't integrate dump super 
into inspect-internal.


In that case, you can use btrfs-show-super -af instead.

Thanks,
Qu


btrfs inspect-internal: unknown token 'dump-super'
usage: btrfs inspect-internal  

btrfs inspect-internal inode-resolve [-v]  
Get file system paths for the given inode
btrfs inspect-internal logical-resolve [-Pv] [-s bufsize]  
Get file system paths for the given logical address
btrfs inspect-internal subvolid-resolve  
Get file system paths for the given subvolume ID.
btrfs inspect-internal rootid 
Get tree ID of the containing subvolume of path.
btrfs inspect-internal min-dev-size [options] 
Get the minimum size the device can be shrunk to. The

query various internal information

On 13 February 2017 at 14:58, Tomasz Kusmierz  wrote:

Problem is to send a larger log into this mailing list :/

Anyway: uname -a
Linux tevva-server 4.8.7-1.el7.elrepo.x86_64 #1 SMP Thu Nov 10
20:47:24 EST 2016 x86_64 x86_64 x86_64 GNU/Linux


cut from messages (bear in mind that this is a single cut with a bit
cut from inside of it to fit it in the email)

Feb 10 00:17:14 server journal: ==>
/var/log/gitlab/gitlab-shell/gitlab-shell.log <==
Feb 10 00:17:30 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:17:29 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:18:00 server kernel: BTRFS info (device sdc): found 22 extents
Feb 10 00:18:01 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:17:59 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:18:05 server kernel: BTRFS info (device sdc): found 22 extents
Feb 10 00:18:06 server kernel: BTRFS info (device sdc): relocating
block group 12353563131904 flags 65
Feb 10 00:18:06 server journal:
Feb 10 00:18:06 server journal: ==> /var/log/gitlab/sidekiq/current <==
Feb 10 00:18:06 server journal: 2017-02-10_00:18:06.99341
2017-02-10T00:18:06.993Z 382 TID-otrr6ws48 PruneOldEventsWorker
JID-99d3a4fb69be748c8674b5e1 INFO: start
Feb 10 00:18:06 server journal: 2017-02-10_00:18:06.99571
2017-02-10T00:18:06.995Z 382 TID-otrr6wqok INFO: Cron Jobs - add job
with name: prune_old_events_worker
Feb 10 00:18:07 server journal: 2017-02-10_00:18:07.00454
2017-02-10T00:18:07.004Z 382 TID-otrr6ws48 PruneOldEventsWorker
JID-99d3a4fb69be748c8674b5e1 INFO: done: 0.011 sec
Feb 10 00:18:30 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:18:29 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:18:43 server kernel: BTRFS info (device sdc): found 32 extents
Feb 10 00:18:48 server kernel: BTRFS info (device sdc): found 32 extents
Feb 10 00:18:49 server kernel: BTRFS info (device sdc): relocating
block group 12349268164608 flags 65
Feb 10 00:19:01 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:19:00 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:19:02 server journal: 2017-02-10_00:19:02.51409
2017-02-10T00:19:02.513Z 382 TID-otrr6wqok INFO: Cron Jobs - add job
with name: prune_old_events_worker
Feb 10 00:19:02 server journal: 2017-02-10_00:19:02.51449
2017-02-10T00:19:02.514Z 382 TID-otrspth10 PruneOldEventsWorker
JID-4a162ace334771baf4befbb7 INFO: start
Feb 10 00:19:02 server journal: 2017-02-10_00:19:02.52994
2017-02-10T00:19:02.529Z 382 TID-otrspth10 PruneOldEventsWorker
JID-4a162ace334771baf4befbb7 INFO: done: 0.015 sec
Feb 10 00:19:26 server kernel: BTRFS info (device sdc): found 33 extents
Feb 10 00:19:31 server kernel: BTRFS info (device sdc): found 33 extents
Feb 10 00:19:31 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:19:29 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:19:32 server kernel: BTRFS info (device sdc): relocating
block group 12344973197312 flags 65
Feb 10 00:19:51 server kernel: perf: interrupt took too long (2513 >
2500), lowering kernel.perf_event_max_sample_rate to 79000
Feb 10 00:20:00 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:19:59 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:20:10 server kernel: BTRFS info (device sdc): found 32 extents
Feb 10 00:20:10 server journal: 2017-02-10_00:20:10.15695
2017-02-10T00:20:10.156Z 382 TID-otrsptg48
RepositoryCheck::BatchWorker JID-a315de601bca406340583585 INFO: start
Feb 10 00:20:10 server journal: 2017-02-10_00:20:10.15968
2017-02-10T00:20:10.159Z 382 TID-otrr6wqok INFO: Cron Jobs - add job
with name: repository_check_worker
Feb 10 00:20:10 server journal: 2017-02-10_00:20:10.17180
2017-02-10T00:20:10.171Z 382 TID-otrsptilo 

Re: FS gives kernel UPS on attempt to create snapshot and after running balance it's unmountable.

2017-02-13 Thread Tomasz Kusmierz
Forgot to mention:

btrfs inspect-internal dump-super -af /dev/sdc

btrfs inspect-internal: unknown token 'dump-super'
usage: btrfs inspect-internal  

btrfs inspect-internal inode-resolve [-v]  
Get file system paths for the given inode
btrfs inspect-internal logical-resolve [-Pv] [-s bufsize]  
Get file system paths for the given logical address
btrfs inspect-internal subvolid-resolve  
Get file system paths for the given subvolume ID.
btrfs inspect-internal rootid 
Get tree ID of the containing subvolume of path.
btrfs inspect-internal min-dev-size [options] 
Get the minimum size the device can be shrunk to. The

query various internal information

On 13 February 2017 at 14:58, Tomasz Kusmierz  wrote:
> Problem is to send a larger log into this mailing list :/
>
> Anyway: uname -a
> Linux tevva-server 4.8.7-1.el7.elrepo.x86_64 #1 SMP Thu Nov 10
> 20:47:24 EST 2016 x86_64 x86_64 x86_64 GNU/Linux
>
>
> cut from messages (bear in mind that this is a single cut with a bit
> cut from inside of it to fit it in the email)
>
> Feb 10 00:17:14 server journal: ==>
> /var/log/gitlab/gitlab-shell/gitlab-shell.log <==
> Feb 10 00:17:30 server journal: 192.168.1.253 - wally_tm
> [10/Feb/2017:00:17:29 +] "PROPFIND /remote.php/webdav/Pictures
> HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
> Feb 10 00:18:00 server kernel: BTRFS info (device sdc): found 22 extents
> Feb 10 00:18:01 server journal: 192.168.1.253 - wally_tm
> [10/Feb/2017:00:17:59 +] "PROPFIND /remote.php/webdav/Pictures
> HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
> Feb 10 00:18:05 server kernel: BTRFS info (device sdc): found 22 extents
> Feb 10 00:18:06 server kernel: BTRFS info (device sdc): relocating
> block group 12353563131904 flags 65
> Feb 10 00:18:06 server journal:
> Feb 10 00:18:06 server journal: ==> /var/log/gitlab/sidekiq/current <==
> Feb 10 00:18:06 server journal: 2017-02-10_00:18:06.99341
> 2017-02-10T00:18:06.993Z 382 TID-otrr6ws48 PruneOldEventsWorker
> JID-99d3a4fb69be748c8674b5e1 INFO: start
> Feb 10 00:18:06 server journal: 2017-02-10_00:18:06.99571
> 2017-02-10T00:18:06.995Z 382 TID-otrr6wqok INFO: Cron Jobs - add job
> with name: prune_old_events_worker
> Feb 10 00:18:07 server journal: 2017-02-10_00:18:07.00454
> 2017-02-10T00:18:07.004Z 382 TID-otrr6ws48 PruneOldEventsWorker
> JID-99d3a4fb69be748c8674b5e1 INFO: done: 0.011 sec
> Feb 10 00:18:30 server journal: 192.168.1.253 - wally_tm
> [10/Feb/2017:00:18:29 +] "PROPFIND /remote.php/webdav/Pictures
> HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
> Feb 10 00:18:43 server kernel: BTRFS info (device sdc): found 32 extents
> Feb 10 00:18:48 server kernel: BTRFS info (device sdc): found 32 extents
> Feb 10 00:18:49 server kernel: BTRFS info (device sdc): relocating
> block group 12349268164608 flags 65
> Feb 10 00:19:01 server journal: 192.168.1.253 - wally_tm
> [10/Feb/2017:00:19:00 +] "PROPFIND /remote.php/webdav/Pictures
> HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
> Feb 10 00:19:02 server journal: 2017-02-10_00:19:02.51409
> 2017-02-10T00:19:02.513Z 382 TID-otrr6wqok INFO: Cron Jobs - add job
> with name: prune_old_events_worker
> Feb 10 00:19:02 server journal: 2017-02-10_00:19:02.51449
> 2017-02-10T00:19:02.514Z 382 TID-otrspth10 PruneOldEventsWorker
> JID-4a162ace334771baf4befbb7 INFO: start
> Feb 10 00:19:02 server journal: 2017-02-10_00:19:02.52994
> 2017-02-10T00:19:02.529Z 382 TID-otrspth10 PruneOldEventsWorker
> JID-4a162ace334771baf4befbb7 INFO: done: 0.015 sec
> Feb 10 00:19:26 server kernel: BTRFS info (device sdc): found 33 extents
> Feb 10 00:19:31 server kernel: BTRFS info (device sdc): found 33 extents
> Feb 10 00:19:31 server journal: 192.168.1.253 - wally_tm
> [10/Feb/2017:00:19:29 +] "PROPFIND /remote.php/webdav/Pictures
> HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
> Feb 10 00:19:32 server kernel: BTRFS info (device sdc): relocating
> block group 12344973197312 flags 65
> Feb 10 00:19:51 server kernel: perf: interrupt took too long (2513 >
> 2500), lowering kernel.perf_event_max_sample_rate to 79000
> Feb 10 00:20:00 server journal: 192.168.1.253 - wally_tm
> [10/Feb/2017:00:19:59 +] "PROPFIND /remote.php/webdav/Pictures
> HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
> Feb 10 00:20:10 server kernel: BTRFS info (device sdc): found 32 extents
> Feb 10 00:20:10 server journal: 2017-02-10_00:20:10.15695
> 2017-02-10T00:20:10.156Z 382 TID-otrsptg48
> RepositoryCheck::BatchWorker JID-a315de601bca406340583585 INFO: start
> Feb 10 00:20:10 server journal: 2017-02-10_00:20:10.15968
> 2017-02-10T00:20:10.159Z 382 TID-otrr6wqok INFO: Cron Jobs - add job
> with name: repository_check_worker
> Feb 10 00:20:10 server journal: 2017-02-10_00:20:10.17180
> 2017-02-10T00:20:10.171Z 382 TID-otrsptilo PruneOldEventsWorker
> JID-4fa75dc5a3d36957d1034f56 INFO: start
> Feb 10 00:20:10 server 

[PATCH] Btrfs: fix if style in find_free_extent

2017-02-13 Thread Liu Bo
This puts '&&' on the first line of if statement.

Signed-off-by: Liu Bo 
---
 fs/btrfs/extent-tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 6832047..4cf332c 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7789,8 +7789,8 @@ static noinline int find_free_extent(struct btrfs_root 
*orig_root,
}
up_read(_info->groups_sem);
 
-   if ((loop == LOOP_CACHING_NOWAIT) && have_caching_bg
-   && !orig_have_caching_bg)
+   if ((loop == LOOP_CACHING_NOWAIT) && have_caching_bg &&
+   !orig_have_caching_bg)
orig_have_caching_bg = true;
 
if (!ins->objectid && loop >= LOOP_CACHING_WAIT && have_caching_bg)
-- 
2.5.5

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Btrfs: use helper to get used bytes of space_info

2017-02-13 Thread Liu Bo
This uses a helper instead of open code around used byte of space_info
everywhere.

Signed-off-by: Liu Bo 
---
 fs/btrfs/extent-tree.c | 42 --
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 097fa4a..b2b0b82 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4118,6 +4118,15 @@ u64 btrfs_get_alloc_profile(struct btrfs_root *root, int 
data)
return ret;
 }
 
+static u64 btrfs_space_info_used(struct btrfs_space_info *s_info,
+bool may_used_included)
+{
+   ASSERT(s_info);
+   return s_info->bytes_used + s_info->bytes_reserved +
+   s_info->bytes_pinned + s_info->bytes_readonly +
+   ((may_used_included) ? s_info->bytes_may_use : 0);
+}
+
 int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes)
 {
struct btrfs_space_info *data_sinfo;
@@ -4143,9 +4152,7 @@ int btrfs_alloc_data_chunk_ondemand(struct inode *inode, 
u64 bytes)
 again:
/* make sure we have enough space to handle the data first */
spin_lock(_sinfo->lock);
-   used = data_sinfo->bytes_used + data_sinfo->bytes_reserved +
-   data_sinfo->bytes_pinned + data_sinfo->bytes_readonly +
-   data_sinfo->bytes_may_use;
+   used = btrfs_space_info_used(data_sinfo, true);
 
if (used + bytes > data_sinfo->total_bytes) {
struct btrfs_trans_handle *trans;
@@ -4420,9 +4427,7 @@ void check_system_chunk(struct btrfs_trans_handle *trans,
 
info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_SYSTEM);
spin_lock(>lock);
-   left = info->total_bytes - info->bytes_used - info->bytes_pinned -
-   info->bytes_reserved - info->bytes_readonly -
-   info->bytes_may_use;
+   left = info->total_bytes - btrfs_space_info_used(info, true);
spin_unlock(>lock);
 
num_devs = get_profile_num_devs(fs_info, type);
@@ -4605,8 +4610,7 @@ static int can_overcommit(struct btrfs_root *root,
return 0;
 
profile = btrfs_get_alloc_profile(root, 0);
-   used = space_info->bytes_used + space_info->bytes_reserved +
-   space_info->bytes_pinned + space_info->bytes_readonly;
+   used = btrfs_space_info_used(space_info, false);
 
/*
 * We only want to allow over committing if we have lots of actual space
@@ -5105,6 +5109,7 @@ static int wait_reserve_ticket(struct btrfs_fs_info 
*fs_info,
return ret;
 }
 
+
 /**
  * reserve_metadata_bytes - try to reserve bytes from the block_rsv's space
  * @root - the root we're allocating for
@@ -5134,9 +5139,7 @@ static int __reserve_metadata_bytes(struct btrfs_root 
*root,
 
spin_lock(_info->lock);
ret = -ENOSPC;
-   used = space_info->bytes_used + space_info->bytes_reserved +
-   space_info->bytes_pinned + space_info->bytes_readonly +
-   space_info->bytes_may_use;
+   used = btrfs_space_info_used(space_info, true);
 
/*
 * If we have enough space then hooray, make our reservation and carry
@@ -5629,9 +5632,7 @@ static void update_global_block_rsv(struct btrfs_fs_info 
*fs_info)
block_rsv->size = min_t(u64, num_bytes, SZ_512M);
 
if (block_rsv->reserved < block_rsv->size) {
-   num_bytes = sinfo->bytes_used + sinfo->bytes_pinned +
-   sinfo->bytes_reserved + sinfo->bytes_readonly +
-   sinfo->bytes_may_use;
+   num_bytes = btrfs_space_info_used(sinfo, true);
if (sinfo->total_bytes > num_bytes) {
num_bytes = sinfo->total_bytes - num_bytes;
num_bytes = min(num_bytes,
@@ -7906,9 +7907,8 @@ static void dump_space_info(struct btrfs_fs_info *fs_info,
spin_lock(>lock);
btrfs_info(fs_info, "space_info %llu has %llu free, is %sfull",
   info->flags,
-  info->total_bytes - info->bytes_used - info->bytes_pinned -
-  info->bytes_reserved - info->bytes_readonly -
-  info->bytes_may_use, (info->full) ? "" : "not ");
+  info->total_bytes - btrfs_space_info_used(info, true),
+  (info->full) ? "" : "not ");
btrfs_info(fs_info,
"space_info total=%llu, used=%llu, pinned=%llu, reserved=%llu, 
may_use=%llu, readonly=%llu",
info->total_bytes, info->bytes_used, info->bytes_pinned,
@@ -9344,8 +9344,7 @@ static int inc_block_group_ro(struct 
btrfs_block_group_cache *cache, int force)
num_bytes = cache->key.offset - cache->reserved - cache->pinned -
cache->bytes_super - btrfs_block_group_used(>item);
 
-   if (sinfo->bytes_used + sinfo->bytes_reserved + sinfo->bytes_pinned +
-   sinfo->bytes_may_use + sinfo->bytes_readonly + num_bytes +
+   if 

[PATCH] Btrfs: try to avoid acquiring free space ctl's lock

2017-02-13 Thread Liu Bo
We don't need to take the lock if the block group has not been cached.

Signed-off-by: Liu Bo 
---
 fs/btrfs/extent-tree.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index b2b0b82..6832047 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7715,18 +7715,19 @@ static noinline int find_free_extent(struct btrfs_root 
*orig_root,
last_ptr->fragmented = 1;
spin_unlock(_ptr->lock);
}
-   spin_lock(_group->free_space_ctl->tree_lock);
-   if (cached &&
-   block_group->free_space_ctl->free_space <
-   num_bytes + empty_cluster + empty_size) {
-   if (block_group->free_space_ctl->free_space >
-   max_extent_size)
-   max_extent_size =
-   block_group->free_space_ctl->free_space;
-   spin_unlock(_group->free_space_ctl->tree_lock);
-   goto loop;
+   if (cached) {
+   struct btrfs_free_space_ctl *ctl =
+   block_group->free_space_ctl;
+   spin_lock(>tree_lock);
+   if (ctl->free_space <
+   num_bytes + empty_cluster + empty_size) {
+   if (ctl->free_space > max_extent_size)
+   max_extent_size = ctl->free_space;
+   spin_unlock(>tree_lock);
+   goto loop;
+   }
+   spin_unlock(>tree_lock);
}
-   spin_unlock(_group->free_space_ctl->tree_lock);
 
offset = btrfs_find_space_for_alloc(block_group, search_start,
num_bytes, empty_size,
-- 
2.5.5

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Btrfs: specify a new ordered extent type for create_io_em

2017-02-13 Thread Liu Bo
As 0 refers to an existing type BTRFS_ORDERED_IO_DONE, this specifies a
new type 'REGULAR' for regular IO.

Signed-off-by: Liu Bo 
---
This fixes the problem in the patch
"[PATCH] Btrfs: create a helper to create em for IO".

 fs/btrfs/inode.c| 8 
 fs/btrfs/ordered-data.h | 2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5e28355..f75c914 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -986,7 +986,7 @@ static noinline int cow_file_range(struct inode *inode,
  ins.offset, /* orig_block_len */
  ram_size, /* ram_bytes */
  BTRFS_COMPRESS_NONE, /* compress_type */
- 0 /* type */);
+ BTRFS_ORDERED_REGULAR /* type */);
if (IS_ERR(em))
goto out_reserve;
free_extent_map(em);
@@ -7490,7 +7490,7 @@ static struct extent_map *create_io_em(struct inode 
*inode, u64 start, u64 len,
ASSERT(type == BTRFS_ORDERED_PREALLOC ||
   type == BTRFS_ORDERED_COMPRESSED ||
   type == BTRFS_ORDERED_NOCOW ||
-  type == 0);
+  type == BTRFS_ORDERED_REGULAR);
 
em_tree = _I(inode)->extent_tree;
em = alloc_extent_map();
@@ -7507,9 +7507,9 @@ static struct extent_map *create_io_em(struct inode 
*inode, u64 start, u64 len,
em->ram_bytes = ram_bytes;
em->generation = -1;
set_bit(EXTENT_FLAG_PINNED, >flags);
-   if (type == BTRFS_ORDERED_PREALLOC)
+   if (type == BTRFS_ORDERED_PREALLOC) {
set_bit(EXTENT_FLAG_FILLING, >flags);
-   else if (type == BTRFS_ORDERED_COMPRESSED) {
+   } else if (type == BTRFS_ORDERED_COMPRESSED) {
set_bit(EXTENT_FLAG_COMPRESSED, >flags);
em->compress_type = compress_type;
}
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index 5f2b0ca..db003761 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -75,6 +75,8 @@ struct btrfs_ordered_sum {
 * in the logging code. */
 #define BTRFS_ORDERED_PENDING 11 /* We are waiting for this ordered extent to
  * complete in the current transaction. */
+#define BTRFS_ORDERED_REGULAR 12 /* Regular IO for COW */
+
 struct btrfs_ordered_extent {
/* logical offset in the file */
u64 file_offset;
-- 
2.5.5

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Root volume (ID 5) in deleting state

2017-02-13 Thread Hans van Kranenburg
Hi,

On 02/13/2017 09:50 PM, Martin Mlynář wrote:
> On 13.2.2017 21:03, Hans van Kranenburg wrote:
>> On 02/13/2017 12:26 PM, Martin Mlynář wrote:
>>> I've currently run into strange problem with BTRFS. I'm using it as my
>>> daily driver as root FS. Nothing complicated, just few subvolumes and
>>> incremental backups using btrbk.
>>>
>>> Now I've noticed that my btrfs root volume (absolute top, ID 5) is in
>>> "deleting" state. As I've done some testing and googling it seems that
>>> this should not be possible.
>>>
>>> [...]
>>>
>>> # btrfs sub list -ad /mnt/btrfs_root/
>>> ID 5 gen 257505 top level 0 path /DELETED
>> I have heard rumours that this is actually a bug in the output of sub
>> list itself.
>>
>> What's the version of your btrfs-progs? (output of `btrfs version`)
> Sorry, I've lost this part:
> 
> $ btrfs version
> btrfs-progs v4.9
> 
>>
>>> # mount | grep btr
>>> /dev/mapper/vg0-btrfsroot on / type btrfs
>>> (rw,noatime,nodatasum,nodatacow,ssd,discard,space_cache,subvolid=1339,subvol=/rootfs)
>>>
>>>
>>> /dev/mapper/vg0-btrfsroot on /mnt/btrfs_root type btrfs
>>> (rw,noatime,nodatasum,nodatacow,ssd,discard,space_cache,subvolid=5,subvol=/)
>>>
>> The rumour was that it had something to do with using space_cache=v2,
>> which this example does not confirm.
> It looks you're right!
> 
> On a different machine:
> 
> # btrfs sub list / | grep -v lxc
> ID 327 gen 1959587 top level 5 path mnt/reaver
> ID 498 gen 593655 top level 5 path var/lib/machines
> 
> # btrfs sub list / -d | wc -l
> 0

Ok, apparently it's a regression in one of the latest versions then.
But, it seems quite harmless.

> # btrfs version
> btrfs-progs v4.8.2
> 
> # uname -a
> Linux nxserver 4.8.6-1-ARCH #1 SMP PREEMPT Mon Oct 31 18:51:30 CET 2016
> x86_64 GNU/Linux
> 
> # mount | grep btrfs
> /dev/vda1 on / type btrfs
> (rw,relatime,nodatasum,nodatacow,space_cache,subvolid=5,subvol=/)
> 
> Then I've upgraded this machine and:
> 
> # btrfs sub list / | grep -v lxc
> ID 327 gen 1959587 top level 5 path mnt/reaver
> ID 498 gen 593655 top level 5 path var/lib/machines
> 
> # btrfs sub list / -d | wc -l
> 1
> 
> # btrfs sub list / -d
> ID 5 gen 2186037 top level 0 path DELETED<==
> 
> 1
> 
> # btrfs version
> btrfs-progs v4.9
> 
> # uname -a
> Linux nxserver 4.9.8-1-ARCH #1 SMP PREEMPT Mon Feb 6 12:59:40 CET 2017
> x86_64 GNU/Linux
> 
> # mount | grep btrfs
> /dev/vda1 on / type btrfs
> (rw,relatime,nodatasum,nodatacow,space_cache,subvolid=5,subvol=/)
> 
> 
>>
>>> # uname -a
>>> Linux interceptor 4.9.6-1-ARCH #1 SMP PREEMPT Thu Jan 26 09:22:26 CET
>>> 2017 x86_64 GNU/Linux
>>>
>>> # btrfs fi show  /
>>> Label: none  uuid: 859dec5c-850c-4660-ad99-bc87456aa309
>>>  Total devices 1 FS bytes used 132.89GiB
>>>  devid1 size 200.00GiB used 200.00GiB path
>>> /dev/mapper/vg0-btrfsroot
>> As a side note, all of your disk space is allocated (200GiB of 200GiB).
>>
>> Even while there's still 70GiB of free space scattered around inside,
>> this might lead to out-of-space issues, depending on how badly
>> fragmented that free space is.
> I have not noticed this at all!
> 
> # btrfs fi show /
> Label: none  uuid: 859dec5c-850c-4660-ad99-bc87456aa309
> Total devices 1 FS bytes used 134.23GiB
> devid1 size 200.00GiB used 200.00GiB path /dev/mapper/vg0-btrfsroot
> 
> # btrfs fi df /
> Data, single: total=195.96GiB, used=131.58GiB
> System, single: total=3.00MiB, used=48.00KiB
> Metadata, single: total=4.03GiB, used=2.64GiB
> GlobalReserve, single: total=512.00MiB, used=0.00B
> 
> After btrfs defrag there is no difference. btrfs fi show says still
> 200/200. I'll try to play with it.

Yes, this is the very first confusing thing every btrfs user encounters.

If you have a 200GiB disk, btrfs will start allocating raw disk space
from it in chunks of 256MiB (for metadata) and 1GiB (for data), when
needed. If, after some time, you throw away files or snapshots or for
whatever reason free up used space, you still have those big 1GiB sized
allocated blocks, which now have gaps of free space inside them.

In the above output, all of the 200GiB has been claimed for either data
or metadata use, in big chunks. In theory this should not be a problem,
unless you need to store more than 4.03GiB of metadata (no new space for
dedicated metadata chunks can be claimed any more).

The "used" in btrfs fi show output is the amount allocated ("claimed"),
which is the sum of the "total" numbers in btrfs fi df output.
The "used" in btrfs fi df is the actual amount of data stored in the
allocated space. Simple, huh...?

If you write new data, btrfs will either put it in free space inside the
already allocated space, or it will just not try hard enough, give up,
and try to claim more raw space (which is not there any more) and throw
up with ENOSPC errors. This leads to the usual "btrfs says my disk is
full, but df says I only have 60% used." reports you see on the mailing
list, because it's usually the first problem people run into when trying

Re: Root volume (ID 5) in deleting state

2017-02-13 Thread Martin Mlynář

On 13.2.2017 21:03, Hans van Kranenburg wrote:

On 02/13/2017 12:26 PM, Martin Mlynář wrote:

I've currently run into strange problem with BTRFS. I'm using it as my
daily driver as root FS. Nothing complicated, just few subvolumes and
incremental backups using btrbk.

Now I've noticed that my btrfs root volume (absolute top, ID 5) is in
"deleting" state. As I've done some testing and googling it seems that
this should not be possible.

[...]

# btrfs sub list -ad /mnt/btrfs_root/
ID 5 gen 257505 top level 0 path /DELETED

I have heard rumours that this is actually a bug in the output of sub
list itself.

What's the version of your btrfs-progs? (output of `btrfs version`)

Sorry, I've lost this part:

$ btrfs version
btrfs-progs v4.9




# mount | grep btr
/dev/mapper/vg0-btrfsroot on / type btrfs
(rw,noatime,nodatasum,nodatacow,ssd,discard,space_cache,subvolid=1339,subvol=/rootfs)

/dev/mapper/vg0-btrfsroot on /mnt/btrfs_root type btrfs
(rw,noatime,nodatasum,nodatacow,ssd,discard,space_cache,subvolid=5,subvol=/)

The rumour was that it had something to do with using space_cache=v2,
which this example does not confirm.

It looks you're right!

On a different machine:

# btrfs sub list / | grep -v lxc
ID 327 gen 1959587 top level 5 path mnt/reaver
ID 498 gen 593655 top level 5 path var/lib/machines

# btrfs sub list / -d | wc -l
0

# btrfs version
btrfs-progs v4.8.2

# uname -a
Linux nxserver 4.8.6-1-ARCH #1 SMP PREEMPT Mon Oct 31 18:51:30 CET 2016 
x86_64 GNU/Linux


# mount | grep btrfs
/dev/vda1 on / type btrfs 
(rw,relatime,nodatasum,nodatacow,space_cache,subvolid=5,subvol=/)


Then I've upgraded this machine and:

# btrfs sub list / | grep -v lxc
ID 327 gen 1959587 top level 5 path mnt/reaver
ID 498 gen 593655 top level 5 path var/lib/machines

# btrfs sub list / -d | wc -l
1

# btrfs sub list / -d
ID 5 gen 2186037 top level 0 path DELETED<==

1

# btrfs version
btrfs-progs v4.9

# uname -a
Linux nxserver 4.9.8-1-ARCH #1 SMP PREEMPT Mon Feb 6 12:59:40 CET 2017 
x86_64 GNU/Linux


# mount | grep btrfs
/dev/vda1 on / type btrfs 
(rw,relatime,nodatasum,nodatacow,space_cache,subvolid=5,subvol=/)






# uname -a
Linux interceptor 4.9.6-1-ARCH #1 SMP PREEMPT Thu Jan 26 09:22:26 CET
2017 x86_64 GNU/Linux

# btrfs fi show  /
Label: none  uuid: 859dec5c-850c-4660-ad99-bc87456aa309
 Total devices 1 FS bytes used 132.89GiB
 devid1 size 200.00GiB used 200.00GiB path /dev/mapper/vg0-btrfsroot

As a side note, all of your disk space is allocated (200GiB of 200GiB).

Even while there's still 70GiB of free space scattered around inside,
this might lead to out-of-space issues, depending on how badly
fragmented that free space is.

I have not noticed this at all!

# btrfs fi show /
Label: none  uuid: 859dec5c-850c-4660-ad99-bc87456aa309
Total devices 1 FS bytes used 134.23GiB
devid1 size 200.00GiB used 200.00GiB path /dev/mapper/vg0-btrfsroot

# btrfs fi df /
Data, single: total=195.96GiB, used=131.58GiB
System, single: total=3.00MiB, used=48.00KiB
Metadata, single: total=4.03GiB, used=2.64GiB
GlobalReserve, single: total=512.00MiB, used=0.00B

After btrfs defrag there is no difference. btrfs fi show says still 
200/200. I'll try to play with it.



--
Martin Mlynář
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Root volume (ID 5) in deleting state

2017-02-13 Thread Hans van Kranenburg
On 02/13/2017 12:26 PM, Martin Mlynář wrote:
> 
> I've currently run into strange problem with BTRFS. I'm using it as my
> daily driver as root FS. Nothing complicated, just few subvolumes and
> incremental backups using btrbk.
> 
> Now I've noticed that my btrfs root volume (absolute top, ID 5) is in
> "deleting" state. As I've done some testing and googling it seems that
> this should not be possible.
> 
> [...]
> 
> # btrfs sub list -ad /mnt/btrfs_root/
> ID 5 gen 257505 top level 0 path /DELETED

I have heard rumours that this is actually a bug in the output of sub
list itself.

What's the version of your btrfs-progs? (output of `btrfs version`)

> # mount | grep btr
> /dev/mapper/vg0-btrfsroot on / type btrfs
> (rw,noatime,nodatasum,nodatacow,ssd,discard,space_cache,subvolid=1339,subvol=/rootfs)
> 
> /dev/mapper/vg0-btrfsroot on /mnt/btrfs_root type btrfs
> (rw,noatime,nodatasum,nodatacow,ssd,discard,space_cache,subvolid=5,subvol=/)

The rumour was that it had something to do with using space_cache=v2,
which this example does not confirm.

> # uname -a
> Linux interceptor 4.9.6-1-ARCH #1 SMP PREEMPT Thu Jan 26 09:22:26 CET
> 2017 x86_64 GNU/Linux
> 
> # btrfs fi show  /
> Label: none  uuid: 859dec5c-850c-4660-ad99-bc87456aa309
> Total devices 1 FS bytes used 132.89GiB
> devid1 size 200.00GiB used 200.00GiB path /dev/mapper/vg0-btrfsroot

As a side note, all of your disk space is allocated (200GiB of 200GiB).

Even while there's still 70GiB of free space scattered around inside,
this might lead to out-of-space issues, depending on how badly
fragmented that free space is.

-- 
Hans van Kranenburg
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: stat(2) returning device ID not existing in mountinfo

2017-02-13 Thread Goffredo Baroncelli
Hi,

I want to highlight this bug another time.

I encountered this bug, when I was looking to a problem with find. I my machine 
find took an huge quantity of memory (up to 3GB) when used by updatedb.


http://lists.gnu.org/archive/html/findutils-patches/2016-12/msg0.html

The root of the problem was a leak memory in find. What was strange however is 
that the findutils developers weren't unable to reproduce this bug. They find 
the leak, but not a so high memory usage.

After some email, it was discovered that find (when used in updatedb) checks if 
the filesystem is changed during the tree walking. They checked the device-id 
returned by stat against the one returned by mountinfo.

For btrfs these differ, and the check is repeat each time. Because the memory 
leak was per "filesystem check", using find on a btrfs filesystem caused a huge 
leak.

I hope that some btrfs developer could address this, because I suspect that a 
lot of tools compare the device id returned by /proc/self/mountinfo against the 
one returned by stat(2).


BR
G.Baroncelli




On 2016-09-20 15:15, Jeff Mahoney wrote:
> On 9/16/16 4:28 PM, Tomasz Sterna wrote:
>> Hi.
>>
>> I have spotted an issue with stat(2) call on files on btrfs.
>> It is giving me dev_t st_dev number that does not correspond to any
>> mounted filesystem in proc's mountinfo.
> 
> That's by design.  Your particular file system may only use one device
> but, internally, btrfs uses virtualized storage that may be spread
> across multiple devices.  To make things more complicated, snapshots
> mean that:
> 
> sled1a:/mnt # btrfs sub list .
> ID 257 gen 14 top level 5 path a
> ID 258 gen 14 top level 5 path b
> 
> sled1a:/mnt # ls -laRi
> .:
> total 16
> 256 drwxr-xr-x 1 root root   4 Sep 20 09:08 .
> 256 drwxr-xr-x 1 root root 220 Sep 16 09:49 ..
> 256 drwxr-xr-x 1 root root   8 Sep 14 10:24 a
> 256 drwxr-xr-x 1 root root   8 Sep 14 10:24 b
> 
> ./a:
> total 4112
> 256 drwxr-xr-x 1 root root   8 Sep 14 10:24 .
> 256 drwxr-xr-x 1 root root   4 Sep 20 09:08 ..
> 257 -rw-r--r-- 1 root root 4194304 Sep 14 10:24 file
> 
> ./b:
> total 4112
> 256 drwxr-xr-x 1 root root   8 Sep 14 10:24 .
> 256 drwxr-xr-x 1 root root   4 Sep 20 09:08 ..
> 257 -rw-r--r-- 1 root root 4194304 Sep 14 10:24 file
> 
> Under normal circumstances those are two files with the same st_dev and
> the same inode number.  That would normally correspond to a hard link,
> but the files do not (necessarily) correspond to the same file.
> 
> ... but because we use anonymous device numbers for each subvolume, we
> have different device numbers for each one.
> 
> sled1a:/mnt # stat --format "%n st_dev=%d" {a,b}/file
> a/file st_dev=69
> b/file st_dev=70
> 
> It's a pretty big usability wart that we don't consistently report the
> device number.  We do it correctly in stat() but there are other places
> in the code that assume that inode->i_sb->s_dev will work.  In the SUSE
> kernels, we have patches that add a super_operation to report the
> correct device number everywhere, but even that is a hack.
> 
>> I already attempted a illinformed-patch in fs/btrfs/super.c:
>>
>> @@ -1127,6 +1127,7 @@ static int btrfs_fill_super(struct super_block *sb,
>>  goto fail_close;
>>  }
>>  
>> +sb->s_dev = inode->i_sb->s_dev;
>>  sb->s_root = d_make_root(inode);
>>  if (!sb->s_root) {
>>  err = -ENOMEM;
>>
>> but it didn't help.
> 
> It wouldn't.  That is assigning a variable to itself.
> 
>> I would like to dig deeper and fix it, but first I have to ask:
>> - Which number is wrong?
>>   The one returned by stat() or the one in mountinfo?
> 
> The one in mountinfo, but then that means that the user only sees the
> anonymous devices in mount(8), which isn't what we want either.
> 
> I'm afraid the correct fix is very involved and requires non-trivial
> changes in the VFS layer as well.  It's on my long-term TODO list.  I
> currently have some patches that do the magic with vfsmounts but it's
> far from being usable.
> 
> -Jeff
> 


-- 
gpg @keyserver.linux.it: Goffredo Baroncelli 
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: BTRFS for OLTP Databases

2017-02-13 Thread linux-btrfs
W dniu 2017-02-13 o 13:44 PM, Austin S. Hemmelgarn pisze:
> On 2017-02-09 22:58, Andrei Borzenkov wrote:
>> 07.02.2017 23:47, Austin S. Hemmelgarn пишет:
>> ...
>>> Sadly, freezefs (the generic interface based off of xfs_freeze) only
>>> works for block device snapshots.  Filesystem level snapshots need the
>>> application software to sync all it's data and then stop writing until
>>> the snapshot is complete.
>>>
>>
>> I expect databases to be using directio, otherwise we have problems even
>> without using snapshots. Is it still an issue with directio?
> It is less of an issue, but it's still an issue because you can still
> call for snapshot creation in the middle of an application I/O
> request. In other words, the application wouldn't need to worry about
> syncing data, but it would need to worry about making sure it's not
> actually writing anything when the snapshot happens.
>
I think this should work the other way around. Snapshot should wait
until all directio writes are done,

and new requests sent when creating snapshot, should wait until snapshot
is done.


-- 

Adrian Brzeziński

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: FS gives kernel UPS on attempt to create snapshot and after running balance it's unmountable.

2017-02-13 Thread Tomasz Kusmierz
Problem is to send a larger log into this mailing list :/

Anyway: uname -a
Linux tevva-server 4.8.7-1.el7.elrepo.x86_64 #1 SMP Thu Nov 10
20:47:24 EST 2016 x86_64 x86_64 x86_64 GNU/Linux


cut from messages (bear in mind that this is a single cut with a bit
cut from inside of it to fit it in the email)

Feb 10 00:17:14 server journal: ==>
/var/log/gitlab/gitlab-shell/gitlab-shell.log <==
Feb 10 00:17:30 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:17:29 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:18:00 server kernel: BTRFS info (device sdc): found 22 extents
Feb 10 00:18:01 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:17:59 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:18:05 server kernel: BTRFS info (device sdc): found 22 extents
Feb 10 00:18:06 server kernel: BTRFS info (device sdc): relocating
block group 12353563131904 flags 65
Feb 10 00:18:06 server journal:
Feb 10 00:18:06 server journal: ==> /var/log/gitlab/sidekiq/current <==
Feb 10 00:18:06 server journal: 2017-02-10_00:18:06.99341
2017-02-10T00:18:06.993Z 382 TID-otrr6ws48 PruneOldEventsWorker
JID-99d3a4fb69be748c8674b5e1 INFO: start
Feb 10 00:18:06 server journal: 2017-02-10_00:18:06.99571
2017-02-10T00:18:06.995Z 382 TID-otrr6wqok INFO: Cron Jobs - add job
with name: prune_old_events_worker
Feb 10 00:18:07 server journal: 2017-02-10_00:18:07.00454
2017-02-10T00:18:07.004Z 382 TID-otrr6ws48 PruneOldEventsWorker
JID-99d3a4fb69be748c8674b5e1 INFO: done: 0.011 sec
Feb 10 00:18:30 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:18:29 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:18:43 server kernel: BTRFS info (device sdc): found 32 extents
Feb 10 00:18:48 server kernel: BTRFS info (device sdc): found 32 extents
Feb 10 00:18:49 server kernel: BTRFS info (device sdc): relocating
block group 12349268164608 flags 65
Feb 10 00:19:01 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:19:00 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:19:02 server journal: 2017-02-10_00:19:02.51409
2017-02-10T00:19:02.513Z 382 TID-otrr6wqok INFO: Cron Jobs - add job
with name: prune_old_events_worker
Feb 10 00:19:02 server journal: 2017-02-10_00:19:02.51449
2017-02-10T00:19:02.514Z 382 TID-otrspth10 PruneOldEventsWorker
JID-4a162ace334771baf4befbb7 INFO: start
Feb 10 00:19:02 server journal: 2017-02-10_00:19:02.52994
2017-02-10T00:19:02.529Z 382 TID-otrspth10 PruneOldEventsWorker
JID-4a162ace334771baf4befbb7 INFO: done: 0.015 sec
Feb 10 00:19:26 server kernel: BTRFS info (device sdc): found 33 extents
Feb 10 00:19:31 server kernel: BTRFS info (device sdc): found 33 extents
Feb 10 00:19:31 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:19:29 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:19:32 server kernel: BTRFS info (device sdc): relocating
block group 12344973197312 flags 65
Feb 10 00:19:51 server kernel: perf: interrupt took too long (2513 >
2500), lowering kernel.perf_event_max_sample_rate to 79000
Feb 10 00:20:00 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:19:59 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:20:10 server kernel: BTRFS info (device sdc): found 32 extents
Feb 10 00:20:10 server journal: 2017-02-10_00:20:10.15695
2017-02-10T00:20:10.156Z 382 TID-otrsptg48
RepositoryCheck::BatchWorker JID-a315de601bca406340583585 INFO: start
Feb 10 00:20:10 server journal: 2017-02-10_00:20:10.15968
2017-02-10T00:20:10.159Z 382 TID-otrr6wqok INFO: Cron Jobs - add job
with name: repository_check_worker
Feb 10 00:20:10 server journal: 2017-02-10_00:20:10.17180
2017-02-10T00:20:10.171Z 382 TID-otrsptilo PruneOldEventsWorker
JID-4fa75dc5a3d36957d1034f56 INFO: start
Feb 10 00:20:10 server journal: 2017-02-10_00:20:10.17430
2017-02-10T00:20:10.174Z 382 TID-otrr6wqok INFO: Cron Jobs - add job
with name: prune_old_events_worker
Feb 10 00:20:10 server journal: 2017-02-10_00:20:10.18948
2017-02-10T00:20:10.189Z 382 TID-otrsptilo PruneOldEventsWorker
JID-4fa75dc5a3d36957d1034f56 INFO: done: 0.018 sec
Feb 10 00:20:11 server journal: 2017-02-10_00:20:11.00073
2017-02-10T00:20:11.000Z 382 TID-otrsptg48
RepositoryCheck::BatchWorker JID-a315de601bca406340583585 INFO: done:
0.844 sec
Feb 10 00:20:14 server kernel: BTRFS info (device sdc): found 32 extents
Feb 10 00:20:15 server kernel: BTRFS info (device sdc): relocating
block group 12340678230016 flags 65
Feb 10 00:20:30 server journal: 192.168.1.253 - wally_tm
[10/Feb/2017:00:20:29 +] "PROPFIND /remote.php/webdav/Pictures
HTTP/1.1" 207 1024 "-" "Mozilla/5.0 (Linux) mirall/2.1.1"
Feb 10 00:20:41 server kernel: systemd-tmpfile: 127 output lines
suppressed due to ratelimiting

[PATCH 7/7] btrfs: remove pointless rcu protection from btrfs_qgroup_inherit

2017-02-13 Thread David Sterba
There was never need for RCU protection around reading nodesize or other
fairly constant filesystem data.

Signed-off-by: David Sterba 
---
 fs/btrfs/qgroup.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 114d6770dc23..052f1410dc14 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -2189,9 +2189,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
goto out;
}
 
-   rcu_read_lock();
level_size = fs_info->nodesize;
-   rcu_read_unlock();
}
 
/*
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/7] btrfs: qgroups: opencode qgroup_free helper

2017-02-13 Thread David Sterba
The helper name is not too helpful and is just wrapping a simple call.

Signed-off-by: David Sterba 
---
 fs/btrfs/qgroup.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 2b3c2ad9..114d6770dc23 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -2465,11 +2465,6 @@ void btrfs_qgroup_free_refroot(struct btrfs_fs_info 
*fs_info,
spin_unlock(_info->qgroup_lock);
 }
 
-static inline void qgroup_free(struct btrfs_root *root, u64 num_bytes)
-{
-   return btrfs_qgroup_free_refroot(root->fs_info, root->objectid,
-num_bytes);
-}
 void assert_qgroups_uptodate(struct btrfs_trans_handle *trans)
 {
if (list_empty(>qgroup_ref_list) && !trans->delayed_ref_elem.seq)
@@ -2870,7 +2865,9 @@ static int __btrfs_qgroup_release_data(struct inode 
*inode, u64 start, u64 len,
goto out;
 
if (free) {
-   qgroup_free(BTRFS_I(inode)->root, changeset.bytes_changed);
+   btrfs_qgroup_free_refroot(BTRFS_I(inode)->root->fs_info,
+   BTRFS_I(inode)->root->objectid,
+   changeset.bytes_changed);
trace_op = QGROUP_FREE;
}
trace_btrfs_qgroup_release_data(inode, start, len,
@@ -2945,7 +2942,7 @@ void btrfs_qgroup_free_meta_all(struct btrfs_root *root)
reserved = atomic_xchg(>qgroup_meta_rsv, 0);
if (reserved == 0)
return;
-   qgroup_free(root, reserved);
+   btrfs_qgroup_free_refroot(fs_info, root->objectid, reserved);
 }
 
 void btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes)
@@ -2959,7 +2956,7 @@ void btrfs_qgroup_free_meta(struct btrfs_root *root, int 
num_bytes)
BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize));
WARN_ON(atomic_read(>qgroup_meta_rsv) < num_bytes);
atomic_sub(num_bytes, >qgroup_meta_rsv);
-   qgroup_free(root, num_bytes);
+   btrfs_qgroup_free_refroot(fs_info, root->objectid, num_bytes);
 }
 
 /*
@@ -2986,7 +2983,10 @@ void btrfs_qgroup_check_reserved_leak(struct inode 
*inode)
"leaking qgroup reserved space, ino: %lu, 
start: %llu, end: %llu",
inode->i_ino, unode->val, unode->aux);
}
-   qgroup_free(BTRFS_I(inode)->root, changeset.bytes_changed);
+   btrfs_qgroup_free_refroot(BTRFS_I(inode)->root->fs_info,
+   BTRFS_I(inode)->root->objectid,
+   changeset.bytes_changed);
+
}
ulist_fini(_changed);
 }
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/7] btrfs: remove unnecessary mutex lock in qgroup_account_snapshot

2017-02-13 Thread David Sterba
The quota status used to be tracked as a variable, so the mutex was
needed (until "Btrfs: add a flags field to btrfs_fs_info" afcdd129e05a9).
Since the status is a bit modified atomically and we don't hold the
mutex beyond the check, we can drop it.

Signed-off-by: David Sterba 
---
 fs/btrfs/transaction.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 48aabb367f73..5eefd77bafc7 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1364,12 +1364,8 @@ static int qgroup_account_snapshot(struct 
btrfs_trans_handle *trans,
 * enabled. If this check races with the ioctl, rescan will
 * kick in anyway.
 */
-   mutex_lock(_info->qgroup_ioctl_lock);
-   if (!test_bit(BTRFS_FS_QUOTA_ENABLED, _info->flags)) {
-   mutex_unlock(_info->qgroup_ioctl_lock);
+   if (!test_bit(BTRFS_FS_QUOTA_ENABLED, _info->flags))
return 0;
-   }
-   mutex_unlock(_info->qgroup_ioctl_lock);
 
/*
 * We are going to commit transaction, see btrfs_commit_transaction()
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/7] Qgroup cleanups

2017-02-13 Thread David Sterba
I've spotted some cleanup-ready code while going through the file, so here it
is. There are no changes to the core qgoups code, just the support and
framework code. For 4.11.

David Sterba (7):
  btrfs: qgroups: make __del_qgroup_relation static
  btrfs: ulist: make the finalization function public
  btrfs: embed extent_changeset::range_changed to the structure
  btrfs: check quota status earlier and don't do unnecessary frees
  btrfs: remove unnecessary mutex lock in qgroup_account_snapshot
  btrfs: qgroups: opencode qgroup_free helper
  btrfs: remove pointless rcu protection from btrfs_qgroup_inherit

 fs/btrfs/extent_io.c   |  2 +-
 fs/btrfs/extent_io.h   |  2 +-
 fs/btrfs/qgroup.c  | 51 ++
 fs/btrfs/transaction.c |  6 +-
 fs/btrfs/ulist.c   |  2 +-
 fs/btrfs/ulist.h   |  1 +
 6 files changed, 27 insertions(+), 37 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/7] btrfs: ulist: make the finalization function public

2017-02-13 Thread David Sterba
Make ulist_fini externally visible so the ulist API is complete.

Signed-off-by: David Sterba 
---
 fs/btrfs/ulist.c | 2 +-
 fs/btrfs/ulist.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/ulist.c b/fs/btrfs/ulist.c
index b1434bb57e36..5deee56434fc 100644
--- a/fs/btrfs/ulist.c
+++ b/fs/btrfs/ulist.c
@@ -58,7 +58,7 @@ void ulist_init(struct ulist *ulist)
  * This is useful in cases where the base 'struct ulist' has been statically
  * allocated.
  */
-static void ulist_fini(struct ulist *ulist)
+void ulist_fini(struct ulist *ulist)
 {
struct ulist_node *node;
struct ulist_node *next;
diff --git a/fs/btrfs/ulist.h b/fs/btrfs/ulist.h
index 007b22fff3f9..1a4130443d7e 100644
--- a/fs/btrfs/ulist.h
+++ b/fs/btrfs/ulist.h
@@ -44,6 +44,7 @@ struct ulist {
 };
 
 void ulist_init(struct ulist *ulist);
+void ulist_fini(struct ulist *ulist);
 void ulist_reinit(struct ulist *ulist);
 struct ulist *ulist_alloc(gfp_t gfp_mask);
 void ulist_free(struct ulist *ulist);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/7] btrfs: check quota status earlier and don't do unnecessary frees

2017-02-13 Thread David Sterba
Status of quotas should be the first check in
btrfs_qgroup_account_extent and we can return immediatelly, no need to
do no-op ulist frees.

Signed-off-by: David Sterba 
---
 fs/btrfs/qgroup.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 7cc2e2221f55..2b3c2ad9 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1945,13 +1945,14 @@ btrfs_qgroup_account_extent(struct btrfs_trans_handle 
*trans,
u64 nr_old_roots = 0;
int ret = 0;
 
+   if (!test_bit(BTRFS_FS_QUOTA_ENABLED, _info->flags))
+   return 0;
+
if (new_roots)
nr_new_roots = new_roots->nnodes;
if (old_roots)
nr_old_roots = old_roots->nnodes;
 
-   if (!test_bit(BTRFS_FS_QUOTA_ENABLED, _info->flags))
-   goto out_free;
BUG_ON(!fs_info->quota_root);
 
trace_btrfs_qgroup_account_extent(fs_info, bytenr, num_bytes,
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/7] btrfs: embed extent_changeset::range_changed to the structure

2017-02-13 Thread David Sterba
We can embed range_changed to the extent changeset to address following
problems:

- no need to allocate ulist dynamically, we also get rid of the GFP_NOFS
  for free
- fix lack of allocation failure checking in btrfs_qgroup_reserve_data

The stack consuption where extent_changeset is used slightly increases:

before: 16
after: 16 - 8 (for pointer) + 32 (sizeof ulist) = 40

Which is bearable.

Signed-off-by: David Sterba 
---
 fs/btrfs/extent_io.c |  2 +-
 fs/btrfs/extent_io.h |  2 +-
 fs/btrfs/qgroup.c| 24 +---
 3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 9df6ed30de00..9140847bfb0c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -144,7 +144,7 @@ static void add_extent_changeset(struct extent_state 
*state, unsigned bits,
if (!set && (state->state & bits) == 0)
return;
changeset->bytes_changed += state->end - state->start + 1;
-   ret = ulist_add(changeset->range_changed, state->start, state->end,
+   ret = ulist_add(>range_changed, state->start, state->end,
GFP_ATOMIC);
/* ENOMEM */
BUG_ON(ret < 0);
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 4551a5b4b8f5..270d03be290e 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -193,7 +193,7 @@ struct extent_changeset {
u64 bytes_changed;
 
/* Changed ranges */
-   struct ulist *range_changed;
+   struct ulist range_changed;
 };
 
 static inline void extent_set_compress_type(unsigned long *bio_flags,
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 971701328229..7cc2e2221f55 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -2828,7 +2828,7 @@ int btrfs_qgroup_reserve_data(struct inode *inode, u64 
start, u64 len)
return 0;
 
changeset.bytes_changed = 0;
-   changeset.range_changed = ulist_alloc(GFP_NOFS);
+   ulist_init(_changed);
ret = set_record_extent_bits(_I(inode)->io_tree, start,
start + len -1, EXTENT_QGROUP_RESERVED, );
trace_btrfs_qgroup_reserve_data(inode, start, len,
@@ -2840,17 +2840,17 @@ int btrfs_qgroup_reserve_data(struct inode *inode, u64 
start, u64 len)
if (ret < 0)
goto cleanup;
 
-   ulist_free(changeset.range_changed);
+   ulist_fini(_changed);
return ret;
 
 cleanup:
/* cleanup already reserved ranges */
ULIST_ITER_INIT();
-   while ((unode = ulist_next(changeset.range_changed, )))
+   while ((unode = ulist_next(_changed, )))
clear_extent_bit(_I(inode)->io_tree, unode->val,
 unode->aux, EXTENT_QGROUP_RESERVED, 0, 0, NULL,
 GFP_NOFS);
-   ulist_free(changeset.range_changed);
+   ulist_fini(_changed);
return ret;
 }
 
@@ -2862,10 +2862,7 @@ static int __btrfs_qgroup_release_data(struct inode 
*inode, u64 start, u64 len,
int ret;
 
changeset.bytes_changed = 0;
-   changeset.range_changed = ulist_alloc(GFP_NOFS);
-   if (!changeset.range_changed)
-   return -ENOMEM;
-
+   ulist_init(_changed);
ret = clear_record_extent_bits(_I(inode)->io_tree, start, 
start + len -1, EXTENT_QGROUP_RESERVED, );
if (ret < 0)
@@ -2878,7 +2875,7 @@ static int __btrfs_qgroup_release_data(struct inode 
*inode, u64 start, u64 len,
trace_btrfs_qgroup_release_data(inode, start, len,
changeset.bytes_changed, trace_op);
 out:
-   ulist_free(changeset.range_changed);
+   ulist_fini(_changed);
return ret;
 }
 
@@ -2976,22 +2973,19 @@ void btrfs_qgroup_check_reserved_leak(struct inode 
*inode)
int ret;
 
changeset.bytes_changed = 0;
-   changeset.range_changed = ulist_alloc(GFP_NOFS);
-   if (WARN_ON(!changeset.range_changed))
-   return;
-
+   ulist_init(_changed);
ret = clear_record_extent_bits(_I(inode)->io_tree, 0, (u64)-1,
EXTENT_QGROUP_RESERVED, );
 
WARN_ON(ret < 0);
if (WARN_ON(changeset.bytes_changed)) {
ULIST_ITER_INIT();
-   while ((unode = ulist_next(changeset.range_changed, ))) {
+   while ((unode = ulist_next(_changed, ))) {
btrfs_warn(BTRFS_I(inode)->root->fs_info,
"leaking qgroup reserved space, ino: %lu, 
start: %llu, end: %llu",
inode->i_ino, unode->val, unode->aux);
}
qgroup_free(BTRFS_I(inode)->root, changeset.bytes_changed);
}
-   ulist_free(changeset.range_changed);
+   ulist_fini(_changed);
 }
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo 

[PATCH 1/7] btrfs: qgroups: make __del_qgroup_relation static

2017-02-13 Thread David Sterba
Internal helper.

Signed-off-by: David Sterba 
---
 fs/btrfs/qgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 8496dbf3f38b..971701328229 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1223,7 +1223,7 @@ int btrfs_add_qgroup_relation(struct btrfs_trans_handle 
*trans,
return ret;
 }
 
-int __del_qgroup_relation(struct btrfs_trans_handle *trans,
+static int __del_qgroup_relation(struct btrfs_trans_handle *trans,
  struct btrfs_fs_info *fs_info, u64 src, u64 dst)
 {
struct btrfs_root *quota_root;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] More GFP_NOFS removals

2017-02-13 Thread David Sterba
A few more conversions to less strict allocation flags, calls originating from
an ioctl and with no chance of getting back with a lock already held. For 4.11.


The following changes since commit 2e94257a41fece589dc4bd737c70dc770e9040ef:

  btrfs: Better csum error message for data csum mismatch (2017-02-10 18:04:51 
+0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git dev/less-nofs

for you to fetch changes up to 8d310939a7d232fc71524fdf83f5a8fdbd5eb31c:

  btrfs: use GFP_KERNEL in btrfs_add/del_qgroup_relation (2017-02-13 13:11:29 
+0100)


David Sterba (4):
  btrfs: use GFP_KERNEL in create_snapshot
  btrfs: use GFP_KERNEL in btrfs_read_qgroup_config
  btrfs: use GFP_KERNEL in btrfs_quota_enable
  btrfs: use GFP_KERNEL in btrfs_add/del_qgroup_relation

 fs/btrfs/ioctl.c  | 4 ++--
 fs/btrfs/qgroup.c | 8 
 2 files changed, 6 insertions(+), 6 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] btrfs: use GFP_KERNEL in create_snapshot

2017-02-13 Thread David Sterba
We don't need to use GFP_NOFS here as this is called from ioctls an the
only lock held is the subvol_sem, which is of a high level and protects
creation/renames/deletion and is never held in the writeout paths.

Signed-off-by: David Sterba 
---
 fs/btrfs/ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 77f93a1e65c7..f65ace58dd2c 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -670,12 +670,12 @@ static int create_snapshot(struct btrfs_root *root, 
struct inode *dir,
if (!test_bit(BTRFS_ROOT_REF_COWS, >state))
return -EINVAL;
 
-   pending_snapshot = kzalloc(sizeof(*pending_snapshot), GFP_NOFS);
+   pending_snapshot = kzalloc(sizeof(*pending_snapshot), GFP_KERNEL);
if (!pending_snapshot)
return -ENOMEM;
 
pending_snapshot->root_item = kzalloc(sizeof(struct btrfs_root_item),
-   GFP_NOFS);
+   GFP_KERNEL);
pending_snapshot->path = btrfs_alloc_path();
if (!pending_snapshot->root_item || !pending_snapshot->path) {
ret = -ENOMEM;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] btrfs: use GFP_KERNEL in btrfs_read_qgroup_config

2017-02-13 Thread David Sterba
The qgroup config is read during mount, we do not have to use NOFS.

Signed-off-by: David Sterba 
---
 fs/btrfs/qgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 8496dbf3f38b..cdd0a16bf469 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -319,7 +319,7 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
if (!test_bit(BTRFS_FS_QUOTA_ENABLED, _info->flags))
return 0;
 
-   fs_info->qgroup_ulist = ulist_alloc(GFP_NOFS);
+   fs_info->qgroup_ulist = ulist_alloc(GFP_KERNEL);
if (!fs_info->qgroup_ulist) {
ret = -ENOMEM;
goto out;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] btrfs: use GFP_KERNEL in btrfs_add/del_qgroup_relation

2017-02-13 Thread David Sterba
Qgroup relations are added/deleted from ioctl, we hold the high level
qgroup lock, no deadlocks or recursion from the allocation possible
here.

Signed-off-by: David Sterba 
---
 fs/btrfs/qgroup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 4759fd46cfb5..d97353440a70 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1174,7 +1174,7 @@ int btrfs_add_qgroup_relation(struct btrfs_trans_handle 
*trans,
if (btrfs_qgroup_level(src) >= btrfs_qgroup_level(dst))
return -EINVAL;
 
-   tmp = ulist_alloc(GFP_NOFS);
+   tmp = ulist_alloc(GFP_KERNEL);
if (!tmp)
return -ENOMEM;
 
@@ -1234,7 +1234,7 @@ int __del_qgroup_relation(struct btrfs_trans_handle 
*trans,
int ret = 0;
int err;
 
-   tmp = ulist_alloc(GFP_NOFS);
+   tmp = ulist_alloc(GFP_KERNEL);
if (!tmp)
return -ENOMEM;
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] btrfs: use GFP_KERNEL in btrfs_quota_enable

2017-02-13 Thread David Sterba
We don't need to use GFP_NOFS here as this is called from ioctls an the
only lock held is the subvol_sem, which is of a high level and protects
creation/renames/deletion and is never held in the writeout paths.

Signed-off-by: David Sterba 
---
 fs/btrfs/qgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index cdd0a16bf469..4759fd46cfb5 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -876,7 +876,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans,
goto out;
}
 
-   fs_info->qgroup_ulist = ulist_alloc(GFP_NOFS);
+   fs_info->qgroup_ulist = ulist_alloc(GFP_KERNEL);
if (!fs_info->qgroup_ulist) {
ret = -ENOMEM;
goto out;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Help understanding autodefrag details

2017-02-13 Thread Austin S. Hemmelgarn

On 2017-02-10 09:21, Peter Zaitsev wrote:

Hi,

As I have been reading btrfs whitepaper  it speaks about autodefrag in very
generic terms - once random write in the file is detected it is put in the
queue to be defragmented.   Yet I could not find any specifics about this
process described anywhere.

My use case is databases and as such large files (100GB+)so my
questions are

- is my understanding what defrag queue is based on files not parts of
files which got fragmented correct ?
Autodefrag is location based within the file, not for the whole file.  I 
forget the exact size of the area around the write it will try to 
defrag, and the maximum size the write can be to trigger it, but the 
selection amounts to the following:
1. Is this write not likely to be followed by a write to the next 
logical address in the file? (I'm not certain exactly what heuristic is 
used to determine this).
2. Is this write small enough to likely cause fragmentation?  (This one 
is a simple threshold test, but I forget the threshold).
3. If both 1 and 2 are true, schedule the area containing the write to 
be defragmented.


- Is single random write is enough to schedule file for defrag or is there
some more elaborate math to consider file fragmented and needing
optimization  ?
I'm not sure.  It depends on whether or not the random write detection 
heuristic that is used has some handling for the first few writes, or 
needs some data from their position to determine the 'randomness' of 
future writes.


- Is this queue FIFO or is it priority queue where files in more need of
fragmentation jump in front (or is there some other mechanics ?
I think it's a FIFO queue, but there may be multiple threads servicing 
it, and I think it's smart enough to merge areas that overlap into a 
single operation.


- Will file to be attempted to be defragmented completely or does defrag
focuses on the most fragmented areas of the file first ?

AFAIK, autodefrag only defrags the region around where the write happened.


- Is there any way to view this defrag queue ?
Not that I know of, but in most cases it should be mostly empty, since 
the areas being handled are usually small enough that items get 
processed pretty quick.


- How are resources allocated to background autodefrag vs resources serving
foreground user load are controlled
AFAIK, there is no way to manually control this.  It would be kind of 
nice though if autodefrag ran as it's own thread.


- What are space requirements for defrag ? is it required for the space to
be available for complete file copy or is it not required ?
Pretty minimal space requirements.  Even regular defrag technically 
doesn't need enough space for the whole file.  Both work with whatever 
amount of space they have, but you obviously get better results with 
more free space.


- Can defrag handle file which is being constantly written to or is it
based on the concept what file should be idle for some time and when it is
going to be defragmented
In my experience, it handles files seeing constant writes just fine, 
even if you're saturating the disk bandwidth (it will just reduce your 
effective bandwidth a small amount).

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: BTRFS for OLTP Databases

2017-02-13 Thread Austin S. Hemmelgarn

On 2017-02-09 22:58, Andrei Borzenkov wrote:

07.02.2017 23:47, Austin S. Hemmelgarn пишет:
...

Sadly, freezefs (the generic interface based off of xfs_freeze) only
works for block device snapshots.  Filesystem level snapshots need the
application software to sync all it's data and then stop writing until
the snapshot is complete.



I expect databases to be using directio, otherwise we have problems even
without using snapshots. Is it still an issue with directio?
It is less of an issue, but it's still an issue because you can still 
call for snapshot creation in the middle of an application I/O request. 
In other words, the application wouldn't need to worry about syncing 
data, but it would need to worry about making sure it's not actually 
writing anything when the snapshot happens.


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Root volume (ID 5) in deleting state

2017-02-13 Thread Martin Mlynář

Hello,


I've currently run into strange problem with BTRFS. I'm using it as my 
daily driver as root FS. Nothing complicated, just few subvolumes and 
incremental backups using btrbk.


Now I've noticed that my btrfs root volume (absolute top, ID 5) is in 
"deleting" state. As I've done some testing and googling it seems that 
this should not be possible.


I've tried scrubbing and checking, but nothing changed. Volume is not 
being deleted in reality. It just sits there in this state.


Is there anything I can do to fix this?

# btrfs sub list -a /mnt/btrfs_root/
ID 1339 gen 262150 top level 5 path rootfs
ID 1340 gen 262101 top level 5 path .btrbk
ID 1987 gen 262149 top level 5 path no_backup
ID 4206 gen 255869 top level 1340 path /.btrbk/rootfs.20170121T1829
ID 4272 gen 257460 top level 1340 path /.btrbk/rootfs.20170123T0933
ID 4468 gen 259194 top level 1340 path /.btrbk/rootfs.20170131T1132
ID 4474 gen 260911 top level 1340 path /.btrbk/rootfs.20170207T0927
ID 4476 gen 261712 top level 1340 path /.btrbk/rootfs.20170211T
ID 4477 gen 261970 top level 1340 path /.btrbk/rootfs.20170212T1331
ID 4478 gen 262102 top level 1340 path /.btrbk/rootfs.20170213T

# btrfs sub list -ad /mnt/btrfs_root/
ID 5 gen 257505 top level 0 path /DELETED

# mount | grep btr
/dev/mapper/vg0-btrfsroot on / type btrfs 
(rw,noatime,nodatasum,nodatacow,ssd,discard,space_cache,subvolid=1339,subvol=/rootfs)
/dev/mapper/vg0-btrfsroot on /mnt/btrfs_root type btrfs 
(rw,noatime,nodatasum,nodatacow,ssd,discard,space_cache,subvolid=5,subvol=/)


# uname -a
Linux interceptor 4.9.6-1-ARCH #1 SMP PREEMPT Thu Jan 26 09:22:26 CET 
2017 x86_64 GNU/Linux


# btrfs fi show  /
Label: none  uuid: 859dec5c-850c-4660-ad99-bc87456aa309
Total devices 1 FS bytes used 132.89GiB
devid1 size 200.00GiB used 200.00GiB path /dev/mapper/vg0-btrfsroot


Thank you for your time,


Best regards

--

Martin Mlynář

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] btrfs: make space cache inode readahead failure nonfatal

2017-02-13 Thread David Sterba
We do a readahead of the free space cache inode to speed things up but
the failure is not fatal, like in other readahead cases. Proper reads
would need to happen anyway and any errors would be caught there.

Signed-off-by: David Sterba 
---
 fs/btrfs/free-space-cache.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 437580e84d9d..e96e981ef01e 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -286,14 +286,14 @@ int btrfs_truncate_free_space_cache(struct btrfs_root 
*root,
return ret;
 }
 
-static int readahead_cache(struct inode *inode)
+static void readahead_cache(struct inode *inode)
 {
struct file_ra_state *ra;
unsigned long last_index;
 
ra = kzalloc(sizeof(*ra), GFP_NOFS);
if (!ra)
-   return -ENOMEM;
+   return;
 
file_ra_state_init(ra, inode->i_mapping);
last_index = (i_size_read(inode) - 1) >> PAGE_SHIFT;
@@ -301,8 +301,6 @@ static int readahead_cache(struct inode *inode)
page_cache_sync_readahead(inode->i_mapping, ra, NULL, 0, last_index);
 
kfree(ra);
-
-   return 0;
 }
 
 static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
@@ -730,9 +728,7 @@ static int __load_free_space_cache(struct btrfs_root *root, 
struct inode *inode,
if (ret)
return ret;
 
-   ret = readahead_cache(inode);
-   if (ret)
-   goto out;
+   readahead_cache(inode);
 
ret = io_ctl_prepare_pages(_ctl, inode, 1);
if (ret)
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/29] btrfs: remove unused parameter from clone_copy_inline_extent

2017-02-13 Thread David Sterba
Never used.

Signed-off-by: David Sterba 
---
 fs/btrfs/ioctl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 1f13f8416d29..b9e6f8a4f760 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3383,8 +3383,7 @@ static void clone_update_extent_map(struct inode *inode,
  * data into the destination inode's inline extent if the later is greater then
  * the former.
  */
-static int clone_copy_inline_extent(struct inode *src,
-   struct inode *dst,
+static int clone_copy_inline_extent(struct inode *dst,
struct btrfs_trans_handle *trans,
struct btrfs_path *path,
struct btrfs_key *new_key,
@@ -3763,7 +3762,7 @@ static int btrfs_clone(struct inode *src, struct inode 
*inode,
size -= skip + trim;
datal -= skip + trim;
 
-   ret = clone_copy_inline_extent(src, inode,
+   ret = clone_copy_inline_extent(inode,
   trans, path,
   _key,
   drop_start,
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 29/29] btrfs: remove unused parameter from adjust_slots_upwards

2017-02-13 Thread David Sterba
Never used.

Signed-off-by: David Sterba 
---
 fs/btrfs/qgroup.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 6d106e623604..4ef513a392a7 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1589,8 +1589,7 @@ int btrfs_qgroup_trace_leaf_items(struct 
btrfs_trans_handle *trans,
  * If we increment the root nodes slot counter past the number of
  * elements, 1 is returned to signal completion of the search.
  */
-static int adjust_slots_upwards(struct btrfs_root *root,
-   struct btrfs_path *path, int root_level)
+static int adjust_slots_upwards(struct btrfs_path *path, int root_level)
 {
int level = 0;
int nr, slot;
@@ -1731,7 +1730,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle 
*trans,
goto out;
 
/* Nonzero return here means we completed our search */
-   ret = adjust_slots_upwards(root, path, root_level);
+   ret = adjust_slots_upwards(path, root_level);
if (ret)
break;
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 26/29] btrfs: remove unused parameter from __add_inode_ref

2017-02-13 Thread David Sterba
Unused since the helper has been split, eb used in the caller.

Signed-off-by: David Sterba 
---
 fs/btrfs/tree-log.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 62dd138018b5..3806853cde08 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -994,7 +994,6 @@ static inline int __add_inode_ref(struct btrfs_trans_handle 
*trans,
  struct btrfs_root *log_root,
  struct btrfs_inode *dir,
  struct btrfs_inode *inode,
- struct extent_buffer *eb,
  u64 inode_objectid, u64 parent_objectid,
  u64 ref_index, char *name, int namelen,
  int *search_done)
@@ -1310,7 +1309,7 @@ static noinline int add_inode_ref(struct 
btrfs_trans_handle *trans,
if (!search_done) {
ret = __add_inode_ref(trans, root, path, log,
  BTRFS_I(dir),
- BTRFS_I(inode), eb,
+ BTRFS_I(inode),
  inode_objectid,
  parent_objectid,
  ref_index, name, namelen,
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/29] btrfs: remove unused parameter from tree_move_down

2017-02-13 Thread David Sterba
Never needed.

Signed-off-by: David Sterba 
---
 fs/btrfs/ctree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index b98e90a3eee7..a981c2acd6fa 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -5241,7 +5241,7 @@ int btrfs_search_forward(struct btrfs_root *root, struct 
btrfs_key *min_key,
 
 static int tree_move_down(struct btrfs_fs_info *fs_info,
   struct btrfs_path *path,
-  int *level, int root_level)
+  int *level)
 {
struct extent_buffer *eb;
 
@@ -5299,7 +5299,7 @@ static int tree_advance(struct btrfs_fs_info *fs_info,
ret = tree_move_next_or_upnext(fs_info, path, level,
   root_level);
} else {
-   ret = tree_move_down(fs_info, path, level, root_level);
+   ret = tree_move_down(fs_info, path, level);
}
if (ret >= 0) {
if (*level == 0)
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 28/29] btrfs: remove unused parameters from __btrfs_write_out_cache

2017-02-13 Thread David Sterba
Both unused after the call to update_cache_item has been moved to
__btrfs_wait_cache_io.

Signed-off-by: David Sterba 
---
 fs/btrfs/free-space-cache.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 0d02599d22bc..c169acef2a23 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1224,8 +1224,6 @@ int btrfs_wait_cache_io(struct btrfs_trans_handle *trans,
  * @ctl - the free space cache we are going to write out
  * @block_group - the block_group for this cache if it belongs to a block_group
  * @trans - the trans handle
- * @path - the path to use
- * @offset - the offset for the key we'll insert
  *
  * This function writes out a free space cache struct to disk for quick 
recovery
  * on mount.  This will return 0 if it was successful in writing the cache out,
@@ -1235,8 +1233,7 @@ static int __btrfs_write_out_cache(struct btrfs_root 
*root, struct inode *inode,
   struct btrfs_free_space_ctl *ctl,
   struct btrfs_block_group_cache *block_group,
   struct btrfs_io_ctl *io_ctl,
-  struct btrfs_trans_handle *trans,
-  struct btrfs_path *path, u64 offset)
+  struct btrfs_trans_handle *trans)
 {
struct btrfs_fs_info *fs_info = root->fs_info;
struct extent_state *cached_state = NULL;
@@ -1394,8 +1391,7 @@ int btrfs_write_out_cache(struct btrfs_fs_info *fs_info,
return 0;
 
ret = __btrfs_write_out_cache(root, inode, ctl, block_group,
- _group->io_ctl, trans,
- path, block_group->key.objectid);
+ _group->io_ctl, trans);
if (ret) {
 #ifdef DEBUG
btrfs_err(fs_info,
@@ -3542,8 +3538,7 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root,
return 0;
 
memset(_ctl, 0, sizeof(io_ctl));
-   ret = __btrfs_write_out_cache(root, inode, ctl, NULL, _ctl,
- trans, path, 0);
+   ret = __btrfs_write_out_cache(root, inode, ctl, NULL, _ctl, trans);
if (!ret) {
/*
 * At this point writepages() didn't error out, so our metadata
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/29] btrfs: remove unused parameter from btrfs_check_super_valid

2017-02-13 Thread David Sterba
None of the checks need to know the RO/RW status.

Signed-off-by: David Sterba 
---
 fs/btrfs/disk-io.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 441a62cd0351..2b06f557c176 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -64,8 +64,7 @@
 static const struct extent_io_ops btree_extent_io_ops;
 static void end_workqueue_fn(struct btrfs_work *work);
 static void free_fs_root(struct btrfs_root *root);
-static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
-   int read_only);
+static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info);
 static void btrfs_destroy_ordered_extents(struct btrfs_root *root);
 static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
  struct btrfs_fs_info *fs_info);
@@ -2801,7 +2800,7 @@ int open_ctree(struct super_block *sb,
 
memcpy(fs_info->fsid, fs_info->super_copy->fsid, BTRFS_FSID_SIZE);
 
-   ret = btrfs_check_super_valid(fs_info, sb->s_flags & MS_RDONLY);
+   ret = btrfs_check_super_valid(fs_info);
if (ret) {
btrfs_err(fs_info, "superblock contains fatal errors");
err = -EINVAL;
@@ -4115,8 +4114,7 @@ int btrfs_read_buffer(struct extent_buffer *buf, u64 
parent_transid)
return btree_read_extent_buffer_pages(fs_info, buf, parent_transid);
 }
 
-static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
- int read_only)
+static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info)
 {
struct btrfs_super_block *sb = fs_info->super_copy;
u64 nodesize = btrfs_super_nodesize(sb);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 27/29] btrfs: remove unused parameter from cleanup_write_cache_enospc

2017-02-13 Thread David Sterba
bitmap_list is unused since the io_ctl framework.

Signed-off-by: David Sterba 
---
 fs/btrfs/free-space-cache.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 437580e84d9d..0d02599d22bc 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1128,8 +1128,7 @@ cleanup_bitmap_list(struct list_head *bitmap_list)
 static void noinline_for_stack
 cleanup_write_cache_enospc(struct inode *inode,
   struct btrfs_io_ctl *io_ctl,
-  struct extent_state **cached_state,
-  struct list_head *bitmap_list)
+  struct extent_state **cached_state)
 {
io_ctl_drop_pages(io_ctl);
unlock_extent_cached(_I(inode)->io_tree, 0,
@@ -1365,7 +1364,7 @@ static int __btrfs_write_out_cache(struct btrfs_root 
*root, struct inode *inode,
mutex_unlock(>cache_writeout_mutex);
 
 out_nospc:
-   cleanup_write_cache_enospc(inode, io_ctl, _state, _list);
+   cleanup_write_cache_enospc(inode, io_ctl, _state);
 
if (block_group && (block_group->flags & BTRFS_BLOCK_GROUP_DATA))
up_write(_group->data_rwsem);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/29] btrfs: remove unused parameter from btrfs_prepare_extent_commit

2017-02-13 Thread David Sterba
Added but never used.

Signed-off-by: David Sterba 
---
 fs/btrfs/ctree.h   | 3 +--
 fs/btrfs/extent-tree.c | 3 +--
 fs/btrfs/transaction.c | 2 +-
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 0f5b85772023..e7dbda3dd3b8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2630,8 +2630,7 @@ int btrfs_free_reserved_extent(struct btrfs_fs_info 
*fs_info,
   u64 start, u64 len, int delalloc);
 int btrfs_free_and_pin_reserved_extent(struct btrfs_fs_info *fs_info,
   u64 start, u64 len);
-void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
-struct btrfs_fs_info *fs_info);
+void btrfs_prepare_extent_commit(struct btrfs_fs_info *fs_info);
 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
   struct btrfs_fs_info *fs_info);
 int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index b33e2c8325c8..2500e3df3250 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6558,8 +6558,7 @@ static int btrfs_free_reserved_bytes(struct 
btrfs_block_group_cache *cache,
spin_unlock(_info->lock);
return ret;
 }
-void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
-   struct btrfs_fs_info *fs_info)
+void btrfs_prepare_extent_commit(struct btrfs_fs_info *fs_info)
 {
struct btrfs_caching_control *next;
struct btrfs_caching_control *caching_ctl;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 7d1d71259cd0..8bfb5e2c31f9 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -2211,7 +2211,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle 
*trans)
goto scrub_continue;
}
 
-   btrfs_prepare_extent_commit(trans, fs_info);
+   btrfs_prepare_extent_commit(fs_info);
 
cur_trans = fs_info->running_transaction;
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/29] btrfs: remove unused parameter from add_pending_csums

2017-02-13 Thread David Sterba
Never used.

Signed-off-by: David Sterba 
---
 fs/btrfs/inode.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 7ed693294498..3ac7474f921d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1961,8 +1961,7 @@ static int btrfs_submit_bio_hook(struct inode *inode, 
struct bio *bio,
  * at IO completion time based on sums calculated at bio submission time.
  */
 static noinline int add_pending_csums(struct btrfs_trans_handle *trans,
-struct inode *inode, u64 file_offset,
-struct list_head *list)
+struct inode *inode, struct list_head *list)
 {
struct btrfs_ordered_sum *sum;
 
@@ -2956,8 +2955,7 @@ static int btrfs_finish_ordered_io(struct 
btrfs_ordered_extent *ordered_extent)
goto out_unlock;
}
 
-   add_pending_csums(trans, inode, ordered_extent->file_offset,
- _extent->list);
+   add_pending_csums(trans, inode, _extent->list);
 
btrfs_ordered_update_i_size(inode, 0, ordered_extent);
ret = btrfs_update_inode_fallback(trans, root, inode);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/29] btrfs: remove unused parameter from create_snapshot

2017-02-13 Thread David Sterba
The name parameters have never been used, as the name is passed via the
dentry.

Signed-off-by: David Sterba 
---
 fs/btrfs/ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index e8c7c313c113..91188a2ac5a1 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -656,7 +656,7 @@ static void btrfs_wait_for_no_snapshoting_writes(struct 
btrfs_root *root)
 }
 
 static int create_snapshot(struct btrfs_root *root, struct inode *dir,
-  struct dentry *dentry, char *name, int namelen,
+  struct dentry *dentry,
   u64 *async_transid, bool readonly,
   struct btrfs_qgroup_inherit *inherit)
 {
@@ -871,7 +871,7 @@ static noinline int btrfs_mksubvol(const struct path 
*parent,
goto out_up_read;
 
if (snap_src) {
-   error = create_snapshot(snap_src, dir, dentry, name, namelen,
+   error = create_snapshot(snap_src, dir, dentry,
async_transid, readonly, inherit);
} else {
error = create_subvol(dir, dentry, name, namelen,
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/29] btrfs: remove unused parameter from btrfs_fill_super

2017-02-13 Thread David Sterba
Never used for anything meaningful since we have our own superblock
filler.

Signed-off-by: David Sterba 
---
 fs/btrfs/super.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 93ed29c2a38b..da687dc79cce 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1114,7 +1114,7 @@ static int get_default_subvol_objectid(struct 
btrfs_fs_info *fs_info, u64 *objec
 
 static int btrfs_fill_super(struct super_block *sb,
struct btrfs_fs_devices *fs_devices,
-   void *data, int silent)
+   void *data)
 {
struct inode *inode;
struct btrfs_fs_info *fs_info = btrfs_sb(sb);
@@ -1611,8 +1611,7 @@ static struct dentry *btrfs_mount(struct file_system_type 
*fs_type, int flags,
} else {
snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
btrfs_sb(s)->bdev_holder = fs_type;
-   error = btrfs_fill_super(s, fs_devices, data,
-flags & MS_SILENT ? 1 : 0);
+   error = btrfs_fill_super(s, fs_devices, data);
}
if (error) {
deactivate_locked_super(s);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/29] btrfs: remove unused parameters from btrfs_cmp_data

2017-02-13 Thread David Sterba
After the page locking has been reworked, we get all pages prepared via
cmp_pages.

Signed-off-by: David Sterba 
---
 fs/btrfs/ioctl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 91188a2ac5a1..1f13f8416d29 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3053,8 +3053,7 @@ static int btrfs_cmp_data_prepare(struct inode *src, u64 
loff,
return 0;
 }
 
-static int btrfs_cmp_data(struct inode *src, u64 loff, struct inode *dst,
- u64 dst_loff, u64 len, struct cmp_pages *cmp)
+static int btrfs_cmp_data(u64 len, struct cmp_pages *cmp)
 {
int ret = 0;
int i;
@@ -3221,7 +3220,7 @@ static int btrfs_extent_same(struct inode *src, u64 loff, 
u64 olen,
}
 
/* pass original length for comparison so we stay within i_size */
-   ret = btrfs_cmp_data(src, loff, dst, dst_loff, olen, );
+   ret = btrfs_cmp_data(olen, );
if (ret == 0)
ret = btrfs_clone(src, dst, loff, olen, len, dst_loff, 1);
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 23/29] btrfs: remove unused parameter from __add_inline_refs

2017-02-13 Thread David Sterba
Never used.

Signed-off-by: David Sterba 
---
 fs/btrfs/backref.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index db706595e631..7699e16784d3 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -956,8 +956,7 @@ static int __add_delayed_refs(struct btrfs_delayed_ref_head 
*head, u64 seq,
 /*
  * add all inline backrefs for bytenr to the list
  */
-static int __add_inline_refs(struct btrfs_fs_info *fs_info,
-struct btrfs_path *path, u64 bytenr,
+static int __add_inline_refs(struct btrfs_path *path, u64 bytenr,
 int *info_level, struct list_head *prefs,
 struct ref_root *ref_tree,
 u64 *total_refs, u64 inum)
@@ -1354,7 +1353,7 @@ static int find_parent_nodes(struct btrfs_trans_handle 
*trans,
if (key.objectid == bytenr &&
(key.type == BTRFS_EXTENT_ITEM_KEY ||
 key.type == BTRFS_METADATA_ITEM_KEY)) {
-   ret = __add_inline_refs(fs_info, path, bytenr,
+   ret = __add_inline_refs(path, bytenr,
_level, ,
ref_tree, _refs,
inum);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/29] btrfs: remove unused parameter from submit_extent_page

2017-02-13 Thread David Sterba
This used to hold number of maximum pages to allocate, but this is now
limited by BIO_MAX_PAGES.

Signed-off-by: David Sterba 
---
 fs/btrfs/extent_io.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 9df6ed30de00..00f3be5c4f2d 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2759,7 +2759,6 @@ static int submit_extent_page(int op, int op_flags, 
struct extent_io_tree *tree,
  size_t size, unsigned long offset,
  struct block_device *bdev,
  struct bio **bio_ret,
- unsigned long max_pages,
  bio_end_io_t end_io_func,
  int mirror_num,
  unsigned long prev_bio_flags,
@@ -3063,7 +3062,7 @@ static int __do_readpage(struct extent_io_tree *tree,
pnr -= page->index;
ret = submit_extent_page(REQ_OP_READ, read_flags, tree, NULL,
 page, sector, disk_io_size, pg_offset,
-bdev, bio, pnr,
+bdev, bio,
 end_bio_extent_readpage, mirror_num,
 *bio_flags,
 this_bio_flag,
@@ -3434,7 +3433,7 @@ static noinline_for_stack int 
__extent_writepage_io(struct inode *inode,
 
ret = submit_extent_page(REQ_OP_WRITE, write_flags, tree, wbc,
 page, sector, iosize, pg_offset,
-bdev, >bio, max_nr,
+bdev, >bio,
 end_bio_extent_writepage,
 0, 0, 0, false);
if (ret) {
@@ -3751,7 +3750,7 @@ static noinline_for_stack int write_one_eb(struct 
extent_buffer *eb,
set_page_writeback(p);
ret = submit_extent_page(REQ_OP_WRITE, write_flags, tree, wbc,
 p, offset >> 9, PAGE_SIZE, 0, bdev,
->bio, -1,
+>bio,
 end_bio_extent_buffer_writepage,
 0, epd->bio_flags, bio_flags, false);
epd->bio_flags = bio_flags;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 22/29] btrfs: remove unused parameters from scrub_setup_wr_ctx

2017-02-13 Thread David Sterba
Never used.

Signed-off-by: David Sterba 
---
 fs/btrfs/scrub.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 9a94670536a6..f7dffacf61fa 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -282,9 +282,7 @@ static void scrub_remap_extent(struct btrfs_fs_info 
*fs_info,
   u64 *extent_physical,
   struct btrfs_device **extent_dev,
   int *extent_mirror_num);
-static int scrub_setup_wr_ctx(struct scrub_ctx *sctx,
- struct scrub_wr_ctx *wr_ctx,
- struct btrfs_fs_info *fs_info,
+static int scrub_setup_wr_ctx(struct scrub_wr_ctx *wr_ctx,
  struct btrfs_device *dev,
  int is_dev_replace);
 static void scrub_free_wr_ctx(struct scrub_wr_ctx *wr_ctx);
@@ -501,7 +499,7 @@ struct scrub_ctx *scrub_setup_ctx(struct btrfs_device *dev, 
int is_dev_replace)
spin_lock_init(>stat_lock);
init_waitqueue_head(>list_wait);
 
-   ret = scrub_setup_wr_ctx(sctx, >wr_ctx, fs_info,
+   ret = scrub_setup_wr_ctx(>wr_ctx,
 fs_info->dev_replace.tgtdev, is_dev_replace);
if (ret) {
scrub_free_ctx(sctx);
@@ -4084,9 +4082,7 @@ static void scrub_remap_extent(struct btrfs_fs_info 
*fs_info,
btrfs_put_bbio(bbio);
 }
 
-static int scrub_setup_wr_ctx(struct scrub_ctx *sctx,
- struct scrub_wr_ctx *wr_ctx,
- struct btrfs_fs_info *fs_info,
+static int scrub_setup_wr_ctx(struct scrub_wr_ctx *wr_ctx,
  struct btrfs_device *dev,
  int is_dev_replace)
 {
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/29] btrfs: remove unused parameter from tree_move_next_or_upnext

2017-02-13 Thread David Sterba
Not needed.

Signed-off-by: David Sterba 
---
 fs/btrfs/ctree.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index a981c2acd6fa..1192bc7d2ee7 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -5256,8 +5256,7 @@ static int tree_move_down(struct btrfs_fs_info *fs_info,
return 0;
 }
 
-static int tree_move_next_or_upnext(struct btrfs_fs_info *fs_info,
-   struct btrfs_path *path,
+static int tree_move_next_or_upnext(struct btrfs_path *path,
int *level, int root_level)
 {
int ret = 0;
@@ -5296,8 +5295,7 @@ static int tree_advance(struct btrfs_fs_info *fs_info,
int ret;
 
if (*level == 0 || !allow_down) {
-   ret = tree_move_next_or_upnext(fs_info, path, level,
-  root_level);
+   ret = tree_move_next_or_upnext(path, level, root_level);
} else {
ret = tree_move_down(fs_info, path, level);
}
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/29] btrfs: remove unused parameter from __push_leaf_right

2017-02-13 Thread David Sterba
Unused since long ago.

Signed-off-by: David Sterba 
---
 fs/btrfs/ctree.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 4c5d7c40c8bf..2283f92b5484 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -3595,8 +3595,7 @@ noinline int btrfs_leaf_free_space(struct btrfs_fs_info 
*fs_info,
  * min slot controls the lowest index we're willing to push to the
  * right.  We'll push up to and including min_slot, but no lower
  */
-static noinline int __push_leaf_right(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
+static noinline int __push_leaf_right(struct btrfs_fs_info *fs_info,
  struct btrfs_path *path,
  int data_size, int empty,
  struct extent_buffer *right,
@@ -3810,7 +3809,7 @@ static int push_leaf_right(struct btrfs_trans_handle 
*trans, struct btrfs_root
return 0;
}
 
-   return __push_leaf_right(trans, fs_info, path, min_data_size, empty,
+   return __push_leaf_right(fs_info, path, min_data_size, empty,
right, free_space, left_nritems, min_slot);
 out_unlock:
btrfs_tree_unlock(right);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/29] btrfs: remove unused parameter from update_nr_written

2017-02-13 Thread David Sterba
The logic has been updated in "Btrfs: make mapping->writeback_index
point to the last written page" (a91326679f2a0a4c2) and page is not
needed anymore.

Signed-off-by: David Sterba 
---
 fs/btrfs/extent_io.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 00f3be5c4f2d..f683fa5a4b91 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3203,7 +3203,7 @@ int extent_read_full_page(struct extent_io_tree *tree, 
struct page *page,
return ret;
 }
 
-static void update_nr_written(struct page *page, struct writeback_control *wbc,
+static void update_nr_written(struct writeback_control *wbc,
  unsigned long nr_written)
 {
wbc->nr_to_write -= nr_written;
@@ -3341,7 +3341,7 @@ static noinline_for_stack int 
__extent_writepage_io(struct inode *inode,
else
redirty_page_for_writepage(wbc, page);
 
-   update_nr_written(page, wbc, nr_written);
+   update_nr_written(wbc, nr_written);
unlock_page(page);
return 1;
}
@@ -3351,7 +3351,7 @@ static noinline_for_stack int 
__extent_writepage_io(struct inode *inode,
 * we don't want to touch the inode after unlocking the page,
 * so we update the mapping writeback index now
 */
-   update_nr_written(page, wbc, nr_written + 1);
+   update_nr_written(wbc, nr_written + 1);
 
end = page_end;
if (i_size <= start) {
@@ -3764,7 +3764,7 @@ static noinline_for_stack int write_one_eb(struct 
extent_buffer *eb,
break;
}
offset += PAGE_SIZE;
-   update_nr_written(p, wbc, 1);
+   update_nr_written(wbc, 1);
unlock_page(p);
}
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/29] btrfs: remove unused parameter from extent_write_cache_pages

2017-02-13 Thread David Sterba
The 'tree' was used to call locking hook that does not exist anymore.

Signed-off-by: David Sterba 
---
 fs/btrfs/extent_io.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index f683fa5a4b91..22a2f2fa62c7 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3916,8 +3916,7 @@ int btree_write_cache_pages(struct address_space *mapping,
  * WB_SYNC_ALL then we were called for data integrity and we must wait for
  * existing IO to complete.
  */
-static int extent_write_cache_pages(struct extent_io_tree *tree,
-struct address_space *mapping,
+static int extent_write_cache_pages(struct address_space *mapping,
 struct writeback_control *wbc,
 writepage_t writepage, void *data,
 void (*flush_fn)(void *))
@@ -4158,8 +4157,7 @@ int extent_writepages(struct extent_io_tree *tree,
.bio_flags = 0,
};
 
-   ret = extent_write_cache_pages(tree, mapping, wbc,
-  __extent_writepage, ,
+   ret = extent_write_cache_pages(mapping, wbc, __extent_writepage, ,
   flush_write_bio);
flush_epd_write_bio();
return ret;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/29] btrfs: remove unused parameter from split_item

2017-02-13 Thread David Sterba
Never used.

Signed-off-by: David Sterba 
---
 fs/btrfs/ctree.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index d509dafdb20c..4c5d7c40c8bf 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -4413,8 +4413,7 @@ static noinline int setup_leaf_for_split(struct 
btrfs_trans_handle *trans,
return ret;
 }
 
-static noinline int split_item(struct btrfs_trans_handle *trans,
-  struct btrfs_fs_info *fs_info,
+static noinline int split_item(struct btrfs_fs_info *fs_info,
   struct btrfs_path *path,
   const struct btrfs_key *new_key,
   unsigned long split_offset)
@@ -4511,7 +4510,7 @@ int btrfs_split_item(struct btrfs_trans_handle *trans,
if (ret)
return ret;
 
-   ret = split_item(trans, root->fs_info, path, new_key, split_offset);
+   ret = split_item(root->fs_info, path, new_key, split_offset);
return ret;
 }
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/29] btrfs: remove unused parameter from __push_leaf_left

2017-02-13 Thread David Sterba
Unused since long ago.

Signed-off-by: David Sterba 
---
 fs/btrfs/ctree.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 2283f92b5484..b98e90a3eee7 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -3825,8 +3825,7 @@ static int push_leaf_right(struct btrfs_trans_handle 
*trans, struct btrfs_root
  * item at 'max_slot' won't be touched.  Use (u32)-1 to make us do all the
  * items
  */
-static noinline int __push_leaf_left(struct btrfs_trans_handle *trans,
-struct btrfs_fs_info *fs_info,
+static noinline int __push_leaf_left(struct btrfs_fs_info *fs_info,
 struct btrfs_path *path, int data_size,
 int empty, struct extent_buffer *left,
 int free_space, u32 right_nritems,
@@ -4035,7 +4034,7 @@ static int push_leaf_left(struct btrfs_trans_handle 
*trans, struct btrfs_root
goto out;
}
 
-   return __push_leaf_left(trans, fs_info, path, min_data_size,
+   return __push_leaf_left(fs_info, path, min_data_size,
   empty, left, free_space, right_nritems,
   max_slot);
 out:
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/29] btrfs: remove unused parameter from init_first_rw_device

2017-02-13 Thread David Sterba
The 'device' used to be added in that function, but now it's done by the
caller.

Signed-off-by: David Sterba 
---
 fs/btrfs/volumes.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index d234625e4e02..1fac98728814 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -134,8 +134,7 @@ const int btrfs_raid_mindev_error[BTRFS_NR_RAID_TYPES] = {
 };
 
 static int init_first_rw_device(struct btrfs_trans_handle *trans,
-   struct btrfs_fs_info *fs_info,
-   struct btrfs_device *device);
+   struct btrfs_fs_info *fs_info);
 static int btrfs_relocate_sys_chunks(struct btrfs_fs_info *fs_info);
 static void __btrfs_reset_dev_stats(struct btrfs_device *dev);
 static void btrfs_dev_stat_print_on_error(struct btrfs_device *dev);
@@ -2440,7 +2439,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, 
char *device_path)
 
if (seeding_dev) {
mutex_lock(_info->chunk_mutex);
-   ret = init_first_rw_device(trans, fs_info, device);
+   ret = init_first_rw_device(trans, fs_info);
mutex_unlock(_info->chunk_mutex);
if (ret) {
btrfs_abort_transaction(trans, ret);
@@ -5012,8 +5011,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
 }
 
 static noinline int init_first_rw_device(struct btrfs_trans_handle *trans,
-struct btrfs_fs_info *fs_info,
-struct btrfs_device *device)
+struct btrfs_fs_info *fs_info)
 {
struct btrfs_root *extent_root = fs_info->extent_root;
u64 chunk_offset;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/29] btrfs: remove unused parameter from btrfs_subvolume_release_metadata

2017-02-13 Thread David Sterba
Unused since qgroup refactoring that split data and metadata accounting,
the btrfs_qgroup_free helper.

Signed-off-by: David Sterba 
---
 fs/btrfs/ctree.h   |  3 +--
 fs/btrfs/extent-tree.c |  3 +--
 fs/btrfs/ioctl.c   | 11 ---
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 1692ebb05955..0f5b85772023 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2703,8 +2703,7 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root 
*root,
 int nitems,
 u64 *qgroup_reserved, bool use_global_rsv);
 void btrfs_subvolume_release_metadata(struct btrfs_fs_info *fs_info,
- struct btrfs_block_rsv *rsv,
- u64 qgroup_reserved);
+ struct btrfs_block_rsv *rsv);
 int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes);
 void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes);
 int btrfs_delalloc_reserve_space(struct inode *inode, u64 start, u64 len);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 9e8d6c2e7a64..b33e2c8325c8 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5826,8 +5826,7 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root 
*root,
 }
 
 void btrfs_subvolume_release_metadata(struct btrfs_fs_info *fs_info,
- struct btrfs_block_rsv *rsv,
- u64 qgroup_reserved)
+ struct btrfs_block_rsv *rsv)
 {
btrfs_block_rsv_release(fs_info, rsv, (u64)-1);
 }
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 77f93a1e65c7..e8c7c313c113 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -487,8 +487,7 @@ static noinline int create_subvol(struct inode *dir,
trans = btrfs_start_transaction(root, 0);
if (IS_ERR(trans)) {
ret = PTR_ERR(trans);
-   btrfs_subvolume_release_metadata(fs_info, _rsv,
-qgroup_reserved);
+   btrfs_subvolume_release_metadata(fs_info, _rsv);
goto fail_free;
}
trans->block_rsv = _rsv;
@@ -613,7 +612,7 @@ static noinline int create_subvol(struct inode *dir,
kfree(root_item);
trans->block_rsv = NULL;
trans->bytes_reserved = 0;
-   btrfs_subvolume_release_metadata(fs_info, _rsv, qgroup_reserved);
+   btrfs_subvolume_release_metadata(fs_info, _rsv);
 
if (async_transid) {
*async_transid = trans->transid;
@@ -753,9 +752,7 @@ static int create_snapshot(struct btrfs_root *root, struct 
inode *dir,
d_instantiate(dentry, inode);
ret = 0;
 fail:
-   btrfs_subvolume_release_metadata(fs_info,
-_snapshot->block_rsv,
-pending_snapshot->qgroup_reserved);
+   btrfs_subvolume_release_metadata(fs_info, _snapshot->block_rsv);
 dec_and_free:
if (atomic_dec_and_test(>will_be_snapshoted))
wake_up_atomic_t(>will_be_snapshoted);
@@ -2555,7 +2552,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file 
*file,
err = ret;
inode->i_flags |= S_DEAD;
 out_release:
-   btrfs_subvolume_release_metadata(fs_info, _rsv, qgroup_reserved);
+   btrfs_subvolume_release_metadata(fs_info, _rsv);
 out_up_write:
up_write(_info->subvol_sem);
if (err) {
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/29] btrfs: merge two superblock writing helpers

2017-02-13 Thread David Sterba
write_all_supers and write_ctree_super are almost equal, the parameter
'trans' is unused so we can drop it and have just one helper.

Signed-off-by: David Sterba 
---
 fs/btrfs/disk-io.c | 8 +---
 fs/btrfs/disk-io.h | 3 +--
 fs/btrfs/transaction.c | 2 +-
 fs/btrfs/tree-log.c| 2 +-
 4 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 43e71457c193..441a62cd0351 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3695,7 +3695,7 @@ int btrfs_calc_num_tolerated_disk_barrier_failures(
return num_tolerated_disk_barrier_failures;
 }
 
-static int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors)
+int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors)
 {
struct list_head *head;
struct btrfs_device *dev;
@@ -3789,12 +3789,6 @@ static int write_all_supers(struct btrfs_fs_info 
*fs_info, int max_mirrors)
return 0;
 }
 
-int write_ctree_super(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info, int max_mirrors)
-{
-   return write_all_supers(fs_info, max_mirrors);
-}
-
 /* Drop a fs root from the radix tree and free it. */
 void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
  struct btrfs_root *root)
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 1864e7ce9c70..0be2d4fe705b 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -57,8 +57,7 @@ int open_ctree(struct super_block *sb,
   struct btrfs_fs_devices *fs_devices,
   char *options);
 void close_ctree(struct btrfs_fs_info *fs_info);
-int write_ctree_super(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info, int max_mirrors);
+int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors);
 struct buffer_head *btrfs_read_dev_super(struct block_device *bdev);
 int btrfs_read_dev_one_super(struct block_device *bdev, int copy_num,
struct buffer_head **bh_ret);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 48aabb367f73..7d1d71259cd0 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -2261,7 +2261,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle 
*trans)
goto scrub_continue;
}
 
-   ret = write_ctree_super(trans, fs_info, 0);
+   ret = write_all_supers(fs_info, 0);
if (ret) {
mutex_unlock(_info->tree_log_mutex);
goto scrub_continue;
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index cea93ba1f099..62dd138018b5 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2961,7 +2961,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
 * the running transaction open, so a full commit can't hop
 * in and cause problems either.
 */
-   ret = write_ctree_super(trans, fs_info, 1);
+   ret = write_all_supers(fs_info, 1);
if (ret) {
btrfs_set_log_full_commit(fs_info, trans);
btrfs_abort_transaction(trans, ret);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/29] btrfs: remove unused parameter from clean_tree_block

2017-02-13 Thread David Sterba
Added but never needed.

Signed-off-by: David Sterba 
---
 fs/btrfs/ctree.c   | 16 
 fs/btrfs/disk-io.c |  3 +--
 fs/btrfs/disk-io.h |  3 +--
 fs/btrfs/extent-tree.c |  4 ++--
 fs/btrfs/free-space-tree.c |  2 +-
 fs/btrfs/qgroup.c  |  2 +-
 fs/btrfs/tree-log.c|  6 +++---
 7 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 35e22349c139..d509dafdb20c 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1074,7 +1074,7 @@ static noinline int update_ref_for_cow(struct 
btrfs_trans_handle *trans,
ret = btrfs_dec_ref(trans, root, buf, 1);
BUG_ON(ret); /* -ENOMEM */
}
-   clean_tree_block(trans, fs_info, buf);
+   clean_tree_block(fs_info, buf);
*last_ref = 1;
}
return 0;
@@ -1938,7 +1938,7 @@ static noinline int balance_level(struct 
btrfs_trans_handle *trans,
 
path->locks[level] = 0;
path->nodes[level] = NULL;
-   clean_tree_block(trans, fs_info, mid);
+   clean_tree_block(fs_info, mid);
btrfs_tree_unlock(mid);
/* once for the path */
free_extent_buffer(mid);
@@ -1999,7 +1999,7 @@ static noinline int balance_level(struct 
btrfs_trans_handle *trans,
if (wret < 0 && wret != -ENOSPC)
ret = wret;
if (btrfs_header_nritems(right) == 0) {
-   clean_tree_block(trans, fs_info, right);
+   clean_tree_block(fs_info, right);
btrfs_tree_unlock(right);
del_ptr(root, path, level + 1, pslot + 1);
root_sub_used(root, right->len);
@@ -2043,7 +2043,7 @@ static noinline int balance_level(struct 
btrfs_trans_handle *trans,
BUG_ON(wret == 1);
}
if (btrfs_header_nritems(mid) == 0) {
-   clean_tree_block(trans, fs_info, mid);
+   clean_tree_block(fs_info, mid);
btrfs_tree_unlock(mid);
del_ptr(root, path, level + 1, pslot);
root_sub_used(root, mid->len);
@@ -3705,7 +3705,7 @@ static noinline int __push_leaf_right(struct 
btrfs_trans_handle *trans,
if (left_nritems)
btrfs_mark_buffer_dirty(left);
else
-   clean_tree_block(trans, fs_info, left);
+   clean_tree_block(fs_info, left);
 
btrfs_mark_buffer_dirty(right);
 
@@ -3717,7 +3717,7 @@ static noinline int __push_leaf_right(struct 
btrfs_trans_handle *trans,
if (path->slots[0] >= left_nritems) {
path->slots[0] -= left_nritems;
if (btrfs_header_nritems(path->nodes[0]) == 0)
-   clean_tree_block(trans, fs_info, path->nodes[0]);
+   clean_tree_block(fs_info, path->nodes[0]);
btrfs_tree_unlock(path->nodes[0]);
free_extent_buffer(path->nodes[0]);
path->nodes[0] = right;
@@ -3946,7 +3946,7 @@ static noinline int __push_leaf_left(struct 
btrfs_trans_handle *trans,
if (right_nritems)
btrfs_mark_buffer_dirty(right);
else
-   clean_tree_block(trans, fs_info, right);
+   clean_tree_block(fs_info, right);
 
btrfs_item_key(right, _key, 0);
fixup_low_keys(fs_info, path, _key, 1);
@@ -5009,7 +5009,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
btrfs_set_header_level(leaf, 0);
} else {
btrfs_set_path_blocking(path);
-   clean_tree_block(trans, fs_info, leaf);
+   clean_tree_block(fs_info, leaf);
btrfs_del_leaf(trans, root, path, leaf);
}
} else {
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 89cd597883fd..48846d215e97 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1248,8 +1248,7 @@ struct extent_buffer *read_tree_block(struct 
btrfs_fs_info *fs_info, u64 bytenr,
 
 }
 
-void clean_tree_block(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
+void clean_tree_block(struct btrfs_fs_info *fs_info,
  struct extent_buffer *buf)
 {
if (btrfs_header_generation(buf) ==
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 44dcd9af6b7c..1864e7ce9c70 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -52,8 +52,7 @@ int reada_tree_block_flagged(struct btrfs_fs_info *fs_info, 
u64 bytenr,
 struct extent_buffer *btrfs_find_create_tree_block(
struct btrfs_fs_info *fs_info,
u64 bytenr);
-void clean_tree_block(struct btrfs_trans_handle *trans,
-

[PATCH 05/29] btrfs: remove unused parameter from write_dev_supers

2017-02-13 Thread David Sterba
The barriers are handled by the caller.

Signed-off-by: David Sterba 
---
 fs/btrfs/disk-io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 48846d215e97..43e71457c193 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3410,7 +3410,7 @@ struct buffer_head *btrfs_read_dev_super(struct 
block_device *bdev)
  */
 static int write_dev_supers(struct btrfs_device *device,
struct btrfs_super_block *sb,
-   int do_barriers, int wait, int max_mirrors)
+   int wait, int max_mirrors)
 {
struct buffer_head *bh;
int i;
@@ -3752,7 +3752,7 @@ static int write_all_supers(struct btrfs_fs_info 
*fs_info, int max_mirrors)
flags = btrfs_super_flags(sb);
btrfs_set_super_flags(sb, flags | BTRFS_HEADER_FLAG_WRITTEN);
 
-   ret = write_dev_supers(dev, sb, do_barriers, 0, max_mirrors);
+   ret = write_dev_supers(dev, sb, 0, max_mirrors);
if (ret)
total_errors++;
}
@@ -3775,7 +3775,7 @@ static int write_all_supers(struct btrfs_fs_info 
*fs_info, int max_mirrors)
if (!dev->in_fs_metadata || !dev->writeable)
continue;
 
-   ret = write_dev_supers(dev, sb, do_barriers, 1, max_mirrors);
+   ret = write_dev_supers(dev, sb, 1, max_mirrors);
if (ret)
total_errors++;
}
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/29] btrfs: remove unused parameter from check_async_write

2017-02-13 Thread David Sterba
Added but never used.

Signed-off-by: David Sterba 
---
 fs/btrfs/disk-io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 18004169552c..89cd597883fd 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1005,7 +1005,7 @@ static int __btree_submit_bio_done(struct inode *inode, 
struct bio *bio,
return ret;
 }
 
-static int check_async_write(struct inode *inode, unsigned long bio_flags)
+static int check_async_write(unsigned long bio_flags)
 {
if (bio_flags & EXTENT_BIO_TREE_LOG)
return 0;
@@ -1021,7 +1021,7 @@ static int btree_submit_bio_hook(struct inode *inode, 
struct bio *bio,
 u64 bio_offset)
 {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-   int async = check_async_write(inode, bio_flags);
+   int async = check_async_write(bio_flags);
int ret;
 
if (bio_op(bio) != REQ_OP_WRITE) {
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/29] btrfs: remove unused parameter from read_block_for_search

2017-02-13 Thread David Sterba
Never used in that function.

Signed-off-by: David Sterba 
---
 fs/btrfs/ctree.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index fbeff20eb194..35e22349c139 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2440,7 +2440,7 @@ noinline void btrfs_unlock_up_safe(struct btrfs_path 
*path, int level)
 static int
 read_block_for_search(struct btrfs_root *root, struct btrfs_path *p,
  struct extent_buffer **eb_ret, int level, int slot,
- const struct btrfs_key *key, u64 time_seq)
+ const struct btrfs_key *key)
 {
struct btrfs_fs_info *fs_info = root->fs_info;
u64 blocknr;
@@ -2871,7 +2871,7 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
}
 
err = read_block_for_search(root, p, , level,
-   slot, key, 0);
+   slot, key);
if (err == -EAGAIN)
goto again;
if (err) {
@@ -3015,7 +3015,7 @@ int btrfs_search_old_slot(struct btrfs_root *root, const 
struct btrfs_key *key,
}
 
err = read_block_for_search(root, p, , level,
-   slot, key, time_seq);
+   slot, key);
if (err == -EAGAIN)
goto again;
if (err) {
@@ -5786,7 +5786,7 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct 
btrfs_path *path,
next = c;
next_rw_lock = path->locks[level];
ret = read_block_for_search(root, path, , level,
-   slot, , 0);
+   slot, );
if (ret == -EAGAIN)
goto again;
 
@@ -5836,7 +5836,7 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct 
btrfs_path *path,
break;
 
ret = read_block_for_search(root, path, , level,
-   0, , 0);
+   0, );
if (ret == -EAGAIN)
goto again;
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/29] Cleanup of unused parameters

2017-02-13 Thread David Sterba
There are quite a few places where function parameters are unused and there's
no reason to keep them. The notable exceptions are callbacks that must match a
given prototype. There are several cases where the parameter has not been
removed after refactoring or other changes, but I'm more disappointed by the
numerous cases where parameters were added but never used.

I haven't measured the effects on runtime stack consumption, the estimate
savings can be counted in tens of bytes.

Found by 'make ccflags-y=-Wunused-parameter', applies on top of my current 4.11
queue.

David Sterba (29):
  btrfs: remove unused parameter from read_block_for_search
  btrfs: remove unused parameter from check_async_write
  btrfs: remove unused parameter from clean_tree_block
  btrfs: remove unused parameter from split_item
  btrfs: remove unused parameter from write_dev_supers
  btrfs: merge two superblock writing helpers
  btrfs: remove unused parameter from __push_leaf_right
  btrfs: remove unused parameter from __push_leaf_left
  btrfs: remove unused parameter from btrfs_subvolume_release_metadata
  btrfs: remove unused parameter from btrfs_prepare_extent_commit
  btrfs: remove unused parameter from btrfs_check_super_valid
  btrfs: remove unused parameter from tree_move_down
  btrfs: remove unused parameter from tree_move_next_or_upnext
  btrfs: remove unused parameter from submit_extent_page
  btrfs: remove unused parameter from update_nr_written
  btrfs: remove unused parameter from add_pending_csums
  btrfs: remove unused parameter from extent_write_cache_pages
  btrfs: remove unused parameter from btrfs_fill_super
  btrfs: remove unused parameter from __btrfs_alloc_chunk
  btrfs: remove unused parameter from init_first_rw_device
  btrfs: remove unused parameter from create_snapshot
  btrfs: remove unused parameters from scrub_setup_wr_ctx
  btrfs: remove unused parameter from __add_inline_refs
  btrfs: remove unused parameters from btrfs_cmp_data
  btrfs: remove unused parameter from clone_copy_inline_extent
  btrfs: remove unused parameter from __add_inode_ref
  btrfs: remove unused parameter from cleanup_write_cache_enospc
  btrfs: remove unused parameters from __btrfs_write_out_cache
  btrfs: remove unused parameter from adjust_slots_upwards

 fs/btrfs/backref.c  |  5 ++---
 fs/btrfs/ctree.c| 51 -
 fs/btrfs/ctree.h|  6 ++
 fs/btrfs/disk-io.c  | 29 +-
 fs/btrfs/disk-io.h  |  6 ++
 fs/btrfs/extent-tree.c  | 10 -
 fs/btrfs/extent_io.c| 21 ---
 fs/btrfs/free-space-cache.c | 16 +-
 fs/btrfs/free-space-tree.c  |  2 +-
 fs/btrfs/inode.c|  6 ++
 fs/btrfs/ioctl.c| 25 +-
 fs/btrfs/qgroup.c   |  7 +++
 fs/btrfs/scrub.c| 10 +++--
 fs/btrfs/super.c|  5 ++---
 fs/btrfs/transaction.c  |  4 ++--
 fs/btrfs/tree-log.c | 11 +-
 fs/btrfs/volumes.c  | 18 +++-
 17 files changed, 92 insertions(+), 140 deletions(-)

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html