linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <fdmanana@gmail.com>
Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
	Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Subject: Re: [PATCH v4 17/18] btrfs: dedup: add a property handler for online dedup
Date: Fri, 15 Jan 2016 09:37:20 +0800	[thread overview]
Message-ID: <56984D50.3040106@cn.fujitsu.com> (raw)
In-Reply-To: <CAL3q7H4-Ztmx9Z4=jNT3610Y6eZbL5GqZXXOajYg3FoP_uyxYA@mail.gmail.com>



Filipe Manana wrote on 2016/01/14 09:56 +0000:
> On Thu, Jan 14, 2016 at 5:57 AM, Qu Wenruo <quwenruo@cn.fujitsu.com> wrote:
>> From: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
>>
>> We use btrfs extended attribute "btrfs.dedup" to record per-file online
>> dedup status, so add a dedup property handler.
>>
>> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
>> ---
>>   fs/btrfs/props.c | 40 ++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 40 insertions(+)
>>
>> diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
>> index f9e6023..ae8b76d 100644
>> --- a/fs/btrfs/props.c
>> +++ b/fs/btrfs/props.c
>> @@ -41,6 +41,10 @@ static int prop_compression_apply(struct inode *inode,
>>                                    size_t len);
>>   static const char *prop_compression_extract(struct inode *inode);
>>
>> +static int prop_dedup_validate(const char *value, size_t len);
>> +static int prop_dedup_apply(struct inode *inode, const char *value, size_t len);
>> +static const char *prop_dedup_extract(struct inode *inode);
>> +
>>   static struct prop_handler prop_handlers[] = {
>>          {
>>                  .xattr_name = XATTR_BTRFS_PREFIX "compression",
>> @@ -49,6 +53,13 @@ static struct prop_handler prop_handlers[] = {
>>                  .extract = prop_compression_extract,
>>                  .inheritable = 1
>>          },
>> +       {
>> +               .xattr_name = XATTR_BTRFS_PREFIX "dedup",
>> +               .validate = prop_dedup_validate,
>> +               .apply = prop_dedup_apply,
>> +               .extract = prop_dedup_extract,
>> +               .inheritable = 1
>> +       },
>>   };
>>
>>   void __init btrfs_props_init(void)
>> @@ -425,4 +436,33 @@ static const char *prop_compression_extract(struct inode *inode)
>>          return NULL;
>>   }
>>
>> +static int prop_dedup_validate(const char *value, size_t len)
>> +{
>> +       if (!strncmp("disable", value, len))
>> +               return 0;
>> +
>> +       return -EINVAL;
>> +}
>> +
>> +static int prop_dedup_apply(struct inode *inode, const char *value, size_t len)
>> +{
>> +       if (len == 0) {
>> +               BTRFS_I(inode)->flags &= ~BTRFS_INODE_NODEDUP;
>> +               return 0;
>> +       }
>> +
>> +       if (!strncmp("disable", value, len)) {
>> +               BTRFS_I(inode)->flags |= BTRFS_INODE_NODEDUP;
>> +               return 0;
>> +       }
>> +
>> +       return -EINVAL;
>> +}
>> +
>> +static const char *prop_dedup_extract(struct inode *inode)
>> +{
>> +       if (BTRFS_I(inode)->flags | BTRFS_INODE_NODEDUP)
>> +               return "disable";
>
> | -> &
>
> How about writing test cases (for xfstests)? Not only for the property
> but for the whole dedup feature, it would avoid such simple
> mistakes...

Yes, it's already in our schedule and we have some internal simple test 
case.

But the problem is,
Some behavior/format is not completely determined yet
Especially for on-disk format (ondisk backend only), and ioctl interface.

So I'm a little concerned about submit them too early before we made 
final decision on the ioctl interface.

> Take a look at the good example of xfs development. For example when
> all the recent patches for their reflink implementation was posted
> (and before getting merged), a comprehensive set of test cases for
> xfstests was also posted...

Yes, test driven development is very nice, but there is also problem, 
especially for btrfs, like btrfs/047 which needs btrfs send 
--stream-version support.

But unfortunately, there is not --stream-version support in upsteam 
btrfs-progs and the test case never get executed on upsteam btrfs-progs.

Personally speaking, xfs development can only happen in that way because 
xfstest maintainer is also the maintainer of xfs.
As Dave knows every aspect of xfs and can determine which feature will 
be merged.
But that's not true for btrfs, so he can merge wrong patch and cause 
inconsistent with what btrfs really supports between test cases.

Thanks,
Qu

>
>>
>> +       return NULL;
>> +}
>> --
>> 2.7.0
>>
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>



  parent reply	other threads:[~2016-01-15  1:37 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-14  5:57 [PATCH v4 00/14][For 4.6] Btrfs: Add inband (write time) de-duplication framework Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 01/18] btrfs: dedup: Introduce dedup framework and its header Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 02/18] btrfs: dedup: Introduce function to initialize dedup info Qu Wenruo
2016-01-14 21:33   ` kbuild test robot
2016-01-14  5:57 ` [PATCH v4 03/18] btrfs: dedup: Introduce function to add hash into in-memory tree Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 04/18] btrfs: dedup: Introduce function to remove hash from " Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 05/18] btrfs: delayed-ref: Add support for atomic increasing extent ref Qu Wenruo
2016-01-14  9:56   ` Filipe Manana
2016-01-15  1:16     ` Qu Wenruo
2016-01-20  3:25       ` Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 06/18] btrfs: dedup: Introduce function to search for an existing hash Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 07/18] btrfs: dedup: Implement btrfs_dedup_calc_hash interface Qu Wenruo
2016-01-14 10:08   ` Filipe Manana
2016-01-15  1:41     ` Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 08/18] btrfs: ordered-extent: Add support for dedup Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 09/18] btrfs: dedup: Inband in-memory only de-duplication implement Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 10/18] btrfs: dedup: Add basic tree structure for on-disk dedup method Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 11/18] btrfs: dedup: Introduce interfaces to resume and cleanup dedup info Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 12/18] btrfs: dedup: Add support for on-disk hash search Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 13/18] btrfs: dedup: Add support to delete hash for on-disk backend Qu Wenruo
2016-01-14 10:19   ` Filipe Manana
2016-01-15  1:43     ` Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 14/18] btrfs: dedup: Add support for adding " Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 15/18] btrfs: dedup: Add ioctl for inband deduplication Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 16/18] btrfs: dedup: add an inode nodedup flag Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 17/18] btrfs: dedup: add a property handler for online dedup Qu Wenruo
2016-01-14  9:56   ` Filipe Manana
2016-01-14 19:04     ` Darrick J. Wong
2016-01-15  1:37     ` Qu Wenruo [this message]
2016-01-15  9:19       ` Filipe Manana
2016-01-15  9:33         ` Qu Wenruo
2016-01-15 12:36         ` Duncan
2016-01-15 15:22           ` Filipe Manana
2016-01-16  2:53             ` Duncan
2016-01-14  5:57 ` [PATCH v4 18/18] btrfs: dedup: add per-file online dedup control Qu Wenruo

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=56984D50.3040106@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=fdmanana@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wangxg.fnst@cn.fujitsu.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;
as well as URLs for NNTP newsgroup(s).