Re: [PATCH v14.8 12/14] btrfs: dedupe: Add ioctl for inband deduplication

2018-07-19 Thread Tsutomu Itoh
On 2018/07/12 10:25, Lu Fengqi wrote:
> From: Wang Xiaoguang 
> 
> Add ioctl interface for inband deduplication, which includes:
> 1) enable
> 2) disable
> 3) status
> 
> And a pseudo RO compat flag, to imply that btrfs now supports inband
> dedup.
> However we don't add any ondisk format change, it's just a pseudo RO
> compat flag.
> 
> All these ioctl interfaces are state-less, which means caller don't need
> to bother previous dedupe state before calling them, and only need to
> care the final desired state.
> 
> For example, if user want to enable dedupe with specified block size and
> limit, just fill the ioctl structure and call enable ioctl.
> No need to check if dedupe is already running.
> 
> These ioctls will handle things like re-configure or disable quite well.
> 
> Also, for invalid parameters, enable ioctl interface will set the field
> of the first encountered invalid parameter to (-1) to inform caller.
> While for limit_nr/limit_mem, the value will be (0).
> 
> Signed-off-by: Qu Wenruo 
> Signed-off-by: Wang Xiaoguang 
> Signed-off-by: Lu Fengqi 
> ---
>  fs/btrfs/dedupe.c  | 50 
>  fs/btrfs/dedupe.h  | 17 +++---
>  fs/btrfs/disk-io.c |  3 ++
>  fs/btrfs/ioctl.c   | 67 ++
>  fs/btrfs/sysfs.c   |  2 ++
>  include/uapi/linux/btrfs.h | 12 ++-
>  6 files changed, 145 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/btrfs/dedupe.c b/fs/btrfs/dedupe.c
> index 14c8d245480e..f068321fdd1c 100644
> --- a/fs/btrfs/dedupe.c
> +++ b/fs/btrfs/dedupe.c
> @@ -29,6 +29,35 @@ static inline struct inmem_hash *inmem_alloc_hash(u16 algo)
>   GFP_NOFS);
>  }
>  
> +void btrfs_dedupe_status(struct btrfs_fs_info *fs_info,
> +  struct btrfs_ioctl_dedupe_args *dargs)
> +{
> + struct btrfs_dedupe_info *dedupe_info = fs_info->dedupe_info;
> +
> + if (!fs_info->dedupe_enabled || !dedupe_info) {
> + dargs->status = 0;
> + dargs->blocksize = 0;
> + dargs->backend = 0;
> + dargs->hash_algo = 0;
> + dargs->limit_nr = 0;
> + dargs->current_nr = 0;
> + memset(dargs->__unused, -1, sizeof(dargs->__unused));
> + return;
> + }
> + mutex_lock(_info->lock);
> + dargs->status = 1;
> + dargs->blocksize = dedupe_info->blocksize;
> + dargs->backend = dedupe_info->backend;
> + dargs->hash_algo = dedupe_info->hash_algo;
> + dargs->limit_nr = dedupe_info->limit_nr;
> + dargs->limit_mem = dedupe_info->limit_nr *
> + (sizeof(struct inmem_hash) +
> +  btrfs_hash_sizes[dedupe_info->hash_algo]);
> + dargs->current_nr = dedupe_info->current_nr;
> + mutex_unlock(_info->lock);
> + memset(dargs->__unused, -1, sizeof(dargs->__unused));
> +}
> +
>  static int init_dedupe_info(struct btrfs_dedupe_info **ret_info,
>   struct btrfs_ioctl_dedupe_args *dargs)
>  {
> @@ -409,6 +438,27 @@ static void unblock_all_writers(struct btrfs_fs_info 
> *fs_info)
>   percpu_up_write(sb->s_writers.rw_sem + SB_FREEZE_WRITE - 1);
>  }
>  
> +int btrfs_dedupe_cleanup(struct btrfs_fs_info *fs_info)
> +{
> + struct btrfs_dedupe_info *dedupe_info;
> +
> + fs_info->dedupe_enabled = 0;
> + /* same as disable */
> + smp_wmb();
> + dedupe_info = fs_info->dedupe_info;
> + fs_info->dedupe_info = NULL;
> +
> + if (!dedupe_info)
> + return 0;
> +
> + if (dedupe_info->backend == BTRFS_DEDUPE_BACKEND_INMEMORY)
> + inmem_destroy(dedupe_info);
> +
> + crypto_free_shash(dedupe_info->dedupe_driver);
> + kfree(dedupe_info);
> + return 0;
> +}
> +
>  int btrfs_dedupe_disable(struct btrfs_fs_info *fs_info)
>  {
>   struct btrfs_dedupe_info *dedupe_info;
> diff --git a/fs/btrfs/dedupe.h b/fs/btrfs/dedupe.h
> index ebcbb89d79a0..85a87093ab04 100644
> --- a/fs/btrfs/dedupe.h
> +++ b/fs/btrfs/dedupe.h
> @@ -96,6 +96,15 @@ static inline struct btrfs_dedupe_hash 
> *btrfs_dedupe_alloc_hash(u16 algo)
>  int btrfs_dedupe_enable(struct btrfs_fs_info *fs_info,
>   struct btrfs_ioctl_dedupe_args *dargs);
>  
> +
> +/*
> + * Get inband dedupe info
> + * Since it needs to access different backends' hash size, which
> + * is not exported, we need such simple function.
> + */
> +void btrfs_dedupe_status(struct btrfs_fs_info *fs_info,
> +  struct btrfs_ioctl_dedupe_args *dargs);
> +
>  /*
>   * Disable dedupe and invalidate all its dedupe data.
>   * Called at dedupe disable time.
> @@ -107,12 +116,10 @@ int btrfs_dedupe_enable(struct btrfs_fs_info *fs_info,
>  int btrfs_dedupe_disable(struct btrfs_fs_info *fs_info);
>  
>  /*
> - * Get current dedupe status.
> - * Return 0 for success
> - * No possible error yet
> + * Cleanup current btrfs_dedupe_info
> + * Called in umount time
>   */
> -void btrfs_dedupe_status(struct btrfs_fs_info *fs_info,
> 

Re: [PATCH] Remove unused dedupe argument btrfs_set_extent_delalloc()

2017-10-10 Thread Tsutomu Itoh

On 2017/10/11 11:29, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues 
> 

'int dedupe' was added to prepare for support of subpage sector size and 
in-band dedupe.

  commit ba8b04c1d4ad ("btrfs: extend btrfs_set_extent_delalloc and its friends 
to support in-band dedupe and subpage size patchset")

So please do not delete it.

Thanks,
Tsutomu

> 
> Signed-off-by: Goldwyn Rodrigues 
> ---
>  fs/btrfs/ctree.h |  2 +-
>  fs/btrfs/file.c  |  2 +-
>  fs/btrfs/inode.c |  9 -
>  fs/btrfs/relocation.c|  2 +-
>  fs/btrfs/tests/inode-tests.c | 12 ++--
>  5 files changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index 8fc690384c58..ac7e2b02a4df 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -3174,7 +3174,7 @@ int btrfs_start_delalloc_inodes(struct btrfs_root 
> *root, int delay_iput);
>  int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput,
>  int nr);
>  int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,
> -   struct extent_state **cached_state, int dedupe);
> +   struct extent_state **cached_state);
>  int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
>struct btrfs_root *new_root,
>struct btrfs_root *parent_root,
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index a3d006d14683..46fa02e109f3 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -504,7 +504,7 @@ int btrfs_dirty_pages(struct inode *inode, struct page 
> **pages,
>  
>   end_of_last_block = start_pos + num_bytes - 1;
>   err = btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block,
> - cached, 0);
> + cached);
>   if (err)
>   return err;
>  
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index d94e3f68b9b1..9a3953fc3b45 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -2036,7 +2036,7 @@ static noinline int add_pending_csums(struct 
> btrfs_trans_handle *trans,
>  }
>  
>  int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,
> -   struct extent_state **cached_state, int dedupe)
> +   struct extent_state **cached_state)
>  {
>   WARN_ON((end & (PAGE_SIZE - 1)) == 0);
>   return set_extent_delalloc(_I(inode)->io_tree, start, end,
> @@ -2101,8 +2101,7 @@ static void btrfs_writepage_fixup_worker(struct 
> btrfs_work *work)
>   goto out;
>}
>  
> - btrfs_set_extent_delalloc(inode, page_start, page_end, _state,
> -   0);
> + btrfs_set_extent_delalloc(inode, page_start, page_end, _state);
>   ClearPageChecked(page);
>   set_page_dirty(page);
>  out:
> @@ -4854,7 +4853,7 @@ int btrfs_truncate_block(struct inode *inode, loff_t 
> from, loff_t len,
> 0, 0, _state, GFP_NOFS);
>  
>   ret = btrfs_set_extent_delalloc(inode, block_start, block_end,
> - _state, 0);
> + _state);
>   if (ret) {
>   unlock_extent_cached(io_tree, block_start, block_end,
>_state, GFP_NOFS);
> @@ -9253,7 +9252,7 @@ int btrfs_page_mkwrite(struct vm_fault *vmf)
> 0, 0, _state, GFP_NOFS);
>  
>   ret = btrfs_set_extent_delalloc(inode, page_start, end,
> - _state, 0);
> + _state);
>   if (ret) {
>   unlock_extent_cached(io_tree, page_start, page_end,
>_state, GFP_NOFS);
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 9841faef08ea..ff19edb84d0e 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -3266,7 +3266,7 @@ static int relocate_file_extent_cluster(struct inode 
> *inode,
>   nr++;
>   }
>  
> - btrfs_set_extent_delalloc(inode, page_start, page_end, NULL, 0);
> + btrfs_set_extent_delalloc(inode, page_start, page_end, NULL);
>   set_page_dirty(page);
>  
>   unlock_extent(_I(inode)->io_tree,
> diff --git a/fs/btrfs/tests/inode-tests.c b/fs/btrfs/tests/inode-tests.c
> index 8c91d03cc82d..1a7d8b65d500 100644
> --- a/fs/btrfs/tests/inode-tests.c
> +++ b/fs/btrfs/tests/inode-tests.c
> @@ -970,7 +970,7 @@ static int test_extent_accounting(u32 sectorsize, u32 
> nodesize)
>   /* [BTRFS_MAX_EXTENT_SIZE] */
>   BTRFS_I(inode)->outstanding_extents++;
>   ret = btrfs_set_extent_delalloc(inode, 0, BTRFS_MAX_EXTENT_SIZE - 1,
> - NULL, 0);
> + NULL);
>   if (ret) {
>   

[PATCH v2] Btrfs: fix overlap of fs_info->flags values

2017-10-03 Thread Tsutomu Itoh
Because the values of BTRFS_FS_EXCL_OP and BTRFS_FS_QUOTA_OVERRIDE overlap,
we should change the value.

First, BTRFS_FS_EXCL_OP was set to 14.

  commit 171938e52807 ("btrfs: track exclusive filesystem operation in flags")

Next, the value of BTRFS_FS_QUOTA_OVERRIDE was set to 14.

  commit f29efe292198 ("btrfs: add quota override flag to enable quota override 
for CAP_SYS_RESOURCE")

As a result, the value 14 overlapped.
This problem is solved by defining the value of BTRFS_FS_QUOTA_OVERRIDE
as 16.

Fixes: f29efe292198 ("btrfs: add quota override flag to enable quota override 
for CAP_SYS_RESOURCE")
CC: sta...@vger.kernel.org # 4.13+
Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
v2: changed the value of BTRFS_FS_QUOTA_OVERRIDE instead of BTRFS_FS_EXCL_OP
to 16.

 fs/btrfs/ctree.h | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 899ddaeeacec..d265ea7f763e 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -714,15 +714,14 @@ struct btrfs_delayed_root;
 #define BTRFS_FS_BTREE_ERR 11
 #define BTRFS_FS_LOG1_ERR  12
 #define BTRFS_FS_LOG2_ERR  13
-#define BTRFS_FS_QUOTA_OVERRIDE14
-/* Used to record internally whether fs has been frozen */
-#define BTRFS_FS_FROZEN15
-
 /*
  * Indicate that a whole-filesystem exclusive operation is running
  * (device replace, resize, device add/delete, balance)
  */
 #define BTRFS_FS_EXCL_OP   14
+/* Used to record internally whether fs has been frozen */
+#define BTRFS_FS_FROZEN15
+#define BTRFS_FS_QUOTA_OVERRIDE16
 
 struct btrfs_fs_info {
u8 fsid[BTRFS_FSID_SIZE];
-- 
2.13.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


[PATCH] Btrfs: fix fs_info->flags value

2017-10-02 Thread Tsutomu Itoh
Because the values of BTRFS_FS_QUOTA_OVERRIDE and BTRFS_FS_EXCL_OP overlap,
we should change the value.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 fs/btrfs/ctree.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 899ddaeeacec..566c0ba8dfb8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -717,12 +717,11 @@ struct btrfs_delayed_root;
 #define BTRFS_FS_QUOTA_OVERRIDE14
 /* Used to record internally whether fs has been frozen */
 #define BTRFS_FS_FROZEN15
-
 /*
  * Indicate that a whole-filesystem exclusive operation is running
  * (device replace, resize, device add/delete, balance)
  */
-#define BTRFS_FS_EXCL_OP   14
+#define BTRFS_FS_EXCL_OP   16
 
 struct btrfs_fs_info {
u8 fsid[BTRFS_FSID_SIZE];
-- 
2.13.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] btrfs: send: fix error code if an unknown inode type is found

2017-09-11 Thread Tsutomu Itoh
Hi David,

On 2017/09/12 1:58, David Sterba wrote:
> There are two types for "not supported", but the correct one is
> EOPNOTSUPP, let's use that one. The error message in the error case is
> not very helpful, enhance it at least with the inode number.

When I first posted a similar patch, you said "I'd rather make it EINVAL".
https://marc.info/?l=linux-btrfs=145342170820262=2

But I think that EOPNOTSUPP is also good.
So, anyway,

Reviewed-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>

> 
> The unknown type seems to be the block device (S_IFBLK)(as it's the only
> unhandled case. Adding this type would need to extend the send protocol,
> so this needs to stay as 'not supported'.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196903
> Signed-off-by: David Sterba <dste...@suse.com>
> ---
>  fs/btrfs/send.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 8f1d3d6e7087..5f944f9135d6 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -2638,9 +2638,9 @@ static int send_create_inode(struct send_ctx *sctx, u64 
> ino)
>   } else if (S_ISSOCK(mode)) {
>   cmd = BTRFS_SEND_C_MKSOCK;
>   } else {
> - btrfs_warn(sctx->send_root->fs_info, "unexpected inode type %o",
> - (int)(mode & S_IFMT));
> - ret = -ENOTSUPP;
> + btrfs_warn(fs_info, "unexpected type 0%o of inode %llu",
> + (int)(mode & S_IFMT), ino);
> + ret = -EOPNOTSUPP;
>   goto out;
>   }
>  
> 


--
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: status of inline deduplication in btrfs

2017-08-23 Thread Tsutomu Itoh
On 2017/08/23 23:52, shally verma wrote:
> HI
> 
> Through btrfs wiki, I got to know about inline patch and this git
> location https://github.com/adam900710/linux but I am not sure what's
> progress and status on this. Could any one please confirm what is the
> status of inline  deduplication into btrfs and if it is the correct
> location to see its support?

Lu Fengqi has posted the latest patchset (v14.4).
https://marc.info/?l=linux-btrfs=149984943031184=2

Unfortunately, it has not been committed yet.

Thanks,
Tsutomu

> 
> Thanks
> Shally
> --
> 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] btrfs-progs: mkfs: Replace number with a macro

2017-06-26 Thread Tsutomu Itoh
On 2017/06/26 17:23, Gu Jinxiang wrote:
> For code maintainability and scalability,
> replace number with a macro of member blocks in btrfs_mkfs_config.
> 
> Signed-off-by: Gu Jinxiang 
> ---
>  mkfs/common.c | 2 +-
>  mkfs/common.h | 5 -
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/mkfs/common.c b/mkfs/common.c
> index e4785c5..420671b 100644
> --- a/mkfs/common.c
> +++ b/mkfs/common.c
> @@ -94,7 +94,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
>   uuid_generate(chunk_tree_uuid);
>  
>   cfg->blocks[0] = BTRFS_SUPER_INFO_OFFSET;
> - for (i = 1; i < 7; i++) {
> + for (i = 1; i <= BTRFS_MKFS_ROOTS_NR; i++) {

If you change 7 to BTRFS_MKFS_ROOTS_NR, you also need to change the following 
code.

 213 for (i = 1; i < 7; i++) {

Thanks,
Tsutomu

>   cfg->blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 +
>   cfg->nodesize * i;
>   }
> diff --git a/mkfs/common.h b/mkfs/common.h
> index 666a75b..e23e79b 100644
> --- a/mkfs/common.h
> +++ b/mkfs/common.h
> @@ -28,6 +28,9 @@
>  #define BTRFS_MKFS_SYSTEM_GROUP_SIZE SZ_4M
>  #define BTRFS_MKFS_SMALL_VOLUME_SIZE SZ_1G
>  
> +/* roots: root tree, extent tree, chunk tree, dev tree, fs tree, csum tree */
> +#define BTRFS_MKFS_ROOTS_NR 6
> +
>  struct btrfs_mkfs_config {
>   /* Label of the new filesystem */
>   const char *label;
> @@ -43,7 +46,7 @@ struct btrfs_mkfs_config {
>   /* Output fields, set during creation */
>  
>   /* Logical addresses of superblock [0] and other tree roots */
> - u64 blocks[8];
> + u64 blocks[BTRFS_MKFS_ROOTS_NR + 1];
>   char fs_uuid[BTRFS_UUID_UNPARSED_SIZE];
>   char chunk_uuid[BTRFS_UUID_UNPARSED_SIZE];
>  
> 

--
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-progs 4.11 broke snap-sync

2017-05-28 Thread Tsutomu Itoh
On 2017/05/29 12:41, Wael M. Nasreddine wrote:
> Hello,
> 
> I use Arch, the system is entirely on btrfs (on a LUKS partition). I
> use snap-sync[0] to sync snapshots to an external drive. When 4.11
> came out, snap-sync errors out with the message: ERROR: unable to
> resolve -c.
> 
> Reverting back to 4.10 fixed the issue. I'm using kernel 4.9.29-lts
> and the problem has also been confirmed with kernel 4.11 zen.
> 
> Please find the bug filed against snap-sync at [1]
> 
> Should I file a bug for this? Is this even a bug or a breaking change?

I think that this is due to the following patch for updating the option parser.

  btrfs-progs: rework option parser to use getopt for global options
  
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git/commit/?id=010ceab56e067b87ea282fde6ff792c1ceefd7dc

cf. https://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg62226.html

Thanks,
Tsutomu

> 
> Thanks,
> 
> Wael
> 
> [0]: https://github.com/wesbarnett/snap-sync
> [1]: https://github.com/wesbarnett/snap-sync/issues/32
> 
> Exerpt from [1]:
> 
> [arch@arch ~]$ sudo snap-sync -n
> [sudo] password for arch:
> Select a mounted BTRFS device to backup to.
>1) c91384af-f210-48f5-ba19-d6415a1bb447 (/)
>2) c91384af-f210-48f5-ba19-d6415a1bb447 (/hackallthethings)
>3) c91384af-f210-48f5-ba19-d6415a1bb447 (/var/tmp)
>4) c91384af-f210-48f5-ba19-d6415a1bb447 (/data)
>5) c91384af-f210-48f5-ba19-d6415a1bb447 (/var/abs)
>6) c91384af-f210-48f5-ba19-d6415a1bb447 (/var/log)
>7) c91384af-f210-48f5-ba19-d6415a1bb447 (/var/cache/pacman/pkg)
>8) c91384af-f210-48f5-ba19-d6415a1bb447 (/home)
>9) c91384af-f210-48f5-ba19-d6415a1bb447 (/.snapshots)
>   10) c91384af-f210-48f5-ba19-d6415a1bb447 (/srv)
>   11) c91384af-f210-48f5-ba19-d6415a1bb447 (/home/arch/hackallthethings)
>   12) c91384af-f210-48f5-ba19-d6415a1bb447 (/home/arch/.local/share/Steam)
>   13) e5b8a2d6-85a1-4640-a659-acb8d6922bd6
> (/run/media/arch/e5b8a2d6-85a1-4640-a659-acb8d6922bd6)
>0) Exit
> Enter a number: 13
> 
> You selected the disk with UUID e5b8a2d6-85a1-4640-a659-acb8d6922bd6.
> The disk is mounted at /run/media/arch/e5b8a2d6-85a1-4640-a659-acb8d6922bd6.
> 
> Creating new snapshot for root...
> Will backup //.snapshots/4641/snapshot to
> /run/media/arch/e5b8a2d6-85a1-4640-a659-acb8d6922bd6/backup/E744/root/4641//snapshot
> Sending incremental snapshot for root...
> ERROR: unable to resolve -c
> 
> 
--
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 progs release 4.11

2017-05-18 Thread Tsutomu Itoh
Hi David,

Could you please apply the following patch?

 [PATCH] btrfs-progs: tests: remove variable quotation from convert-tests
 http://marc.info/?l=linux-btrfs=149490441323349=2

Thanks,
Tsutomu

On 2017/05/18 23:35, David Sterba wrote:
> Hi,
> 
> btrfs-progs version 4.11 have been released. It's a small release with handful
> of fixes and minor other updates.
> 
> Changes:
>   * receive: fix handling empty stream with -e (multi-stream)
>   * send dump: fix printing long file names
>   * stability fixes for: dump-super, print-tree, check
>   * option parser updates: global options are parsed before the subcommand 
> name
> (old xfstests will fail)
>   * new and updated tests
>   * documentation updates
> 
> Tarballs: https://www.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/
> Git: git://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
> 
> Shortlog:
> 
> Christian Brauner (3):
>   btrfs-progs: fix btrfs send & receive with -e flag
>   btrfs-progs: tests: misc/018-receive use receive -e to terminate on end 
> marker
>   btrfs-progs: receiv: fail on first -ENODATA only
> 
> Christophe de Dinechin (3):
>   btrfs-progs: check: disambiguate between cases where add_tree_backref 
> fails
>   btrfs-progs: check: prevent attempt to insert extent record with 
> max_size==0
>   btrfs-progs: check: make max_size consistent with nr
> 
> David Sterba (10):
>   btrfs-progs: docs: mount options, enhance ssd/nossd
>   btrfs-progs: rework option parser to use getopt for global options
>   btrfs-progs: README: sort bug reports means by preference
>   btrfs-progs: docs: btrfs-replace, fix typo
>   btrfs-progs: balance: minor wording adjustment for full balance warning
>   btrfs-progs: docs: update formatting and wording for btrfs(5)
>   btrfs-progs: fssum: fix warning, include correct header for major()
>   btrfs-progs: tests: fix misc/019-receive-clones-on-munted-subvol
>   btrfs-progs: update CHANGES for v4.11
>   Btrfs progs v4.11
> 
> Evan Danaher (1):
>   btrfs-progs: send: always print a space after path in dump
> 
> Hans van Kranenburg (2):
>   btrfs-progs: docs: Fix missing newline in man 5 btrfs
>   btrfs-progs: docs: Fix newlines for man btrfstune
> 
> Lakshmipathi.G (3):
>   btrfs-progs: misc-tests: Superblock corruption and recovery using backup
>   btrfs-progs: tests: add variable quotation to fsck-tests
>   btrfs-progs: tests: add variable quotation to convert-tests
> 
> Lu Fengqi (4):
>   btrfs-progs: dump-super: check array_size in print_sys_chunk_array
>   btrfs-progs: print-tree: add validation to print_chunk
>   btrfs-progs: tests: fssum, fix memory leak
>   btrfs-progs: tests: Fix fuzz-test for bko-161821.raw.txt
> 
> Qu Wenruo (6):
>   btrfs-progs: Fix memory leak when 0 sized block group item is found
>   btrfs-progs: check: Fix memory leak in check_chunks_and_extents
>   btrfs-progs: Use more strict check to read out tree root
>   btrfs-progs: check: Avoid reading beyond item boundary for inode_ref
>   btrfs-progs: check: Avoid reading beyond item boundary for dir_item and 
> dir_index
>   btrfs-progs: print-tree: Add leaf flags and backref revision output
> 
> Su Yue (1):
>   btrfs-progs: check: Fix heap use after free
> --
> 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] btrfs-progs: tests: remove variable quotation from convert-tests

2017-05-15 Thread Tsutomu Itoh
In btrfs-progs-v4.11-rc1, the following convert-tests failed.

[TEST/conv]   008-readonly-image
[TEST/conv] readonly image test, btrfs defaults
failed: mke2fs -t ext4 -b 4096 -F /Build/btrfs-progs-v4.11-rc1/tests/test.img
test failed for case 008-readonly-image
Makefile:271: recipe for target 'test-convert' failed
make: *** [test-convert] Error 1
[TEST/conv]   009-common-inode-flags
[TEST/conv] common inode flags test, btrfs defaults
failed: mke2fs -t ext4 -b 4096 -F /Build/btrfs-progs-v4.11-rc1/tests/test.img
test failed for case 009-common-inode-flags
Makefile:271: recipe for target 'test-convert' failed
make: *** [test-convert] Error 1

So, remove quotes from $default_mke2fs.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 tests/convert-tests/008-readonly-image/test.sh | 2 +-
 tests/convert-tests/009-common-inode-flags/test.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/convert-tests/008-readonly-image/test.sh 
b/tests/convert-tests/008-readonly-image/test.sh
index b2f1ae37..27c9373e 100755
--- a/tests/convert-tests/008-readonly-image/test.sh
+++ b/tests/convert-tests/008-readonly-image/test.sh
@@ -10,7 +10,7 @@ check_prereq btrfs-convert
 
 default_mke2fs="mke2fs -t ext4 -b 4096"
 convert_test_preamble '' 'readonly image test' 16k "$default_mke2fs"
-convert_test_prep_fs "$default_mke2fs"
+convert_test_prep_fs $default_mke2fs
 run_check_umount_test_dev
 convert_test_do_convert
 run_check_mount_test_dev
diff --git a/tests/convert-tests/009-common-inode-flags/test.sh 
b/tests/convert-tests/009-common-inode-flags/test.sh
index a5828790..02823e14 100755
--- a/tests/convert-tests/009-common-inode-flags/test.sh
+++ b/tests/convert-tests/009-common-inode-flags/test.sh
@@ -11,7 +11,7 @@ check_prereq btrfs-convert
 fail=0
 default_mke2fs="mke2fs -t ext4 -b 4096"
 convert_test_preamble '' 'common inode flags test' 16k "$default_mke2fs"
-convert_test_prep_fs "$default_mke2fs"
+convert_test_prep_fs $default_mke2fs
 
 # create file with specific flags
 run_check $SUDO_HELPER touch "$TEST_MNT/flag_test"
-- 
2.12.2


Tsutomu Itoh  t-i...@jp.fujitsu.com
--
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 progs pre-release 4.10-rc1

2017-03-07 Thread Tsutomu Itoh
On 2017/03/07 20:54, David Sterba wrote:
> On Tue, Mar 07, 2017 at 11:03:33AM +0900, Tsutomu Itoh wrote:
>> Hi David,
>>
>> On 2017/03/02 23:59, David Sterba wrote:
>>> Hi,
>>>
>>> a pre-release has been tagged. There are patches that have queued so far, 
>>> but
>>> I haven't gone through everything that's in the mailinglist. The 4.10 
>>> release
>>> ETA is next week so I'll try to process the backlog and merge what would 
>>> seem
>>> applicable.
>>>
>>> Changes:
>>>   * send: dump output fixes: missing newlies
>>>   * check: several fixes for the lowmem mode, improved error reporting
>>>   * build
>>> * removed some library deps for binaries that not use them
>>> * ctags, cscope
>>> * split Makefile to the autotool generated part and the rest, not needed
>>>   to autogen.sh after adding a file
>>>   * shared code: sync easy parts with kernel sources
>>>   * other
>>> * lots of cleanups
>>> * source file reorganization: convert, mkfs, utils
>>> * lots of spelling fixes in docs, other updates
>>> * more tests
>>>
>>> ETA for 4.10 is in +7 days (2017-03-08).
>>>
>>> Tarballs: https://www.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/
>>> Git: git://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
>>>
>>> Shortlog:
>>>
>>> Austin S. Hemmelgarn (1):
>>>   btrfs-progs: better document btrfs receive security
>>>
>>> Benedikt Morbach (1):
>>>   btrfs-progs: send-dump: add missing newlines
>>>
>>> David Sterba (102):
>>
>>>   btrfs-progs: rework option parser to use getopt for global options
>>
>> I think that btrfs/{008,016,019,...} of xfstests has failed due to the
>> above patch.
>>
>> btrfs/008 1s ... [failed, exit status 1] - output mismatch (see 
>> /xfstests/results//btrfs/008.out.bad)
>> --- tests/btrfs/008.out 2015-08-04 16:09:38.0 +0900
>> +++ /xfstests/results//btrfs/008.out.bad2017-03-07 
>> 09:00:50.581906234 +0900
>> @@ -1,2 +1,3 @@
>>  QA output created by 008
>> -Silence is golden
>> +send failed
>> +(see /xfstests/results//btrfs/008.full for details)
> 
> What's in the .full report?

$ cat 008.full
Create subvolume '/test5/send_temp_008/send'
Create a readonly snapshot of '/test5/send_temp_008/send' in 
'/test5/send_temp_008/send/snapshots/backup2'
Create a readonly snapshot of '/test5/send_temp_008/send' in 
'/test5/send_temp_008/send/snapshots/backup3'
ERROR: unable to resolve -f
send failed
$

- Tsutomu

> 
>> ...
>> (Run 'diff -u tests/btrfs/008.out /xfstests/results//btrfs/008.out.bad'  
>> to see the entire diff)
> --
> 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: Btrfs progs pre-release 4.10-rc1

2017-03-06 Thread Tsutomu Itoh
iate number
>   btrfs-progs: Introduce macro to calculate backup superblock offset
>   btrfs-progs: check: lowmem: Fix several bugs related to afterward search
>   btrfs-progs: check: Output verbose error when fsck found a bug in any 
> tree
>   btrfs-progs: check: lowmem: Fix false alert in checking data extent 
> csums
>   btrfs-progs: check: lowmem: Fix extent item size false alert
>   btrfs-progs: check: lowmem: Fix false alert on inline compressed extent
>   btrfs-progs: check: lowmem: Fix silent error if first inode item missing
>   btrfs-progs: tests: Move fsck-tests/015 to fuzz tests
>   btrfs-progs: tests: Add test image for lowmem mode block group false 
> alert
>   btrfs-progs: tests: Make fsck-test/013 compatible with lowmem mode
>   btrfs-progs: tests: Add new test case for file extent false alerts
> 
> Su Yue (1):
>   btrfs-progs: check: enhance return values of walk_down_tree_v2
> 
> Tsutomu Itoh (1):
>   btrfs-progs: tests: add test for --sync option of qgroup show
> 
> --
> 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 v2] btrfs-progs: Fix NULL pointer when receive clone operation

2016-12-15 Thread Tsutomu Itoh
On 2016/12/15 17:37, Qu Wenruo wrote:
> Regression introduced by:
> commit a2f7af94abe4a3491ca1280a2ae1d63edc0d62ab
> Author: Prasanth K S R <prasanth@dell.com>
> Date:   Sat Dec 10 19:17:43 2016 +0530
> 
> btrfs-progs: subvol_uuid_search: return error encoded pointer
> 
> IS_ERR() will only check if it's an error code, won't check if it's
> NULL.
> And for all the caller the commit modifies, it can return NULL and makes
> cause segfault.
> 
> Fix it by introducing new IS_ERR_OR_NULL() macro, and for NULL pointer
> and needs to return int case, convert NULL pointer to -ENOENT.

This patch also passed xfstests btrfs/{108,109,117}. Thanks for your work.

Thanks,
Tsutomu

> 
> Reported-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
> Signed-off-by: Qu Wenruo <quwen...@cn.fujitsu.com>
> ---
>  cmds-receive.c | 16 +++-
>  cmds-send.c| 26 ++
>  kerncompat.h   |  7 ++-
>  3 files changed, 35 insertions(+), 14 deletions(-)
> 
> diff --git a/cmds-receive.c b/cmds-receive.c
> index cb42aa2..166d37d 100644
> --- a/cmds-receive.c
> +++ b/cmds-receive.c
> @@ -287,13 +287,16 @@ static int process_snapshot(const char *path, const u8 
> *uuid, u64 ctransid,
>   parent_subvol = subvol_uuid_search(>sus, 0, parent_uuid,
>  parent_ctransid, NULL,
>  subvol_search_by_received_uuid);
> - if (IS_ERR(parent_subvol)) {
> + if (IS_ERR_OR_NULL(parent_subvol)) {
>   parent_subvol = subvol_uuid_search(>sus, 0, parent_uuid,
>  parent_ctransid, NULL,
>  subvol_search_by_uuid);
>   }
> - if (IS_ERR(parent_subvol)) {
> - ret = PTR_ERR(parent_subvol);
> + if (IS_ERR_OR_NULL(parent_subvol)) {
> + if (!parent_subvol)
> + ret = -ENOENT;
> + else
> + ret = PTR_ERR(parent_subvol);
>   error("cannot find parent subvolume");
>   goto out;
>   }
> @@ -750,13 +753,16 @@ static int process_clone(const char *path, u64 offset, 
> u64 len,
>   si = subvol_uuid_search(>sus, 0, clone_uuid, clone_ctransid,
>   NULL,
>   subvol_search_by_received_uuid);
> - if (IS_ERR(si)) {
> + if (IS_ERR_OR_NULL(si)) {
>   if (memcmp(clone_uuid, rctx->cur_subvol.received_uuid,
>   BTRFS_UUID_SIZE) == 0) {
>   /* TODO check generation of extent */
>   subvol_path = strdup(rctx->cur_subvol_path);
>   } else {
> - ret = PTR_ERR(si);
> + if (!si)
> + ret = -ENOENT;
> + else
> + ret = PTR_ERR(si);
>   error("clone: did not find source subvol");
>   goto out;
>   }
> diff --git a/cmds-send.c b/cmds-send.c
> index 5da64d8..cec11e6 100644
> --- a/cmds-send.c
> +++ b/cmds-send.c
> @@ -70,8 +70,12 @@ static int get_root_id(struct btrfs_send *sctx, const char 
> *path, u64 *root_id)
>  
>   si = subvol_uuid_search(>sus, 0, NULL, 0, path,
>   subvol_search_by_path);
> - if (IS_ERR(si))
> - return PTR_ERR(si);
> + if (IS_ERR_OR_NULL(si)) {
> + if (!si)
> + return -ENOENT;
> + else
> + return PTR_ERR(si);
> + }
>   *root_id = si->root_id;
>   free(si->path);
>   free(si);
> @@ -85,7 +89,7 @@ static struct subvol_info *get_parent(struct btrfs_send 
> *sctx, u64 root_id)
>  
>   si_tmp = subvol_uuid_search(>sus, root_id, NULL, 0, NULL,
>   subvol_search_by_root_id);
> - if (IS_ERR(si_tmp))
> + if (IS_ERR_OR_NULL(si_tmp))
>   return si_tmp;
>  
>   si = subvol_uuid_search(>sus, 0, si_tmp->parent_uuid, 0, NULL,
> @@ -105,8 +109,11 @@ static int find_good_parent(struct btrfs_send *sctx, u64 
> root_id, u64 *found)
>   int i;
>  
>   parent = get_parent(sctx, root_id);
> - if (IS_ERR(parent)) {
> - ret = PTR_ERR(parent);
> + if (IS_ERR_OR_NULL(parent)) {
> + if (!parent)
> + ret = -ENOENT;
> + else
> + ret = PTR_ERR(parent);
>   goto out;
>   }
>  
> @@ -122,7 +129,7 @@ static int find_good_parent(struct btrfs_send *sctx, u64 
> r

Re: Btrfs progs pre-release 4.9-rc1

2016-12-15 Thread Tsutomu Itoh
On 2016/12/15 15:45, Tsutomu Itoh wrote:
> On 2016/12/14 23:42, David Sterba wrote:
>> Hi,
>>
>> a pre-release has been tagged. Contains almost the entire devel branch from
>> today. There are small fixes, the lowmem mode of check gets more updates but
>> still does not work in the --repair mode and is considered experimental.
>>
>> ETA for 4.9 is in +6 days (2016-12-20).
>>
>> Minor fixes, docs improvements or more testcases will be still considered for
>> 4.9 release.
> 
> xfstests btrfs/{108,109,117} that was working in 4.8.5 will not work properly.
> 
> + ./check btrfs/108
> FSTYP -- btrfs
> PLATFORM  -- Linux/x86_64 luna 4.9.0
> MKFS_OPTIONS  -- /dev/sdb3
> MOUNT_OPTIONS -- /dev/sdb3 /test6
> 
> btrfs/108 1s ... [failed, exit status 1] - output mismatch (see 
> /xfstests/results//btrfs/108.out.bad)
> --- tests/btrfs/108.out 2015-10-19 09:55:52.0 +0900
> +++ /xfstests/results//btrfs/108.out.bad2016-12-15 15:41:43.771411349 
> +0900
> @@ -8,6 +8,6 @@
>  File digests in the original filesystem:
>  fbf36a062ffcbd644b5739c4d683ccc7  SCRATCH_MNT/snap/foo
>  5d2c92827a70aad932cfe7363105c55e  SCRATCH_MNT/snap/bar
> -File digests in the new filesystem:
> -fbf36a062ffcbd644b5739c4d683ccc7  SCRATCH_MNT/snap/foo
> -5d2c92827a70aad932cfe7363105c55e  SCRATCH_MNT/snap/bar
> +./common/rc: line 2784: 22352 Segmentation fault  (core dumped) "$@" 
> >> $seqres.full 2>&1
> ...
> (Run 'diff -u tests/btrfs/108.out /xfstests/results//btrfs/108.out.bad'  
> to see the entire diff)
> Ran: btrfs/108
> Failures: btrfs/108
> Failed 1 of 1 tests

Another problem was found. xfstests btrfs/012 will not succeed.

btrfs/012 58s ... [failed, exit status 1] - output mismatch (see 
/xfstests/results//btrfs/012.out.bad)
--- tests/btrfs/012.out 2015-08-04 16:09:38.0 +0900
+++ /xfstests/results//btrfs/012.out.bad2016-12-15 17:38:10.305009249 
+0900
@@ -1 +1,3 @@
 == QA output created by 012
+btrfs-convert rollback failed
+(see /xfstests/results//btrfs/012.full for details)
...
(Run 'diff -u tests/btrfs/012.out /xfstests/results//btrfs/012.out.bad'  to 
see the entire diff)

Thanks,
Tsutomu

> 
> Thanks,
> Tsutomu
> 
>>
>> Changes:
>>   * check: many lowmem mode updates
>>   * send: use splice syscall to copy buffer from kernel
>>   * receive: new option to dump the stream in textual form
>>   * convert:
>> * move sources to own directory
>> * prevent accounting of blocks beyond end of the device
>> * make it work with 64k sectorsize
>>   * mkfs: move sources to own directory
>>   * defrag: warns if directory used without -r
>>   * dev stats:
>> * new option to check stats for non-zero values
>> * add long option for -z
>>   * library: version bump to 0.1.2, added subvol_uuid_search2
>>   * other:
>> * cleanups
>> * docs updates
>>
>> Tarballs: https://www.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/
>> Git: git://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
>>
>> Shortlog:
>>
>> Adam Borowski (1):
>>   btrfs-progs: man mkfs: warn about RAID5/6 being experimental
>>
>> Anand Jain (1):
>>   btrfs-progs: recursive defrag cleanup duplicate code
>>
>> Austin S. Hemmelgarn (1):
>>   btrfs-progs: dev stats: add dev stats returncode option
>>
>> Chandan Rajendra (3):
>>   btrfs-progs: Use helper function to access 
>> btrfs_super_block->sys_chunk_array_size
>>   btrfs-progs: convert: Prevent accounting blocks beyond end of device
>>   btrfs-progs: convert: Fix migrate_super_block() to work with 64k 
>> sectorsize
>>
>> David Sterba (35):
>>   btrfs-progs: remove extra newline from messages
>>   btrfs-progs: use symbolic name for first inode number when searching
>>   btrfs-progs: send: use splice syscall instead of read/write to 
>> transfer buffer
>>   btrfs-progs: send: rename thread callback to read data from kernel
>>   btrfs-progs: make incompat bit wrappers more compact
>>   btrfs-progs: receive: rename receive context variable
>>   btrfs-progs: check: use on-stack path buffer in check_fs_first_inode
>>   btrfs-progs: check: use on-stack path buffer in check_fs_root_v2
>>   btrfs-progs: check: use on-stack path buffer in check_fs_roots_v2
>>   btrfs-progs: send dump: introduce helper for printing escaped path
>>   btrfs-progs: send dump: print escaped path
>>   btrfs-progs: send dump: use

Re: [PATCH] btrfs-progs: Fix NULL pointer when receive clone operation

2016-12-15 Thread Tsutomu Itoh
On 2016/12/15 16:28, Qu Wenruo wrote:
> The subvol_info returned from subvol_uuid_search() can be NULL.
> So the branch checking IS_ERR(si) should also check if it's NULL.
> 
> Reported-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
> Signed-off-by: Qu Wenruo <quwen...@cn.fujitsu.com>
> ---
>  cmds-receive.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cmds-receive.c b/cmds-receive.c
> index cb42aa2..c8f2fff 100644
> --- a/cmds-receive.c
> +++ b/cmds-receive.c
> @@ -750,7 +750,7 @@ static int process_clone(const char *path, u64 offset, 
> u64 len,
>   si = subvol_uuid_search(>sus, 0, clone_uuid, clone_ctransid,
>   NULL,
>   subvol_search_by_received_uuid);
> -     if (IS_ERR(si)) {
> + if (IS_ERR(si) || !si) {

Tested-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>

But I like  if (!si || IS_ERR(si)) {

Thanks,
Tsutomu

>   if (memcmp(clone_uuid, rctx->cur_subvol.received_uuid,
>   BTRFS_UUID_SIZE) == 0) {
>   /* TODO check generation of extent */
> 

--
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 progs pre-release 4.9-rc1

2016-12-14 Thread Tsutomu Itoh
On 2016/12/14 23:42, David Sterba wrote:
> Hi,
> 
> a pre-release has been tagged. Contains almost the entire devel branch from
> today. There are small fixes, the lowmem mode of check gets more updates but
> still does not work in the --repair mode and is considered experimental.
> 
> ETA for 4.9 is in +6 days (2016-12-20).
> 
> Minor fixes, docs improvements or more testcases will be still considered for
> 4.9 release.

xfstests btrfs/{108,109,117} that was working in 4.8.5 will not work properly.

+ ./check btrfs/108
FSTYP -- btrfs
PLATFORM  -- Linux/x86_64 luna 4.9.0
MKFS_OPTIONS  -- /dev/sdb3
MOUNT_OPTIONS -- /dev/sdb3 /test6

btrfs/108 1s ... [failed, exit status 1] - output mismatch (see 
/xfstests/results//btrfs/108.out.bad)
--- tests/btrfs/108.out 2015-10-19 09:55:52.0 +0900
+++ /xfstests/results//btrfs/108.out.bad2016-12-15 15:41:43.771411349 
+0900
@@ -8,6 +8,6 @@
 File digests in the original filesystem:
 fbf36a062ffcbd644b5739c4d683ccc7  SCRATCH_MNT/snap/foo
 5d2c92827a70aad932cfe7363105c55e  SCRATCH_MNT/snap/bar
-File digests in the new filesystem:
-fbf36a062ffcbd644b5739c4d683ccc7  SCRATCH_MNT/snap/foo
-5d2c92827a70aad932cfe7363105c55e  SCRATCH_MNT/snap/bar
+./common/rc: line 2784: 22352 Segmentation fault  (core dumped) "$@" 
>> $seqres.full 2>&1
...
(Run 'diff -u tests/btrfs/108.out /xfstests/results//btrfs/108.out.bad'  to 
see the entire diff)
Ran: btrfs/108
Failures: btrfs/108
Failed 1 of 1 tests

Thanks,
Tsutomu

> 
> Changes:
>   * check: many lowmem mode updates
>   * send: use splice syscall to copy buffer from kernel
>   * receive: new option to dump the stream in textual form
>   * convert:
> * move sources to own directory
> * prevent accounting of blocks beyond end of the device
> * make it work with 64k sectorsize
>   * mkfs: move sources to own directory
>   * defrag: warns if directory used without -r
>   * dev stats:
> * new option to check stats for non-zero values
> * add long option for -z
>   * library: version bump to 0.1.2, added subvol_uuid_search2
>   * other:
> * cleanups
> * docs updates
> 
> Tarballs: https://www.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/
> Git: git://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
> 
> Shortlog:
> 
> Adam Borowski (1):
>   btrfs-progs: man mkfs: warn about RAID5/6 being experimental
> 
> Anand Jain (1):
>   btrfs-progs: recursive defrag cleanup duplicate code
> 
> Austin S. Hemmelgarn (1):
>   btrfs-progs: dev stats: add dev stats returncode option
> 
> Chandan Rajendra (3):
>   btrfs-progs: Use helper function to access 
> btrfs_super_block->sys_chunk_array_size
>   btrfs-progs: convert: Prevent accounting blocks beyond end of device
>   btrfs-progs: convert: Fix migrate_super_block() to work with 64k 
> sectorsize
> 
> David Sterba (35):
>   btrfs-progs: remove extra newline from messages
>   btrfs-progs: use symbolic name for first inode number when searching
>   btrfs-progs: send: use splice syscall instead of read/write to transfer 
> buffer
>   btrfs-progs: send: rename thread callback to read data from kernel
>   btrfs-progs: make incompat bit wrappers more compact
>   btrfs-progs: receive: rename receive context variable
>   btrfs-progs: check: use on-stack path buffer in check_fs_first_inode
>   btrfs-progs: check: use on-stack path buffer in check_fs_root_v2
>   btrfs-progs: check: use on-stack path buffer in check_fs_roots_v2
>   btrfs-progs: send dump: introduce helper for printing escaped path
>   btrfs-progs: send dump: print escaped path
>   btrfs-progs: send dump: use reentrant variant of localtime
>   btrfs-progs: tests: add more gobal option to test 001-btrfs
>   btrfs-progs: docs: update receive help and manual page
>   btrfs-progs: build: extend pattern rules for standalone directories
>   btrfs-progs: move btrfs-convert to own directory
>   btrfs-progs: move mkfs.btrfs sources to own directory
>   btrfs-progs: tests: check for partscan support in 
> misc/006-partitioned-loopdev
>   btrfs-progs: run mkfs tests in CI
>   btrfs-progs: mkfs: annotation of a case
>   btrfs-progs: docs: clarify trim after mkfs -K
>   btrfs-progs: docs: make documentation updates workflow more clear
>   btrfs-progs: dev stats: adjust some error messages
>   btrfs-progs: dev stats: use char type path
>   btrfs-progs: dev stats: use table based printing of items
>   btrfs-progs: dev stats: add long option for -z
>   btrfs-progs: docs: update dev stats help and manual page
>   btrfs-progs: help: fix printing of aliased commands
>   btrfs-progs: fixup API after change in subvol_uuid_search
>   btrfs-progs: library: bump to 0.1.2
>   btrfs-progs: handle failed strdup in subvol_uuid_search2
>   btrfs-progs: dev stats: update option name for checking non-zero 

[PATCH v2] btrfs-progs: tests: add test for --sync option of qgroup show

2016-12-14 Thread Tsutomu Itoh
Simple test script for the following patch.

   btrfs-progs: qgroup: add sync option to 'qgroup show'

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
v2: dropped the test of --no-sync
---
 tests/cli-tests/005-qgroup-show-sync/test.sh | 30 
 1 file changed, 30 insertions(+)
 create mode 100755 tests/cli-tests/005-qgroup-show-sync/test.sh

diff --git a/tests/cli-tests/005-qgroup-show-sync/test.sh 
b/tests/cli-tests/005-qgroup-show-sync/test.sh
new file mode 100755
index 000..a325b48
--- /dev/null
+++ b/tests/cli-tests/005-qgroup-show-sync/test.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+#
+# simple test of qgroup show --sync option
+
+source $TOP/tests/common
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+prepare_test_dev 1g
+
+run_check $TOP/mkfs.btrfs -f $IMAGE
+run_check_mount_test_dev
+
+run_check $SUDO_HELPER $TOP/btrfs subvolume create $TEST_MNT/Sub
+run_check $SUDO_HELPER $TOP/btrfs quota enable $TEST_MNT/Sub
+
+for opt in '' '--' '--sync'; do
+   run_check $SUDO_HELPER $TOP/btrfs qgroup limit 300M $TEST_MNT/Sub
+   run_check $SUDU_HELPER dd if=/dev/zero of=$TEST_MNT/Sub/file bs=1M 
count=200
+
+   run_check $SUDO_HELPER $TOP/btrfs qgroup show -re $opt $TEST_MNT/Sub
+
+   run_check $SUDO_HELPER $TOP/btrfs qgroup limit none $TEST_MNT/Sub
+   run_check rm -f $TEST_MNT/Sub/file
+   run_check $TOP/btrfs filesystem sync $TEST_MNT/Sub
+done
+
+run_check_umount_test_dev
-- 
2.9.3


--
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 v3 2/2] btrfs-progs: qgroup: change the value of sort option

2016-12-14 Thread Tsutomu Itoh
The value of sort option ('S') is not used for option letter.
Therefore, I'll change the single letter to non-character.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
This patch is separated from patch of --sync option.
---
 cmds-qgroup.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 2a10c97..34e3bcc 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -313,10 +313,11 @@ static int cmd_qgroup_show(int argc, char **argv)
while (1) {
int c;
enum {
-   GETOPT_VAL_SYNC = 256
+   GETOPT_VAL_SORT = 256,
+   GETOPT_VAL_SYNC
};
static const struct option long_options[] = {
-   {"sort", required_argument, NULL, 'S'},
+   {"sort", required_argument, NULL, GETOPT_VAL_SORT},
{"sync", no_argument, NULL, GETOPT_VAL_SYNC},
{ NULL, 0, NULL, 0 }
};
@@ -347,7 +348,7 @@ static int cmd_qgroup_show(int argc, char **argv)
case 'f':
filter_flag |= 0x2;
break;
-   case 'S':
+   case GETOPT_VAL_SORT:
ret = btrfs_qgroup_parse_sort_string(optarg,
 _set);
if (ret)
-- 
2.9.3
--
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 v3 1/2] btrfs-progs: qgroup: add sync option to 'qgroup show'

2016-12-14 Thread Tsutomu Itoh
The 'qgroup show' command does not synchronize filesystem.
Therefore, 'qgroup show' may not display the correct value unless
synchronized with 'filesystem sync' command etc.

So add the '--sync' option so that we can choose whether or not
to synchronize when executing the command.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
v2: use getopt_long with enum instead of single letter (suggested by Qu)
v3: dropped the --no-sync option and separated the patch of sort
option (suggested by David)
---
 Documentation/btrfs-qgroup.asciidoc |  4 
 cmds-qgroup.c   | 22 --
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/Documentation/btrfs-qgroup.asciidoc 
b/Documentation/btrfs-qgroup.asciidoc
index 438dbc7..3053f2e 100644
--- a/Documentation/btrfs-qgroup.asciidoc
+++ b/Documentation/btrfs-qgroup.asciidoc
@@ -126,6 +126,10 @@ Prefix \'+' means ascending order and \'-' means 
descending order of .
 If no prefix is given, use ascending order by default.
 +
 If multiple s is given, use comma to separate.
++
+--sync
+To retrieve information after updating the state of qgroups,
+force sync of the filesystem identified by  before getting information.
 
 EXIT STATUS
 ---
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index bc15077..2a10c97 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -272,8 +272,7 @@ static int cmd_qgroup_destroy(int argc, char **argv)
 }
 
 static const char * const cmd_qgroup_show_usage[] = {
-   "btrfs qgroup show -pcreFf "
-   "[--sort=qgroupid,rfer,excl,max_rfer,max_excl] ",
+   "btrfs qgroup show [options] ",
"Show subvolume quota groups.",
"-p print parent qgroup id",
"-c print child qgroup id",
@@ -288,6 +287,7 @@ static const char * const cmd_qgroup_show_usage[] = {
"   list qgroups sorted by specified items",
"   you can use '+' or '-' in front of each item.",
"   (+:ascending, -:descending, ascending default)",
+   "--sync force sync of the filesystem before getting info",
NULL
 };
 
@@ -301,6 +301,7 @@ static int cmd_qgroup_show(int argc, char **argv)
u64 qgroupid;
int filter_flag = 0;
unsigned unit_mode;
+   int sync = 0;
 
struct btrfs_qgroup_comparer_set *comparer_set;
struct btrfs_qgroup_filter_set *filter_set;
@@ -311,8 +312,12 @@ static int cmd_qgroup_show(int argc, char **argv)
 
while (1) {
int c;
+   enum {
+   GETOPT_VAL_SYNC = 256
+   };
static const struct option long_options[] = {
{"sort", required_argument, NULL, 'S'},
+   {"sync", no_argument, NULL, GETOPT_VAL_SYNC},
{ NULL, 0, NULL, 0 }
};
 
@@ -348,6 +353,9 @@ static int cmd_qgroup_show(int argc, char **argv)
if (ret)
usage(cmd_qgroup_show_usage);
break;
+   case GETOPT_VAL_SYNC:
+   sync = 1;
+   break;
default:
usage(cmd_qgroup_show_usage);
}
@@ -365,6 +373,16 @@ static int cmd_qgroup_show(int argc, char **argv)
return 1;
}
 
+   if (sync) {
+   ret = ioctl(fd, BTRFS_IOC_SYNC);
+   if (ret < 0) {
+   error("sync ioctl failed on '%s': %s", path,
+ strerror(errno));
+   close_file_or_dir(fd, dirstream);
+   goto out;
+   }
+   }
+
if (filter_flag) {
ret = lookup_path_rootid(fd, );
if (ret < 0) {
-- 
2.9.3
--
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 v2] btrfs-progs: qgroup: add sync option to 'qgroup show'

2016-12-14 Thread Tsutomu Itoh
Hi David,

Thanks for the review.

On 2016/12/14 19:54, David Sterba wrote:
> On Wed, Dec 07, 2016 at 04:55:15PM +0900, Tsutomu Itoh wrote:
>> The 'qgroup show' command does not synchronize filesystem.
>> Therefore, 'qgroup show' may not display the correct value unless
>> synchronized with 'filesystem sync' command etc.
>>
>> So add the '--sync' and '--no-sync' options so that we can choose
>> whether or not to synchronize when executing the command.
>>
>> Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
>> ---
>> v2: use getopt_long with enum instead of single letter (suggested by Qu)
>> ---
>>  Documentation/btrfs-qgroup.asciidoc |  6 ++
>>  cmds-qgroup.c   | 33 +
>>  2 files changed, 35 insertions(+), 4 deletions(-)
>>
>> diff --git a/Documentation/btrfs-qgroup.asciidoc 
>> b/Documentation/btrfs-qgroup.asciidoc
>> index 438dbc7..9c65795 100644
>> --- a/Documentation/btrfs-qgroup.asciidoc
>> +++ b/Documentation/btrfs-qgroup.asciidoc
>> @@ -126,6 +126,12 @@ Prefix \'+' means ascending order and \'-' means 
>> descending order of .
>>  If no prefix is given, use ascending order by default.
>>  +
>>  If multiple s is given, use comma to separate.
>> ++
>> +--sync
>> +To retrieve information after updating the status of qgroups,
>> +invoke sync before getting information.
> 
> This could be more specific, that it's a filesystem sync.
> 
>> +--no-sync
>> +Do not invoke sync before getting information (default).
> 
> I'm not sure we need this option, how is it supposed to be used?

I made it to pair with --sync, but there is no use case in particular.
So, I would like to drop this with the next patch.

> 
>> @@ -311,8 +313,15 @@ static int cmd_qgroup_show(int argc, char **argv)
>>  
>>  while (1) {
>>  int c;
>> +enum {
>> +GETOPT_VAL_SORT = 256,
>> +GETOPT_VAL_SYNC,
>> +GETOPT_VAL_NO_SYNC
>> +};
>>  static const struct option long_options[] = {
>> -{"sort", required_argument, NULL, 'S'},
>> +{"sort", required_argument, NULL, GETOPT_VAL_SORT},
> 
> This change is unrelated to the patch, please make a separate patch for
> that.

OK. I'll separate this with the next patch.

Thanks,
Tsutomu

> 
> Otherwise looks good.
> 
>> +{"sync", no_argument, NULL, GETOPT_VAL_SYNC},
>> +{"no-sync", no_argument, NULL, GETOPT_VAL_NO_SYNC},
>>  { NULL, 0, NULL, 0 }
>>  };
>>  


--
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 3/3] btrfs-progs: convert-test: trigger chunk allocation after convert

2016-12-13 Thread Tsutomu Itoh
On 2016/12/13 18:44, Qu Wenruo wrote:
> Populate fs after convert so we can trigger data chunk allocation.
> This can expose too restrict old rollback condition
> 
> Reported-by: Chandan Rajendra 
> Signed-off-by: Qu Wenruo 
> ---
>  tests/common | 4 
>  tests/common.convert | 3 +++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/tests/common b/tests/common
> index 571118a..4a1330f 100644
> --- a/tests/common
> +++ b/tests/common
> @@ -486,6 +486,10 @@ generate_dataset() {
>   run_check $SUDO_HELPER ln -s 
> "$dirpath/$long_filename" "$dirpath/slow_slink.$num"
>   done
>   ;;
> + large)
> + run_check $SUDO_HELPER dd if=/dev/urandom bs=32M 
> count=1 \
> + of="$dirpath/$dataset_type" bs=32M >/dev/null 2>&1
> + ;;

Too many bs=.

Thanks,
Tsutomu

>   esac
>  }
>  
> diff --git a/tests/common.convert b/tests/common.convert
> index a2d3152..8c9242e 100644
> --- a/tests/common.convert
> +++ b/tests/common.convert
> @@ -160,6 +160,9 @@ convert_test_post_checks_all() {
>   convert_test_post_check_checksums "$1"
>   convert_test_post_check_permissions "$2"
>   convert_test_post_check_acl "$3"
> +
> + # Create a large file to trigger data chunk allocation
> + generate_dataset "large"
>   run_check_umount_test_dev
>  }
>  
> 

--
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-progs: tests: add test for --sync option of qgroup show

2016-12-07 Thread Tsutomu Itoh
Simple test script for the following patch.

   btrfs-progs: qgroup: add sync option to 'qgroup show'

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 tests/cli-tests/005-qgroup-show-sync/test.sh | 30 
 1 file changed, 30 insertions(+)
 create mode 100755 tests/cli-tests/005-qgroup-show-sync/test.sh

diff --git a/tests/cli-tests/005-qgroup-show-sync/test.sh 
b/tests/cli-tests/005-qgroup-show-sync/test.sh
new file mode 100755
index 000..2be684d
--- /dev/null
+++ b/tests/cli-tests/005-qgroup-show-sync/test.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+#
+# simple test of qgroup show --sync and --no-sync options
+
+source $TOP/tests/common
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+prepare_test_dev 1g
+
+run_check $TOP/mkfs.btrfs -f $IMAGE
+run_check_mount_test_dev
+
+run_check $SUDO_HELPER $TOP/btrfs subvolume create $TEST_MNT/Sub
+run_check $SUDO_HELPER $TOP/btrfs quota enable $TEST_MNT/Sub
+
+for opt in '' '--' '--sync' '--no-sync'; do
+   run_check $SUDO_HELPER $TOP/btrfs qgroup limit 300M $TEST_MNT/Sub
+   run_check $SUDU_HELPER dd if=/dev/zero of=$TEST_MNT/Sub/file bs=1M 
count=200
+
+   run_check $SUDO_HELPER $TOP/btrfs qgroup show -re $opt $TEST_MNT/Sub
+
+   run_check $SUDO_HELPER $TOP/btrfs qgroup limit none $TEST_MNT/Sub
+   run_check rm -f $TEST_MNT/Sub/file
+   run_check $TOP/btrfs filesystem sync $TEST_MNT/Sub
+done
+
+run_check_umount_test_dev
-- 
2.9.3
--
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-progs: qgroup: add sync option to 'qgroup show'

2016-12-06 Thread Tsutomu Itoh
The 'qgroup show' command does not synchronize filesystem.
Therefore, 'qgroup show' may not display the correct value unless
synchronized with 'filesystem sync' command etc.

So add the '--sync' and '--no-sync' options so that we can choose
whether or not to synchronize when executing the command.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
v2: use getopt_long with enum instead of single letter (suggested by Qu)
---
 Documentation/btrfs-qgroup.asciidoc |  6 ++
 cmds-qgroup.c   | 33 +
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/Documentation/btrfs-qgroup.asciidoc 
b/Documentation/btrfs-qgroup.asciidoc
index 438dbc7..9c65795 100644
--- a/Documentation/btrfs-qgroup.asciidoc
+++ b/Documentation/btrfs-qgroup.asciidoc
@@ -126,6 +126,12 @@ Prefix \'+' means ascending order and \'-' means 
descending order of .
 If no prefix is given, use ascending order by default.
 +
 If multiple s is given, use comma to separate.
++
+--sync
+To retrieve information after updating the status of qgroups,
+invoke sync before getting information.
+--no-sync
+Do not invoke sync before getting information (default).
 
 EXIT STATUS
 ---
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index bc15077..b494f6f 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -272,8 +272,7 @@ static int cmd_qgroup_destroy(int argc, char **argv)
 }
 
 static const char * const cmd_qgroup_show_usage[] = {
-   "btrfs qgroup show -pcreFf "
-   "[--sort=qgroupid,rfer,excl,max_rfer,max_excl] ",
+   "btrfs qgroup show [options] ",
"Show subvolume quota groups.",
"-p print parent qgroup id",
"-c print child qgroup id",
@@ -288,6 +287,8 @@ static const char * const cmd_qgroup_show_usage[] = {
"   list qgroups sorted by specified items",
"   you can use '+' or '-' in front of each item.",
"   (+:ascending, -:descending, ascending default)",
+   "--sync invoke sync before getting info",
+   "--no-sync  do not invoke sync before getting info (default)",
NULL
 };
 
@@ -301,6 +302,7 @@ static int cmd_qgroup_show(int argc, char **argv)
u64 qgroupid;
int filter_flag = 0;
unsigned unit_mode;
+   int sync = 0;
 
struct btrfs_qgroup_comparer_set *comparer_set;
struct btrfs_qgroup_filter_set *filter_set;
@@ -311,8 +313,15 @@ static int cmd_qgroup_show(int argc, char **argv)
 
while (1) {
int c;
+   enum {
+   GETOPT_VAL_SORT = 256,
+   GETOPT_VAL_SYNC,
+   GETOPT_VAL_NO_SYNC
+   };
static const struct option long_options[] = {
-   {"sort", required_argument, NULL, 'S'},
+   {"sort", required_argument, NULL, GETOPT_VAL_SORT},
+   {"sync", no_argument, NULL, GETOPT_VAL_SYNC},
+   {"no-sync", no_argument, NULL, GETOPT_VAL_NO_SYNC},
{ NULL, 0, NULL, 0 }
};
 
@@ -342,12 +351,18 @@ static int cmd_qgroup_show(int argc, char **argv)
case 'f':
filter_flag |= 0x2;
break;
-   case 'S':
+   case GETOPT_VAL_SORT:
ret = btrfs_qgroup_parse_sort_string(optarg,
 _set);
if (ret)
usage(cmd_qgroup_show_usage);
break;
+   case GETOPT_VAL_SYNC:
+   sync = 1;
+   break;
+   case GETOPT_VAL_NO_SYNC:
+   sync = 0;
+   break;
default:
usage(cmd_qgroup_show_usage);
}
@@ -365,6 +380,16 @@ static int cmd_qgroup_show(int argc, char **argv)
return 1;
}
 
+   if (sync) {
+   ret = ioctl(fd, BTRFS_IOC_SYNC);
+   if (ret < 0) {
+   error("sync ioctl failed on '%s': %s", path,
+ strerror(errno));
+   close_file_or_dir(fd, dirstream);
+   goto out;
+   }
+   }
+
if (filter_flag) {
ret = lookup_path_rootid(fd, );
if (ret < 0) {
-- 
2.9.3
--
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] btrfs-progs: qgroup: add sync option to 'qgroup show'

2016-12-06 Thread Tsutomu Itoh
On 2016/12/07 13:59, Qu Wenruo wrote:
> 
> 
> At 12/07/2016 12:31 PM, Tsutomu Itoh wrote:
>> Hi Qu,
>>
>> Thanks for the review.
>>
>> On 2016/12/07 12:24, Qu Wenruo wrote:
>>>
>>>
>>> At 12/07/2016 11:07 AM, Tsutomu Itoh wrote:
>>>> The 'qgroup show' command does not synchronize filesystem.
>>>> Therefore, 'qgroup show' may not display the correct value unless
>>>> synchronized with 'filesystem sync' command etc.
>>>>
>>>> So add the '--sync' and '--no-sync' options so that we can choose
>>>> whether or not to synchronize when executing the command.
>>>
>>> Indeed, --sync would help in a lot of cases.
>>>
>>>>
>>>> Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
>>>> ---
>>>>  Documentation/btrfs-qgroup.asciidoc |  5 +
>>>>  cmds-qgroup.c   | 24 ++--
>>>>  2 files changed, 27 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/Documentation/btrfs-qgroup.asciidoc 
>>>> b/Documentation/btrfs-qgroup.asciidoc
>>>> index 438dbc7..dd133ec 100644
>>>> --- a/Documentation/btrfs-qgroup.asciidoc
>>>> +++ b/Documentation/btrfs-qgroup.asciidoc
>>>> @@ -126,6 +126,11 @@ Prefix \'+' means ascending order and \'-' means 
>>>> descending order of .
>>>>  If no prefix is given, use ascending order by default.
>>>>  +
>>>>  If multiple s is given, use comma to separate.
>>>> ++
>>>> +--sync
>>>> +invoke sync before getting info.
>>>
>>> A little more words would help, to info user that qgroup will only update 
>>> after sync.
>>>
>>>> +--no-sync
>>>> +do not invoke sync before getting info (default).
>>>>
>>>>  EXIT STATUS
>>>>  ---
>>>> diff --git a/cmds-qgroup.c b/cmds-qgroup.c
>>>> index bc15077..ac339f3 100644
>>>> --- a/cmds-qgroup.c
>>>> +++ b/cmds-qgroup.c
>>>> @@ -272,8 +272,7 @@ static int cmd_qgroup_destroy(int argc, char **argv)
>>>>  }
>>>>
>>>>  static const char * const cmd_qgroup_show_usage[] = {
>>>> -"btrfs qgroup show -pcreFf "
>>>> -"[--sort=qgroupid,rfer,excl,max_rfer,max_excl] ",
>>>> +"btrfs qgroup show [options] ",
>>>>  "Show subvolume quota groups.",
>>>>  "-p print parent qgroup id",
>>>>  "-c print child qgroup id",
>>>> @@ -288,6 +287,8 @@ static const char * const cmd_qgroup_show_usage[] = {
>>>>  "   list qgroups sorted by specified items",
>>>>  "   you can use '+' or '-' in front of each item.",
>>>>  "   (+:ascending, -:descending, ascending default)",
>>>> +"--sync invoke sync before getting info",
>>>> +"--no-sync  do not invoke sync before getting info (default)",
>>>
>>> I see you're using -Y and -N option, it's better also to show
>>> the short option together, if we will use that short option.
>>
>> Do you think that a short option is necessary?
>> I thought it was not necessary...
> 
> Just mean if we use short option in getopt, it's better to mention it in both 
> man page and help string.
> 
>>
>>>
>>>>  NULL
>>>>  };
>>>>
>>>> @@ -301,6 +302,7 @@ static int cmd_qgroup_show(int argc, char **argv)
>>>>  u64 qgroupid;
>>>>  int filter_flag = 0;
>>>>  unsigned unit_mode;
>>>> +int sync = 0;
>>>>
>>>>  struct btrfs_qgroup_comparer_set *comparer_set;
>>>>  struct btrfs_qgroup_filter_set *filter_set;
>>>> @@ -313,6 +315,8 @@ static int cmd_qgroup_show(int argc, char **argv)
>>>>  int c;
>>>>  static const struct option long_options[] = {
>>>>  {"sort", required_argument, NULL, 'S'},
>>>> +{"sync", no_argument, NULL, 'Y'},
>>>> +{"no-sync", no_argument, NULL, 'N'},
>>>
>>> Although I'm not sure if "-Y" and "-N" is proper here.
>>> IMHO, it's more like something to say all "Yes" or "No" to any interactive 
>>&

Re: [PATCH] btrfs-progs: qgroup: add sync option to 'qgroup show'

2016-12-06 Thread Tsutomu Itoh
Hi Qu,

Thanks for the review.

On 2016/12/07 12:24, Qu Wenruo wrote:
> 
> 
> At 12/07/2016 11:07 AM, Tsutomu Itoh wrote:
>> The 'qgroup show' command does not synchronize filesystem.
>> Therefore, 'qgroup show' may not display the correct value unless
>> synchronized with 'filesystem sync' command etc.
>>
>> So add the '--sync' and '--no-sync' options so that we can choose
>> whether or not to synchronize when executing the command.
> 
> Indeed, --sync would help in a lot of cases.
> 
>>
>> Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
>> ---
>>  Documentation/btrfs-qgroup.asciidoc |  5 +
>>  cmds-qgroup.c   | 24 ++--
>>  2 files changed, 27 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/btrfs-qgroup.asciidoc 
>> b/Documentation/btrfs-qgroup.asciidoc
>> index 438dbc7..dd133ec 100644
>> --- a/Documentation/btrfs-qgroup.asciidoc
>> +++ b/Documentation/btrfs-qgroup.asciidoc
>> @@ -126,6 +126,11 @@ Prefix \'+' means ascending order and \'-' means 
>> descending order of .
>>  If no prefix is given, use ascending order by default.
>>  +
>>  If multiple s is given, use comma to separate.
>> ++
>> +--sync
>> +invoke sync before getting info.
> 
> A little more words would help, to info user that qgroup will only update 
> after sync.
> 
>> +--no-sync
>> +do not invoke sync before getting info (default).
>>
>>  EXIT STATUS
>>  ---
>> diff --git a/cmds-qgroup.c b/cmds-qgroup.c
>> index bc15077..ac339f3 100644
>> --- a/cmds-qgroup.c
>> +++ b/cmds-qgroup.c
>> @@ -272,8 +272,7 @@ static int cmd_qgroup_destroy(int argc, char **argv)
>>  }
>>
>>  static const char * const cmd_qgroup_show_usage[] = {
>> -"btrfs qgroup show -pcreFf "
>> -"[--sort=qgroupid,rfer,excl,max_rfer,max_excl] ",
>> +"btrfs qgroup show [options] ",
>>  "Show subvolume quota groups.",
>>  "-p print parent qgroup id",
>>  "-c print child qgroup id",
>> @@ -288,6 +287,8 @@ static const char * const cmd_qgroup_show_usage[] = {
>>  "   list qgroups sorted by specified items",
>>  "   you can use '+' or '-' in front of each item.",
>>  "   (+:ascending, -:descending, ascending default)",
>> +"--sync invoke sync before getting info",
>> +"--no-sync  do not invoke sync before getting info (default)",
> 
> I see you're using -Y and -N option, it's better also to show
> the short option together, if we will use that short option.

Do you think that a short option is necessary?
I thought it was not necessary...

> 
>>  NULL
>>  };
>>
>> @@ -301,6 +302,7 @@ static int cmd_qgroup_show(int argc, char **argv)
>>  u64 qgroupid;
>>  int filter_flag = 0;
>>  unsigned unit_mode;
>> +int sync = 0;
>>
>>  struct btrfs_qgroup_comparer_set *comparer_set;
>>  struct btrfs_qgroup_filter_set *filter_set;
>> @@ -313,6 +315,8 @@ static int cmd_qgroup_show(int argc, char **argv)
>>  int c;
>>  static const struct option long_options[] = {
>>  {"sort", required_argument, NULL, 'S'},
>> +{"sync", no_argument, NULL, 'Y'},
>> +{"no-sync", no_argument, NULL, 'N'},
> 
> Although I'm not sure if "-Y" and "-N" is proper here.
> IMHO, it's more like something to say all "Yes" or "No" to any interactive 
> confirmation.
> 
> Maybe non-charactor option will be better.

Umm, these mean s(Y)nc/(N)osync, and the user can not specify short options...
Still would you rather change to another character?

Thanks,
Tsutomu

> 
> Other part looks good to me.
> 
> Thanks,
> Qu
> 
>>  { NULL, 0, NULL, 0 }
>>  };
>>
>> @@ -348,6 +352,12 @@ static int cmd_qgroup_show(int argc, char **argv)
>>  if (ret)
>>  usage(cmd_qgroup_show_usage);
>>  break;
>> +case 'Y':
>> +sync = 1;
>> +break;
>> +case 'N':
>> +sync = 0;
>> +break;
>>  default:
>>  usage(cmd_qgroup_show_usage);
>>  }
>> @@ -365,6 +375,16 @@ static int cmd_qgroup_show(int argc, char **argv)
>>  return 1;
>>  }
>>
>> +if (sync) {
>> +ret = ioctl(fd, BTRFS_IOC_SYNC);
>> +if (ret < 0) {
>> +error("sync ioctl failed on '%s': %s", path,
>> +  strerror(errno));
>> +close_file_or_dir(fd, dirstream);
>> +goto out;
>> +}
>> +}
>> +
>>  if (filter_flag) {
>>  ret = lookup_path_rootid(fd, );
>>  if (ret < 0) {
>>
> 
> 
> -- 
> 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] btrfs-progs: qgroup: add sync option to 'qgroup show'

2016-12-06 Thread Tsutomu Itoh
The 'qgroup show' command does not synchronize filesystem.
Therefore, 'qgroup show' may not display the correct value unless
synchronized with 'filesystem sync' command etc.

So add the '--sync' and '--no-sync' options so that we can choose
whether or not to synchronize when executing the command.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 Documentation/btrfs-qgroup.asciidoc |  5 +
 cmds-qgroup.c   | 24 ++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/Documentation/btrfs-qgroup.asciidoc 
b/Documentation/btrfs-qgroup.asciidoc
index 438dbc7..dd133ec 100644
--- a/Documentation/btrfs-qgroup.asciidoc
+++ b/Documentation/btrfs-qgroup.asciidoc
@@ -126,6 +126,11 @@ Prefix \'+' means ascending order and \'-' means 
descending order of .
 If no prefix is given, use ascending order by default.
 +
 If multiple s is given, use comma to separate.
++
+--sync
+invoke sync before getting info.
+--no-sync
+do not invoke sync before getting info (default).
 
 EXIT STATUS
 ---
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index bc15077..ac339f3 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -272,8 +272,7 @@ static int cmd_qgroup_destroy(int argc, char **argv)
 }
 
 static const char * const cmd_qgroup_show_usage[] = {
-   "btrfs qgroup show -pcreFf "
-   "[--sort=qgroupid,rfer,excl,max_rfer,max_excl] ",
+   "btrfs qgroup show [options] ",
"Show subvolume quota groups.",
"-p print parent qgroup id",
"-c print child qgroup id",
@@ -288,6 +287,8 @@ static const char * const cmd_qgroup_show_usage[] = {
"   list qgroups sorted by specified items",
"   you can use '+' or '-' in front of each item.",
"   (+:ascending, -:descending, ascending default)",
+   "--sync invoke sync before getting info",
+   "--no-sync  do not invoke sync before getting info (default)",
NULL
 };
 
@@ -301,6 +302,7 @@ static int cmd_qgroup_show(int argc, char **argv)
u64 qgroupid;
int filter_flag = 0;
unsigned unit_mode;
+   int sync = 0;
 
struct btrfs_qgroup_comparer_set *comparer_set;
struct btrfs_qgroup_filter_set *filter_set;
@@ -313,6 +315,8 @@ static int cmd_qgroup_show(int argc, char **argv)
int c;
static const struct option long_options[] = {
{"sort", required_argument, NULL, 'S'},
+   {"sync", no_argument, NULL, 'Y'},
+   {"no-sync", no_argument, NULL, 'N'},
{ NULL, 0, NULL, 0 }
};
 
@@ -348,6 +352,12 @@ static int cmd_qgroup_show(int argc, char **argv)
if (ret)
usage(cmd_qgroup_show_usage);
break;
+   case 'Y':
+   sync = 1;
+   break;
+   case 'N':
+   sync = 0;
+   break;
default:
usage(cmd_qgroup_show_usage);
}
@@ -365,6 +375,16 @@ static int cmd_qgroup_show(int argc, char **argv)
return 1;
}
 
+   if (sync) {
+   ret = ioctl(fd, BTRFS_IOC_SYNC);
+   if (ret < 0) {
+   error("sync ioctl failed on '%s': %s", path,
+ strerror(errno));
+   close_file_or_dir(fd, dirstream);
+   goto out;
+   }
+   }
+
if (filter_flag) {
ret = lookup_path_rootid(fd, );
if (ret < 0) {
-- 
2.9.3
--
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: [bug] btrfs-progs-v4.8.4: test of 'btrfs receive' in xfstests fails

2016-11-29 Thread Tsutomu Itoh
Hi David,

On 2016/11/30 0:34, David Sterba wrote:
> On Mon, Nov 28, 2016 at 04:27:06PM +0900, Tsutomu Itoh wrote:
>> Many test of xfstests such as btrfs/007, btrfs/008 and btrfs/016 failed
>> with the following patch.
>>
>>   fefbab75  btrfs-progs: send-stream: check number of read bytes from stream
>>
>> This is because cmds-receive.c:do_receive() make a judgement of the end
>> of stream by returning 1 from send-stream.c:read_buf().
>> So, when applying this patch, 'btrfs receive' will always output the
>> following message at the end of stream.
>>
>>   ERROR: short read from stream: expected 17 read 0
> 
> Thanks for the report, should be fixed in devel, I'm also adding more
> tests.

I tried devel branch, btrfs/007 works fine. Thanks for your work.
But I found another problem in current devel branch.

btrfs/008, btrfs/016 etc. fail due to the following patch, probably.

   btrfs-progs: rework option parser to use getopt for global options

Thanks,
Tsutomu

--
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


[bug] btrfs-progs-v4.8.4: test of 'btrfs receive' in xfstests fails

2016-11-27 Thread Tsutomu Itoh
Hi, David,

Many test of xfstests such as btrfs/007, btrfs/008 and btrfs/016 failed
with the following patch.

  fefbab75  btrfs-progs: send-stream: check number of read bytes from stream

This is because cmds-receive.c:do_receive() make a judgement of the end
of stream by returning 1 from send-stream.c:read_buf().
So, when applying this patch, 'btrfs receive' will always output the
following message at the end of stream.

  ERROR: short read from stream: expected 17 read 0

Thanks,
Tsutomu

--
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 2/3] btrfs-progs: test: fix how to make test files in fsck-tests 013

2016-11-20 Thread Tsutomu Itoh
In my test environment, following error was occurred because the size
of /lib/modules/`uname -r`/* is larger than 1GB.

# make test-fsck
[TEST]   fsck-tests.sh
[TEST/fsck]   013-extent-tree-rebuild
failed: cp -aR /lib/modules/4.9.0-rc5/ /test/btrfs-progs/tests/mnt
test failed for case 013-extent-tree-rebuild
Makefile:272: recipe for target 'test-fsck' failed
make: *** [test-fsck] Error 1
#

In this test case, 'generate_dataset small' is enough for making the
test files, so I will use 'generate_dataset' instead of 'cp'.

For this, move 'generate_dataset()' from 'common.convert' to 'common'.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
v2: change how to make test files
---
 tests/common | 89 
 tests/common.convert | 89 
 tests/fsck-tests/013-extent-tree-rebuild/test.sh |  2 +-
 3 files changed, 90 insertions(+), 90 deletions(-)

diff --git a/tests/common b/tests/common
index c61962d..8b760f7 100644
--- a/tests/common
+++ b/tests/common
@@ -309,6 +309,95 @@ check_kernel_support()
return 0
 }
 
+# how many files to create.
+DATASET_SIZE=50
+
+generate_dataset() {
+
+   dataset_type="$1"
+   dirpath=$TEST_MNT/$dataset_type
+   run_check $SUDO_HELPER mkdir -p "$dirpath"
+
+   case $dataset_type in
+   small)
+   for num in $(seq 1 "$DATASET_SIZE"); do
+   run_check $SUDO_HELPER dd if=/dev/urandom 
of="$dirpath/$dataset_type.$num" bs=10K \
+   count=1 >/dev/null 2>&1
+   done
+   ;;
+
+   hardlink)
+   for num in $(seq 1 "$DATASET_SIZE"); do
+   run_check $SUDO_HELPER touch 
$dirpath/$dataset_type.$num
+   run_check $SUDO_HELPER ln 
"$dirpath/$dataset_type.$num" "$dirpath/hlink.$num"
+   done
+   ;;
+
+   fast_symlink)
+   for num in $(seq 1 "$DATASET_SIZE"); do
+   run_check $SUDO_HELPER touch 
$dirpath/$dataset_type.$num
+   run_check cd "$dirpath" && \
+   $SUDO_HELPER ln -s "$dataset_type.$num" 
"$dirpath/slink.$num" && \
+   cd /
+   done
+   ;;
+
+   brokenlink)
+   for num in $(seq 1 "$DATASET_SIZE"); do
+   run_check $SUDO_HELPER ln -s 
"$dirpath/$dataset_type.$num" "$dirpath/blink.$num"
+   done
+   ;;
+
+   perm)
+   for modes in 777 775 755 750 700 666 664 644 640 600 
444 440 400 000\
+   1777 1775 1755 1750 1700 1666 1664 1644 1640 
1600 1444 1440 1400 1000   \
+   2777 2775 2755 2750 2700 2666 2664 2644 2640 
2600 2444 2440 2400 2000   \
+   4777 4775 4755 4750 4700 4666 4664 4644 4640 
4600  4440 4400 4000; do
+   if [[ "$modes" == *9* ]] || [[ "$modes" == *8* 
]]
+   then
+   continue;
+   else
+   run_check $SUDO_HELPER touch 
"$dirpath/$dataset_type.$modes"
+   run_check $SUDO_HELPER chmod "$modes" 
"$dirpath/$dataset_type.$modes"
+   fi
+   done
+   ;;
+
+   sparse)
+   for num in $(seq 1 "$DATASET_SIZE"); do
+   run_check $SUDO_HELPER dd if=/dev/urandom 
of="$dirpath/$dataset_type.$num" bs=10K \
+   count=1 >/dev/null 2>&1
+   run_check $SUDO_HELPER truncate -s 500K 
"$dirpath/$dataset_type.$num"
+   run_check $SUDO_HELPER dd if=/dev/urandom 
of="$dirpath/$dataset_type.$num" bs=10K \
+   oflag=append conv=notrunc count=1 >/dev/null 
2>&1
+   run_check $SUDO_HELPER truncate -s 800K 
"$dirpath/$dataset_type.$num"
+   done
+   ;;
+
+   acls)
+   for num in $(seq 1 "$DATASET_SIZE"); do
+   run_check $SUDO_HELPER touch 
"$dirpath/$dataset_type.$num"
+   run_check $SUDO_HELPER setf

Re: [PATCH 2/3] btrfs-progs: test: expand size of test device of fsck-tests 013

2016-11-20 Thread Tsutomu Itoh
Hi, Qu and David,

On 2016/11/19 3:28, David Sterba wrote:
> On Fri, Nov 18, 2016 at 02:36:28PM +0800, Qu Wenruo wrote:
>>
>>
>> On 11/18/2016 01:47 PM, Tsutomu Itoh wrote:
>>> In my test environment, size of /lib/modules/`uname -r`/* is
>>> larger than 1GB, so test data can not copy to testdev.
>>> Therefore we need expand the size of testdev.
>>
>> IMHO the correct fix is to enhance populate_fs() to fill the fs into a 
>> given size, other than using the unreliable copy.
> 
> Yeah that would be better, the contents of the modules dir could be
> anything, but was enough to use for initial testing.

Thanks for your comments. I'll post v2 patch.

Thanks,
Tsutomu

--
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/3] btrfs-progs: test: fix convert-tests 004 failure

2016-11-17 Thread Tsutomu Itoh
convert-tests 004 failed because the argument to check_all_images
is not specified.

# make test-convert
[TEST]   convert-tests.sh
[TEST/conv]   004-ext2-backup-superblock-ranges
find: '': No such file or directory
#

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 tests/convert-tests/004-ext2-backup-superblock-ranges/test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/convert-tests/004-ext2-backup-superblock-ranges/test.sh 
b/tests/convert-tests/004-ext2-backup-superblock-ranges/test.sh
index c56650b..d764ed8 100755
--- a/tests/convert-tests/004-ext2-backup-superblock-ranges/test.sh
+++ b/tests/convert-tests/004-ext2-backup-superblock-ranges/test.sh
@@ -39,4 +39,4 @@ function check_image() {
rm -f $TEST_DEV
 }
 
-check_all_images
+check_all_images `pwd`
-- 
2.9.3
--
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/3] btrfs-progs: test: expand size of test device of fsck-tests 013

2016-11-17 Thread Tsutomu Itoh
In my test environment, size of /lib/modules/`uname -r`/* is
larger than 1GB, so test data can not copy to testdev.
Therefore we need expand the size of testdev.

# make test-fsck
[TEST]   fsck-tests.sh
[TEST/fsck]   013-extent-tree-rebuild
failed: cp -aR /lib/modules/4.9.0-rc5/ /test/btrfs-progs/tests/mnt
test failed for case 013-extent-tree-rebuild
Makefile:272: recipe for target 'test-fsck' failed
make: *** [test-fsck] Error 1
#

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 tests/fsck-tests/013-extent-tree-rebuild/test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/fsck-tests/013-extent-tree-rebuild/test.sh 
b/tests/fsck-tests/013-extent-tree-rebuild/test.sh
index f678e29..92c5d04 100755
--- a/tests/fsck-tests/013-extent-tree-rebuild/test.sh
+++ b/tests/fsck-tests/013-extent-tree-rebuild/test.sh
@@ -7,7 +7,7 @@ check_prereq mkfs.btrfs
 check_prereq btrfs
 
 setup_root_helper
-prepare_test_dev 1G
+prepare_test_dev 2G
 
 # test whether fsck can rebuild a corrupted extent tree
 test_extent_tree_rebuild()
-- 
2.9.3
--
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/3] btrfs-progs: test: fix error of test target of Makefile

2016-11-17 Thread Tsutomu Itoh
Add test-cli to test target of Makefile.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 Makefile.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.in b/Makefile.in
index 4bd3e63..6c78841 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -298,7 +298,7 @@ test-inst: all
$(MAKE) DESTDIR=$$tmpdest install && \
$(RM) -rf -- $$tmpdest
 
-test: test-fsck test-mkfs test-convert test-misc test-fuzz
+test: test-fsck test-mkfs test-convert test-misc test-fuzz test-cli
 
 #
 # NOTE: For static compiles, you need to have all the required libs
-- 
2.9.3
--
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-progs: qgroup: fix error in ASSERT condition expression

2016-11-16 Thread Tsutomu Itoh
Option -f, -F and --sort don't work because a conditional expression
of ASSERT is wrong.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 qgroup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qgroup.c b/qgroup.c
index 9d10cb8..071d15e 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -480,7 +480,7 @@ int btrfs_qgroup_setup_comparer(struct 
btrfs_qgroup_comparer_set  **comp_set,
*comp_set = set;
}
 
-   ASSERT(set->comps[set->ncomps].comp_func != NULL);
+   ASSERT(set->comps[set->ncomps].comp_func == NULL);
 
set->comps[set->ncomps].comp_func = all_comp_funcs[comparer];
set->comps[set->ncomps].is_descending = is_descending;
@@ -847,7 +847,7 @@ int btrfs_qgroup_setup_filter(struct 
btrfs_qgroup_filter_set **filter_set,
*filter_set = set;
}
 
-   ASSERT(set->filters[set->nfilters].filter_func != NULL);
+   ASSERT(set->filters[set->nfilters].filter_func == NULL);
set->filters[set->nfilters].filter_func = all_filter_funcs[filter];
set->filters[set->nfilters].data = data;
set->nfilters++;
-- 
2.9.3
--
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 2/3] btrfs-progs: send: fix handling of multiple snapshots (-p option)

2016-11-15 Thread Tsutomu Itoh
xfstests btrfs/038 fails when this patch is applied. Sorry for my fault.
I posted the patch that corrected this problem.

  [PATCH] btrfs-progs: send: fix failure of xfstests btrfs/038

Thanks,
Tsutomu

On 2016/10/19 11:35, Tsutomu Itoh wrote:
> We cannot send multiple snapshots at once by -p option.
> 
> [before]
> # btrfs send -f /tmp/data0 -p Snap0 Snap[12]
> At subvol Snap1
> At subvol Snap2
> ERROR: parent determination failed for 0
> # 
> 
> [after]
> # btrfs send -f /tmp/data0 -p Snap0 Snap[12]
> At subvol Snap1
> At subvol Snap2
> # 
> 
> Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
> ---
>  cmds-send.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/cmds-send.c b/cmds-send.c
> index dfdfe01..2a8a697 100644
> --- a/cmds-send.c
> +++ b/cmds-send.c
> @@ -650,7 +650,7 @@ int cmd_send(int argc, char **argv)
>   goto out;
>   }
>  
> - if (!full_send && !parent_root_id) {
> + if (!full_send && root_id) {
>   ret = find_good_parent(, root_id, _root_id);
>   if (ret < 0) {
>   error("parent determination failed for %lld",
> @@ -673,7 +673,7 @@ int cmd_send(int argc, char **argv)
>   if (ret < 0)
>   goto out;
>  
> - if (!full_send) {
> + if (!full_send && root_id) {
>   /* done with this subvol, so add it to the clone 
> sources */
>   ret = add_clone_source(, root_id);
>   if (ret < 0) {
> @@ -681,8 +681,6 @@ int cmd_send(int argc, char **argv)
>   goto out;
>   }
>   }
> -
> - parent_root_id = 0;
>   }
>  
>   ret = 0;
> 

--
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-progs: send: fix failure of xfstests btrfs/038

2016-11-15 Thread Tsutomu Itoh
The following patch was imperfect, so xfstests btrfs/038 was failed.

  6d4fb3d  btrfs-progs: send: fix handling of multiple snapshots (-p option)

[before]
| # ./check btrfs/038
| FSTYP -- btrfs
| PLATFORM  -- Linux/x86_64 luna 4.9.0-rc5
| MKFS_OPTIONS  -- /dev/sdb3
| MOUNT_OPTIONS -- /dev/sdb3 /test6
|
| btrfs/038 1s ... [failed, exit status 1] - output mismatch (see 
/For_RT/xfstests2/results//btrfs/038.out.bad)
| --- tests/btrfs/038.out 2015-08-04 16:09:38.0 +0900
| +++ /For_RT/xfstests2/results//btrfs/038.out.bad2016-11-15 
13:39:48.589435290 +0900
| @@ -7,3 +7,5 @@
|  XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|  wrote 1/1 bytes at offset 30
|  XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
| +failed: '/usr/local/bin/btrfs send -p /test6/mysnap1 -c 
/test6/clones_snap /test6/mysnap2 -f /tmp/tmp.aLpvAC7lsx/2.snap'
| +(see /For_RT/xfstests2/results//btrfs/038.full for details)
| ...
| (Run 'diff -u tests/btrfs/038.out 
/For_RT/xfstests2/results//btrfs/038.out.bad'  to see the entire diff)
| Ran: btrfs/038
| Failures: btrfs/038

[after]
| # ./check btrfs/038
| FSTYP -- btrfs
| PLATFORM  -- Linux/x86_64 luna 4.9.0-rc5
| MKFS_OPTIONS  -- /dev/sdb3
| MOUNT_OPTIONS -- /dev/sdb3 /test6
| 
| btrfs/038 1s ... 1s
| Ran: btrfs/038
| Passed all 1 tests

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 cmds-send.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmds-send.c b/cmds-send.c
index 7aa4b36..1ca4b8e 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -686,7 +686,7 @@ int cmd_send(int argc, char **argv)
goto out;
}
 
-   if (!full_send && root_id) {
+   if (!full_send && !snapshot_parent) {
ret = set_root_info(, subvol, _id);
if (ret < 0)
goto out;
@@ -713,7 +713,7 @@ int cmd_send(int argc, char **argv)
if (ret < 0)
goto out;
 
-   if (!full_send && root_id) {
+   if (!full_send && !snapshot_parent) {
/* done with this subvol, so add it to the clone 
sources */
ret = add_clone_source(, root_id);
if (ret < 0) {
-- 
2.9.3
--
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 v3] btrfs-progs: send-test: add checking of clone-src option

2016-11-08 Thread Tsutomu Itoh
Sending stream size of clone-src(-c) option is checked.
Fixed by "btrfs-progs: send: fix handling of -c option".

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
V2: old sending stream image is used
V3: image file has been compressed by gzip
---
 .../016-send-clone-src/send-stream-v4.8.2.img.gz   | Bin 0 -> 11826 bytes
 tests/misc-tests/016-send-clone-src/test.sh|  50 +
 2 files changed, 50 insertions(+)
 create mode 100644 
tests/misc-tests/016-send-clone-src/send-stream-v4.8.2.img.gz
 create mode 100755 tests/misc-tests/016-send-clone-src/test.sh

diff --git a/tests/misc-tests/016-send-clone-src/send-stream-v4.8.2.img.gz 
b/tests/misc-tests/016-send-clone-src/send-stream-v4.8.2.img.gz
new file mode 100644
index 
..f49c5cba1a8307f99732530ab8613f4a22902b9d
GIT binary patch
literal 11826
zcmeI2ZBSEJ8plz$(rwqq-EN!dR!O%VWvxh5gzzS5*KJv)lBuZZfP_^MD@uR}F_7d+
zU1eM>8KH^_N!r!QD3T~xUJQ9@sUlSpkU~Tt;VlG62!xP?yxqGuAtku(EKTyQ17Da6
zcb+-tx#X|MNQsmH+a~*ABnC$7=~ODfQqw;_-~6e;iwvwaGu$CACqx{tN2
zQhew$oD;FBXZ-OV`cKJ&=MU$8_{#lft$RYP1^b(B-opF*Z7r*>nl<3F4O`$C&
z;d_sgeiTmp-fzdr^dtKo`L{0hjrsV}#NOEe*cI-4S$ad2sdVHRu$=SGPB?y*hSR
zELr52A!P<UQEqJqg*zFRTJ}x0He6AMGxYQ*4BFAWgf><fQT?^VZ@dnjSJ?e+#A^yP
z$dat|54lX_P<0K-q8>neO8XJ%FR^l+Y`VojwFC*BYWr{=@(hGuoq8W_%<41U)
zh!mdQR)WpeM#-oqaI_$jog)ua>WWHqRWU<#kb(!1_R^zo2?S~5%Shv#da#WZl4%iA
z3>AcxiDC0ZNM%qm@X;|b?XQq3hi7o7Y%AM(ZW{o@q5>JB8MZtU^8$c}+6dHxAg
zQ>Ld)Xnwx}98T=N*}P^b--wiqmPlB!@*9HbQ;0xi8$M%f6aUDcij%1<(W?
zG|B++BiZo=4W6rKhXFazqJ5@5BI^rgL|U~qt~M0v-zC#v5T(lD+^Fu_h(mQmT_0w}
z%PYdt)81sa*YK4fL?#2ZTC>E_qD2eRK0fYlh<^as7YMDnNBo-#T<NLF{0rnzq^
zLO~MLvv7Tvs2hG<0e+4ons4B!>csv|WE(XdeSM_?WhGb`V#W!*|GiV=hcBL6nExlB(p7T?*vob$j2~r7tZH$2VsZosmkhn_fE9
zRNH>W)nKg!Tbs(%Yk~M3-{6-$GX6Vdhi^_^nb7a8nrF*hj1}~3!<srsUpDS%6NQ}8
z8hAqz6?xqjYp<)Z{6A~FHrRs-0}ndqcn*$rbn~+#TU;F1)5CBqImgt1^`9MBkv7u(
zNs?7csaCx0=2ZDVLh#48j~*QV*P8WF4=RFw<J!nhev$RbHkv69FqAoi>7LxN1v~bp
ztHGk+^pmH%aIC*LXQ_Gm$4eEFamQYEZD3w+!xE#=3

Re: [PATCH v2] btrfs-progs: send-test: add checking of clone-src option

2016-11-08 Thread Tsutomu Itoh
On 2016/11/09 10:39, Qu Wenruo wrote:
> 
> 
> At 11/09/2016 09:25 AM, Tsutomu Itoh wrote:
>> Sending stream size of clone-src(-c) option is checked.
>> Fixed by "btrfs-progs: send: fix handling of -c option".
>>
>> Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
>> ---
>> V2: old sending stream image is used
>> ---
>>  .../016-send-clone-src/send-stream-v4.8.2.img  | Bin 0 -> 6299778 bytes
> 
> The image seems quite large.
> 
> How about compressing it? And the script seems only checking the size of the 
> file, not the content.
> 
> So it seems that we don't even need to upload the file.

Certainly, only the size of the image file is necessary, and we don't need 
image file.
But I want to keep the image file as a record.
Therefore, I'll post the version that compresses the image file soon.

Thanks,
Tsutomu

> 
> Thanks,
> Qu
> 
>>  tests/misc-tests/016-send-clone-src/test.sh|  49 
>> +
>>  2 files changed, 49 insertions(+)
>>  create mode 100644 
>> tests/misc-tests/016-send-clone-src/send-stream-v4.8.2.img
>>  create mode 100755 tests/misc-tests/016-send-clone-src/test.sh
>>

(snip)

--
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-progs: send-test: add checking of clone-src option

2016-11-08 Thread Tsutomu Itoh
Sending stream size of clone-src(-c) option is checked.
Fixed by "btrfs-progs: send: fix handling of -c option".

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
V2: old sending stream image is used
---
 .../016-send-clone-src/send-stream-v4.8.2.img  | Bin 0 -> 6299778 bytes
 tests/misc-tests/016-send-clone-src/test.sh|  49 +
 2 files changed, 49 insertions(+)
 create mode 100644 tests/misc-tests/016-send-clone-src/send-stream-v4.8.2.img
 create mode 100755 tests/misc-tests/016-send-clone-src/test.sh

diff --git a/tests/misc-tests/016-send-clone-src/send-stream-v4.8.2.img 
b/tests/misc-tests/016-send-clone-src/send-stream-v4.8.2.img
new file mode 100644
index 
..ab774171b9677344f59fbfdacf13aebe8929ccfc
GIT binary patch
literal 6299778
zcmeF(ZOmk6eID>@pU2*reZgmaX3g3hD@1my$dNbp%(Gj+Db32RVkxA>5UH|hn>0!Hq?o5XmG;Qa4t~QB_K*0r>@2l-dmu7-T7c`@tb<
z!StT<_+@aUe({I-^7~6O`xbIvut^L)N<y8X89)X`J7-!{MTmh4G#U3qQgNB`@t
ztttm|>W-W4JbLQnjqjPZvpqSKyWe{IuRZ<TpZ$}6^Z8G{`?)LrUcZ%b_LXm}=5RUx
znTH;|_@hr<a`nSUPL8g+_q?~CQ_dgUJ)L7i=8gaL=Kooh)q(Q)12<oA{p#f1-+u1!
z{<Y(s`|oM?z2^A9@SW}#{`OdvQM$!)K5M7vmJhe{fsa33%8qmE?D%CzFF$(ec3JOP
z{gyIE%4=W#<ZYk+?t0?TOP83o)7RJP9p&<e^8Anf`mws)^yN8sSRWb=Uv67}wX
zp}+j?Km3(PuKmab`@eYZb=Q1-1@!V4-}q{)Bd>h8`xDO2pWg89pIy7w8Edz=u-s^p
zYZi~ccP+4Y?Fyr{^$MiU`yRdb{<ZL#CGfyYVpo;G;e6>+_dLE9SbtiVjeqsX`qNq+
zuRpET@$Q59-QWE4$6jK;{OA?C4`%Df9?TVopM7CH@#=$_y}k$2^huSk{L%{tUi}rb
z^=C9mO2iN#K!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C7
z2oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N
z0t5+009C72oNAZfB*pk1PBlyK!5-N0t5+
z009C72oNAZfB=Eb3p9OFW$Take4@%I-C{YPwzE3pq?}mI<dxO#v3CLl2oNAZfB*pk
z1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZ
zfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5>KY
zeE3_>Us7e1Zn2zC+gY7)a(d6uX_AzPAwYlt0RjXF5FkK+009C72oNAZfB*pk1PBly
zK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk
z1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0-G0T`lQOUw^ZM+GD^2t
zHME-~C1MB=AV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk
z1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZ
zfB*pk1PBlyK!CvJ1)4soa`K87uc<Ohw^+`n?X1qYG}|89O_CBZ1PBlyK!5-N0t5
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C7
z2oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N
z0t5+009C72oNAZfB*pk1PBlyK!5-N0t5+
z009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZVDkb^pHzAH
ztNWj<GD^2t%6}hjx>)+I*pk1PBlyK!5-N0t5
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk
z1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZ
zfB*pk1PBlyK!5-N0t5+K+^O{m1}SK~(k+(rX*;VkPEMaO
z_)L-#F$4$@AV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk
z1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZ
zfB*pk1PBlyKw$F%O`lYG@E0HXy(*)0i{*UU+XCP|4H0t5
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk
z1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZ
zfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyuz7)|PpW+K
zL*MvBl~KCIaz1Tmb;hOH-l5$jDG@_}009C72oNAZfB*pk1PBlyK!5-N0t5
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZ
zfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C7
z2oNAZfB*pk1PBlyK!5-N0t5!l{?>c<Uo~Cy2WxnZD)1HNxye!
zHz}*l*VKRj0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+
z009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBly
zK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk
z1PBlyK!5-N0t5`lZx;m)`IqRJ@UVmY6-vpVDC^l0#zBqd@95FkK+009C72oNAZ
zfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C7
z2oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N
z0t5+009C72oNAZfB*pk1PBlyK!5-N0t5?<^`HQsdDc-
zzj}3*QM$!)K5b`p#>t8DDl<t+#1J4rfB*pk1PBlyK!5-N0t5+
z009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBly
zK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk
z1PBlyK!5-N0t5+0D;X5G<{NK`_ha4rphSYVmY6-vpVC_Y~Rps
zl9Y%cK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZ
zfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C7
z2oNAZfB*pkn-^{>r|KhsqirCTiL({@&8ob>yKc9XK`%4q5FkK+009C72oNAZ
zfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C7
z2oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N
z0t5+009C72oNAZfB*pk1PBlyK!5-N0t5()3A{XPRIC
z<tn3ei{*UU)B6XXNm3$)009C72oNAZfB*pk1PBlyK!5-N0t5
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5+009C72oNAZfB*pk
z1PBlyK!5-N0t5+009C72oNAZfB*pk1PBlyK!5-N0t5
z0RjXF5FkK+009C7

Re: [PATCH] btrfs-progs: send-test: add checking of clone-src option

2016-11-08 Thread Tsutomu Itoh
On 2016/11/08 21:47, David Sterba wrote:
> On Tue, Nov 08, 2016 at 08:53:04AM +0900, Tsutomu Itoh wrote:
>> On 2016/11/08 0:16, David Sterba wrote:
>>> On Fri, Nov 04, 2016 at 05:35:18PM +0900, Tsutomu Itoh wrote:
>>>> +before_size=`ls -l "$here"/send.stream.before | awk '{print $5}'`
>>>> +after_size=`ls -l "$here"/send.stream.after | awk '{print $5}'`
>>>
>>> Thanks for the test. Minor fixes: "stat --format=%s" instead of the
>>> above, and /dev/zero instead of urandom and stream redirection so it
>>> works in my NFS setup.
>>
>> Thanks for the fixing.
>> But following command should be old btrfs. So please use 'btrfs' instead
>> of '$TOP/btrfs'.
>>
>>run_check $SUDO_HELPER $TOP/btrfs send -f "$here"/send.stream.before \
>>-c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]
> 
> Oh, I see, but this would make the test unreliable. What if there's a
> updated version installed? So we have to produce the right stream and
> then compare the result with the one generated by the built version.

I understood. I'll post V2 patch.

Thanks,
Tsutomu

--
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] btrfs-progs: send-test: add checking of clone-src option

2016-11-07 Thread Tsutomu Itoh
On 2016/11/08 0:16, David Sterba wrote:
> On Fri, Nov 04, 2016 at 05:35:18PM +0900, Tsutomu Itoh wrote:
>> +before_size=`ls -l "$here"/send.stream.before | awk '{print $5}'`
>> +after_size=`ls -l "$here"/send.stream.after | awk '{print $5}'`
> 
> Thanks for the test. Minor fixes: "stat --format=%s" instead of the
> above, and /dev/zero instead of urandom and stream redirection so it
> works in my NFS setup.

Thanks for the fixing.
But following command should be old btrfs. So please use 'btrfs' instead
of '$TOP/btrfs'.

   run_check $SUDO_HELPER $TOP/btrfs send -f "$here"/send.stream.before \
   -c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]

Thanks,
Tsutomu

> --
> 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] btrfs-progs: send-test: add checking of clone-src option

2016-11-04 Thread Tsutomu Itoh
Sending stream size of clone-src(-c) option is checked.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 tests/misc-tests/016-send-clone-src/test.sh | 54 +
 1 file changed, 54 insertions(+)
 create mode 100755 tests/misc-tests/016-send-clone-src/test.sh

diff --git a/tests/misc-tests/016-send-clone-src/test.sh 
b/tests/misc-tests/016-send-clone-src/test.sh
new file mode 100755
index 000..16d
--- /dev/null
+++ b/tests/misc-tests/016-send-clone-src/test.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+#
+# test for sending stream size of clone-src option
+
+source $TOP/tests/common
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+prepare_test_dev 2g
+
+run_check $TOP/mkfs.btrfs -f $IMAGE
+run_check_mount_test_dev
+
+here=`pwd`
+cd "$TEST_MNT" || _fail "cannot chdir to TEST_MNT"
+
+run_check $SUDO_HELPER btrfs subvolume create subv-parent1
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent1/file1_1 bs=1M 
count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent1 subv-snap1_1
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent1/file1_2 bs=1M 
count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent1 subv-snap1_2
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent1/file1_3 bs=1M 
count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent1 subv-snap1_3
+
+run_check $SUDO_HELPER btrfs subvolume create subv-parent2
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent2/file2_1 bs=1M 
count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent2 subv-snap2_1
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent2/file2_2 bs=1M 
count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent2 subv-snap2_2
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent2/file2_3 bs=1M 
count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent2 subv-snap2_3
+
+run_check $SUDO_HELPER btrfs send -f "$here"/send.stream.before \
+   -c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]
+
+run_check $SUDO_HELPER $TOP/btrfs send -f "$here"/send.stream.after \
+   -c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]
+
+before_size=`ls -l "$here"/send.stream.before | awk '{print $5}'`
+after_size=`ls -l "$here"/send.stream.after | awk '{print $5}'`
+
+if [ $before_size -lt $after_size ]; then
+   run_check ls -l "$here"/send.stream.*
+   _fail "sending stream size is bigger than old stream"
+fi
+
+run_check rm -f "$here"/send.stream.*
+
+cd "$here" || _fail "cannot chdir back to test directory"
+
+run_check_umount_test_dev
+
-- 
2.9.3
--
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 3/3] btrfs-progs: send: fix handling of -c option

2016-11-04 Thread Tsutomu Itoh
When two or more -c options are specified, cannot find a suitable
parent. So, output stream is bigger than correct one.

[before]
# btrfs send -f /tmp/data1 -c Snap0 -c ../SnapX Snap[12] ../SnapY
At subvol Snap1
At subvol Snap2
At subvol ../SnapY
# ls -l /tmp/data1
-rw--- 1 root root 3153 Oct 19 10:37 /tmp/data1
#

[after]
# btrfs send -f /tmp/data1 -c Snap0 -c ../SnapX Snap[12] ../SnapY
At subvol Snap1
At subvol Snap2
At subvol ../SnapY
# ls -l /tmp/data1
-rw--- 1 root root 1492 Oct 19 10:39 /tmp/data1
#

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
v2: make helper functions
---
 cmds-send.c | 58 ++
 1 file changed, 38 insertions(+), 20 deletions(-)

diff --git a/cmds-send.c b/cmds-send.c
index 2a8a697..f831e99 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -411,6 +411,36 @@ out:
return ret;
 }
 
+static int set_root_info(struct btrfs_send *s, char *subvol, u64 *root_id)
+{
+   int ret;
+
+   ret = init_root_path(s, subvol);
+   if (ret < 0)
+   goto out;
+
+   ret = get_root_id(s, subvol_strip_mountpoint(s->root_path, subvol),
+   root_id);
+   if (ret < 0) {
+   error("cannot resolve rootid for %s", subvol);
+   goto out;
+   }
+
+out:
+   return ret;
+}
+
+static void free_send_info(struct btrfs_send *s)
+{
+   if (s->mnt_fd >= 0) {
+   close(s->mnt_fd);
+   s->mnt_fd = -1;
+   }
+   free(s->root_path);
+   s->root_path = NULL;
+   subvol_uuid_search_finit(>sus);
+}
+
 int cmd_send(int argc, char **argv)
 {
char *subvol = NULL;
@@ -460,18 +490,10 @@ int cmd_send(int argc, char **argv)
goto out;
}
 
-   ret = init_root_path(, subvol);
+   ret = set_root_info(, subvol, _id);
if (ret < 0)
goto out;
 
-   ret = get_root_id(,
-   subvol_strip_mountpoint(send.root_path, subvol),
-   _id);
-   if (ret < 0) {
-   error("cannot resolve rootid for %s", subvol);
-   goto out;
-   }
-
ret = is_subvol_ro(, subvol);
if (ret < 0)
goto out;
@@ -486,15 +508,9 @@ int cmd_send(int argc, char **argv)
error("cannot add clone source: %s", 
strerror(-ret));
goto out;
}
-   subvol_uuid_search_finit();
free(subvol);
subvol = NULL;
-   if (send.mnt_fd >= 0) {
-   close(send.mnt_fd);
-   send.mnt_fd = -1;
-   }
-   free(send.root_path);
-   send.root_path = NULL;
+   free_send_info();
full_send = 0;
break;
case 'f':
@@ -651,6 +667,10 @@ int cmd_send(int argc, char **argv)
}
 
if (!full_send && root_id) {
+   ret = set_root_info(, subvol, _id);
+   if (ret < 0)
+   goto out;
+
ret = find_good_parent(, root_id, _root_id);
if (ret < 0) {
error("parent determination failed for %lld",
@@ -680,6 +700,7 @@ int cmd_send(int argc, char **argv)
error("cannot add clone source: %s", 
strerror(-ret));
goto out;
}
+   free_send_info();
}
}
 
@@ -689,10 +710,7 @@ out:
free(subvol);
free(snapshot_parent);
free(send.clone_sources);
-   if (send.mnt_fd >= 0)
-   close(send.mnt_fd);
-   free(send.root_path);
-   subvol_uuid_search_finit();
+   free_send_info();
return !!ret;
 }
 
-- 
2.9.3
--
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 3/3] btrfs-progs: send: fix handling of -c option

2016-11-03 Thread Tsutomu Itoh
On 2016/11/02 21:22, David Sterba wrote:
> On Wed, Oct 19, 2016 at 11:35:40AM +0900, Tsutomu Itoh wrote:
>> When two or more -c options are specified, cannot find a suitable
>> parent. So, output stream is bigger than correct one.
>>
>> [before]
>> # btrfs send -f /tmp/data1 -c Snap0 -c ../SnapX Snap[12] ../SnapY
>> At subvol Snap1
>> At subvol Snap2
>> At subvol ../SnapY
>> # ls -l /tmp/data1
>> -rw--- 1 root root 3153 Oct 19 10:37 /tmp/data1
>> #
>>
>> [after]
>> # btrfs send -f /tmp/data1 -c Snap0 -c ../SnapX Snap[12] ../SnapY
>> At subvol Snap1
>> At subvol Snap2
>> At subvol ../SnapY
>> # ls -l /tmp/data1
>> -rw--- 1 root root 1492 Oct 19 10:39 /tmp/data1
>> #
> 
> Can you please create a test for that?

OK, I'll try to create a test case.

> 
>> Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
>> ---
>>  cmds-send.c | 12 
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/cmds-send.c b/cmds-send.c
>> index 2a8a697..b93a667 100644
>> --- a/cmds-send.c
>> +++ b/cmds-send.c
>> @@ -651,6 +651,18 @@ int cmd_send(int argc, char **argv)
>>  }
>>  
>>  if (!full_send && root_id) {
>> +ret = init_root_path(, subvol);
>> +if (ret < 0)
>> +goto out;
>> +
>> +ret = get_root_id(,
>> +subvol_strip_mountpoint(send.root_path, subvol),
>> +_id);
>> +if (ret < 0) {
>> +error("cannot resolve rootid for %s", subvol);
>> +goto out;
>> +}
> 
> This duplicates the code that handles the '-c' option, please factori it
> toa helper function.

I will update the patch.

Thanks,
Tsutomu

> 
>> +
>>  ret = find_good_parent(, root_id, _root_id);
>>  if (ret < 0) {
>>  error("parent determination failed for %lld",
> --
> 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 2/3] btrfs-progs: send: fix handling of multiple snapshots (-p option)

2016-11-01 Thread Tsutomu Itoh
Sorry for the late reply.

On 2016/10/29 0:10, David Sterba wrote:
> On Wed, Oct 19, 2016 at 11:35:03AM +0900, Tsutomu Itoh wrote:
>> We cannot send multiple snapshots at once by -p option.
> 
> We cannot like that it's broken, or we cannot because it's not supposed
> to work that way. I guess it's the former, but the changelog text is a
> bit confusing.

Sorry, I'm not good at English.

>>
>> [before]
>> # btrfs send -f /tmp/data0 -p Snap0 Snap[12]
>> At subvol Snap1
>> At subvol Snap2
>> ERROR: parent determination failed for 0
>> # 
>>
>> [after]
>> # btrfs send -f /tmp/data0 -p Snap0 Snap[12]
>> At subvol Snap1
>> At subvol Snap2
>> # 
> 
> I'm not sure it's fixed, I wrote a simple test, attached, that triggers
> the bug even with the patch applied.
> 

In the attached script,

   run_check $SUDO_HELPER btrfs send -f "$here"/send.stream -p subv-snap1 
subv-snap2 subv-snap3

I think that 'btrfs' is a mistake of '$TOP/btrfs'.

Thanks,
Tsutomu

--
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 1/3] btrfs-progs: send: remove unnecessary code

2016-10-18 Thread Tsutomu Itoh
Some unnecessary codes are deleted.

 - the setting of subvol is double.
 - read only check was already done by previous loop.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
v2: description was changed
---
 cmds-send.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/cmds-send.c b/cmds-send.c
index 74d0128..dfdfe01 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -564,8 +564,6 @@ int cmd_send(int argc, char **argv)
}
 
/* use first send subvol to determine mount_root */
-   subvol = argv[optind];
-
subvol = realpath(argv[optind], NULL);
if (!subvol) {
ret = -errno;
@@ -661,15 +659,6 @@ int cmd_send(int argc, char **argv)
}
}
 
-   ret = is_subvol_ro(, subvol);
-   if (ret < 0)
-   goto out;
-   if (!ret) {
-   ret = -EINVAL;
-   error("subvolume %s is not read-only", subvol);
-   goto out;
-   }
-
if (new_end_cmd_semantic) {
/* require new kernel */
is_first_subvol = (i == optind);
-- 
2.9.3
--
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/3] btrfs-progs: send: fix handling of multiple snapshots (-p option)

2016-10-18 Thread Tsutomu Itoh
We cannot send multiple snapshots at once by -p option.

[before]
# btrfs send -f /tmp/data0 -p Snap0 Snap[12]
At subvol Snap1
At subvol Snap2
ERROR: parent determination failed for 0
# 

[after]
# btrfs send -f /tmp/data0 -p Snap0 Snap[12]
At subvol Snap1
At subvol Snap2
# 

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 cmds-send.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/cmds-send.c b/cmds-send.c
index dfdfe01..2a8a697 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -650,7 +650,7 @@ int cmd_send(int argc, char **argv)
goto out;
}
 
-   if (!full_send && !parent_root_id) {
+   if (!full_send && root_id) {
ret = find_good_parent(, root_id, _root_id);
if (ret < 0) {
error("parent determination failed for %lld",
@@ -673,7 +673,7 @@ int cmd_send(int argc, char **argv)
if (ret < 0)
goto out;
 
-   if (!full_send) {
+   if (!full_send && root_id) {
/* done with this subvol, so add it to the clone 
sources */
ret = add_clone_source(, root_id);
if (ret < 0) {
@@ -681,8 +681,6 @@ int cmd_send(int argc, char **argv)
goto out;
}
}
-
-   parent_root_id = 0;
}
 
ret = 0;
-- 
2.9.3
--
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/3] btrfs-progs: send: fix handling of -c option

2016-10-18 Thread Tsutomu Itoh
When two or more -c options are specified, cannot find a suitable
parent. So, output stream is bigger than correct one.

[before]
# btrfs send -f /tmp/data1 -c Snap0 -c ../SnapX Snap[12] ../SnapY
At subvol Snap1
At subvol Snap2
At subvol ../SnapY
# ls -l /tmp/data1
-rw--- 1 root root 3153 Oct 19 10:37 /tmp/data1
#

[after]
# btrfs send -f /tmp/data1 -c Snap0 -c ../SnapX Snap[12] ../SnapY
At subvol Snap1
At subvol Snap2
At subvol ../SnapY
# ls -l /tmp/data1
-rw--- 1 root root 1492 Oct 19 10:39 /tmp/data1
#

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 cmds-send.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/cmds-send.c b/cmds-send.c
index 2a8a697..b93a667 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -651,6 +651,18 @@ int cmd_send(int argc, char **argv)
}
 
if (!full_send && root_id) {
+   ret = init_root_path(, subvol);
+   if (ret < 0)
+   goto out;
+
+   ret = get_root_id(,
+   subvol_strip_mountpoint(send.root_path, subvol),
+   _id);
+   if (ret < 0) {
+   error("cannot resolve rootid for %s", subvol);
+   goto out;
+   }
+
ret = find_good_parent(, root_id, _root_id);
if (ret < 0) {
error("parent determination failed for %lld",
-- 
2.9.3
--
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/3] btrfs-progs: send: remove unnecessary code

2016-10-18 Thread Tsutomu Itoh
Some unnecessary codes is deleted.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 cmds-send.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/cmds-send.c b/cmds-send.c
index 74d0128..dfdfe01 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -564,8 +564,6 @@ int cmd_send(int argc, char **argv)
}
 
/* use first send subvol to determine mount_root */
-   subvol = argv[optind];
-
subvol = realpath(argv[optind], NULL);
if (!subvol) {
ret = -errno;
@@ -661,15 +659,6 @@ int cmd_send(int argc, char **argv)
}
}
 
-   ret = is_subvol_ro(, subvol);
-   if (ret < 0)
-   goto out;
-   if (!ret) {
-   ret = -EINVAL;
-   error("subvolume %s is not read-only", subvol);
-   goto out;
-   }
-
if (new_end_cmd_semantic) {
/* require new kernel */
is_first_subvol = (i == optind);
-- 
2.9.3
--
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-progs: image: fix compiler warning

2016-10-05 Thread Tsutomu Itoh
In v4.8-rc1, gcc 5.3.1 gives following warning. Fixed it.

[CC] btrfs-image.o
btrfs-image.c: In function 'flush_pending':
btrfs-image.c:708:17: warning: 'start' may be used uninitialized in this 
function [-Wmaybe-uninitialized]
  header->bytenr = cpu_to_le64(start);
 ^
btrfs-image.c:927:6: note: 'start' was declared here
  u64 start;
  ^

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 btrfs-image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/btrfs-image.c b/btrfs-image.c
index 0d410f8..47f36b9 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -924,7 +924,7 @@ static int flush_pending(struct metadump_struct *md, int 
done)
struct async_work *async = NULL;
struct extent_buffer *eb;
u64 blocksize = md->root->nodesize;
-   u64 start;
+   u64 start = 0;
u64 size;
size_t offset;
int ret = 0;
-- 
2.9.3

----
Tsutomu Itoh  t-i...@jp.fujitsu.com
--
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] btrfs-progs: add the error message when open fails

2016-06-09 Thread Tsutomu Itoh

Hi, David,

On 2016/06/09 22:13, David Sterba wrote:

On Thu, Jun 09, 2016 at 10:23:15AM +0900, Tsutomu Itoh wrote:

When open in btrfs_open_devices failed, only the following message is
displayed. Therefore the user doesn't understand the reason why open
failed.

  # btrfs check /dev/sdb8
  Couldn't open file system

This patch adds the error message when open fails.


I think the message should be printed by the caller, not by the helper.


However in this case, error device name is not understood in the caller.

Thanks,
Tsutomu


--
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] btrfs-progs: add the error message when open fails

2016-06-08 Thread Tsutomu Itoh
When open in btrfs_open_devices failed, only the following message is
displayed. Therefore the user doesn't understand the reason why open
failed.

  # btrfs check /dev/sdb8
  Couldn't open file system

This patch adds the error message when open fails.

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 volumes.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/volumes.c b/volumes.c
index ccfa732..80d61cf 100644
--- a/volumes.c
+++ b/volumes.c
@@ -227,6 +227,8 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, 
int flags)
fd = open(device->name, flags);
if (fd < 0) {
ret = -errno;
+   error("cannot open '%s': %s", device->name,
+ strerror(errno));
goto fail;
}
 
-- 
2.8.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: [PATCH v2] btrfs: use dynamic allocation for root item in create_subvol

2016-04-25 Thread Tsutomu Itoh
On 2016/04/25 20:18, David Sterba wrote:
> The size of root item is more than 400 bytes, which is quite a lot of
> stack space. As we do IO from inside the subvolume ioctls, we should
> keep the stack usage low in case the filesystem is on top of other
> layers (NFS, device mapper, iscsi, etc).
> 
> Signed-off-by: David Sterba <dste...@suse.com>

Looks good to me.

Reviewed-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>

> ---
>   fs/btrfs/ioctl.c | 65 
> 
>   1 file changed, 37 insertions(+), 28 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 053e677839fe..9a63fe07bc2e 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -439,7 +439,7 @@ static noinline int create_subvol(struct inode *dir,
>   {
>   struct btrfs_trans_handle *trans;
>   struct btrfs_key key;
> - struct btrfs_root_item root_item;
> + struct btrfs_root_item *root_item;
>   struct btrfs_inode_item *inode_item;
>   struct extent_buffer *leaf;
>   struct btrfs_root *root = BTRFS_I(dir)->root;
> @@ -455,16 +455,22 @@ static noinline int create_subvol(struct inode *dir,
>   u64 qgroup_reserved;
>   uuid_le new_uuid;
>   
> + root_item = kzalloc(sizeof(*root_item), GFP_KERNEL);
> + if (!root_item)
> + return -ENOMEM;
> +
>   ret = btrfs_find_free_objectid(root->fs_info->tree_root, );
>   if (ret)
> - return ret;
> + goto fail_free;
>   
>   /*
>* Don't create subvolume whose level is not zero. Or qgroup will be
>* screwed up since it assume subvolme qgroup's level to be 0.
>*/
> - if (btrfs_qgroup_level(objectid))
> - return -ENOSPC;
> + if (btrfs_qgroup_level(objectid)) {
> + ret = -ENOSPC;
> + goto fail_free;
> + }
>   
>   btrfs_init_block_rsv(_rsv, BTRFS_BLOCK_RSV_TEMP);
>   /*
> @@ -474,14 +480,14 @@ static noinline int create_subvol(struct inode *dir,
>   ret = btrfs_subvolume_reserve_metadata(root, _rsv,
>  8, _reserved, false);
>   if (ret)
> - return ret;
> + goto fail_free;
>   
>   trans = btrfs_start_transaction(root, 0);
>   if (IS_ERR(trans)) {
>   ret = PTR_ERR(trans);
>   btrfs_subvolume_release_metadata(root, _rsv,
>qgroup_reserved);
> - return ret;
> + goto fail_free;
>   }
>   trans->block_rsv = _rsv;
>   trans->bytes_reserved = block_rsv.size;
> @@ -509,47 +515,45 @@ static noinline int create_subvol(struct inode *dir,
>   BTRFS_UUID_SIZE);
>   btrfs_mark_buffer_dirty(leaf);
>   
> - memset(_item, 0, sizeof(root_item));
> -
> - inode_item = _item.inode;
> + inode_item = _item->inode;
>   btrfs_set_stack_inode_generation(inode_item, 1);
>   btrfs_set_stack_inode_size(inode_item, 3);
>   btrfs_set_stack_inode_nlink(inode_item, 1);
>   btrfs_set_stack_inode_nbytes(inode_item, root->nodesize);
>   btrfs_set_stack_inode_mode(inode_item, S_IFDIR | 0755);
>   
> - btrfs_set_root_flags(_item, 0);
> - btrfs_set_root_limit(_item, 0);
> + btrfs_set_root_flags(root_item, 0);
> + btrfs_set_root_limit(root_item, 0);
>   btrfs_set_stack_inode_flags(inode_item, BTRFS_INODE_ROOT_ITEM_INIT);
>   
> - btrfs_set_root_bytenr(_item, leaf->start);
> - btrfs_set_root_generation(_item, trans->transid);
> - btrfs_set_root_level(_item, 0);
> - btrfs_set_root_refs(_item, 1);
> - btrfs_set_root_used(_item, leaf->len);
> - btrfs_set_root_last_snapshot(_item, 0);
> + btrfs_set_root_bytenr(root_item, leaf->start);
> + btrfs_set_root_generation(root_item, trans->transid);
> + btrfs_set_root_level(root_item, 0);
> + btrfs_set_root_refs(root_item, 1);
> + btrfs_set_root_used(root_item, leaf->len);
> + btrfs_set_root_last_snapshot(root_item, 0);
>   
> - btrfs_set_root_generation_v2(_item,
> - btrfs_root_generation(_item));
> + btrfs_set_root_generation_v2(root_item,
> + btrfs_root_generation(root_item));
>   uuid_le_gen(_uuid);
> - memcpy(root_item.uuid, new_uuid.b, BTRFS_UUID_SIZE);
> - btrfs_set_stack_timespec_sec(_item.otime, cur_time.tv_sec);
> - btrfs_set_stack_timespec_nsec(_item.otime, cur_time.tv_nsec);
> - root_item.ctime = root_item.otime;
> - btrfs_set_root_ctransid(_item, trans->transid);
> - btrfs_set_root_otransid(_

Re: [PATCH 1/2] btrfs: use dynamic allocation for root item in create_subvol

2016-04-11 Thread Tsutomu Itoh
On 2016/04/12 3:04, David Sterba wrote:
> The size of root item is more than 400 bytes, which is quite a lot of
> stack space. As we do IO from inside the subvolume ioctls, we should
> keep the stack usage low in case the filesystem is on top of other
> layers (NFS, device mapper, iscsi, etc).
> 
> Signed-off-by: David Sterba 
> ---
>   fs/btrfs/ioctl.c | 49 ++---
>   1 file changed, 26 insertions(+), 23 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 053e677839fe..0be13b9c53d9 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -439,7 +439,7 @@ static noinline int create_subvol(struct inode *dir,
>   {
>   struct btrfs_trans_handle *trans;
>   struct btrfs_key key;
> - struct btrfs_root_item root_item;
> + struct btrfs_root_item *root_item;
>   struct btrfs_inode_item *inode_item;
>   struct extent_buffer *leaf;
>   struct btrfs_root *root = BTRFS_I(dir)->root;
> @@ -455,6 +455,10 @@ static noinline int create_subvol(struct inode *dir,
>   u64 qgroup_reserved;
>   uuid_le new_uuid;
>   
> + root_item = kzalloc(sizeof(*root_item), GFP_KERNEL);
> + if (!root_item)
> + return -ENOMEM;
> +
>   ret = btrfs_find_free_objectid(root->fs_info->tree_root, );
>   if (ret)
>   return ret;

'kfree(root_item)' is necessary here and other 'return'.

Thanks,
Tsutomu

> @@ -509,47 +513,45 @@ static noinline int create_subvol(struct inode *dir,
>   BTRFS_UUID_SIZE);
>   btrfs_mark_buffer_dirty(leaf);
>   
> - memset(_item, 0, sizeof(root_item));
> -
> - inode_item = _item.inode;
> + inode_item = _item->inode;
>   btrfs_set_stack_inode_generation(inode_item, 1);
>   btrfs_set_stack_inode_size(inode_item, 3);
>   btrfs_set_stack_inode_nlink(inode_item, 1);
>   btrfs_set_stack_inode_nbytes(inode_item, root->nodesize);
>   btrfs_set_stack_inode_mode(inode_item, S_IFDIR | 0755);
>   
> - btrfs_set_root_flags(_item, 0);
> - btrfs_set_root_limit(_item, 0);
> + btrfs_set_root_flags(root_item, 0);
> + btrfs_set_root_limit(root_item, 0);
>   btrfs_set_stack_inode_flags(inode_item, BTRFS_INODE_ROOT_ITEM_INIT);
>   
> - btrfs_set_root_bytenr(_item, leaf->start);
> - btrfs_set_root_generation(_item, trans->transid);
> - btrfs_set_root_level(_item, 0);
> - btrfs_set_root_refs(_item, 1);
> - btrfs_set_root_used(_item, leaf->len);
> - btrfs_set_root_last_snapshot(_item, 0);
> + btrfs_set_root_bytenr(root_item, leaf->start);
> + btrfs_set_root_generation(root_item, trans->transid);
> + btrfs_set_root_level(root_item, 0);
> + btrfs_set_root_refs(root_item, 1);
> + btrfs_set_root_used(root_item, leaf->len);
> + btrfs_set_root_last_snapshot(root_item, 0);
>   
> - btrfs_set_root_generation_v2(_item,
> - btrfs_root_generation(_item));
> + btrfs_set_root_generation_v2(root_item,
> + btrfs_root_generation(root_item));
>   uuid_le_gen(_uuid);
> - memcpy(root_item.uuid, new_uuid.b, BTRFS_UUID_SIZE);
> - btrfs_set_stack_timespec_sec(_item.otime, cur_time.tv_sec);
> - btrfs_set_stack_timespec_nsec(_item.otime, cur_time.tv_nsec);
> - root_item.ctime = root_item.otime;
> - btrfs_set_root_ctransid(_item, trans->transid);
> - btrfs_set_root_otransid(_item, trans->transid);
> + memcpy(root_item->uuid, new_uuid.b, BTRFS_UUID_SIZE);
> + btrfs_set_stack_timespec_sec(_item->otime, cur_time.tv_sec);
> + btrfs_set_stack_timespec_nsec(_item->otime, cur_time.tv_nsec);
> + root_item->ctime = root_item->otime;
> + btrfs_set_root_ctransid(root_item, trans->transid);
> + btrfs_set_root_otransid(root_item, trans->transid);
>   
>   btrfs_tree_unlock(leaf);
>   free_extent_buffer(leaf);
>   leaf = NULL;
>   
> - btrfs_set_root_dirid(_item, new_dirid);
> + btrfs_set_root_dirid(root_item, new_dirid);
>   
>   key.objectid = objectid;
>   key.offset = 0;
>   key.type = BTRFS_ROOT_ITEM_KEY;
>   ret = btrfs_insert_root(trans, root->fs_info->tree_root, ,
> - _item);
> + root_item);
>   if (ret)
>   goto fail;
>   
> @@ -601,12 +603,13 @@ static noinline int create_subvol(struct inode *dir,
>   BUG_ON(ret);
>   
>   ret = btrfs_uuid_tree_add(trans, root->fs_info->uuid_root,
> -   root_item.uuid, BTRFS_UUID_KEY_SUBVOL,
> +   root_item->uuid, BTRFS_UUID_KEY_SUBVOL,
> objectid);
>   if (ret)
>   btrfs_abort_transaction(trans, root, ret);
>   
>   fail:
> + kfree(root_item);
>   trans->block_rsv = NULL;
>   trans->bytes_reserved = 0;
>   btrfs_subvolume_release_metadata(root, _rsv, qgroup_reserved);
> 

--
To unsubscribe from this list: send the line 

Re: [PATCH] Btrfs: fix missing s_id setting

2016-04-05 Thread Tsutomu Itoh

On 2016/04/05 17:52, Tsutomu Itoh wrote:

On 2016/04/05 16:56, Anand Jain wrote:

On 04/05/2016 08:08 AM, Tsutomu Itoh wrote:

When fs_devices->latest_bdev is deleted or is replaced, sb->s_id has
not been updated.
As a result, the deleted device name is displayed by btrfs_printk.

[before fix]
  # btrfs dev del /dev/sdc4 /mnt2
  # btrfs dev add /dev/sdb6 /mnt2

  [  217.458249] BTRFS info (device sdc4): found 1 extents
  [  217.695798] BTRFS info (device sdc4): disk deleted /dev/sdc4
  [  217.941284] BTRFS info (device sdc4): disk added /dev/sdb6

[after fix]
  # btrfs dev del /dev/sdc4 /mnt2
  # btrfs dev add /dev/sdb6 /mnt2

  [   83.835072] BTRFS info (device sdc4): found 1 extents
  [   84.080617] BTRFS info (device sdc3): disk deleted /dev/sdc4
  [   84.401951] BTRFS info (device sdc3): disk added /dev/sdb6



  [PATCH 05/13] Btrfs: fix fs logging for multi device

  any comments ?

  We would want to maintain the logging prefix as constant, so that
  troubleshooters with filters/scripts will find it helpful.


I think it is good to make the identifier constant for the troubleshooting.
However, fsid(uuid) is a little long for the print purpose, I think.
(But an appropriate value isn't found...)


BTW, the state that the deleted device name is set to sb->s_id
is not good.

Thanks,
Tsutomu



Thanks,
Tsutomu



Thanks, Anand



Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
  fs/btrfs/dev-replace.c |  5 -
  fs/btrfs/volumes.c | 11 +--
  2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index a1d6652..11c4198 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -560,8 +560,11 @@ static int btrfs_dev_replace_finishing(struct 
btrfs_fs_info *fs_info,
  tgt_device->commit_bytes_used = src_device->bytes_used;
  if (fs_info->sb->s_bdev == src_device->bdev)
  fs_info->sb->s_bdev = tgt_device->bdev;
-if (fs_info->fs_devices->latest_bdev == src_device->bdev)
+if (fs_info->fs_devices->latest_bdev == src_device->bdev) {
  fs_info->fs_devices->latest_bdev = tgt_device->bdev;
+snprintf(fs_info->sb->s_id, sizeof(fs_info->sb->s_id), "%pg",
+ tgt_device->bdev);
+}
  list_add(_device->dev_alloc_list, _info->fs_devices->alloc_list);
  fs_info->fs_devices->rw_devices++;

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index e2b54d5..a471385 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1846,8 +1846,12 @@ int btrfs_rm_device(struct btrfs_root *root, char 
*device_path)
   struct btrfs_device, dev_list);
  if (device->bdev == root->fs_info->sb->s_bdev)
  root->fs_info->sb->s_bdev = next_device->bdev;
-if (device->bdev == root->fs_info->fs_devices->latest_bdev)
+if (device->bdev == root->fs_info->fs_devices->latest_bdev) {
  root->fs_info->fs_devices->latest_bdev = next_device->bdev;
+snprintf(root->fs_info->sb->s_id,
+ sizeof(root->fs_info->sb->s_id), "%pg",
+ next_device->bdev);
+}

  if (device->bdev) {
  device->fs_devices->open_devices--;
@@ -2034,8 +2038,11 @@ void btrfs_destroy_dev_replace_tgtdev(struct 
btrfs_fs_info *fs_info,
   struct btrfs_device, dev_list);
  if (tgtdev->bdev == fs_info->sb->s_bdev)
  fs_info->sb->s_bdev = next_device->bdev;
-if (tgtdev->bdev == fs_info->fs_devices->latest_bdev)
+if (tgtdev->bdev == fs_info->fs_devices->latest_bdev) {
  fs_info->fs_devices->latest_bdev = next_device->bdev;
+snprintf(fs_info->sb->s_id, sizeof(fs_info->sb->s_id), "%pg",
+ next_device->bdev);
+}
  list_del_rcu(>dev_list);

  call_rcu(>rcu, free_device);


--
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] Btrfs: fix missing s_id setting

2016-04-05 Thread Tsutomu Itoh

On 2016/04/05 16:56, Anand Jain wrote:

On 04/05/2016 08:08 AM, Tsutomu Itoh wrote:

When fs_devices->latest_bdev is deleted or is replaced, sb->s_id has
not been updated.
As a result, the deleted device name is displayed by btrfs_printk.

[before fix]
  # btrfs dev del /dev/sdc4 /mnt2
  # btrfs dev add /dev/sdb6 /mnt2

  [  217.458249] BTRFS info (device sdc4): found 1 extents
  [  217.695798] BTRFS info (device sdc4): disk deleted /dev/sdc4
  [  217.941284] BTRFS info (device sdc4): disk added /dev/sdb6

[after fix]
  # btrfs dev del /dev/sdc4 /mnt2
  # btrfs dev add /dev/sdb6 /mnt2

  [   83.835072] BTRFS info (device sdc4): found 1 extents
  [   84.080617] BTRFS info (device sdc3): disk deleted /dev/sdc4
  [   84.401951] BTRFS info (device sdc3): disk added /dev/sdb6



  [PATCH 05/13] Btrfs: fix fs logging for multi device

  any comments ?

  We would want to maintain the logging prefix as constant, so that
  troubleshooters with filters/scripts will find it helpful.


I think it is good to make the identifier constant for the troubleshooting.
However, fsid(uuid) is a little long for the print purpose, I think.
(But an appropriate value isn't found...)

Thanks,
Tsutomu



Thanks, Anand



Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
  fs/btrfs/dev-replace.c |  5 -
  fs/btrfs/volumes.c | 11 +--
  2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index a1d6652..11c4198 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -560,8 +560,11 @@ static int btrfs_dev_replace_finishing(struct 
btrfs_fs_info *fs_info,
  tgt_device->commit_bytes_used = src_device->bytes_used;
  if (fs_info->sb->s_bdev == src_device->bdev)
  fs_info->sb->s_bdev = tgt_device->bdev;
-if (fs_info->fs_devices->latest_bdev == src_device->bdev)
+if (fs_info->fs_devices->latest_bdev == src_device->bdev) {
  fs_info->fs_devices->latest_bdev = tgt_device->bdev;
+snprintf(fs_info->sb->s_id, sizeof(fs_info->sb->s_id), "%pg",
+ tgt_device->bdev);
+}
  list_add(_device->dev_alloc_list, _info->fs_devices->alloc_list);
  fs_info->fs_devices->rw_devices++;

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index e2b54d5..a471385 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1846,8 +1846,12 @@ int btrfs_rm_device(struct btrfs_root *root, char 
*device_path)
   struct btrfs_device, dev_list);
  if (device->bdev == root->fs_info->sb->s_bdev)
  root->fs_info->sb->s_bdev = next_device->bdev;
-if (device->bdev == root->fs_info->fs_devices->latest_bdev)
+if (device->bdev == root->fs_info->fs_devices->latest_bdev) {
  root->fs_info->fs_devices->latest_bdev = next_device->bdev;
+snprintf(root->fs_info->sb->s_id,
+ sizeof(root->fs_info->sb->s_id), "%pg",
+ next_device->bdev);
+}

  if (device->bdev) {
  device->fs_devices->open_devices--;
@@ -2034,8 +2038,11 @@ void btrfs_destroy_dev_replace_tgtdev(struct 
btrfs_fs_info *fs_info,
   struct btrfs_device, dev_list);
  if (tgtdev->bdev == fs_info->sb->s_bdev)
  fs_info->sb->s_bdev = next_device->bdev;
-if (tgtdev->bdev == fs_info->fs_devices->latest_bdev)
+if (tgtdev->bdev == fs_info->fs_devices->latest_bdev) {
  fs_info->fs_devices->latest_bdev = next_device->bdev;
+snprintf(fs_info->sb->s_id, sizeof(fs_info->sb->s_id), "%pg",
+ next_device->bdev);
+}
  list_del_rcu(>dev_list);

  call_rcu(>rcu, free_device);


--
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] Btrfs: fix missing s_id setting

2016-04-04 Thread Tsutomu Itoh
When fs_devices->latest_bdev is deleted or is replaced, sb->s_id has
not been updated.
As a result, the deleted device name is displayed by btrfs_printk.

[before fix]
 # btrfs dev del /dev/sdc4 /mnt2
 # btrfs dev add /dev/sdb6 /mnt2

 [  217.458249] BTRFS info (device sdc4): found 1 extents
 [  217.695798] BTRFS info (device sdc4): disk deleted /dev/sdc4
 [  217.941284] BTRFS info (device sdc4): disk added /dev/sdb6

[after fix]
 # btrfs dev del /dev/sdc4 /mnt2
 # btrfs dev add /dev/sdb6 /mnt2

 [   83.835072] BTRFS info (device sdc4): found 1 extents
 [   84.080617] BTRFS info (device sdc3): disk deleted /dev/sdc4
 [   84.401951] BTRFS info (device sdc3): disk added /dev/sdb6

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 fs/btrfs/dev-replace.c |  5 -
 fs/btrfs/volumes.c | 11 +--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index a1d6652..11c4198 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -560,8 +560,11 @@ static int btrfs_dev_replace_finishing(struct 
btrfs_fs_info *fs_info,
tgt_device->commit_bytes_used = src_device->bytes_used;
if (fs_info->sb->s_bdev == src_device->bdev)
fs_info->sb->s_bdev = tgt_device->bdev;
-   if (fs_info->fs_devices->latest_bdev == src_device->bdev)
+   if (fs_info->fs_devices->latest_bdev == src_device->bdev) {
fs_info->fs_devices->latest_bdev = tgt_device->bdev;
+   snprintf(fs_info->sb->s_id, sizeof(fs_info->sb->s_id), "%pg",
+tgt_device->bdev);
+   }
list_add(_device->dev_alloc_list, _info->fs_devices->alloc_list);
fs_info->fs_devices->rw_devices++;
 
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index e2b54d5..a471385 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1846,8 +1846,12 @@ int btrfs_rm_device(struct btrfs_root *root, char 
*device_path)
 struct btrfs_device, dev_list);
if (device->bdev == root->fs_info->sb->s_bdev)
root->fs_info->sb->s_bdev = next_device->bdev;
-   if (device->bdev == root->fs_info->fs_devices->latest_bdev)
+   if (device->bdev == root->fs_info->fs_devices->latest_bdev) {
root->fs_info->fs_devices->latest_bdev = next_device->bdev;
+   snprintf(root->fs_info->sb->s_id,
+sizeof(root->fs_info->sb->s_id), "%pg",
+next_device->bdev);
+   }
 
if (device->bdev) {
device->fs_devices->open_devices--;
@@ -2034,8 +2038,11 @@ void btrfs_destroy_dev_replace_tgtdev(struct 
btrfs_fs_info *fs_info,
 struct btrfs_device, dev_list);
if (tgtdev->bdev == fs_info->sb->s_bdev)
fs_info->sb->s_bdev = next_device->bdev;
-   if (tgtdev->bdev == fs_info->fs_devices->latest_bdev)
+   if (tgtdev->bdev == fs_info->fs_devices->latest_bdev) {
fs_info->fs_devices->latest_bdev = next_device->bdev;
+   snprintf(fs_info->sb->s_id, sizeof(fs_info->sb->s_id), "%pg",
+next_device->bdev);
+   }
list_del_rcu(>dev_list);
 
call_rcu(>rcu, free_device);
-- 
2.6.4


--
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-progs: send: fix handling of multiple snapshots

2016-03-24 Thread Tsutomu Itoh
We cannot send multiple snapshots at once.

[before fix]
# btrfs send ./snap[12] > snap12.data
At subvol ./snap1
At subvol ./snap2
ERROR: parent determination failed for 0
#

[after fix]
# btrfs send ./snap[12] > snap12.data
At subvol ./snap1
At subvol ./snap2
#

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 cmds-send.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/cmds-send.c b/cmds-send.c
index 3e34d75..a220a49 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -683,15 +683,16 @@ int cmd_send(int argc, char **argv)
if (ret < 0)
goto out;
 
-   /* done with this subvol, so add it to the clone sources */
-   ret = add_clone_source(, root_id);
-   if (ret < 0) {
-   error("not enough memory");
-   goto out;
+   if (!full_send) {
+   /* done with this subvol, so add it to the clone 
sources */
+   ret = add_clone_source(, root_id);
+   if (ret < 0) {
+   error("not enough memory");
+   goto out;
+   }
}
 
parent_root_id = 0;
-   full_send = 0;
}
 
ret = 0;
-- 
2.6.4


--
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: fix output of compression message in btrfs_parse_options()

2016-01-06 Thread Tsutomu Itoh
The compression message might not be correctly output.
Fix it.

[[before fix]]

# mount -o compress /dev/sdb3 /test3
[  996.874264] BTRFS info (device sdb3): disk space caching is enabled
[  996.874268] BTRFS: has skinny extents
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)

# mount -o remount,compress-force /dev/sdb3 /test3
[ 1035.075017] BTRFS info (device sdb3): force zlib compression
[ 1035.075021] BTRFS info (device sdb3): disk space caching is enabled
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress-force=zlib,space_cache,subvolid=5,subvol=/)

# mount -o remount,compress /dev/sdb3 /test3
[ 1053.679092] BTRFS info (device sdb3): disk space caching is enabled
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)

[[after fix]]

# mount -o compress /dev/sdb3 /test3
[  401.021753] BTRFS info (device sdb3): use zlib compression
[  401.021758] BTRFS info (device sdb3): disk space caching is enabled
[  401.021760] BTRFS: has skinny extents
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)

# mount -o remount,compress-force /dev/sdb3 /test3
[  439.824624] BTRFS info (device sdb3): force zlib compression
[  439.824629] BTRFS info (device sdb3): disk space caching is enabled
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress-force=zlib,space_cache,subvolid=5,subvol=/)

# mount -o remount,compress /dev/sdb3 /test3
[  459.918430] BTRFS info (device sdb3): use zlib compression
[  459.918434] BTRFS info (device sdb3): disk space caching is enabled
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
V1->V2: It is corrected that API doesn't change.

 fs/btrfs/super.c | 29 ++---
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 24154e4..12d04c9 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -381,6 +381,9 @@ int btrfs_parse_options(struct btrfs_root *root, char 
*options)
int ret = 0;
char *compress_type;
bool compress_force = false;
+   enum btrfs_compression_type saved_compress_type;
+   bool saved_compress_force;
+   int no_compress = 0;
 
cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy);
if (cache_gen)
@@ -458,6 +461,10 @@ int btrfs_parse_options(struct btrfs_root *root, char 
*options)
/* Fallthrough */
case Opt_compress:
case Opt_compress_type:
+   saved_compress_type = btrfs_test_opt(root, COMPRESS) ?
+   info->compress_type : BTRFS_COMPRESS_NONE;
+   saved_compress_force =
+   btrfs_test_opt(root, FORCE_COMPRESS);
if (token == Opt_compress ||
token == Opt_compress_force ||
strcmp(args[0].from, "zlib") == 0) {
@@ -466,6 +473,7 @@ int btrfs_parse_options(struct btrfs_root *root, char 
*options)
btrfs_set_opt(info->mount_opt, COMPRESS);
btrfs_clear_opt(info->mount_opt, NODATACOW);
btrfs_clear_opt(info->mount_opt, NODATASUM);
+   no_compress = 0;
} else if (strcmp(args[0].from, "lzo") == 0) {
compress_type = "lzo";
info->compress_type = BTRFS_COMPRESS_LZO;
@@ -473,25 +481,21 @@ int btrfs_parse_options(struct btrfs_root *root, char 
*options)
btrfs_clear_opt(info->mount_opt, NODATACOW);
btrfs_clear_opt(info->mount_opt, NODATASUM);
btrfs_set_fs_incompat(info, COMPRESS_LZO);
+   no_compress = 0;
} else if (strncmp(args[0].from, "no", 2) == 0) {
compress_type = "no";
btrfs_clear_opt(info->mount_opt, COMPRESS);
btrfs_clear_opt(info->mount_opt, 
FORCE_COMPRESS);
compress_force = false;
+   no_compress++;
} else {
ret = -EINVAL;
goto out;
}
 
if (compress_force) {
-   btrfs_set_and_info(root, FORCE_COMPRESS,
-  "force %s compression",
- 

Re: [PATCH] Btrfs: fix output of compression message in btrfs_parse_options()

2016-01-05 Thread Tsutomu Itoh

Hi, David,

On 2016/01/05 23:12, David Sterba wrote:

On Wed, Dec 16, 2015 at 11:57:38AM +0900, Tsutomu Itoh wrote:

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 974be09..dcc1f15 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2709,7 +2709,7 @@ int open_ctree(struct super_block *sb,
 * In the long term, we'll store the compression type in the super
 * block, and it'll be used for per file compression control.
 */
-   fs_info->compress_type = BTRFS_COMPRESS_ZLIB;
+   fs_info->compress_type = BTRFS_COMPRESS_NONE;


This would change the default compression type, eg. when the compression
is turned on via chattr +c . This would break the applications out
there, the fix has to avoid changing that.


Thanks for pointing that out. I had forgotten chattr +c.
I'll post V2 patch later.

Thanks,
Tsutomu

--
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: fix output of compression message in btrfs_parse_options()

2015-12-15 Thread Tsutomu Itoh
The compression message might not be correctly output.
Fix it.

[[before fix]]

# mount -o compress /dev/sdb3 /test3
[  996.874264] BTRFS info (device sdb3): disk space caching is enabled
[  996.874268] BTRFS: has skinny extents
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)

# mount -o remount,compress-force /dev/sdb3 /test3
[ 1035.075017] BTRFS info (device sdb3): force zlib compression
[ 1035.075021] BTRFS info (device sdb3): disk space caching is enabled
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress-force=zlib,space_cache,subvolid=5,subvol=/)

# mount -o remount,compress /dev/sdb3 /test3
[ 1053.679092] BTRFS info (device sdb3): disk space caching is enabled
[root@luna compress-info]# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)

[[after fix]]

# mount -o compress /dev/sdb3 /test3
[  401.021753] BTRFS info (device sdb3): use zlib compression
[  401.021758] BTRFS info (device sdb3): disk space caching is enabled
[  401.021760] BTRFS: has skinny extents
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)

# mount -o remount,compress-force /dev/sdb3 /test3
[  439.824624] BTRFS info (device sdb3): force zlib compression
[  439.824629] BTRFS info (device sdb3): disk space caching is enabled
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress-force=zlib,space_cache,subvolid=5,subvol=/)

# mount -o remount,compress /dev/sdb3 /test3
[  459.918430] BTRFS info (device sdb3): use zlib compression
[  459.918434] BTRFS info (device sdb3): disk space caching is enabled
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs 
(rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 fs/btrfs/disk-io.c |  2 +-
 fs/btrfs/super.c   | 21 ++---
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 974be09..dcc1f15 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2709,7 +2709,7 @@ int open_ctree(struct super_block *sb,
 * In the long term, we'll store the compression type in the super
 * block, and it'll be used for per file compression control.
 */
-   fs_info->compress_type = BTRFS_COMPRESS_ZLIB;
+   fs_info->compress_type = BTRFS_COMPRESS_NONE;
 
ret = btrfs_parse_options(tree_root, options);
if (ret) {
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 24154e4..e2e8a54 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -381,6 +381,8 @@ int btrfs_parse_options(struct btrfs_root *root, char 
*options)
int ret = 0;
char *compress_type;
bool compress_force = false;
+   enum btrfs_compression_type saved_compress_type;
+   bool saved_compress_force;
 
cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy);
if (cache_gen)
@@ -458,6 +460,9 @@ int btrfs_parse_options(struct btrfs_root *root, char 
*options)
/* Fallthrough */
case Opt_compress:
case Opt_compress_type:
+   saved_compress_type = info->compress_type;
+   saved_compress_force =
+   btrfs_test_opt(root, FORCE_COMPRESS);
if (token == Opt_compress ||
token == Opt_compress_force ||
strcmp(args[0].from, "zlib") == 0) {
@@ -475,6 +480,7 @@ int btrfs_parse_options(struct btrfs_root *root, char 
*options)
btrfs_set_fs_incompat(info, COMPRESS_LZO);
} else if (strncmp(args[0].from, "no", 2) == 0) {
compress_type = "no";
+   info->compress_type = BTRFS_COMPRESS_NONE;
btrfs_clear_opt(info->mount_opt, COMPRESS);
btrfs_clear_opt(info->mount_opt, 
FORCE_COMPRESS);
compress_force = false;
@@ -484,14 +490,8 @@ int btrfs_parse_options(struct btrfs_root *root, char 
*options)
}
 
if (compress_force) {
-   btrfs_set_and_info(root, FORCE_COMPRESS,
-  "force %s compression",
-  compress_type);
+   btrfs_set_opt(info->mount_opt, FORCE_COMPRESS);
} else {
-   if (!btrfs_test_opt(root, COMPRESS))
-   btrfs_info(root->fs_info,
-  "btrfs: use 

[PATCH] Btrfs: change the initialization point of fs_root in open_ctree()

2015-10-22 Thread Tsutomu Itoh
t 811ed6ea
 #6 [8800b9fdb9b8] iput at 811ed996
 #7 [8800b9fdb9e8] btrfs_orphan_cleanup at a0204c57 [btrfs]
 #8 [8800b9fdba60] btrfs_recover_relocation at a0247a8e [btrfs]
 #9 [8800b9fdbaf0] open_ctree at a01f576b [btrfs]
#10 [8800b9fdbbc8] btrfs_mount at a01cc6a9 [btrfs]
#11 [8800b9fdbc90] mount_fs at 811d7ab8
#12 [8800b9fdbcd8] vfs_kern_mount at 811f1be7
#13 [8800b9fdbd10] btrfs_mount at a01cbf57 [btrfs]
#14 [8800b9fdbdd8] mount_fs at 811d7ab8
#15 [8800b9fdbe20] vfs_kern_mount at 811f1be7
#16 [8800b9fdbe58] do_mount at 811f3f8d
#17 [8800b9fdbf08] sys_mount at 811f4e1c
#18 [8800b9fdbf50] entry_SYSCALL_64_fastpath at 8169536e
RIP: 7f6250fc733a  RSP: 7ffdcd40ba88  RFLAGS: 0246
RAX: ffda  RBX: 7f6251b2f42a  RCX: 7f6250fc733a
RDX: 564b58511070  RSI: 564b5850e290  RDI: 564b5850e270
RBP: 564b5850e150   R8:    R9: 0014
R10: c0ed  R11: 0246  R12: 7f6251d3f1dc
R13: 7ffdcd40bd88  R14:   R15: 
ORIG_RAX: 00a5  CS: 0033  SS: 002b


Therefore, the initialization point of fs_info->fs_root is changed
before btrfs_recover_relocation().

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 fs/btrfs/disk-io.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1e60d00..a1bfa27 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3019,6 +3019,16 @@ retry_root_backup:
if (ret)
goto fail_qgroup;
 
+   location.objectid = BTRFS_FS_TREE_OBJECTID;
+   location.type = BTRFS_ROOT_ITEM_KEY;
+   location.offset = 0;
+
+   fs_info->fs_root = btrfs_read_fs_root_no_name(fs_info, );
+   if (IS_ERR(fs_info->fs_root)) {
+   err = PTR_ERR(fs_info->fs_root);
+   goto fail_qgroup;
+   }
+
if (!(sb->s_flags & MS_RDONLY)) {
ret = btrfs_cleanup_fs_roots(fs_info);
if (ret)
@@ -3033,20 +3043,9 @@ retry_root_backup:
err = -EINVAL;
goto fail_qgroup;
}
-   }
-
-   location.objectid = BTRFS_FS_TREE_OBJECTID;
-   location.type = BTRFS_ROOT_ITEM_KEY;
-   location.offset = 0;
-
-   fs_info->fs_root = btrfs_read_fs_root_no_name(fs_info, );
-   if (IS_ERR(fs_info->fs_root)) {
-   err = PTR_ERR(fs_info->fs_root);
-   goto fail_qgroup;
-   }
-
-   if (sb->s_flags & MS_RDONLY)
+   } else {
return 0;
+   }
 
down_read(_info->cleanup_work_sem);
if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) ||
-- 
2.4.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: [PATCH] Btrfs: add a check of whether fs_info->fs_root is NULL in btrfs_async_reclaim_metadata_space()

2015-10-21 Thread Tsutomu Itoh

On 2015/10/21 20:27, David Sterba wrote:

On Wed, Oct 21, 2015 at 04:20:00PM +0900, Tsutomu Itoh wrote:

Kernel panic occurred due to NULL pointer reference in can_overcommit().
Because btrfs_async_reclaim_metadata_space() passed NULL pointer to
btrfs_calc_reclaim_metadata_size().



fs_info->fs_root is referred in btrfs_async_reclaim_metadata_space()
when mount kicked kworker(btrfs_async_reclaim_metadata_space).

But at this time, fs_info->fs_root had not been initialized yet,
so NULL pointer passed to btrfs_calc_reclaim_metadata_size().


I don't think it's the right fix, the initialization sequence should
take care of such situations. The fs_tree must exist at the time we
reach the point where it crashed, the code expects it.


OK. I will try to change initialization sequence.

Thanks,
Tsutomu


--
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: add a check of whether fs_info->fs_root is NULL in btrfs_async_reclaim_metadata_space()

2015-10-21 Thread Tsutomu Itoh
t 811ed6ea
 #6 [8800b9fdb9b8] iput at 811ed996
 #7 [8800b9fdb9e8] btrfs_orphan_cleanup at a0204c57 [btrfs]
 #8 [8800b9fdba60] btrfs_recover_relocation at a0247a8e [btrfs]
 #9 [8800b9fdbaf0] open_ctree at a01f576b [btrfs]
#10 [8800b9fdbbc8] btrfs_mount at a01cc6a9 [btrfs]
#11 [8800b9fdbc90] mount_fs at 811d7ab8
#12 [8800b9fdbcd8] vfs_kern_mount at 811f1be7
#13 [8800b9fdbd10] btrfs_mount at a01cbf57 [btrfs]
#14 [8800b9fdbdd8] mount_fs at 811d7ab8
#15 [8800b9fdbe20] vfs_kern_mount at 811f1be7
#16 [8800b9fdbe58] do_mount at 811f3f8d
#17 [8800b9fdbf08] sys_mount at 811f4e1c
#18 [8800b9fdbf50] entry_SYSCALL_64_fastpath at 8169536e
RIP: 7f6250fc733a  RSP: 7ffdcd40ba88  RFLAGS: 0246
RAX: ffda  RBX: 7f6251b2f42a  RCX: 7f6250fc733a
RDX: 564b58511070  RSI: 564b5850e290  RDI: 564b5850e270
RBP: 564b5850e150   R8:    R9: 0014
R10: c0ed  R11: 0246  R12: 7f6251d3f1dc
R13: 7ffdcd40bd88  R14:   R15: 
ORIG_RAX: 00a5  CS: 0033  SS: 002b


Therefore, check of whether fs_info->fs_root is NULL is added to
btrfs_async_reclaim_metadata_space().

Signed-off-by: Tsutomu Itoh <t-i...@jp.fujitsu.com>
---
 fs/btrfs/extent-tree.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 601d7d4..a2621e3 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4694,6 +4694,9 @@ static void btrfs_async_reclaim_metadata_space(struct 
work_struct *work)
fs_info = container_of(work, struct btrfs_fs_info, async_reclaim_work);
space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA);
 
+   if (!fs_info->fs_root)
+   return;
+
to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info->fs_root,
  space_info);
if (!to_reclaim)
-- 
2.4.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: [PATCH v2] fstests: generic: Check if a bull fallocate will change extent number

2015-09-29 Thread Tsutomu Itoh

On 2015/09/30 10:05, Qu Wenruo wrote:

Dave Chinner wrote on 2015/09/30 07:51 +1000:

On Tue, Sep 29, 2015 at 05:34:24PM +0800, Qu Wenruo wrote:

Normally, a bull fallocate call on a fully written and synced file
should not add an extent.


Why not? Filesystems can do whatever they want with extents during
a fallocate call. e.g. if the blocks are shared, then fallocate
might break the block sharing so future overwrites don't get
ENOSPC. This is a requirement set down by posix_fallocate(3)

"After a successful call to posix_fallocate(), subsequent writes to
bytes in the specified range are guaranteed not  to fail because of
lack of disk space."

Hence if you've got a file with shared blocks, a "full fallocate"
must change the extent layout to break the sharing. As such, the
premise of this test is wrong.


First, btrfs never meets the posix_fallocate requirement by its COW nature.

Btrfs fallocate can only ensure at most next write will not cause ENOSPC.
Only when btrfs fallocate a new prealloc extent, next write into it may use the 
space if they are not shared between different snapshots.

Under most case, btrfs fallocate follows the behavior of other non-COW 
filesystems.
Which means, btrfs won't alloc new extent if there is existing extent, not 
matter if it's shared or not.

As a result, fallocate in btrfs only works in a limited use-case, and can 
easily break posix requirement.
Like the following case without snapshots:
1)Fallocate 0~50M
2)Write 0~50M<- Will not return ENOSPC
3)Write 0~25M<- COW happens, allocate another 25M,
may cause ENOSPC.
Or even easier with snapshot:
1)Fallocate 0~50M in subvol A
2)Snapshot subvol A into snap B
3)Write 0~25M in subvol A *OR* snap B <- COW happens, may cause ENOSPC

As in step 3), fallocated 50M is shared, so write will be forced COW.

So I'd prefer to make btrfs follows the behavior of other non-COW filesystems, 
as posix standard doesn't fit well here.


That's not to say that btrfs has a bug:


Btrfs has a bug to always truncate the last page if the fallocate start
offset is smaller than inode size.


But it' not clear that this behaviour is actually a bug if it's not
changing the file data.

File data is not changed, as btrfs just COW the last tailing page, as reset the 
last already 0 part.

Like the follow ascii arts:

0)Before
04K8K12K16K
|///|000|
|<--Extent A--->|
The file is 14K size, on disk(to be accurate, btrfs logical address space) it 
takes 16K, with last 2K padding 0.

And all that 16K is in extent A.

1)Fallocate 0~14K
In fact, all space in range 0~14K is allocated, so there is no need to 
reallocate any space.

2)But in btrfs
Result will be:
04K8K12K16K
|///|000|
|<--Extent A--->|<--B-->|

Btrfs has a wrong judgment, which will always re-padding the last page.
Causing a new extent, extent B to be created.
Even the contents is the same with original last page.

It's OK not to consider it as a bug, at least data is not corrupted.
But IMO the btrfs behavior is not needed and need optimization.



So kernel patch is submitted to btrfs ml:
https://patchwork.kernel.org/patch/7284431/


Is this https://patchwork.kernel.org/patch/7283461/ ?  Right?

Thanks,
Tsutomu



And if fstests is not the proper place, any idea where such "test case" should 
belong?

Thanks,
Qu



Cheers,

Dave.


--
To unsubscribe from this list: send the line "unsubscribe fstests" 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/19] btrfs: qgroup: New function declaration for new reserve implement

2015-09-08 Thread Tsutomu Itoh
Hi, Qu,

On 2015/09/08 17:56, Qu Wenruo wrote:
> Add new structures and functions for new qgroup reserve implement dirty
> phase.
> Which will focus on avoiding over-reserve as in that case, which means
> for already reserved dirty space range, we won't reserve space again.
> 
> This patch adds the needed structure declaration and comments.
> 
> Signed-off-by: Qu Wenruo 
> ---
>   fs/btrfs/btrfs_inode.h |  4 
>   fs/btrfs/qgroup.c  | 58 
> ++
>   fs/btrfs/qgroup.h  |  3 +++
>   3 files changed, 65 insertions(+)
> 
> diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
> index 81220b2..e3ece65 100644
> --- a/fs/btrfs/btrfs_inode.h
> +++ b/fs/btrfs/btrfs_inode.h
> @@ -24,6 +24,7 @@
>   #include "extent_io.h"
>   #include "ordered-data.h"
>   #include "delayed-inode.h"
> +#include "qgroup.h"
>   
>   /*
>* ordered_data_close is set by truncate when a file that used
> @@ -195,6 +196,9 @@ struct btrfs_inode {
>   struct timespec i_otime;
>   
>   struct inode vfs_inode;
> +
> + /* qgroup dirty map for data space reserve */
> + struct btrfs_qgroup_data_rsv_map *qgroup_rsv_map;
>   };
>   
>   extern unsigned char btrfs_filetype_table[];
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index e9ace09..561c36d 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -91,6 +91,64 @@ struct btrfs_qgroup {
>   u64 new_refcnt;
>   };
>   
> +/*
> + * Record one range of reserved space.
> + */
> +struct data_rsv_range {
> + struct rb_node node;
> + u64 start;
> + u64 len;
> +};
> +
> +/*
> + * Record per inode reserved range.
> + * This is mainly used to resolve reserved space leaking problem.
> + * One of the cause is the mismatch with reserve and free.
> + *
> + * New qgroup will handle reserve in two phase.
> + * 1) Dirty phase.
> + *Pages are just marked dirty, but not written to disk.
> + * 2) Flushed phase
> + *Pages are written to disk, but transaction is not committed yet.
> + *

> + * At Diryt phase, we only need to focus on avoiding over-reserve.

 dirty

> + *
> + * The idea is like below.
> + * 1) Write [0,8K)
> + * 0 4K  8K  12K 16K
> + * ||
> + * Reserve +8K, total reserved: 8K
> + *
> + * 2) Write [0,4K)
> + * 0 4K  8K  12K 16K
> + * ||
> + * Reserve 0, total reserved 8K
> + *
> + * 3) Write [12K,16K)
> + * 0 4K  8K  12K 16K

> + * |||///|
> + * Reserve +4K, tocal reserved 12K

   total

> + *
> + * 4) Flush [0,8K)
> + * Can happen without commit transaction, like fallocate will trigger the
> + * write.
> + * 0 4K  8K  12K 16K
> + *   |///|

> + * Reserve 0, tocal reserved 12K

 total

Thanks,
Tsutomu

> + * As the extent is written to disk, not dirty any longer, the range get
> + * removed.
> + * But as its delayed_refs is not run, its reserved space will not be freed.
> + * And things continue to Flushed phase.
> + *
> + * By this method, we can avoid over-reserve, which will lead to reserved
> + * space leak.
> + */
> +struct btrfs_qgroup_data_rsv_map {
> + struct rb_root root;
> + u64 reserved;
> + spinlock_t lock;
> +};
> +
>   static void btrfs_qgroup_update_old_refcnt(struct btrfs_qgroup *qg, u64 seq,
>  int mod)
>   {
> diff --git a/fs/btrfs/qgroup.h b/fs/btrfs/qgroup.h
> index 6387dcf..2f863a4 100644
> --- a/fs/btrfs/qgroup.h
> +++ b/fs/btrfs/qgroup.h
> @@ -33,6 +33,9 @@ struct btrfs_qgroup_extent_record {
>   struct ulist *old_roots;
>   };
>   
> +/* For per-inode dirty range reserve */
> +struct btrfs_qgroup_data_rsv_map;
> +
>   int btrfs_quota_enable(struct btrfs_trans_handle *trans,
>  struct btrfs_fs_info *fs_info);
>   int btrfs_quota_disable(struct btrfs_trans_handle *trans,
> 


--
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 08/19] btrfs: qgroup: Introduce function to release/free reserved data range

2015-09-08 Thread Tsutomu Itoh
Hi, Qu,

On 2015/09/08 18:08, Qu Wenruo wrote:
> Introduce functions btrfs_qgroup_release/free_data() to release/free
> reserved data range.
> 
> Release means, just remove the data range from data rsv map, but doesn't
> free the reserved space.
> This is for normal buffered write case, when data is written into disc
> and its metadata is added into tree, its reserved space should still be
> kept until commit_trans().
> So in that case, we only release dirty range, but keep the reserved
> space recorded some other place until commit_tran().
> 
> Free means not only remove data range, but also free reserved space.
> This is used for case for cleanup.
> 
> Signed-off-by: Qu Wenruo 
> ---
>   fs/btrfs/qgroup.c | 48 
>   fs/btrfs/qgroup.h |  2 ++
>   2 files changed, 50 insertions(+)
> 
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index e24c10d..ba7888f 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -2979,6 +2979,54 @@ next:
>   return 0;
>   }
>   
> +static int __btrfs_qgroup_release_data(struct inode *inode, u64 start, u64 
> len,
> +int free_reserved)
> +{
> + struct data_rsv_range *tmp;
> + struct btrfs_qgroup_data_rsv_map *map;
> + u64 reserved = 0;
> + int ret;
> +
> + spin_lock(_I(inode)->qgroup_init_lock);
> + map = BTRFS_I(inode)->qgroup_rsv_map;
> + spin_unlock(_I(inode)->qgroup_init_lock);
> + if (!map)
> + return 0;
> +
> + tmp = kmalloc(sizeof(*tmp), GFP_NOFS);
> + if (!tmp)
> + return -ENOMEM;
> + spin_lock(>lock);
> + ret = release_data_range(map, tmp, start, len, );
> + /* release_data_range() won't fail only check if memory is used */
> + if (ret == 0)
> + kfree(tmp);
> + if (free_reserved)
> + btrfs_qgroup_free(BTRFS_I(inode)->root, reserved);
> + spin_unlock(>lock);
> + return 0;
> +}
> +
> +/*
> + * Caller should be truncate/invalidate_page.
> + * As it will release the reserved data.
> + */
> +int btrfs_qgroup_free_data(struct inode *inode, u64 start, u64 len)
> +{
> + return __btrfs_qgroup_release_data(inode, start, len, 1);
> +}
> +
> +/*
> + * Caller should be finish_ordered_io

> + * As qgroup accouting happens at commit time, for data written to disk

accounting

Thanks,
Tsutomu

> + * its reserved space should not be freed until commit.
> + * Or we may beyond the limit.
> + */
> +int btrfs_qgroup_release_data(struct inode *inode, u64 start, u64 len)
> +{
> + return __btrfs_qgroup_release_data(inode, start, len, 0);
> +}
> +
>   /*
>* Init data_rsv_map for a given inode.
>*
> diff --git a/fs/btrfs/qgroup.h b/fs/btrfs/qgroup.h
> index 366b853..8e69dc1 100644
> --- a/fs/btrfs/qgroup.h
> +++ b/fs/btrfs/qgroup.h
> @@ -88,4 +88,6 @@ int btrfs_verify_qgroup_counts(struct btrfs_fs_info 
> *fs_info, u64 qgroupid,
>   int btrfs_qgroup_init_data_rsv_map(struct inode *inode);
>   void btrfs_qgroup_free_data_rsv_map(struct inode *inode);
>   int btrfs_qgroup_reserve_data(struct inode *inode, u64 start, u64 len);
> +int btrfs_qgroup_release_data(struct inode *inode, u64 start, u64 len);
> +int btrfs_qgroup_free_data(struct inode *inode, u64 start, u64 len);
>   #endif /* __BTRFS_QGROUP__ */
> 


--
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 10/19] btrfs: delayed_ref: release and free qgroup reserved at proper timing

2015-09-08 Thread Tsutomu Itoh
Hi, Qu,

On 2015/09/08 18:08, Qu Wenruo wrote:
> Qgroup reserved space needs to be released from inode dirty map and get
> freed at different timing:
> 
> 1) Release when the metadata is written into tree
> After corresponding metadata is written into tree, any newer write will
> be COWed(don't include NOCOW case yet).
> So we must release its range from inode dirty range map, or we will
> forget to reserve needed range, causing accounting exceeding the limit.
> 
> 2) Free reserved bytes when delayed ref is run
> When delayed refs are run, qgroup accounting will follow soon and turn
> the reserved bytes into rfer/excl numbers.
> As run_delayed_refs and qgroup accounting are all done at
> commit_transaction() time, we are safe to free reserved space in
> run_delayed_ref time().
> 
> With these timing to release/free reserved space, we should be able to
> resolve the long existing qgroup reserve space leak problem.
> 
> Signed-off-by: Qu Wenruo 
> ---
>   fs/btrfs/extent-tree.c |  4 
>   fs/btrfs/inode.c   | 10 ++
>   fs/btrfs/qgroup.c  |  5 ++---
>   fs/btrfs/qgroup.h  |  8 +++-
>   4 files changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 5411f0a..65e60eb 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -2345,6 +2345,10 @@ static int run_one_delayed_ref(struct 
> btrfs_trans_handle *trans,
> node->num_bytes);
>   }
>   }
> +
> + /* Also free its reserved qgroup space */
> + btrfs_qgroup_free_refroot(root->fs_info, head->qgroup_ref_root,
> +   head->qgroup_reserved);
>   return ret;
>   }
>   
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 61b2c17..1f7cac0 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -2112,6 +2112,16 @@ static int insert_reserved_file_extent(struct 
> btrfs_trans_handle *trans,
>   ret = btrfs_alloc_reserved_file_extent(trans, root,
>   root->root_key.objectid,
>   btrfs_ino(inode), file_pos, );
> + if (ret < 0)
> + goto out;
> + /*
> +  * Release the reserved range from inode dirty range map, and
> +  * move it to delayed ref codes, as now accounting only happens at
> +  * commit_transaction() time.
> +  */
> + btrfs_qgroup_release_data(inode, file_pos, ram_bytes);
> + ret = btrfs_add_delayed_qgroup_reserve(root->fs_info, trans,
> + root->objectid, disk_bytenr, ram_bytes);
>   out:
>   btrfs_free_path(path);
>   
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index ba7888f..5a69a2d 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -2169,14 +2169,13 @@ out:
>   return ret;
>   }
>   
> -void btrfs_qgroup_free(struct btrfs_root *root, u64 num_bytes)
> +void btrfs_qgroup_free_refroot(struct btrfs_fs_info *fs_info,
> +u64 ref_root, u64 num_bytes)
>   {
>   struct btrfs_root *quota_root;
>   struct btrfs_qgroup *qgroup;
> - struct btrfs_fs_info *fs_info = root->fs_info;
>   struct ulist_node *unode;
>   struct ulist_iterator uiter;
> - u64 ref_root = root->root_key.objectid;
>   int ret = 0;
>   
>   if (!is_fstree(ref_root))
> diff --git a/fs/btrfs/qgroup.h b/fs/btrfs/qgroup.h
> index 8e69dc1..49fa15e 100644
> --- a/fs/btrfs/qgroup.h
> +++ b/fs/btrfs/qgroup.h
> @@ -75,7 +75,13 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
>struct btrfs_fs_info *fs_info, u64 srcid, u64 objectid,
>struct btrfs_qgroup_inherit *inherit);
>   int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes);
> -void btrfs_qgroup_free(struct btrfs_root *root, u64 num_bytes);
> +void btrfs_qgroup_free_refroot(struct btrfs_fs_info *fs_info,
> +u64 ref_root, u64 num_bytes);
> +static inline void btrfs_qgroup_free(struct btrfs_root *root, u64 num_bytes)
> +{
> + return btrfs_qgroup_free_refroot(root->fs_info, root->objectid,
> +  num_bytes);

Is 'return' necessary?

Thanks,
Tsutomu

> +}
>   
>   void assert_qgroups_uptodate(struct btrfs_trans_handle *trans);
>   
> 


--
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 04/19] btrfs: qgroup: Introduce function to insert non-overlap reserve range

2015-09-08 Thread Tsutomu Itoh
Hi, Qu,

On 2015/09/08 18:01, Qu Wenruo wrote:
> New function insert_data_ranges() will insert non-overlap reserve ranges
> into reserve map.
> 
> It provides the basis for later qgroup reserve map implement.
> 
> Signed-off-by: Qu Wenruo 
> ---
>   fs/btrfs/qgroup.c | 124 
> ++
>   1 file changed, 124 insertions(+)
> 
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index fc24fc3..a4e3af4 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -2577,6 +2577,130 @@ find_reserve_range(struct btrfs_qgroup_data_rsv_map 
> *map, u64 start)
>   }
>   
>   /*
> + * Insert one data range

> + * [start,len) here won't overflap with each other.

 overlap

Thanks,
Tsutomu

> + *
> + * Return 0 if range is inserted and tmp is not used.
> + * Return > 0 if range is inserted and tmp is used.
> + * No catchable error case. Only possible error will cause BUG_ON() as
> + * that's logical error.
> + */
> +static int insert_data_range(struct btrfs_qgroup_data_rsv_map *map,
> +  struct data_rsv_range *tmp,
> +  u64 start, u64 len)
> +{
> + struct rb_node **p = >root.rb_node;
> + struct rb_node *parent = NULL;
> + struct rb_node *tmp_node = NULL;
> + struct data_rsv_range *range = NULL;
> + struct data_rsv_range *prev_range = NULL;
> + struct data_rsv_range *next_range = NULL;
> + int prev_merged = 0;
> + int next_merged = 0;
> + int ret = 0;
> +
> + while (*p) {
> + parent = *p;
> + range = rb_entry(parent, struct data_rsv_range, node);
> + if (range->start < start)
> + p = &(*p)->rb_right;
> + else if (range->start > start)
> + p = &(*p)->rb_left;
> + else
> + BUG_ON(1);
> + }
> +
> + /* Empty tree, goto isolated case */
> + if (!range)
> + goto insert_isolated;
> +
> + /* get adjusted ranges */
> + if (range->start < start) {
> + prev_range = range;
> + tmp_node = rb_next(parent);
> + if (tmp)
> + next_range = rb_entry(tmp_node, struct data_rsv_range,
> +   node);
> + } else {
> + next_range = range;
> + tmp_node = rb_prev(parent);
> + if (tmp)
> + prev_range = rb_entry(tmp_node, struct data_rsv_range,
> +   node);
> + }
> +
> + /* try to merge with previous and next ranges */
> + if (prev_range && prev_range->start + prev_range->len == start) {
> + prev_merged = 1;
> + prev_range->len += len;
> + }
> + if (next_range && start + len == next_range->start) {
> + next_merged = 1;
> +
> + /*
> +  * the range can be merged with adjusted two ranges into one,
> +  * remove the tailing range.
> +  */
> + if (prev_merged) {
> + prev_range->len += next_range->len;
> + rb_erase(_range->node, >root);
> + kfree(next_range);
> + } else {
> + next_range->start = start;
> + next_range->len += len;
> + }
> + }
> +
> +insert_isolated:
> + /* isolated case, need to insert range now */
> + if (!next_merged && !prev_merged) {
> + BUG_ON(!tmp);
> +
> + tmp->start = start;
> + tmp->len = len;
> + rb_link_node(>node, parent, p);
> + rb_insert_color(>node, >root);
> + ret = 1;
> + }
> + return ret;
> +}
> +
> +/*
> + * insert reserve range and merge them if possible
> + *
> + * Return 0 if all inserted and tmp not used
> + * Return > 0 if all inserted and tmp used
> + * No catchable error return value.
> + */
> +static int insert_data_ranges(struct btrfs_qgroup_data_rsv_map *map,
> +   struct data_rsv_range *tmp,
> +   struct ulist *insert_list)
> +{
> + struct ulist_node *unode;
> + struct ulist_iterator uiter;
> + int tmp_used = 0;
> + int ret = 0;
> +
> + ULIST_ITER_INIT();
> + while ((unode = ulist_next(insert_list, ))) {
> + ret = insert_data_range(map, tmp, unode->val, unode->aux);
> +
> + /*
> +  * insert_data_range() won't return error return value,
> +  * no need to hanle <0 case.
> +  *
> +  * Also tmp should be used at most one time, so clear it to
> +  * NULL to cooperate with sanity check in insert_data_range().
> +  */
> + if (ret > 0) {
> + tmp_used = 1;
> + tmp = NULL;
> + }
> + }
> + return tmp_used;
> +}
> +
> +/*
>* 

Re: [PATCH 13/19] btrfs: extent-tree: Add new verions of btrfs_check_data_free_space

2015-09-08 Thread Tsutomu Itoh
Hi, Qu,

On 2015/09/08 18:22, Qu Wenruo wrote:
> Add new function __btrfs_check_data_free_space() to do precious space
> reservation.
> 
> The new function will replace old btrfs_check_data_free_space(), but
> until all the change is done, let's just use the new name.
> 
> Also, export internal use function btrfs_alloc_data_chunk_ondemand(), as
> now qgroup reserve requires precious bytes, which can only be got in
> later loop(like fallocate).
> But data space info check and data chunk allocate doesn't need to be
> that accurate, and can be called at the beginning.
> 
> So export it for later operations.
> 
> Signed-off-by: Qu Wenruo 
> ---
>   fs/btrfs/ctree.h   |  2 ++
>   fs/btrfs/extent-tree.c | 50 
> +-
>   2 files changed, 43 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index ae86025..c1a0aaf 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -3453,6 +3453,8 @@ enum btrfs_reserve_flush_enum {
>   };
>   
>   int btrfs_check_data_free_space(struct inode *inode, u64 bytes, u64 
> write_bytes);
> +int __btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len);
> +int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes);
>   void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes);
>   void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
>   struct btrfs_root *root);
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 402415c..61366ca 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -3907,11 +3907,7 @@ u64 btrfs_get_alloc_profile(struct btrfs_root *root, 
> int data)
>   return ret;
>   }
>   
> -/*
> - * This will check the space that the inode allocates from to make sure we 
> have
> - * enough space for bytes.
> - */
> -int btrfs_check_data_free_space(struct inode *inode, u64 bytes, u64 
> write_bytes)
> +int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes)
>   {
>   struct btrfs_space_info *data_sinfo;
>   struct btrfs_root *root = BTRFS_I(inode)->root;
> @@ -4032,19 +4028,55 @@ commit_trans:
> data_sinfo->flags, bytes, 1);
>   return -ENOSPC;
>   }
> - ret = btrfs_qgroup_reserve(root, write_bytes);
> - if (ret)
> - goto out;
>   data_sinfo->bytes_may_use += bytes;
>   trace_btrfs_space_reservation(root->fs_info, "space_info",
> data_sinfo->flags, bytes, 1);
> -out:
>   spin_unlock(_sinfo->lock);
>   
>   return ret;
>   }
>   
>   /*
> + * This will check the space that the inode allocates from to make sure we 
> have
> + * enough space for bytes.
> + */
> +int btrfs_check_data_free_space(struct inode *inode, u64 bytes, u64 
> write_bytes)
> +{
> + struct btrfs_root *root = BTRFS_I(inode)->root;
> + int ret;
> +
> + ret = btrfs_alloc_data_chunk_ondemand(inode, bytes);
> + if (ret < 0)
> + return ret;
> + ret = btrfs_qgroup_reserve(root, write_bytes);
> + return ret;
> +}
> +
> +/*

> + * New check_data_free_space() with ability for precious data reserveation

 reservation

Thanks,
Tsutomu

> + * Will replace old btrfs_check_data_free_space(), but for patch split,
> + * add a new function first and then replace it.
> + */
> +int __btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len)
> +{
> + struct btrfs_root *root = BTRFS_I(inode)->root;
> + int ret;
> +
> + /* align the range */
> + len = round_up(start + len, root->sectorsize) -
> +   round_down(start, root->sectorsize);
> + start = round_down(start, root->sectorsize);
> +
> + ret = btrfs_alloc_data_chunk_ondemand(inode, len);
> + if (ret < 0)
> + return ret;
> +
> + /* Use new btrfs_qgroup_reserve_data to reserve precious data space */
> + ret = btrfs_qgroup_reserve_data(inode, start, len);
> + return ret;
> +}
> +
> +/*
>* Called if we need to clear a data reservation for this inode.
>*/
>   void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes)
> 


--
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 18/19] btrfs: qgroup: Cleanup old inaccurate facilities

2015-09-08 Thread Tsutomu Itoh
Hi, Qu,

On 2015/09/08 18:25, Qu Wenruo wrote:
> Cleanup the old facilities which use old btrfs_qgroup_reserve() function
> call, replace them with the newer version, and remove the "__" prefix in
> them.
> 
> Also, make btrfs_qgroup_reserve/free() functions private, as they are
> now only used inside qgroup codes.
> 
> Now, the whole btrfs qgroup is swithed to use the new reserve facilities.
> 
> Signed-off-by: Qu Wenruo 
> ---
>   fs/btrfs/ctree.h   |  6 ++
>   fs/btrfs/extent-tree.c | 56 
> --
>   fs/btrfs/file.c|  2 +-
>   fs/btrfs/inode-map.c   |  2 +-
>   fs/btrfs/inode.c   | 12 +--
>   fs/btrfs/ioctl.c   |  2 +-
>   fs/btrfs/qgroup.c  | 19 ++---
>   fs/btrfs/qgroup.h  |  7 ---
>   8 files changed, 27 insertions(+), 79 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index 12f14fd..8489419 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -3452,8 +3452,7 @@ enum btrfs_reserve_flush_enum {
>   BTRFS_RESERVE_FLUSH_ALL,
>   };
>   
> -int btrfs_check_data_free_space(struct inode *inode, u64 bytes, u64 
> write_bytes);
> -int __btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len);
> +int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len);
>   int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes);
>   void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes);
>   void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
> @@ -3471,8 +3470,7 @@ void btrfs_subvolume_release_metadata(struct btrfs_root 
> *root,
> u64 qgroup_reserved);
>   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 num_bytes);
> -int __btrfs_delalloc_reserve_space(struct inode *inode, u64 start, u64 len);
> +int btrfs_delalloc_reserve_space(struct inode *inode, u64 start, u64 len);
>   void btrfs_delalloc_release_space(struct inode *inode, u64 num_bytes);
>   void btrfs_init_block_rsv(struct btrfs_block_rsv *rsv, unsigned short type);
>   struct btrfs_block_rsv *btrfs_alloc_block_rsv(struct btrfs_root *root,
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 07f45b7..ab1b1a1 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -3352,7 +3352,7 @@ again:
>   num_pages *= 16;
>   num_pages *= PAGE_CACHE_SIZE;
>   
> - ret = __btrfs_check_data_free_space(inode, 0, num_pages);
> + ret = btrfs_check_data_free_space(inode, 0, num_pages);
>   if (ret)
>   goto out_put;
>   
> @@ -4037,27 +4037,11 @@ commit_trans:
>   }
>   
>   /*
> - * This will check the space that the inode allocates from to make sure we 
> have
> - * enough space for bytes.
> - */
> -int btrfs_check_data_free_space(struct inode *inode, u64 bytes, u64 
> write_bytes)
> -{
> - struct btrfs_root *root = BTRFS_I(inode)->root;
> - int ret;
> -
> - ret = btrfs_alloc_data_chunk_ondemand(inode, bytes);
> - if (ret < 0)
> - return ret;
> - ret = btrfs_qgroup_reserve(root, write_bytes);
> - return ret;
> -}
> -
> -/*
>* New check_data_free_space() with ability for precious data reserveation
>* Will replace old btrfs_check_data_free_space(), but for patch split,
>* add a new function first and then replace it.
>*/
> -int __btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len)
> +int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len)
>   {
>   struct btrfs_root *root = BTRFS_I(inode)->root;
>   int ret;
> @@ -5710,11 +5694,11 @@ void btrfs_delalloc_release_metadata(struct inode 
> *inode, u64 num_bytes)
>* Return 0 for success
>* Return <0 for error(-ENOSPC or -EQUOT)
>*/
> -int __btrfs_delalloc_reserve_space(struct inode *inode, u64 start, u64 len)
> +int btrfs_delalloc_reserve_space(struct inode *inode, u64 start, u64 len)
>   {
>   int ret;
>   
> - ret = __btrfs_check_data_free_space(inode, start, len);
> + ret = btrfs_check_data_free_space(inode, start, len);
>   if (ret < 0)
>   return ret;
>   ret = btrfs_delalloc_reserve_metadata(inode, len);
> @@ -5724,38 +5708,6 @@ int __btrfs_delalloc_reserve_space(struct inode 
> *inode, u64 start, u64 len)
>   }
>   
>   /**
> - * btrfs_delalloc_reserve_space - reserve data and metadata space for 
> delalloc
> - * @inode: inode we're writing to
> - * @num_bytes: the number of bytes we want to allocate
> - *
> - * This will do the following things
> - *
> - * o reserve space in the data space info for num_bytes
> - * o reserve space in the metadata space info based on number of outstanding
> - *   extents and how much csums will be needed
> - * o add to the inodes ->delalloc_bytes
> - * o add it to the 

Re: [PATCH] Btrfs: cleanup: remove unnecessary check before btrfs_free_path is called

2015-08-19 Thread Tsutomu Itoh

On 2015/08/19 16:34, Qu Wenruo wrote:

Tsutomu Itoh wrote on 2015/08/19 14:55 +0900:

We need not check path before btrfs_free_path() is called because
path is checked in btrfs_free_path().

Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com


Reviewed-by: Qu Wenruo quwen...@cn.fujitsu.com


Thanks for the review.



BTW, did you check btrfs-progs for the such cleanup?


I will check btrfs-progs soon.

Thanks,
Tsutomu



Thanks,
Qu


---
  fs/btrfs/dev-replace.c | 3 +--
  fs/btrfs/inode.c   | 3 +--
  fs/btrfs/tree-defrag.c | 3 +--
  3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 564a7de..e54dd59 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -183,8 +183,7 @@ no_valid_dev_replace_entry_found:
  }

  out:
-if (path)
-btrfs_free_path(path);
+btrfs_free_path(path);
  return ret;
  }

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e33dff3..21ba036 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6876,8 +6876,7 @@ out:

  trace_btrfs_get_extent(root, em);

-if (path)
-btrfs_free_path(path);
+btrfs_free_path(path);
  if (trans) {
  ret = btrfs_end_transaction(trans, root);
  if (!err)
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index a4b9c8b..f31db43 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -115,8 +115,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
  ret = -EAGAIN;
  }
  out:
-if (path)
-btrfs_free_path(path);
+btrfs_free_path(path);
  if (ret == -EAGAIN) {
  if (root-defrag_max.objectid  root-defrag_progress.objectid)
  goto done;




--
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-progs: cleanup: remove unnecessary check before btrfs_free_path is called

2015-08-19 Thread Tsutomu Itoh
We need not check path before btrfs_free_path() is called because
path is checked in btrfs_free_path().

Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com
---
 cmds-check.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/cmds-check.c b/cmds-check.c
index 4fa8709..8019fb0 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -9226,8 +9226,7 @@ next:
ret = 0;
 out:
free_roots_info_cache();
-   if (path)
-   btrfs_free_path(path);
+   btrfs_free_path(path);
if (trans)
btrfs_commit_transaction(trans, info-tree_root);
if (ret  0)
-- 
2.4.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: cleanup: remove unnecessary check before btrfs_free_path is called

2015-08-18 Thread Tsutomu Itoh
We need not check path before btrfs_free_path() is called because
path is checked in btrfs_free_path().

Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com
---
 fs/btrfs/dev-replace.c | 3 +--
 fs/btrfs/inode.c   | 3 +--
 fs/btrfs/tree-defrag.c | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 564a7de..e54dd59 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -183,8 +183,7 @@ no_valid_dev_replace_entry_found:
}
 
 out:
-   if (path)
-   btrfs_free_path(path);
+   btrfs_free_path(path);
return ret;
 }
 
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e33dff3..21ba036 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6876,8 +6876,7 @@ out:
 
trace_btrfs_get_extent(root, em);
 
-   if (path)
-   btrfs_free_path(path);
+   btrfs_free_path(path);
if (trans) {
ret = btrfs_end_transaction(trans, root);
if (!err)
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index a4b9c8b..f31db43 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -115,8 +115,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
ret = -EAGAIN;
}
 out:
-   if (path)
-   btrfs_free_path(path);
+   btrfs_free_path(path);
if (ret == -EAGAIN) {
if (root-defrag_max.objectid  root-defrag_progress.objectid)
goto done;
-- 
2.4.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 V2] btrfs-progs: add newline to some error messages

2015-08-06 Thread Tsutomu Itoh
Added a missing newline to some error messages.
Also printf() was changed to fprintf(stderr) for error message.

Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com
---
 btrfs-corrupt-block.c |  2 +-
 cmds-check.c  |  4 ++--
 cmds-send.c   |  4 ++--
 dir-item.c|  6 +++---
 free-space-cache.c| 24 +++-
 mkfs.c|  2 +-
 6 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index 1a2aa23..ea871f4 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -1010,7 +1010,7 @@ int find_chunk_offset(struct btrfs_root *root,
goto out;
}
if (ret  0) {
-   fprintf(stderr, Error searching chunk);
+   fprintf(stderr, Error searching chunk\n);
goto out;
}
 out:
diff --git a/cmds-check.c b/cmds-check.c
index 50bb6f3..d0ffc94 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -2399,7 +2399,7 @@ static int repair_inode_nlinks(struct btrfs_trans_handle 
*trans,
  BTRFS_FIRST_FREE_OBJECTID, lost_found_ino,
  mode);
if (ret  0) {
-   fprintf(stderr, Failed to create '%s' dir: %s,
+   fprintf(stderr, Failed to create '%s' dir: %s\n,
dir_name, strerror(-ret));
goto out;
}
@@ -2427,7 +2427,7 @@ static int repair_inode_nlinks(struct btrfs_trans_handle 
*trans,
}
if (ret  0) {
fprintf(stderr,
-   Failed to link the inode %llu to %s dir: %s,
+   Failed to link the inode %llu to %s dir: %s\n,
rec-ino, dir_name, strerror(-ret));
goto out;
}
diff --git a/cmds-send.c b/cmds-send.c
index a0b7f95..6f2f340 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -193,13 +193,13 @@ static int write_buf(int fd, const void *buf, int size)
ret = write(fd, (char*)buf + pos, size - pos);
if (ret  0) {
ret = -errno;
-   fprintf(stderr, ERROR: failed to dump stream. %s,
+   fprintf(stderr, ERROR: failed to dump stream. %s\n,
strerror(-ret));
goto out;
}
if (!ret) {
ret = -EIO;
-   fprintf(stderr, ERROR: failed to dump stream. %s,
+   fprintf(stderr, ERROR: failed to dump stream. %s\n,
strerror(-ret));
goto out;
}
diff --git a/dir-item.c b/dir-item.c
index a5bf861..f3ad98f 100644
--- a/dir-item.c
+++ b/dir-item.c
@@ -285,7 +285,7 @@ int verify_dir_item(struct btrfs_root *root,
u8 type = btrfs_dir_type(leaf, dir_item);
 
if (type = BTRFS_FT_MAX) {
-   fprintf(stderr, invalid dir item type: %d,
+   fprintf(stderr, invalid dir item type: %d\n,
   (int)type);
return 1;
}
@@ -294,7 +294,7 @@ int verify_dir_item(struct btrfs_root *root,
namelen = XATTR_NAME_MAX;
 
if (btrfs_dir_name_len(leaf, dir_item)  namelen) {
-   fprintf(stderr, invalid dir item name len: %u,
+   fprintf(stderr, invalid dir item name len: %u\n,
   (unsigned)btrfs_dir_data_len(leaf, dir_item));
return 1;
}
@@ -302,7 +302,7 @@ int verify_dir_item(struct btrfs_root *root,
/* BTRFS_MAX_XATTR_SIZE is the same for all dir items */
if ((btrfs_dir_data_len(leaf, dir_item) +
 btrfs_dir_name_len(leaf, dir_item))  BTRFS_MAX_XATTR_SIZE(root)) {
-   fprintf(stderr, invalid dir item name + data len: %u + %u,
+   fprintf(stderr, invalid dir item name + data len: %u + %u\n,
   (unsigned)btrfs_dir_name_len(leaf, dir_item),
   (unsigned)btrfs_dir_data_len(leaf, dir_item));
return 1;
diff --git a/free-space-cache.c b/free-space-cache.c
index 67f00fd..19ab0c9 100644
--- a/free-space-cache.c
+++ b/free-space-cache.c
@@ -107,7 +107,8 @@ static int io_ctl_prepare_pages(struct io_ctl *io_ctl, 
struct btrfs_root *root,
 
ret = btrfs_search_slot(NULL, root, key, path, 0, 0);
if (ret) {
-   printf(Couldn't find file extent item for free space inode
+   fprintf(stderr,
+  Couldn't find file extent item for free space inode
%Lu\n, ino);
btrfs_release_path(path);
return -EINVAL;
@@ -138,7 +139,7 @@ static int io_ctl_prepare_pages(struct io_ctl *io_ctl, 
struct btrfs_root *root,
struct

Re: [PATCH] btrfs-progs: add newline to some error messages

2015-08-06 Thread Tsutomu Itoh

On 2015/08/06 15:07, Zhao Lei wrote:

Hi, Itho-san


-Original Message-
From: Tsutomu Itoh [mailto:t-i...@jp.fujitsu.com]
Sent: Thursday, August 06, 2015 12:01 PM
To: Zhao Lei; linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs-progs: add newline to some error messages

On 2015/08/06 12:51, Zhao Lei wrote:

Hi, Itoh


-Original Message-
From: linux-btrfs-ow...@vger.kernel.org
[mailto:linux-btrfs-ow...@vger.kernel.org] On Behalf Of Tsutomu Itoh
Sent: Thursday, August 06, 2015 11:06 AM
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs-progs: add newline to some error messages

Added a missing newline to some error messages.


Good found!

Seems more code need to be fixed, as:

# cat mkfs.c | tr -d '\n' | grep -o -w 'f\?printf([^(]*);' | sed

's/f\?printf[[:blank:]]*(\(stderr,\|\)[[:blank:]]*\(.*\)[,)].*/\2/g' | grep 
-v '\\n'
symlink too long for %s

Incompat features:  %s
#


It's OK.

printf(Incompat features:  %s, features_buf);
printf(\n);



# cat utils.c | tr -d '\n' | grep -o -w 'f\?printf([^(]*);' | sed

's/f\?printf[[:blank:]]*(\(stderr,\|\)[[:blank:]]*\(.*\)[,)].*/\2/g' | grep 
-v '\\n'

ERROR: DUP for data is allowed only in mixed mode %s [y/N]: *1 #
*1: It is not problem, should to be ignored


Already fixed by David in devel branch.


Got it.

I run above script for all .c files, nearly all are fixed by this patch,
except this:

free-space-cache.c
   Duplicate entries in free space cache, dumping
   Duplicate entries in free space cache, dumping
   block group %llu has wrong amount of free space

Above message seems having these problem:
1: lack of '\n'
2: better to use fprintf(stderr,
3: there is dumping in message, but I havn't see
   dump code in source.


I will send V2 patch, soon,

Thanks,
Tsutomu



Thanks
Zhaolei


Thanks,
Tsutomu



Thanks
Zhaolei


Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com
---
   btrfs-corrupt-block.c | 2 +-
   cmds-check.c  | 4 ++--
   cmds-send.c   | 4 ++--
   dir-item.c| 6 +++---
   mkfs.c| 2 +-
   5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c index
1a2aa23..ea871f4
100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -1010,7 +1010,7 @@ int find_chunk_offset(struct btrfs_root *root,
goto out;
}
if (ret  0) {
-   fprintf(stderr, Error searching chunk);
+   fprintf(stderr, Error searching chunk\n);
goto out;
}
   out:
diff --git a/cmds-check.c b/cmds-check.c index dd2fce3..0ddf57c
100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -2398,7 +2398,7 @@ static int repair_inode_nlinks(struct
btrfs_trans_handle *trans,
  BTRFS_FIRST_FREE_OBJECTID, lost_found_ino,
  mode);
if (ret  0) {
-   fprintf(stderr, Failed to create '%s' dir: %s,
+   fprintf(stderr, Failed to create '%s' dir: %s\n,
dir_name, strerror(-ret));
goto out;
}
@@ -2426,7 +2426,7 @@ static int repair_inode_nlinks(struct
btrfs_trans_handle *trans,
}
if (ret  0) {
fprintf(stderr,
-   Failed to link the inode %llu to %s dir: %s,
+   Failed to link the inode %llu to %s dir: %s\n,
rec-ino, dir_name, strerror(-ret));
goto out;
}
diff --git a/cmds-send.c b/cmds-send.c index 20bba18..78ee54c 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -192,13 +192,13 @@ static int write_buf(int fd, const void *buf, int

size)

ret = write(fd, (char*)buf + pos, size - pos);
if (ret  0) {
ret = -errno;
-   fprintf(stderr, ERROR: failed to dump stream. %s,
+   fprintf(stderr, ERROR: failed to dump stream. %s\n,
strerror(-ret));
goto out;
}
if (!ret) {
ret = -EIO;
-   fprintf(stderr, ERROR: failed to dump stream. %s,
+   fprintf(stderr, ERROR: failed to dump stream. %s\n,
strerror(-ret));
goto out;
}
diff --git a/dir-item.c b/dir-item.c
index a5bf861..f3ad98f 100644
--- a/dir-item.c
+++ b/dir-item.c
@@ -285,7 +285,7 @@ int verify_dir_item(struct btrfs_root *root,
u8 type = btrfs_dir_type(leaf, dir_item);

if (type = BTRFS_FT_MAX) {
-   fprintf(stderr, invalid dir item type: %d,
+   fprintf(stderr, invalid dir item type: %d\n,
   (int)type);
return 1;
}
@@ -294,7 +294,7 @@ int verify_dir_item(struct btrfs_root

Re: [PATCH] btrfs-progs: add newline to some error messages

2015-08-05 Thread Tsutomu Itoh

On 2015/08/06 12:51, Zhao Lei wrote:

Hi, Itoh


-Original Message-
From: linux-btrfs-ow...@vger.kernel.org
[mailto:linux-btrfs-ow...@vger.kernel.org] On Behalf Of Tsutomu Itoh
Sent: Thursday, August 06, 2015 11:06 AM
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs-progs: add newline to some error messages

Added a missing newline to some error messages.


Good found!

Seems more code need to be fixed, as:

# cat mkfs.c | tr -d '\n' | grep -o -w 'f\?printf([^(]*);' | sed 
's/f\?printf[[:blank:]]*(\(stderr,\|\)[[:blank:]]*\(.*\)[,)].*/\2/g' | grep 
-v '\\n'  symlink too long for %s
Incompat features:  %s
#


It's OK.

  printf(Incompat features:  %s, features_buf);
  printf(\n);



# cat utils.c | tr -d '\n' | grep -o -w 'f\?printf([^(]*);' | sed 
's/f\?printf[[:blank:]]*(\(stderr,\|\)[[:blank:]]*\(.*\)[,)].*/\2/g' | grep 
-v '\\n'
ERROR: DUP for data is allowed only in mixed mode
%s [y/N]: *1
#
*1: It is not problem, should to be ignored


Already fixed by David in devel branch.

Thanks,
Tsutomu



Thanks
Zhaolei


Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com
---
  btrfs-corrupt-block.c | 2 +-
  cmds-check.c  | 4 ++--
  cmds-send.c   | 4 ++--
  dir-item.c| 6 +++---
  mkfs.c| 2 +-
  5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c index 
1a2aa23..ea871f4
100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -1010,7 +1010,7 @@ int find_chunk_offset(struct btrfs_root *root,
goto out;
}
if (ret  0) {
-   fprintf(stderr, Error searching chunk);
+   fprintf(stderr, Error searching chunk\n);
goto out;
}
  out:
diff --git a/cmds-check.c b/cmds-check.c index dd2fce3..0ddf57c 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -2398,7 +2398,7 @@ static int repair_inode_nlinks(struct
btrfs_trans_handle *trans,
  BTRFS_FIRST_FREE_OBJECTID, lost_found_ino,
  mode);
if (ret  0) {
-   fprintf(stderr, Failed to create '%s' dir: %s,
+   fprintf(stderr, Failed to create '%s' dir: %s\n,
dir_name, strerror(-ret));
goto out;
}
@@ -2426,7 +2426,7 @@ static int repair_inode_nlinks(struct
btrfs_trans_handle *trans,
}
if (ret  0) {
fprintf(stderr,
-   Failed to link the inode %llu to %s dir: %s,
+   Failed to link the inode %llu to %s dir: %s\n,
rec-ino, dir_name, strerror(-ret));
goto out;
}
diff --git a/cmds-send.c b/cmds-send.c
index 20bba18..78ee54c 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -192,13 +192,13 @@ static int write_buf(int fd, const void *buf, int size)
ret = write(fd, (char*)buf + pos, size - pos);
if (ret  0) {
ret = -errno;
-   fprintf(stderr, ERROR: failed to dump stream. %s,
+   fprintf(stderr, ERROR: failed to dump stream. %s\n,
strerror(-ret));
goto out;
}
if (!ret) {
ret = -EIO;
-   fprintf(stderr, ERROR: failed to dump stream. %s,
+   fprintf(stderr, ERROR: failed to dump stream. %s\n,
strerror(-ret));
goto out;
}
diff --git a/dir-item.c b/dir-item.c
index a5bf861..f3ad98f 100644
--- a/dir-item.c
+++ b/dir-item.c
@@ -285,7 +285,7 @@ int verify_dir_item(struct btrfs_root *root,
u8 type = btrfs_dir_type(leaf, dir_item);

if (type = BTRFS_FT_MAX) {
-   fprintf(stderr, invalid dir item type: %d,
+   fprintf(stderr, invalid dir item type: %d\n,
   (int)type);
return 1;
}
@@ -294,7 +294,7 @@ int verify_dir_item(struct btrfs_root *root,
namelen = XATTR_NAME_MAX;

if (btrfs_dir_name_len(leaf, dir_item)  namelen) {
-   fprintf(stderr, invalid dir item name len: %u,
+   fprintf(stderr, invalid dir item name len: %u\n,
   (unsigned)btrfs_dir_data_len(leaf, dir_item));
return 1;
}
@@ -302,7 +302,7 @@ int verify_dir_item(struct btrfs_root *root,
/* BTRFS_MAX_XATTR_SIZE is the same for all dir items */
if ((btrfs_dir_data_len(leaf, dir_item) +
 btrfs_dir_name_len(leaf, dir_item)) 
BTRFS_MAX_XATTR_SIZE(root)) {
-   fprintf(stderr, invalid dir item name + data len: %u + %u,
+   fprintf(stderr, invalid dir item name + data len: %u + %u\n

[PATCH] btrfs-progs: add newline to some error messages

2015-08-05 Thread Tsutomu Itoh
Added a missing newline to some error messages.

Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com
---
 btrfs-corrupt-block.c | 2 +-
 cmds-check.c  | 4 ++--
 cmds-send.c   | 4 ++--
 dir-item.c| 6 +++---
 mkfs.c| 2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index 1a2aa23..ea871f4 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -1010,7 +1010,7 @@ int find_chunk_offset(struct btrfs_root *root,
goto out;
}
if (ret  0) {
-   fprintf(stderr, Error searching chunk);
+   fprintf(stderr, Error searching chunk\n);
goto out;
}
 out:
diff --git a/cmds-check.c b/cmds-check.c
index dd2fce3..0ddf57c 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -2398,7 +2398,7 @@ static int repair_inode_nlinks(struct btrfs_trans_handle 
*trans,
  BTRFS_FIRST_FREE_OBJECTID, lost_found_ino,
  mode);
if (ret  0) {
-   fprintf(stderr, Failed to create '%s' dir: %s,
+   fprintf(stderr, Failed to create '%s' dir: %s\n,
dir_name, strerror(-ret));
goto out;
}
@@ -2426,7 +2426,7 @@ static int repair_inode_nlinks(struct btrfs_trans_handle 
*trans,
}
if (ret  0) {
fprintf(stderr,
-   Failed to link the inode %llu to %s dir: %s,
+   Failed to link the inode %llu to %s dir: %s\n,
rec-ino, dir_name, strerror(-ret));
goto out;
}
diff --git a/cmds-send.c b/cmds-send.c
index 20bba18..78ee54c 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -192,13 +192,13 @@ static int write_buf(int fd, const void *buf, int size)
ret = write(fd, (char*)buf + pos, size - pos);
if (ret  0) {
ret = -errno;
-   fprintf(stderr, ERROR: failed to dump stream. %s,
+   fprintf(stderr, ERROR: failed to dump stream. %s\n,
strerror(-ret));
goto out;
}
if (!ret) {
ret = -EIO;
-   fprintf(stderr, ERROR: failed to dump stream. %s,
+   fprintf(stderr, ERROR: failed to dump stream. %s\n,
strerror(-ret));
goto out;
}
diff --git a/dir-item.c b/dir-item.c
index a5bf861..f3ad98f 100644
--- a/dir-item.c
+++ b/dir-item.c
@@ -285,7 +285,7 @@ int verify_dir_item(struct btrfs_root *root,
u8 type = btrfs_dir_type(leaf, dir_item);
 
if (type = BTRFS_FT_MAX) {
-   fprintf(stderr, invalid dir item type: %d,
+   fprintf(stderr, invalid dir item type: %d\n,
   (int)type);
return 1;
}
@@ -294,7 +294,7 @@ int verify_dir_item(struct btrfs_root *root,
namelen = XATTR_NAME_MAX;
 
if (btrfs_dir_name_len(leaf, dir_item)  namelen) {
-   fprintf(stderr, invalid dir item name len: %u,
+   fprintf(stderr, invalid dir item name len: %u\n,
   (unsigned)btrfs_dir_data_len(leaf, dir_item));
return 1;
}
@@ -302,7 +302,7 @@ int verify_dir_item(struct btrfs_root *root,
/* BTRFS_MAX_XATTR_SIZE is the same for all dir items */
if ((btrfs_dir_data_len(leaf, dir_item) +
 btrfs_dir_name_len(leaf, dir_item))  BTRFS_MAX_XATTR_SIZE(root)) {
-   fprintf(stderr, invalid dir item name + data len: %u + %u,
+   fprintf(stderr, invalid dir item name + data len: %u + %u\n,
   (unsigned)btrfs_dir_name_len(leaf, dir_item),
   (unsigned)btrfs_dir_data_len(leaf, dir_item));
return 1;
diff --git a/mkfs.c b/mkfs.c
index dafd500..909b591 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -599,7 +599,7 @@ static int add_symbolic_link(struct btrfs_trans_handle 
*trans,
goto fail;
}
if (ret = sectorsize) {
-   fprintf(stderr, symlink too long for %s, path_name);
+   fprintf(stderr, symlink too long for %s\n, path_name);
ret = -1;
goto fail;
}
-- 
2.4.5


Tsutomu Itoh  t-i...@jp.fujitsu.com

--
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 v2] fstests: btrfs: Add regression test for reserved space leak.

2015-08-04 Thread Tsutomu Itoh
On 2015/08/05 10:08, Qu Wenruo wrote:
 The regression is introduced in v4.2-rc1, with the big btrfs qgroup
 change.
 The problem is, qgroup reserved space is never freed, causing even we
 increase the limit, we can still hit the EDQUOT much faster than it
 should.
 
 Reported-by: Tsutomu Itoh t-i...@jp.fujitsu.com
 Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
 ---
   tests/btrfs/089 | 88 
 +
   tests/btrfs/089.out |  5 +++
   tests/btrfs/group   |  1 +
   3 files changed, 94 insertions(+)
   create mode 100755 tests/btrfs/089
   create mode 100644 tests/btrfs/089.out
 
 diff --git a/tests/btrfs/089 b/tests/btrfs/089
 new file mode 100755
 index 000..82db96c
 --- /dev/null
 +++ b/tests/btrfs/089
 @@ -0,0 +1,88 @@
 +#! /bin/bash
 +# FS QA Test 089
 +#
 +# Regression test for btrfs qgroup reserved space leak.
 +#
 +# Due to qgroup reserved space leak, EDQUOT can be trigged even it's not
 +# over limit after previous write.
 +#
 +#---
 +# Copyright (c) 2015 Fujitsu. All Rights Reserved.
 +#
 +# This program is free software; you can redistribute it and/or
 +# modify it under the terms of the GNU General Public License as
 +# published by the Free Software Foundation.
 +#
 +# This program is distributed in the hope that it would be useful,
 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +# GNU General Public License for more details.
 +#
 +# You should have received a copy of the GNU General Public License
 +# along with this program; if not, write the Free Software Foundation,
 +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 +#---
 +#
 +
 +seq=`basename $0`
 +seqres=$RESULT_DIR/$seq
 +echo QA output created by $seq
 +
 +here=`pwd`
 +tmp=/tmp/$$
 +status=1 # failure is the default!
 +trap _cleanup; exit \$status 0 1 2 3 15
 +
 +_cleanup()
 +{
 + cd /
 + rm -f $tmp.*
 +}
 +
 +# get standard environment, filters and checks
 +. ./common/rc
 +. ./common/filter
 +
 +# real QA test starts here
 +
 +# Modify as appropriate.
 +_supported_fs btrfs
 +_supported_os Linux
 +_require_scratch
 +_need_to_be_root
 +
 +# Use big blocksize to ensure there is still enough space left
 +# for metadata reserve after hitting EDQUOT
 +BLOCKSIZE=$(( 2 * 1024 * 1024 ))
 +FILESIZE=$(( 128 * 1024 * 1024 )) # 128Mbytes
 +
 +# The last block won't be able to finish write, as metadata takes
 +# $NODESIZE space, causing the last block triggering EDQUOT
 +LENGTH=$(( $FILESIZE - $BLOCKSIZE ))
 +
 +_scratch_mkfs $seqres.full 21
 +_scratch_mount
 +_require_fs_space $SCRATCH_MNT $(($FILESIZE * 2 / 1024))
 +
 +_run_btrfs_util_prog quota enable $SCRATCH_MNT
 +_run_btrfs_util_prog qgroup limit $FILESIZE 5 $SCRATCH_MNT
 +
 +$XFS_IO_PROG -f -c pwrite -b $BLOCKSIZE 0 $LENGTH \
 + $SCRATCH_MNT/foo | _filter_xfs_io
 +
 +# A sync is needed to trigger a commit_transaction.
 +# As the reserved space freeing happens at commit_transaction time,
 +# without a transaction commit, no reserved space needs freeing and
 +# won't trigger the bug.
 +sync

Isn't '$BTRFS_UTIL_PROG filesystem sync' better instead of 'sync'?

Thanks,
Tsutomu

 +
 +# Double the limit to allow further write
 +_run_btrfs_util_prog qgroup limit $(($FILESIZE * 2)) 5 $SCRATCH_MNT
 +
 +# Test whether further write can succeed
 +$XFS_IO_PROG -f -c pwrite -b $BLOCKSIZE $LENGTH $LENGTH \
 + $SCRATCH_MNT/foo | _filter_xfs_io
 +
 +# success, all done
 +status=0
 +exit
 diff --git a/tests/btrfs/089.out b/tests/btrfs/089.out
 new file mode 100644
 index 000..396888f
 --- /dev/null
 +++ b/tests/btrfs/089.out
 @@ -0,0 +1,5 @@
 +QA output created by 089
 +wrote 132120576/132120576 bytes at offset 0
 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 +wrote 132120576/132120576 bytes at offset 132120576
 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 diff --git a/tests/btrfs/group b/tests/btrfs/group
 index ffe18bf..225b532 100644
 --- a/tests/btrfs/group
 +++ b/tests/btrfs/group
 @@ -91,6 +91,7 @@
   086 auto quick clone
   087 auto quick send
   088 auto quick metadata
 +089 auto quick qgroup
   090 auto quick metadata
   091 auto quick qgroup
   092 auto quick send
 


--
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 v2] fstests: btrfs: Add regression test for reserved space leak.

2015-08-04 Thread Tsutomu Itoh

On 2015/08/05 12:10, Dave Chinner wrote:

On Wed, Aug 05, 2015 at 11:52:36AM +0900, Tsutomu Itoh wrote:

On 2015/08/05 10:57, Dave Chinner wrote:

On Wed, Aug 05, 2015 at 09:39:35AM +0800, Qu Wenruo wrote:

Tsutomu Itoh wrote on 2015/08/05 10:26 +0900:

On 2015/08/05 10:08, Qu Wenruo wrote:

+# As the reserved space freeing happens at commit_transaction time,
+# without a transaction commit, no reserved space needs freeing and
+# won't trigger the bug.
+sync


Isn't '$BTRFS_UTIL_PROG filesystem sync' better instead of 'sync'?

Thanks,
Tsutomu

Hi, Tsutomu-san,

Yes, I did use such method before, but Dave said it's better to use
unified interface to sync a filesystem other than the specialized
one.

So I still use sync as Dave said.


Mainly because sync is what users will use to make sure their data
is safe. filesystem specific tools have a habit of doing special
stuff to sync a filesystem, so it may not reflect the way users
expect the system to behaviour when they run sync.

The other option is this:

_syncfs()
{
mntpt=$1

$XFS_IO_PROG -c syncfs $mntpt
}

_sync_test()
{
_syncfs $TEST_DIR
}

_sync_scratch()
{
_syncfs $SCRATCH_MNT
}

which only runs sync on the filesystem that needs syncing (via the
syncfs() syscall)


I think that syncfs is better instead of sync because the syncing of
the specified filesystem is necessary.


sync guarantees that. IOWs, there's no difference between sync and
syncfs for the persepctive of this test and so the test does not
need really need changing.


I agree that sync and syncfs is not different for this test.

However, sync is syncing of all filesystems, and, syncfs is syncing
of the specified filesystem only.
Therefor, I think that it is better to use sync and syncfs properly
according to the necessity.

Thanks,
Tsutomu


--
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 v2] fstests: btrfs: Add regression test for reserved space leak.

2015-08-04 Thread Tsutomu Itoh

On 2015/08/05 10:57, Dave Chinner wrote:

On Wed, Aug 05, 2015 at 09:39:35AM +0800, Qu Wenruo wrote:

Tsutomu Itoh wrote on 2015/08/05 10:26 +0900:

On 2015/08/05 10:08, Qu Wenruo wrote:

+# As the reserved space freeing happens at commit_transaction time,
+# without a transaction commit, no reserved space needs freeing and
+# won't trigger the bug.
+sync


Isn't '$BTRFS_UTIL_PROG filesystem sync' better instead of 'sync'?

Thanks,
Tsutomu

Hi, Tsutomu-san,

Yes, I did use such method before, but Dave said it's better to use
unified interface to sync a filesystem other than the specialized
one.

So I still use sync as Dave said.


Mainly because sync is what users will use to make sure their data
is safe. filesystem specific tools have a habit of doing special
stuff to sync a filesystem, so it may not reflect the way users
expect the system to behaviour when they run sync.

The other option is this:

_syncfs()
{
mntpt=$1

$XFS_IO_PROG -c syncfs $mntpt
}

_sync_test()
{
_syncfs $TEST_DIR
}

_sync_scratch()
{
_syncfs $SCRATCH_MNT
}

which only runs sync on the filesystem that needs syncing (via the
syncfs() syscall)


I think that syncfs is better instead of sync because the syncing of
the specified filesystem is necessary.

Thanks,
Tsutomu



Cheers,

Dave.




--
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-progs: doc: fix short explanation of restore in btrfs

2015-06-30 Thread Tsutomu Itoh
Short explanation of restore is wrong. Fix it.

Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com
---
 Documentation/btrfs.asciidoc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/btrfs.asciidoc b/Documentation/btrfs.asciidoc
index 1b3aa29..72d0e0a 100644
--- a/Documentation/btrfs.asciidoc
+++ b/Documentation/btrfs.asciidoc
@@ -75,7 +75,7 @@ COMMANDS
See `btrfs-rescue`(8) for details.
 
 *restore*::
-   Manage a btrfs filesystem, including label setting/sync and so on. +
+   Try to restore files from damaged btrfs filesystem. +
See `btrfs-restore`(8) for details.
 
 *scrub*::
-- 
2.3.1


Tsutomu Itoh  t-i...@jp.fujitsu.com

--
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: qgroup limit clearing, was Re: Btrfs progs release 4.1

2015-06-22 Thread Tsutomu Itoh

On 2015/06/23 3:18, Christian Robottom Reis wrote:

On Mon, Jun 22, 2015 at 05:00:23PM +0200, David Sterba wrote:

   - qgroup:
 - show: distinguish no limits and 0 limit value
 - limit: ability to clear the limit


I'm using kernel 4.1-rc7 as per:

 root@riff:/var/lib/lxc/juju-trusty-lxc-template/rootfs# uname -a
 Linux riff 4.1.0-040100rc7-generic #201506080035 SMP Mon Jun 8 04:36:20 
UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

But apart from still having major issues with qgroups (quota enforcement
triggers even when there seems to be plenty of free space) clearing
limits with btrfs-progs 4.1 doesn't revert back to 'none', instead
confusingly setting the quota to 16EiB. Using:

 root@riff:/var/lib/lxc/juju-trusty-lxc-template/rootfs# btrfs version
 btrfs-progs v4.1

I start from:

 qgroupid rfer excl max_rfer max_excl
     
 0/5   2.15GiB  1.95GiB none none
 0/261 1.42GiB  1.11GiB none100.00GiB
 0/265 1.09GiB600.59MiB none100.00GiB
 0/271   793.32MiB366.40MiB none100.00GiB
 0/274   514.96MiB142.92MiB none100.00GiB

I then issue:

 root@riff# btrfs qgroup limit -e none 261 /var
 root@riff# btrfs qgroup limit none 261 /var

I end up with:

 qgroupid rfer excl max_rfer max_excl
     
 0/5   2.15GiB  1.95GiB none none
 0/261 1.42GiB  1.11GiB 16.00EiB 16.00EiB
 0/265 1.09GiB600.59MiB none100.00GiB
 0/271   793.32MiB366.40MiB none100.00GiB
 0/274   514.96MiB142.92MiB none100.00GiB

Is that expected?



The following fix is necessary for the kernel to display it correctly.

 [PATCH] btrfs: qgroup: allow user to clear the limitation on qgroup
 http://marc.info/?l=linux-btrfsm=143331495409594w=2

Thanks,
Tsutomu


--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in


Re: [PATCH] btrfs: qgroup: allow user to clear the limitation on qgroup

2015-06-03 Thread Tsutomu Itoh
On 2015/06/03 15:57, Dongsheng Yang wrote:
 Currently, we can only set a limitation on a qgroup, but we
 can not clear it.
 
 This patch provide a choice to user to clear a limitation on
 qgroup by passing a value of CLEAR_VALUE(-1) to kernel.
 
 Reported-by: Tsutomu Itoh t-i...@jp.fujitsu.com
 Signed-off-by: Dongsheng Yang yangds.f...@cn.fujitsu.com

Tested-by: Tsutomu Itoh t-i...@jp.fujitsu.com

 ---
   fs/btrfs/qgroup.c | 49 +
   1 file changed, 41 insertions(+), 8 deletions(-)
 
 diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
 index 3d65465..0412d5b 100644
 --- a/fs/btrfs/qgroup.c
 +++ b/fs/btrfs/qgroup.c
 @@ -1317,6 +1317,11 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle 
 *trans,
   struct btrfs_root *quota_root;
   struct btrfs_qgroup *qgroup;
   int ret = 0;
 + /* Sometimes we would want to clear the limit on this qgroup.
 +  * To meet this requirement, we treat the -1 as a special value
 +  * which tell kernel to clear the limit on this qgroup.
 +  */
 + const u64 CLEAR_VALUE = -1;
   
   mutex_lock(fs_info-qgroup_ioctl_lock);
   quota_root = fs_info-quota_root;
 @@ -1332,14 +1337,42 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle 
 *trans,
   }
   
   spin_lock(fs_info-qgroup_lock);
 - if (limit-flags  BTRFS_QGROUP_LIMIT_MAX_RFER)
 - qgroup-max_rfer = limit-max_rfer;
 - if (limit-flags  BTRFS_QGROUP_LIMIT_MAX_EXCL)
 - qgroup-max_excl = limit-max_excl;
 - if (limit-flags  BTRFS_QGROUP_LIMIT_RSV_RFER)
 - qgroup-rsv_rfer = limit-rsv_rfer;
 - if (limit-flags  BTRFS_QGROUP_LIMIT_RSV_EXCL)
 - qgroup-rsv_excl = limit-rsv_excl;
 + if (limit-flags  BTRFS_QGROUP_LIMIT_MAX_RFER) {
 + if (limit-max_rfer == CLEAR_VALUE) {
 + qgroup-lim_flags = ~BTRFS_QGROUP_LIMIT_MAX_RFER;
 + limit-flags = ~BTRFS_QGROUP_LIMIT_MAX_RFER;
 + qgroup-max_rfer = 0;
 + } else {
 + qgroup-max_rfer = limit-max_rfer;
 + }
 + }
 + if (limit-flags  BTRFS_QGROUP_LIMIT_MAX_EXCL) {
 + if (limit-max_excl == CLEAR_VALUE) {
 + qgroup-lim_flags = ~BTRFS_QGROUP_LIMIT_MAX_EXCL;
 + limit-flags = ~BTRFS_QGROUP_LIMIT_MAX_EXCL;
 + qgroup-max_excl = 0;
 + } else {
 + qgroup-max_excl = limit-max_excl;
 + }
 + }
 + if (limit-flags  BTRFS_QGROUP_LIMIT_RSV_RFER) {
 + if (limit-rsv_rfer == CLEAR_VALUE) {
 + qgroup-lim_flags = ~BTRFS_QGROUP_LIMIT_RSV_RFER;
 + limit-flags = ~BTRFS_QGROUP_LIMIT_RSV_RFER;
 + qgroup-rsv_rfer = 0;
 + } else {
 + qgroup-rsv_rfer = limit-rsv_rfer;
 + }
 + }
 + if (limit-flags  BTRFS_QGROUP_LIMIT_RSV_EXCL) {
 + if (limit-rsv_excl == CLEAR_VALUE) {
 + qgroup-lim_flags = ~BTRFS_QGROUP_LIMIT_RSV_EXCL;
 + limit-flags = ~BTRFS_QGROUP_LIMIT_RSV_EXCL;
 + qgroup-rsv_excl = 0;
 + } else {
 + qgroup-rsv_excl = limit-rsv_excl;
 + }
 + }
   qgroup-lim_flags |= limit-flags;
   
   spin_unlock(fs_info-qgroup_lock);
 


--
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 2/2] btrfs-progs: qgroup: allow user to clear some limitation on qgroup.

2015-06-03 Thread Tsutomu Itoh
On 2015/06/03 15:57, Dongsheng Yang wrote:
 Currently, we can not clear a limitation on a qgroup. Although
 there is a 'none' choice provided to user to do it, it does not
 work well.
 
 It does not set the flag which user want to clear, then kernel
 will never know what the user want to do at all.
 
 *Without this commit*
   # ./btrfs qgroup show -re /mnt
 qgroupid rfer excl max_rfer max_excl
     
 0/5   2.19GiB  2.19GiB  5.00GiB none
 0/257   100.02MiB100.02MiB none none
   # ./btrfs qgroup limit none /mnt
   # ./btrfs qgroup show -re /mnt
 qgroupid rfer excl max_rfer max_excl
     
 0/5   2.19GiB  2.19GiB  5.00GiB none
 0/257   100.02MiB100.02MiB none none
 
 This patch will set the flag user want to clear and pass a
 size=-1 to kernel. Then kernel will clear it correctly.
 
 *With this commit*
   # ./btrfs qgroup show -re /mnt
 qgroupid rfer excl max_rfer max_excl
     
 0/5   2.19GiB  2.19GiB  5.00GiB none
 0/257   100.02MiB100.02MiB none none
   # ./btrfs qgroup limit none /mnt
   # ./btrfs qgroup show -re /mnt
 qgroupid rfer excl max_rfer max_excl
     
 0/5   2.19GiB  2.19GiB none none
 0/257   100.02MiB100.02MiB none none
 
 Reported-by: Tsutomu Itoh t-i...@jp.fujitsu.com
 Signed-off-by: Dongsheng Yang yangds.f...@cn.fujitsu.com
 ---
   cmds-qgroup.c | 23 +++
   1 file changed, 11 insertions(+), 12 deletions(-)
 
 diff --git a/cmds-qgroup.c b/cmds-qgroup.c
 index b073250..00cc089 100644
 --- a/cmds-qgroup.c
 +++ b/cmds-qgroup.c
 @@ -110,9 +110,10 @@ static int parse_limit(const char *p, unsigned long long 
 *s)
   {
   char *endptr;
   unsigned long long size;
 + unsigned long long CLEAR_VALUE = -1;

Even if a negative value is specified, it doesn't become an error...
So, it doesn't make an error of the following command.

# btrfs qg lim -- -1 sub1
# btrfs qg show -prce /test1
qgroupid rfer excl max_rfer max_excl parent  child
     --  -
0/5  16.00KiB 16.00KiB none none --- ---
0/259 8.86GiB  7.88GiB none none --- ---
# btrfs qg lim -- -2 sub1
# btrfs qg show -prce /test1
qgroupid rfer excl max_rfer max_excl parent  child
     --  -
0/5  16.00KiB 16.00KiB none none --- ---
0/259 8.86GiB  7.88GiB 16.00EiB none --- ---

Otherwise OK,

Tested-by: Tsutomu Itoh t-i...@jp.fujitsu.com


   
   if (strcasecmp(p, none) == 0) {
 - *s = 0;
 + *s = CLEAR_VALUE;
   return 1;
   }
   size = strtoull(p, endptr, 10);
 @@ -406,17 +407,15 @@ static int cmd_qgroup_limit(int argc, char **argv)
   }
   
   memset(args, 0, sizeof(args));
 - if (size) {
 - if (compressed)
 - args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
 -   BTRFS_QGROUP_LIMIT_EXCL_CMPR;
 - if (exclusive) {
 - args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL;
 - args.lim.max_exclusive = size;
 - } else {
 - args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER;
 - args.lim.max_referenced = size;
 - }
 + if (compressed)
 + args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
 +   BTRFS_QGROUP_LIMIT_EXCL_CMPR;
 + if (exclusive) {
 + args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL;
 + args.lim.max_exclusive = size;
 + } else {
 + args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER;
 + args.lim.max_referenced = size;
   }
   
   if (argc - optind == 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 1/2] btrfs-progs: qgroup: show 'none' when we did not limit it on this qgroup

2015-06-03 Thread Tsutomu Itoh
On 2015/06/03 15:57, Dongsheng Yang wrote:
 There are two understanding of the '0' value in btrfs qgroup show.
 (1) is no-limitation on this qgroup. (2) is the max-limitation is 0.
 
 This patch make it showing in different way.
 
 (1). max-limitation for 0 is still showing '0'.
 (2). no-limitation will show 'none'.
 
 qgroupid rfer excl max_rfer max_excl parent
      --
 0/5   2.19GiB  2.19GiB none none ---
 0/257   100.02MiB100.02MiB none none ---
 
 Signed-off-by: Dongsheng Yang yangds.f...@cn.fujitsu.com

Tested-by: Tsutomu Itoh t-i...@jp.fujitsu.com

 ---
   qgroup.c | 10 --
   1 file changed, 8 insertions(+), 2 deletions(-)
 
 diff --git a/qgroup.c b/qgroup.c
 index 53815b5..dc04b03 100644
 --- a/qgroup.c
 +++ b/qgroup.c
 @@ -237,10 +237,16 @@ static void print_qgroup_column(struct btrfs_qgroup 
 *qgroup,
   print_qgroup_column_add_blank(BTRFS_QGROUP_PARENT, len);
   break;
   case BTRFS_QGROUP_MAX_RFER:
 - len = printf(%*s, max_len, pretty_size_mode(qgroup-max_rfer, 
 unit_mode));
 + if (qgroup-flags  BTRFS_QGROUP_LIMIT_MAX_RFER)
 + len = printf(%*s, max_len, 
 pretty_size_mode(qgroup-max_rfer, unit_mode));
 + else
 + len = printf(%*s, max_len, none);
   break;
   case BTRFS_QGROUP_MAX_EXCL:
 - len = printf(%*s, max_len, pretty_size_mode(qgroup-max_excl, 
 unit_mode));
 + if (qgroup-flags  BTRFS_QGROUP_LIMIT_MAX_EXCL)
 + len = printf(%*s, max_len, 
 pretty_size_mode(qgroup-max_excl, unit_mode));
 + else
 + len = printf(%*s, max_len, none);
   break;
   case BTRFS_QGROUP_CHILD:
   len = print_child_column(qgroup);
 


--
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: 3.18.11 - no space left on device and 'fi usage' shows lots

2015-04-19 Thread Tsutomu Itoh

On 2015/04/20 5:15, Joel Best wrote:

Hi all, We have recently had major issues with our large btrfs volume crashing 
and remounting read-only because it thinks it's out of space. The volume is 
55TB on h/w raid 6 with 44TB free and the server is running Ubuntu 14.04 server 
x64. The problem first happened with kernel 3.13 but I've since upgraded to 
3.18 while trying to resolve this issue. The volume was first created with 
kernel 3.13 and btfs-progs 3.12.

When this problem first cropped up, it crashed the kernel with the following 
error:

 BTRFS debug (device sda1): run_one_delayed_ref returned -28
 Apr 17 19:49:28 NAS1 kernel: [189102.821859] BTRFS error (device sda1) in 
btrfs_run_delayed_refs:2730: errno=-28 No space left
 Apr 17 19:49:28 NAS1 kernel: [189102.821861] BTRFS info (device sda1): 
forced readonly
 Apr 17 19:49:28 NAS1 kernel: [189102.916132] btrfs: Transaction aborted 
(error -28)

After some reading, it seemed like mounting with clear_cache to clear the disk 
caching but the problem recurred a short time later. We then tried a balance, 
and and fsck/fsck --repair which both failed to resolve the issue. Finally, we 
decided to upgrade kernels from 3.13 to 3.18.




To try and reproduce the issue after the upgrade, I created a script which uses 
fallocate to generate 1000 1GB files, deletes them, and repeats:

 #!/bin/bash
 while [ 1 ] ; do
 echo Creating 1000 files...
 i=0
 while [ 1 ] ; do
 fallocate -l 1G test.${i}
 (( i++ ))
 if [[ $i == 1000 ]] ; then
 break
 fi
 done
 echo Removing Files...
 rm -f test.*
 done

After a few successful iterations, this happened:

 # /root/April2015-storage-failure/stress-fallocate.sh
 Creating 1000 files...
 fallocate: test.147: fallocate failed: No space left on device
 fallocate: test.148: fallocate failed: No space left on device
 fallocate: test.149: fallocate failed: No space left on device
 fallocate: test.150: fallocate failed: No space left on device
 fallocate: test.151: fallocate failed: No space left on device
 fallocate: test.152: fallocate failed: No space left on device
 fallocate: test.153: fallocate failed: No space left on device
 fallocate: test.154: fallocate failed: No space left on device
 fallocate: test.155: fallocate failed: No space left on device
 fallocate: test.156: fallocate failed: No space left on device
 ^C


I think this problem to be fixed by the following patches.
However, it is not in the Linus's master tree yet.

  Forrest Liu's patch:
   [PATCH] Btrfs: fix find_free_dev_extent() malfunction in case device tree 
has hole
   http://marc.info/?l=linux-btrfsm=142286232508765w=2

  Zhao Lei's patch:
   [PATCH v2 0/9] btrfs: Fix no_space on dd and rm loop
   http://marc.info/?l=linux-btrfsm=142855419528331w=2

Thanks,
Tsutomu



There was no kernel crash this time. All btrfs tools show lots of space 
available:

 root@NAS1:/mlrg/tmp# btrfs fi usage /mlrg
 Overall:
 Device size:54.56TiB
 Device allocated:   11.31TiB
 Device unallocated:   43.26TiB
 Used:   11.30TiB
 Free (estimated):   43.26TiB  (min: 43.26TiB)
 Data ratio:   1.00
 Metadata ratio:   1.00
 Global reserve:  512.00MiB  (used: 0.00B)
 Data,single: Size:11.26TiB, Used:11.26TiB
/dev/sdc1  11.26TiB
 Metadata,single: Size:48.01GiB, Used:46.29GiB
/dev/sdc1  48.01GiB
 System,single: Size:32.00MiB, Used:1.20MiB
/dev/sdc1  32.00MiB
 Unallocated:
/dev/sdc1  43.26TiB


I'm not sure if this is expected behaviour with fallocate or a bug. It's the 
only way I've found to reliably reproduce the problem (aside from making the 
server available to my users).


Also, I first inadvertently ran the fallocate script when a scrub was running I 
experienced a different crash... I'm not sure if it's related:

 [12996.654120] kernel BUG at /home/kernel/COD/linux/fs/btrfs/inode.c:3123!
 [12996.656776] invalid opcode:  [#1] SMP
 [12996.658473] Modules linked in: nfsv3 ip6t_REJECT nf_reject_ipv6 xt_hl 
ip6t_rt nf_conntrack_ipv6 nf_defrag_ipv6 x86_pkg_temp_thermal intel_powerclamp 
ipt_REJECT coretemp ipmi_devintf nf_reject_ipv4 xt_limit xt_tcpudp kvm 
xt_addrtype crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel 
aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd nf_conntrack_ipv4 
nf_defrag_ipv4 xt_conntrack ip6table_filter ip6_tables nf_conntrack_netbios_ns 
nf_conntrack_broadcast nf_nat_ftp nf_nat nf_conntrack_ftp nf_conntrack 
iptable_filter ip_tables x_tables sb_edac lpc_ich edac_core mei_me mei ioatdma 
shpchp wmi ipmi_si ipmi_msghandler 8250_fintek mac_hid megaraid lp parport 
rpcsec_gss_krb5 nfsd auth_rpcgss nfs_acl
nfs lockd grace sunrpc fscache btrfs 

Re: 3.18.11 - no space left on device and 'fi usage' shows lots

2015-04-19 Thread Tsutomu Itoh

On 2015/04/20 13:08, Tsutomu Itoh wrote:

On 2015/04/20 5:15, Joel Best wrote:

Hi all, We have recently had major issues with our large btrfs volume crashing 
and remounting read-only because it thinks it's out of space. The volume is 
55TB on h/w raid 6 with 44TB free and the server is running Ubuntu 14.04 server 
x64. The problem first happened with kernel 3.13 but I've since upgraded to 
3.18 while trying to resolve this issue. The volume was first created with 
kernel 3.13 and btfs-progs 3.12.

When this problem first cropped up, it crashed the kernel with the following 
error:

 BTRFS debug (device sda1): run_one_delayed_ref returned -28
 Apr 17 19:49:28 NAS1 kernel: [189102.821859] BTRFS error (device sda1) in 
btrfs_run_delayed_refs:2730: errno=-28 No space left
 Apr 17 19:49:28 NAS1 kernel: [189102.821861] BTRFS info (device sda1): 
forced readonly
 Apr 17 19:49:28 NAS1 kernel: [189102.916132] btrfs: Transaction aborted 
(error -28)

After some reading, it seemed like mounting with clear_cache to clear the disk 
caching but the problem recurred a short time later. We then tried a balance, 
and and fsck/fsck --repair which both failed to resolve the issue. Finally, we 
decided to upgrade kernels from 3.13 to 3.18.




To try and reproduce the issue after the upgrade, I created a script which uses 
fallocate to generate 1000 1GB files, deletes them, and repeats:

 #!/bin/bash
 while [ 1 ] ; do
 echo Creating 1000 files...
 i=0
 while [ 1 ] ; do
 fallocate -l 1G test.${i}
 (( i++ ))
 if [[ $i == 1000 ]] ; then
 break
 fi
 done
 echo Removing Files...
 rm -f test.*
 done

After a few successful iterations, this happened:

 # /root/April2015-storage-failure/stress-fallocate.sh
 Creating 1000 files...
 fallocate: test.147: fallocate failed: No space left on device
 fallocate: test.148: fallocate failed: No space left on device
 fallocate: test.149: fallocate failed: No space left on device
 fallocate: test.150: fallocate failed: No space left on device
 fallocate: test.151: fallocate failed: No space left on device
 fallocate: test.152: fallocate failed: No space left on device
 fallocate: test.153: fallocate failed: No space left on device
 fallocate: test.154: fallocate failed: No space left on device
 fallocate: test.155: fallocate failed: No space left on device
 fallocate: test.156: fallocate failed: No space left on device
 ^C


I think this problem to be fixed by the following patches.
However, it is not in the Linus's master tree yet.




   Forrest Liu's patch:
[PATCH] Btrfs: fix find_free_dev_extent() malfunction in case device tree 
has hole
http://marc.info/?l=linux-btrfsm=142286232508765w=2


Oops, following patch is newer.

  [PATCH v3] Btrfs: fix find_free_dev_extent() malfunction in case device tree 
has hole
  http://marc.info/?l=linux-btrfsm=142347427506763w=2

Thanks,
Tsutomu



   Zhao Lei's patch:
[PATCH v2 0/9] btrfs: Fix no_space on dd and rm loop
http://marc.info/?l=linux-btrfsm=142855419528331w=2

Thanks,
Tsutomu



There was no kernel crash this time. All btrfs tools show lots of space 
available:

 root@NAS1:/mlrg/tmp# btrfs fi usage /mlrg
 Overall:
 Device size:54.56TiB
 Device allocated:   11.31TiB
 Device unallocated:   43.26TiB
 Used:   11.30TiB
 Free (estimated):   43.26TiB  (min: 43.26TiB)
 Data ratio:   1.00
 Metadata ratio:   1.00
 Global reserve:  512.00MiB  (used: 0.00B)
 Data,single: Size:11.26TiB, Used:11.26TiB
/dev/sdc1  11.26TiB
 Metadata,single: Size:48.01GiB, Used:46.29GiB
/dev/sdc1  48.01GiB
 System,single: Size:32.00MiB, Used:1.20MiB
/dev/sdc1  32.00MiB
 Unallocated:
/dev/sdc1  43.26TiB


I'm not sure if this is expected behaviour with fallocate or a bug. It's the 
only way I've found to reliably reproduce the problem (aside from making the 
server available to my users).


Also, I first inadvertently ran the fallocate script when a scrub was running I 
experienced a different crash... I'm not sure if it's related:

 [12996.654120] kernel BUG at /home/kernel/COD/linux/fs/btrfs/inode.c:3123!
 [12996.656776] invalid opcode:  [#1] SMP
 [12996.658473] Modules linked in: nfsv3 ip6t_REJECT nf_reject_ipv6 xt_hl 
ip6t_rt nf_conntrack_ipv6 nf_defrag_ipv6 x86_pkg_temp_thermal intel_powerclamp 
ipt_REJECT coretemp ipmi_devintf nf_reject_ipv4 xt_limit xt_tcpudp kvm 
xt_addrtype crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel 
aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd nf_conntrack_ipv4 
nf_defrag_ipv4 xt_conntrack ip6table_filter ip6_tables nf_conntrack_netbios_ns 
nf_conntrack_broadcast nf_nat_ftp nf_nat nf_conntrack_ftp

Re: [PATCH] btrfs: wait for delayed iputs on no space

2015-03-31 Thread Tsutomu Itoh
On 2015/03/27 19:21, Zhaolei wrote:
 From: Zhao Lei zhao...@cn.fujitsu.com
 
 This is another fix of no_space case.
 
 All patchs for fix no_space bug are available at fix_no_space
 branch on:
git://github.com/zhaoleidd/btrfs

I tested in the environment that applied the following patch to
'fix_no_space' branch.
 - Btrfs: fix find_free_dev_extent() malfunction in case device tree has hole

It works fine to me. Thanks.

Tested-by: Tsutomu Itoh t-i...@jp.fujitsu.com

 
 Any suggestions are welcome.
 
 Zhao Lei (1):
btrfs: wait for delayed iputs on no space
 
   fs/btrfs/extent-tree.c | 3 +++
   1 file changed, 3 insertions(+)
 

--
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: fix typo of variable in scrub_stripe

2015-01-09 Thread Tsutomu Itoh
The address that should be freed is not 'ppath' but 'path'.

Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com 
---
 fs/btrfs/scrub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index f2bb13a..403fbdb 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -3053,7 +3053,7 @@ static noinline_for_stack int scrub_stripe(struct 
scrub_ctx *sctx,
 
ppath = btrfs_alloc_path();
if (!ppath) {
-   btrfs_free_path(ppath);
+   btrfs_free_path(path);
return -ENOMEM;
}
 
-- 
2.2.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] btrfs-progs: doc: fix format of btrfs-replace

2015-01-07 Thread Tsutomu Itoh
Current 'man btrfs-replace' is as follows:


...
...
   -f
   force using and overwriting targetdev even if it looks like
   containing a valid btrfs filesystem.

   A valid filesystem is assumed if a btrfs superblock is found
   which contains a correct checksum. Devices which are currently
   mounted are never allowed to be used as the targetdev. -B
   no background replace.
...
...


The format of 'B' option is wrong. So, fix it.

Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com 
---
NOTE: This patch based on v3.18.x branch.

 Documentation/btrfs-replace.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/btrfs-replace.txt b/Documentation/btrfs-replace.txt
index 7402484..e8eac2c 100644
--- a/Documentation/btrfs-replace.txt
+++ b/Documentation/btrfs-replace.txt
@@ -52,6 +52,7 @@ containing a valid btrfs filesystem.
 A valid filesystem is assumed if a btrfs superblock is found which contains a
 correct checksum. Devices which are currently mounted are
 never allowed to be used as the targetdev.
++
 -B
 no background replace.
 
-- 
2.2.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] btrfs-progs: doc: fix incorrect format of 'l' option in mkfs.btrfs

2014-12-23 Thread Tsutomu Itoh
The format of 'l' option in mkfs.btrfs.txt is wrong.
And, when the head of the character string is 65536, the following warning
is displayed.

$ make
Making all in Documentation
[ASCII]  mkfs.btrfs.xml
asciidoc: WARNING: mkfs.btrfs.xml.tmp1: line 67: list item index: expected 
1 got 65536
[XMLTO]  mkfs.btrfs.8
[GZ] mkfs.btrfs.8.gz
rm mkfs.btrfs.8 mkfs.btrfs.xml

So, fix it.

Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com
---
 Documentation/mkfs.btrfs.txt | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/Documentation/mkfs.btrfs.txt b/Documentation/mkfs.btrfs.txt
index ba7e42b..01b615d 100644
--- a/Documentation/mkfs.btrfs.txt
+++ b/Documentation/mkfs.btrfs.txt
@@ -59,19 +59,18 @@ By default, mkfs.btrfs will not write to the device if it 
suspects that
 there is a filesystem or partition table on the device already.
 
 -n|--nodesize size
-+
+
 -l|--leafsize size::
 Specify the nodesize, the tree block size in which btrfs stores
 data. The default value is 16KB (16384) or the page size, whichever is
-bigger. Must be a multiple of the sectorsize, but not larger than
-65536. Leafsize always equals nodesize and the options are aliases.
+bigger. Must be a multiple of the sectorsize, but not larger than 65536.
+Leafsize always equals nodesize and the options are aliases.
 
 -L|--label name::
 Specify a label for the filesystem.
 +
 NOTE: name should be less than 256 characters.
 
-
 -m|--metadata profile::
 Specify how metadata must be spanned across the devices specified. Valid
 values are 'raid0', 'raid1', 'raid5', 'raid6', 'raid10', 'single' or 'dup'.
-- 
2.1.0

--
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-progs: doc: fix incorrect subvol name

2014-07-13 Thread Tsutomu Itoh
Subvolume name is wrong. Fix it.

Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com
---
 Documentation/btrfs-convert.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/btrfs-convert.txt b/Documentation/btrfs-convert.txt
index ed61d14..1eff0bf 100644
--- a/Documentation/btrfs-convert.txt
+++ b/Documentation/btrfs-convert.txt
@@ -13,7 +13,7 @@ DESCRIPTION
 ---
 *btrfs-convert* is used to convert existed ext2/3/4 to btrfs filesystem,
 and the original filesystem image is accessible as from separate subvolume
-named 'ext2_subvol' as file image.
+named 'ext2_saved' as file image.
 
 OPTIONS
 ---
-- 
1.8.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: Lockups with btrfs on 3.16-rc1 - bisected

2014-06-19 Thread Tsutomu Itoh

On 2014/06/20 8:21, Waiman Long wrote:

On 06/19/2014 05:50 PM, Chris Mason wrote:


I would like to take back my comments. I took out the read_lock, but the
process still hang while doing file activities on btrfs filesystem. So
the problem is trickier than I thought. Below are the stack backtraces
of some of the relevant processes.


You weren't wrong, but it was also the tree trylock code.  Our trylocks
only back off if the blocking lock is held.  btrfs_next_leaf needs it to
be a true trylock.  The confusing part is this hasn't really changed,
but one of the callers must be a spinner where we used to have a blocker.

This is what I have queued up, it's working here.

-chris

commit ea4ebde02e08558b020c4b61bb9a4c0fcf63028e
Author: Chris Masonc...@fb.com
Date:   Thu Jun 19 14:16:52 2014 -0700

 Btrfs: fix deadlocks with trylock on tree nodes

 The Btrfs tree trylock function is poorly named.  It always takes
 the spinlock and backs off if the blocking lock is held.  This
 can lead to surprising lockups because people expect it to really be a
 trylock.

 This commit makes it a pure trylock, both for the spinlock and the
 blocking lock.  It also reworks the nested lock handling slightly to
 avoid taking the read lock while a spinning write lock might be held.

 Signed-off-by: Chris Masonc...@fb.com


I didn't realize that those non-blocking lock functions are really trylocks. 
Yes, the patch did seem to fix the hanging problem that I saw when I just untar 
the kernel source files into a btrfs filesystem. However, when I tried did a 
kernel build on a 24-thread (-j 24) system, the build process hanged after a 
while. The following kind of stack trace messages were printed:

INFO: task btrfs-transacti:16576 blocked for more than 120 seconds.
   Tainted: GE 3.16.0-rc1 #5
echo 0  /proc/sys/kernel/hung_task_timeout_secs disables this message.
btrfs-transacti D 000f 0 16576  2 0x
  88080eabbbf8 0046 880803b98350 88080eab8010
  00012b80 00012b80 880805ed8f10 88080d162310
  88080eabbce8 8807be170880 8807be170888 7fff
Call Trace:
  [81592de9] schedule+0x29/0x70
  [815920bd] schedule_timeout+0x13d/0x1d0
  [8106b474] ? wake_up_worker+0x24/0x30
  [8106d595] ? insert_work+0x65/0xb0
  [81593cc6] wait_for_completion+0xc6/0x100
  [810868d0] ? try_to_wake_up+0x220/0x220
  [a06bb9ba] btrfs_wait_and_free_delalloc_work+0x1a/0x30 [btrfs]
  [a06d458d] btrfs_run_ordered_operations+0x1dd/0x2c0 [btrfs]
  [a06b7fd5] btrfs_flush_all_pending_stuffs+0x35/0x40 [btrfs]
  [a06ba099] btrfs_commit_transaction+0x229/0xa30 [btrfs]
  [8105ef30] ? lock_timer_base+0x70/0x70
  [a06b51db] transaction_kthread+0x1eb/0x270 [btrfs]
  [a06b4ff0] ? close_ctree+0x2d0/0x2d0 [btrfs]
  [8107544e] kthread+0xce/0xf0
  [81075380] ? kthread_freezable_should_stop+0x70/0x70
  [8159636c] ret_from_fork+0x7c/0xb0
  [81075380] ? kthread_freezable_should_stop+0x70/0x70

It looks like some more work may still be needed. Or it could be a problem in 
my system configuration.



Umm, after applying Chris's patch to my environment, xfstests ran
completely and the above messages were not output. (Are above messages
another bug?)

Thanks,
Tsutomu


--
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


[3.16-rc1] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]

2014-06-16 Thread Tsutomu Itoh
I encountered soft lockup when executing 'xfstests btrfs/042' on 3.16-rc1.



[ 1121.983975] BTRFS: device fsid 8cc641f9-563a-4d62-9157-9503156ce62c devid 1 
transid 4 /dev/sdc5
[ 1121.987994] BTRFS info (device sdc5): disk space caching is enabled
[ 1121.987999] BTRFS: flagging fs with big metadata feature
[ 1121.996312] BTRFS: creating UUID tree
[ 1122.050762] BTRFS info (device sdc5): qgroup scan completed
[ 1147.942181] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]
[ 1147.949658] Modules linked in: loop ipt_MASQUERADE iptable_nat nf_nat_ipv4 
nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack xt_CHECKSUM 
iptable_mangle bridge stp llc ip6table_filter ip6_tables ebtable_nat ebtables 
btrfs coretemp kvm_intel kvm xor raid6_pq crc32_pclmul crc32c_intel 
ghash_clmulni_intel nfsd igb microcode ptp pps_core dca iTCO_wdt shpchp 
auth_rpcgss iTCO_vendor_support i7core_edac pcspkr edac_core i2c_i801 lpc_ich 
mfd_core ipmi_si tpm_infineon ipmi_msghandler tpm_tis nfs_acl tpm 
acpi_power_meter lockd acpi_cpufreq sunrpc usb_storage mgag200 syscopyarea 
sysfillrect sysimgblt i2c_algo_bit drm_kms_helper ttm ata_generic pata_acpi drm 
megaraid_sas i2c_core ata_piix
[ 1147.949695] CPU: 0 PID: 5189 Comm: kworker/u25:4 Not tainted 3.16.0-rc1 #1
[ 1147.949696] Hardware name: FUJITSU-SV   PRIMERGY 
 /D2619, BIOS 6.00 Rev. 1.03.2619.N1   04/06/2010
[ 1147.949717] Workqueue: btrfs-endio-write normal_work_helper [btrfs]
[ 1147.949718] task: 88007408b840 ti: 8800740e4000 task.ti: 
8800740e4000
[ 1147.949720] RIP: 0010:[810ba858]  [810ba858] 
queue_read_lock_slowpath+0x68/0x90
[ 1147.949725] RSP: 0018:8800740e7b08  EFLAGS: 0202
[ 1147.949726] RAX: 00ee RBX: 0012 RCX: 0001
[ 1147.949727] RDX: 00ef RSI: 0004 RDI: 88003db221b0
[ 1147.949728] RBP: 8800740e7b08 R08: 0001 R09: 880071486b58
[ 1147.949729] R10:  R11:  R12: 8800715d1900
[ 1147.949730] R13:  R14: 0003 R15: 0002
[ 1147.949732] FS:  () GS:88007dc0() 
knlGS:
[ 1147.949733] CS:  0010 DS:  ES:  CR0: 8005003b
[ 1147.949734] CR2: 0036c97b9490 CR3: 01c0e000 CR4: 07f0
[ 1147.949735] Stack:
[ 1147.949736]  8800740e7b18 8166bcbc 8800740e7b38 
a070ffe4
[ 1147.949738]  0001 ffe8 8800740e7b58 
a06b0c2a
[ 1147.949740]  8800719de360  8800740e7bf8 
a06b5e32
[ 1147.949742] Call Trace:
[ 1147.949748]  [8166bcbc] _raw_read_lock+0x1c/0x30
[ 1147.949760]  [a070ffe4] btrfs_clear_lock_blocking_rw+0x44/0x150 
[btrfs]
[ 1147.949767]  [a06b0c2a] btrfs_clear_path_blocking+0x3a/0x80 [btrfs]
[ 1147.949774]  [a06b5e32] btrfs_search_slot+0x702/0xa10 [btrfs]
[ 1147.949783]  [a06cbe2e] btrfs_lookup_csum+0x5e/0x180 [btrfs]
[ 1147.949792]  [a06cd19c] btrfs_csum_file_blocks+0xbc/0x680 [btrfs]
[ 1147.949798]  [a06b0d46] ? btrfs_free_path+0x26/0x30 [btrfs]
[ 1147.949809]  [a06db1e0] add_pending_csums.isra.42+0x50/0x80 [btrfs]
[ 1147.949819]  [a06e1410] btrfs_finish_ordered_io+0x470/0x570 [btrfs]
[ 1147.949830]  [a06e1785] finish_ordered_fn+0x15/0x20 [btrfs]
[ 1147.949841]  [a0706b3c] normal_work_helper+0xbc/0x290 [btrfs]
[ 1147.949844]  [8108ab95] process_one_work+0x175/0x430
[ 1147.949846]  [8108b23b] worker_thread+0x11b/0x520
[ 1147.949848]  [8108b120] ? rescuer_thread+0x2d0/0x2d0
[ 1147.949851]  [81091712] kthread+0xd2/0xf0
[ 1147.949853]  [81091640] ? insert_kthread_work+0x40/0x40
[ 1147.949855]  [8166c23c] ret_from_fork+0x7c/0xb0
[ 1147.949857]  [81091640] ? insert_kthread_work+0x40/0x40
[ 1147.949858] Code: 00 00 00 f3 90 8b 07 84 c0 75 f8 b8 00 01 00 00 f0 0f c1 
07 3c ff 75 0b 0f 1f 00 f3 90 8b 07 3c ff 74 f8 80 47 04 01 5d c3 f3 90 0f b6 
47 04 38 c2 75 f6 eb bf 8b 07 3c ff 75 ec f3 90 8b 07 3c

--
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: [3.16-rc1] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]

2014-06-16 Thread Tsutomu Itoh
Hi Chris,

On 2014/06/17 2:56, Chris Mason wrote:
 On 06/16/2014 02:35 AM, Tsutomu Itoh wrote:
 I encountered soft lockup when executing 'xfstests btrfs/042' on 3.16-rc1.

 
 Did we recover, or was it stuck forever?

The following messages are repeatedly output.
And stuck forever.

[ 1147.942181] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]
[ 1147.967175] BUG: soft lockup - CPU#3 stuck for 23s! [kworker/u25:9:5194]
[ 1147.979172] BUG: soft lockup - CPU#4 stuck for 23s! [kworker/u25:15:5200]
[ 1147.991169] BUG: soft lockup - CPU#5 stuck for 23s! [kworker/u25:7:5192]
[ 1148.064153] BUG: soft lockup - CPU#6 stuck for 23s! [kworker/u26:3:3182]

Thanks,
Tsutomu


--
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: [3.16-rc1] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]

2014-06-16 Thread Tsutomu Itoh
On 2014/06/17 8:52, Chris Mason wrote:
 On 06/16/2014 07:28 PM, Tsutomu Itoh wrote:
 Hi Chris,

 On 2014/06/17 2:56, Chris Mason wrote:
 On 06/16/2014 02:35 AM, Tsutomu Itoh wrote:
 I encountered soft lockup when executing 'xfstests btrfs/042' on 3.16-rc1.


 Did we recover, or was it stuck forever?

 The following messages are repeatedly output.
 And stuck forever.

 [ 1147.942181] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]
 [ 1147.967175] BUG: soft lockup - CPU#3 stuck for 23s! [kworker/u25:9:5194]
 [ 1147.979172] BUG: soft lockup - CPU#4 stuck for 23s! [kworker/u25:15:5200]
 [ 1147.991169] BUG: soft lockup - CPU#5 stuck for 23s! [kworker/u25:7:5192]
 [ 1148.064153] BUG: soft lockup - CPU#6 stuck for 23s! [kworker/u26:3:3182]
 
 Can you please capture a stack trace from all the cpus?
 

crash log
...
[ 1121.996312] BTRFS: creating UUID tree
[ 1122.050762] BTRFS info (device sdc5): qgroup scan completed
[ 1147.942181] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]
[ 1147.949658] Modules linked in: loop ipt_MASQUERADE iptable_nat nf_nat_ipv4 
nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack xt_CHECKSUM 
iptable_mangle bridge stp llc ip6table_filter ip6_tables ebtable_nat ebtables 
btrfs coretemp kvm_intel kvm xor raid6_pq crc32_pclmul crc32c_intel 
ghash_clmulni_intel nfsd igb microcode ptp pps_core dca iTCO_wdt shpchp 
auth_rpcgss iTCO_vendor_support i7core_edac pcspkr edac_core i2c_i801 lpc_ich 
mfd_core ipmi_si tpm_infineon ipmi_msghandler tpm_tis nfs_acl tpm 
acpi_power_meter lockd acpi_cpufreq sunrpc usb_storage mgag200 syscopyarea 
sysfillrect sysimgblt i2c_algo_bit drm_kms_helper ttm ata_generic pata_acpi drm 
megaraid_sas i2c_core ata_piix
[ 1147.949695] CPU: 0 PID: 5189 Comm: kworker/u25:4 Not tainted 3.16.0-rc1 #1
[ 1147.949696] Hardware name: FUJITSU-SV   PRIMERGY 
 /D2619, BIOS 6.00 Rev. 1.03.2619.N1   04/06/2010
[ 1147.949717] Workqueue: btrfs-endio-write normal_work_helper [btrfs]
[ 1147.949718] task: 88007408b840 ti: 8800740e4000 task.ti: 
8800740e4000
[ 1147.949720] RIP: 0010:[810ba858]  [810ba858] 
queue_read_lock_slowpath+0x68/0x90
[ 1147.949725] RSP: 0018:8800740e7b08  EFLAGS: 0202
[ 1147.949726] RAX: 00ee RBX: 0012 RCX: 0001
[ 1147.949727] RDX: 00ef RSI: 0004 RDI: 88003db221b0
[ 1147.949728] RBP: 8800740e7b08 R08: 0001 R09: 880071486b58
[ 1147.949729] R10:  R11:  R12: 8800715d1900
[ 1147.949730] R13:  R14: 0003 R15: 0002
[ 1147.949732] FS:  () GS:88007dc0() 
knlGS:
[ 1147.949733] CS:  0010 DS:  ES:  CR0: 8005003b
[ 1147.949734] CR2: 0036c97b9490 CR3: 01c0e000 CR4: 07f0
[ 1147.949735] Stack:
[ 1147.949736]  8800740e7b18 8166bcbc 8800740e7b38 
a070ffe4
[ 1147.949738]  0001 ffe8 8800740e7b58 
a06b0c2a
[ 1147.949740]  8800719de360  8800740e7bf8 
a06b5e32
[ 1147.949742] Call Trace:
[ 1147.949748]  [8166bcbc] _raw_read_lock+0x1c/0x30
[ 1147.949760]  [a070ffe4] btrfs_clear_lock_blocking_rw+0x44/0x150 
[btrfs]
[ 1147.949767]  [a06b0c2a] btrfs_clear_path_blocking+0x3a/0x80 [btrfs]
[ 1147.949774]  [a06b5e32] btrfs_search_slot+0x702/0xa10 [btrfs]
[ 1147.949783]  [a06cbe2e] btrfs_lookup_csum+0x5e/0x180 [btrfs]
[ 1147.949792]  [a06cd19c] btrfs_csum_file_blocks+0xbc/0x680 [btrfs]
[ 1147.949798]  [a06b0d46] ? btrfs_free_path+0x26/0x30 [btrfs]
[ 1147.949809]  [a06db1e0] add_pending_csums.isra.42+0x50/0x80 [btrfs]
[ 1147.949819]  [a06e1410] btrfs_finish_ordered_io+0x470/0x570 [btrfs]
[ 1147.949830]  [a06e1785] finish_ordered_fn+0x15/0x20 [btrfs]
[ 1147.949841]  [a0706b3c] normal_work_helper+0xbc/0x290 [btrfs]
[ 1147.949844]  [8108ab95] process_one_work+0x175/0x430
[ 1147.949846]  [8108b23b] worker_thread+0x11b/0x520
[ 1147.949848]  [8108b120] ? rescuer_thread+0x2d0/0x2d0
[ 1147.949851]  [81091712] kthread+0xd2/0xf0
[ 1147.949853]  [81091640] ? insert_kthread_work+0x40/0x40
[ 1147.949855]  [8166c23c] ret_from_fork+0x7c/0xb0
[ 1147.949857]  [81091640] ? insert_kthread_work+0x40/0x40
[ 1147.949858] Code: 00 00 00 f3 90 8b 07 84 c0 75 f8 b8 00 01 00 00 f0 0f c1 
07 3c ff 75 0b 0f 1f 00 f3 90 8b 07 3c ff 74 f8 80 47 04 01 5d c3 f3 90 0f b6 
47 04 38 c2 75 f6 eb bf 8b 07 3c ff 75 ec f3 90 8b 07 3c
[ 1147.949877] Kernel panic - not syncing: softlockup: hung tasks
[ 1147.956981] CPU: 0 PID: 5189 Comm: kworker/u25:4 Not tainted 3.16.0-rc1 #1
[ 1147.965228] Hardware name: FUJITSU-SV   PRIMERGY 
 /D2619, BIOS 6.00 Rev. 1.03.2619.N1   04/06/2010
[ 1147.967175

Re: [3.16-rc1] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]

2014-06-16 Thread Tsutomu Itoh
On 2014/06/17 10:11, Chris Mason wrote:
 
 
 On 06/16/2014 07:57 PM, Tsutomu Itoh wrote:
 On 2014/06/17 8:52, Chris Mason wrote:
 On 06/16/2014 07:28 PM, Tsutomu Itoh wrote:
 Hi Chris,

 On 2014/06/17 2:56, Chris Mason wrote:
 On 06/16/2014 02:35 AM, Tsutomu Itoh wrote:
 I encountered soft lockup when executing 'xfstests btrfs/042' on 
 3.16-rc1.


 Did we recover, or was it stuck forever?

 The following messages are repeatedly output.
 And stuck forever.

 [ 1147.942181] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]
 [ 1147.967175] BUG: soft lockup - CPU#3 stuck for 23s! [kworker/u25:9:5194]
 [ 1147.979172] BUG: soft lockup - CPU#4 stuck for 23s! 
 [kworker/u25:15:5200]
 [ 1147.991169] BUG: soft lockup - CPU#5 stuck for 23s! [kworker/u25:7:5192]
 [ 1148.064153] BUG: soft lockup - CPU#6 stuck for 23s! [kworker/u26:3:3182]

 Can you please capture a stack trace from all the cpus?


 crash log
 ...
 [ 1121.996312] BTRFS: creating UUID tree
 [ 1122.050762] BTRFS info (device sdc5): qgroup scan completed
 [ 1147.942181] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]
 [ 1147.949658] Modules linked in: loop ipt_MASQUERADE iptable_nat 
 nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack 
 nf_conntrack xt_CHECKSUM iptable_mangle bridge stp llc ip6table_filter 
 ip6_tables ebtable_nat ebtables btrfs coretemp kvm_intel kvm xor raid6_pq 
 crc32_pclmul crc32c_intel ghash_clmulni_intel nfsd igb microcode ptp 
 pps_core dca iTCO_wdt shpchp auth_rpcgss iTCO_vendor_support i7core_edac 
 pcspkr edac_core i2c_i801 lpc_ich mfd_core ipmi_si tpm_infineon 
 ipmi_msghandler tpm_tis nfs_acl tpm acpi_power_meter lockd acpi_cpufreq 
 sunrpc usb_storage mgag200 syscopyarea sysfillrect sysimgblt i2c_algo_bit 
 drm_kms_helper ttm ata_generic pata_acpi drm megaraid_sas i2c_core ata_piix
 [ 1147.949695] CPU: 0 PID: 5189 Comm: kworker/u25:4 Not tainted 3.16.0-rc1 #1
 [ 1147.949696] Hardware name: FUJITSU-SV   PRIMERGY  
 /D2619, BIOS 6.00 Rev. 1.03.2619.N1   04/06/2010
 [ 1147.949717] Workqueue: btrfs-endio-write normal_work_helper [btrfs]
 [ 1147.949718] task: 88007408b840 ti: 8800740e4000 task.ti: 
 8800740e4000
 [ 1147.949720] RIP: 0010:[810ba858]  [810ba858] 
 queue_read_lock_slowpath+0x68/0x90
 [ 1147.949725] RSP: 0018:8800740e7b08  EFLAGS: 0202
 [ 1147.949726] RAX: 00ee RBX: 0012 RCX: 
 0001
 [ 1147.949727] RDX: 00ef RSI: 0004 RDI: 
 88003db221b0
 [ 1147.949728] RBP: 8800740e7b08 R08: 0001 R09: 
 880071486b58
 [ 1147.949729] R10:  R11:  R12: 
 8800715d1900
 [ 1147.949730] R13:  R14: 0003 R15: 
 0002
 [ 1147.949732] FS:  () GS:88007dc0() 
 knlGS:
 [ 1147.949733] CS:  0010 DS:  ES:  CR0: 8005003b
 [ 1147.949734] CR2: 0036c97b9490 CR3: 01c0e000 CR4: 
 07f0
 [ 1147.949735] Stack:
 [ 1147.949736]  8800740e7b18 8166bcbc 8800740e7b38 
 a070ffe4
 [ 1147.949738]  0001 ffe8 8800740e7b58 
 a06b0c2a
 [ 1147.949740]  8800719de360  8800740e7bf8 
 a06b5e32
 [ 1147.949742] Call Trace:
 [ 1147.949748]  [8166bcbc] _raw_read_lock+0x1c/0x30
 [ 1147.949760]  [a070ffe4] btrfs_clear_lock_blocking_rw+0x44/0x150 
 [btrfs]
 [ 1147.949767]  [a06b0c2a] btrfs_clear_path_blocking+0x3a/0x80 
 [btrfs]
 [ 1147.949774]  [a06b5e32] btrfs_search_slot+0x702/0xa10 [btrfs]
 
 Also, which line of ctree.c is this call?

/Build/linux-3.16-rc1/fs/btrfs/ctree.c: 2898
0xa06b5e10 btrfs_search_slot+0x6e0:   mov%rbx,%rdi
0xa06b5e13 btrfs_search_slot+0x6e3:   callq  0xa06b0b70 
btrfs_set_path_blocking
/Build/linux-3.16-rc1/fs/btrfs/ctree.c: 2899
0xa06b5e18 btrfs_search_slot+0x6e8:   mov-0x30(%rbp),%rdi
0xa06b5e1c btrfs_search_slot+0x6ec:   callq  0xa0710450 
btrfs_tree_lock
/Build/linux-3.16-rc1/fs/btrfs/ctree.c: 2900
0xa06b5e21 btrfs_search_slot+0x6f1:   mov-0x30(%rbp),%rsi
0xa06b5e25 btrfs_search_slot+0x6f5:   mov$0x1,%edx
0xa06b5e2a btrfs_search_slot+0x6fa:   mov%rbx,%rdi
0xa06b5e2d btrfs_search_slot+0x6fd:   callq  0xa06b0bf0 
btrfs_clear_path_blocking
0xa06b5e32 btrfs_search_slot+0x702:   jmpq   0xa06b5b54 
btrfs_search_slot+0x424
0xa06b5e37 btrfs_search_slot+0x707:   nopw   0x0(%rax,%rax,1)


2686 int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
2687   *root, struct btrfs_key *key, struct btrfs_path *p, 
int
2688   ins_len, int cow)
2689 {
2690 struct extent_buffer *b;
2691 int slot;
2692 int ret;
2693 int err;
2694 int level;
2695 int

Re: [3.16-rc1] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]

2014-06-16 Thread Tsutomu Itoh
On 2014/06/17 9:47, Chris Mason wrote:
 On 06/16/2014 07:57 PM, Tsutomu Itoh wrote:
 On 2014/06/17 8:52, Chris Mason wrote:
 On 06/16/2014 07:28 PM, Tsutomu Itoh wrote:
 Hi Chris,

 On 2014/06/17 2:56, Chris Mason wrote:
 On 06/16/2014 02:35 AM, Tsutomu Itoh wrote:
 I encountered soft lockup when executing 'xfstests btrfs/042' on 
 3.16-rc1.


 Did we recover, or was it stuck forever?

 The following messages are repeatedly output.
 And stuck forever.

 [ 1147.942181] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]
 [ 1147.967175] BUG: soft lockup - CPU#3 stuck for 23s! [kworker/u25:9:5194]
 [ 1147.979172] BUG: soft lockup - CPU#4 stuck for 23s! 
 [kworker/u25:15:5200]
 [ 1147.991169] BUG: soft lockup - CPU#5 stuck for 23s! [kworker/u25:7:5192]
 [ 1148.064153] BUG: soft lockup - CPU#6 stuck for 23s! [kworker/u26:3:3182]

 Can you please capture a stack trace from all the cpus?
 
 Very strange, please try to reproduce again, I'll dig through things here.

I can reproduce it easily in my environment.

Thanks,
Tsutomu

==
Message from syslogd@luna at Jun 17 11:06:33 ...
 kernel:[  560.076282] BUG: soft lockup - CPU#0 stuck for 22s! 
[kworker/u25:1:193]

Message from syslogd@luna at Jun 17 11:06:33 ...
 kernel:[  560.076283] BUG: soft lockup - CPU#1 stuck for 22s! 
[kworker/u25:3:3174]

Message from syslogd@luna at Jun 17 11:06:33 ...
 kernel:[  560.101276] BUG: soft lockup - CPU#3 stuck for 22s! 
[kworker/u25:4:3175]

Message from syslogd@luna at Jun 17 11:06:33 ...
 kernel:[  560.113274] BUG: soft lockup - CPU#4 stuck for 22s! 
[kworker/u25:6:3177]

Message from syslogd@luna at Jun 17 11:06:33 ...
 kernel:[  560.125271] BUG: soft lockup - CPU#5 stuck for 22s! 
[kworker/u25:5:3176]



--
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: [3.16-rc1] BUG: soft lockup - CPU#0 stuck for 23s! [kworker/u25:4:5189]

2014-06-16 Thread Tsutomu Itoh
On 2014/06/17 11:10, Tsutomu Itoh wrote:
 On 2014/06/17 9:47, Chris Mason wrote:
 On 06/16/2014 07:57 PM, Tsutomu Itoh wrote:
 On 2014/06/17 8:52, Chris Mason wrote:
 On 06/16/2014 07:28 PM, Tsutomu Itoh wrote:
 Hi Chris,

 On 2014/06/17 2:56, Chris Mason wrote:
 On 06/16/2014 02:35 AM, Tsutomu Itoh wrote:
 I encountered soft lockup when executing 'xfstests btrfs/042' on 
 3.16-rc1.


 Did we recover, or was it stuck forever?

 The following messages are repeatedly output.
 And stuck forever.

 [ 1147.942181] BUG: soft lockup - CPU#0 stuck for 23s! 
 [kworker/u25:4:5189]
 [ 1147.967175] BUG: soft lockup - CPU#3 stuck for 23s! 
 [kworker/u25:9:5194]
 [ 1147.979172] BUG: soft lockup - CPU#4 stuck for 23s! 
 [kworker/u25:15:5200]
 [ 1147.991169] BUG: soft lockup - CPU#5 stuck for 23s! 
 [kworker/u25:7:5192]
 [ 1148.064153] BUG: soft lockup - CPU#6 stuck for 23s! 
 [kworker/u26:3:3182]

 Can you please capture a stack trace from all the cpus?

 Very strange, please try to reproduce again, I'll dig through things here.
 
 I can reproduce it easily in my environment.

This is my reproducer.

===
#! /bin/bash

export TEST_DIR=/test5
export TEST_DEV=/dev/sdb4
TEST_DEV2=/dev/sdc6

export SCRATCH_MNT=/test6
export SCRATCH_DEV=/dev/sdc5

export MKFS_OPTIONS=
export MOUNT_OPTIONS=

umount ${TEST_DIR} ${SCRATCH_MNT}

mkfs.btrfs -f ${TEST_DEV} ${TEST_DEV2}

for i in $(seq 1 10)
do
./check 'btrfs/042'
done

umount ${TEST_DIR} ${SCRATCH_MNT}
===

Stack trace is here.

==
[ 1631.835052] BUG: soft lockup - CPU#0 stuck for 22s! [kworker/u25:1:193]
[ 1631.835053] BUG: soft lockup - CPU#1 stuck for 22s! [kworker/u25:3:3174]
[ 1631.835074] Modules linked in: ipt_MASQUERADE iptable_nat nf_nat_ipv4 nf_nat 
nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack xt_CHECKSUM 
iptable_mangle bridge stp llc ip6table_filter ip6_tables ebtable_nat ebtables 
btrfs coretemp kvm_intel kvm crc32_pclmul crc32c_intel ghash_clmulni_intel nfsd 
xor raid6_pq igb microcode ptp pps_core dca iTCO_wdt auth_rpcgss shpchp 
iTCO_vendor_support nfs_acl i7core_edac pcspkr edac_core lpc_ich i2c_i801 
mfd_core acpi_power_meter tpm_infineon tpm_tis tpm ipmi_si lockd 
ipmi_msghandler acpi_cpufreq sunrpc usb_storage mgag200 syscopyarea sysfillrect 
sysimgblt i2c_algo_bit drm_kms_helper ttm drm ata_generic pata_acpi 
megaraid_sas i2c_core ata_piix
[ 1631.835076] CPU: 1 PID: 3174 Comm: kworker/u25:3 Not tainted 3.16.0-rc1 #1
[ 1631.835076] Hardware name: FUJITSU-SV   PRIMERGY 
 /D2619, BIOS 6.00 Rev. 1.03.2619.N1   04/06/2010
[ 1631.835094] Workqueue: btrfs-endio-write normal_work_helper [btrfs]
[ 1631.835094] task: 880073d6 ti: 88007188c000 task.ti: 
88007188c000
[ 1631.835097] RIP: 0010:[810ba858]  [810ba858] 
queue_read_lock_slowpath+0x68/0x90
[ 1631.835098] RSP: 0018:88007188fac8  EFLAGS: 0206
[ 1631.835098] RAX: 0033 RBX:  RCX: 000a
[ 1631.835099] RDX: 0039 RSI: 000a RDI: 8801356755b0
[ 1631.835099] RBP: 88007188fac8 R08: 880135675574 R09: 
[ 1631.835100] R10:  R11: 0001 R12: 1000
[ 1631.835100] R13:  R14: 8800766d3000 R15: a05800a1
[ 1631.835101] FS:  () GS:88007dc4() 
knlGS:
[ 1631.835101] CS:  0010 DS:  ES:  CR0: 8005003b
[ 1631.835102] CR2: 01858000 CR3: 01c0e000 CR4: 07e0
[ 1631.835102] Stack:
[ 1631.835103]  88007188fad8 8166bcbc 88007188fb38 
a05da140
[ 1631.835104]  0069 0035  
88007188fb58
[ 1631.835105]  a057881f 880135675540 8800b7117800 
8800
[ 1631.835105] Call Trace:
[ 1631.835109]  [8166bcbc] _raw_read_lock+0x1c/0x30
[ 1631.835119]  [a05da140] btrfs_tree_read_lock+0x50/0x100 [btrfs]
[ 1631.835124]  [a057881f] ? leaf_space_used+0xcf/0x110 [btrfs]
[ 1631.835129]  [a057adeb] btrfs_read_lock_root_node+0x3b/0x50 [btrfs]
[ 1631.835134]  [a057fc3e] btrfs_search_slot+0x50e/0xa10 [btrfs]
[ 1631.835143]  [a05eaee4] ? btrfs_add_delayed_data_ref+0x114/0x180 
[btrfs]
[ 1631.835150]  [a0595e2e] btrfs_lookup_csum+0x5e/0x180 [btrfs]
[ 1631.835157]  [a059719c] btrfs_csum_file_blocks+0xbc/0x680 [btrfs]
[ 1631.835162]  [a057ad46] ? btrfs_free_path+0x26/0x30 [btrfs]
[ 1631.835170]  [a05a51e0] add_pending_csums.isra.42+0x50/0x80 [btrfs]
[ 1631.835178]  [a05ab410] btrfs_finish_ordered_io+0x470/0x570 [btrfs]
[ 1631.835187]  [a05ab785] finish_ordered_fn+0x15/0x20 [btrfs]
[ 1631.835196]  [a05d0b3c] normal_work_helper+0xbc/0x290 [btrfs]
[ 1631.835198]  [8108ab95] process_one_work+0x175/0x430
[ 1631.835199]  [8108b23b] worker_thread+0x11b/0x520
[ 1631.835200

  1   2   3   >