linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Zach Brown <zab@redhat.com>
Cc: linux-btrfs@vger.kernel.org, dsterba@suse.cz
Subject: Re: [PATCH] btrfs-progs: calculate disk space that a subvol could free
Date: Sun, 29 Sep 2013 23:02:29 +0800	[thread overview]
Message-ID: <52484105.8090302@oracle.com> (raw)
In-Reply-To: <52470F85.6040405@oracle.com>


>>>
>>> +    printf("\tUnshared space: \t%s\n",
>>> +        pretty_size(freeable_bytes));
>>
>> There's no reason to have a local variable:
>>
>>     printf("\tUnshared space: \t%s\n",
>>         pretty_size(get_subvol_freeable_bytes(fd));
>>
>>

this is taken care.


>> These two fiddly functions only differ in the tree search and what they
>> do with each item.  So replace them with a function that takes a
>> description of the search and calls the caller's callback for each item.
>>
>> typedef void (*item_func_t)(struct btrfs_key *key, void *data, void
>> *arg);
>>
>> int btrfs_for_each_item(int fd, min and max and junk,
>>             item_func_t func, void *arg);
>>
>> u64 get_subvol_freeable_bytes(int fd)
>> {
>>     u64 size_bytes = 0;
>>
>>     btrfs_for_each_item(fd, ...., sum_extents, &size_bytes);
>>
>>     return size_bytes;
>> }
>>
>> Etc.  You get the idea.
>
>
>   Will fix them.  Thanks !
>
> -Anand

  this is to avoid duplicate codes, which indeed spans across
  most of the search functions that's in there in btrfs-progs.
  what you suggest is good, but its better to do that collectively.


Thanks, Anand

  reply	other threads:[~2013-09-29 15:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-27 16:45 [PATCH] btrfs-progs: calculate disk space that a subvol could free Anand Jain
2013-09-27 19:10 ` Zach Brown
2013-09-28 17:19   ` Anand Jain
2013-09-29 15:02     ` Anand Jain [this message]
2013-10-01 13:25       ` David Sterba
2013-09-29 15:15 ` [PATCH V2] btrfs-progs: device add should check existing FS before adding Anand Jain
2013-09-29 15:26   ` Anand Jain
2013-09-29 15:25 ` [PATCH v2] btrfs-progs: calculate disk space that a subvol could free Anand Jain
2013-10-01 13:39   ` David Sterba
2013-10-01 14:05     ` Wang Shilong
2013-10-07  2:47       ` Anand Jain
2013-10-07  3:01         ` Wang Shilong
2013-10-07  3:22           ` Anand Jain
2013-10-08 16:49         ` David Sterba
2013-10-09 14:17           ` Wang Shilong
2013-10-10  3:35             ` Anand Jain
2013-10-10  3:33               ` Wang Shilong
2013-11-28 17:39                 ` Alex Lyakas
2013-11-29  1:34                   ` Wang Shilong
2013-11-29  1:57                     ` Anand Jain
2013-10-09  8:03       ` Anand Jain
2013-10-09  8:35         ` Wang Shilong

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=52484105.8090302@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=zab@redhat.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).