public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Nikolay Borisov <nborisov@suse.com>, <fstests@vger.kernel.org>,
	<linux-btrfs@vger.kernel.org>
Cc: Josef Bacik <josef@toxicpanda.com>
Subject: Re: [PATCH 1/3] fstests: btrfs: Use word mathcing for _btrfs_get_subvolid()
Date: Fri, 7 Feb 2020 18:02:42 +0800	[thread overview]
Message-ID: <829c0acb-a734-56a6-9649-5dd697fea6cf@suse.com> (raw)
In-Reply-To: <b7a6bacf-0434-9743-1ff0-41f9344421db@suse.com>



On 2020/2/7 下午5:41, Nikolay Borisov wrote:
> 
> 
> On 7.02.20 г. 3:59 ч., Qu Wenruo wrote:
>> Current _btrfs_get_subvolid() can't handle the following case at all:
>>   # btrfs subvol list $SCRATCH_MNT
>>   ID 256 gen 9 top level 5 path subv1
>>   ID 257 gen 7 top level 256 path subv1/subv2
>>   ID 258 gen 8 top level 256 path subv1/subv3
>>   ID 259 gen 9 top level 256 path subv1/subv4
>>
>> If we call "_btrfs_get_subvolid $SCRATCH_MNT subv1" we will get a list
>> of all subvolumes, not the subvolid of subv1.
>>
>> To address this problem, we go egrep to match $name which starts with a
>> space, and at the end of a line.
>> So that all other subvolumes won't hit.
>>
>> Suggested-by: Josef Bacik <josef@toxicpanda.com>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
> 
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> 
>> ---
>>  common/btrfs | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/common/btrfs b/common/btrfs
>> index 19ac7cc4..85b33e4c 100644
>> --- a/common/btrfs
>> +++ b/common/btrfs
>> @@ -7,7 +7,7 @@ _btrfs_get_subvolid()
>>  	mnt=$1
>>  	name=$2
>>  
>> -	$BTRFS_UTIL_PROG sub list $mnt | grep $name | awk '{ print $2 }'
>> +	$BTRFS_UTIL_PROG sub list $mnt | egrep "\s$name$" | awk '{ print $2 }'
> 
> nit: But you don't even need egrep for this, you could have simply used
> "grep $name$"

That \s is needed. Or the following case can't be handled:

   ID 256 gen 9 top level 5 path subv1
   ID 257 gen 7 top level 256 path subv1/subv1

Thanks,
Qu

> 
>>  }
>>  
>>  # _require_btrfs_command <command> [<subcommand>|<option>]
>>

  reply	other threads:[~2020-02-07 10:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07  1:59 [PATCH 0/3] fstests: btrfs/022 fixes Qu Wenruo
2020-02-07  1:59 ` [PATCH 1/3] fstests: btrfs: Use word mathcing for _btrfs_get_subvolid() Qu Wenruo
2020-02-07  2:09   ` Josef Bacik
2020-02-07  9:41   ` Nikolay Borisov
2020-02-07 10:02     ` Qu Wenruo [this message]
2020-02-07 11:07       ` Nikolay Borisov
2020-02-07  1:59 ` [PATCH 2/3] fstests: btrfs/022: Match qgroup id more correctly Qu Wenruo
2020-02-07  2:10   ` Josef Bacik
2020-02-07  9:46   ` Nikolay Borisov
2020-02-07 10:03     ` Qu Wenruo
2020-02-07  1:59 ` [PATCH 3/3] fstests: btrfs/022: Add debug output Qu Wenruo
2020-02-07  2:10   ` Josef Bacik
2020-02-07  9:48   ` Nikolay Borisov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=829c0acb-a734-56a6-9649-5dd697fea6cf@suse.com \
    --to=wqu@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox