Re: moving a subvol

2013-12-15 Thread Gene Czarcinski

On 12/14/2013 01:43 PM, Chris Murphy wrote:

On Dec 14, 2013, at 2:57 AM, Gene Czarcinski gczarcin...@gmail.com wrote:

  Since I run Fedora with anaconda I use kickstart installs and can easily 
repeat an install since it included almost everything I want installed.  And 
then I have a post-install script I run to pickup additional stuff.

This is a bit of a hijack question, but does kickstart offer a way to mount 
Btrfs with compression option?


Chris Murphy
Interesting; it does not currently but that sounds like it should be 
(RFE time) an added option so that it would be in fstab from the start.  
It may not be that simple since if you specify compression for a 
subvolume, that means that everything anaconda installs on the subvolume 
should be subjected to compression and not just stuff written post-install.


I do not currently use compression but I should give it a try.

Chris, since I know kickstart and you do not, I will BZ the RFE. BTW, is 
this an option on the regular GUI install?


Gene
--
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: moving a subvol

2013-12-14 Thread Gene Czarcinski

On 12/14/2013 02:07 AM, Chris Samuel wrote:

On Fri, 13 Dec 2013 02:25:34 PM Gene Czarcinski wrote:


Next it is to delete the old BTRFS volume, use fdisk to increase the
size of the partition and then attempt to increate the size of this new
volume.  I hope I don't get bit in the rear end with this.


Just make sure you have good (tested) backups..

Data subvolumes such as for /home have separate backups but the rootfs 
subvolumes do not.  If somethings gets screwed up, it is a matter of 
reinstalling.  Since I run Fedora with anaconda I use kickstart installs 
and can easily repeat an install since it included almost everything I 
want installed.  And then I have a post-install script I run to pickup 
additional stuff.


After successfully resizing, I then repeated with a two-device BTRFS 
volume.  Here the resize needs to be done for each device.


Question:  What is did involved two BTRFS volumes on /dev/sdb1 and 
/dev/sdb2.  I deleted /dev/sdb2 and then expanded/resized /dev/sdb1. 
This worked but I assume that doing the opposite would not work.  That 
is, deleteing the lower /dev/sdb1 and then expanding the upper 
/dev/sdb2 because after rebooting the filesystem would not be at the 
beginning of the partition.


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


moving a subvol

2013-12-13 Thread Gene Czarcinski
I have hunted high and low for the information but, if it is out there, 
it is well hidden.


What I want to do:  I want to relocate (move) a subvolume from one BTRFS 
volume to a different BTRFS volume.


I have seen the writeup for incremental backup which takes a snapshot, 
and then using btrfs-send and btrfs-receive to create a copy on a 
different volume.  That works fine except the btrfs-receive set the new 
copy to be readonly.


What I want to do is to use that new subvolume read/write.  The only way 
I have figured out to do this is to create another snapshot on the new 
volume which is NOT readonly.  I believe that means I need to keep both 
of these subvolumes around.


Gene
--
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: moving a subvol

2013-12-13 Thread Gene Czarcinski

On 12/13/2013 11:07 AM, Gene Czarcinski wrote:

I have hunted high and low for the information but, if it is out there,
it is well hidden.

What I want to do:  I want to relocate (move) a subvolume from one BTRFS
volume to a different BTRFS volume.

I have seen the writeup for incremental backup which takes a snapshot,
and then using btrfs-send and btrfs-receive to create a copy on a
different volume.  That works fine except the btrfs-receive set the new
copy to be readonly.

What I want to do is to use that new subvolume read/write.  The only way
I have figured out to do this is to create another snapshot on the new
volume which is NOT readonly.  I believe that means I need to keep both
of these subvolumes around.


As soon as I sent this I believe I found the answer.

I was sort of right about creating the new read-write (NOT readonly) 
snapshot.  After it is created simply delete the one which was created 
by btrfs-receive.


I also found out that if you want to rename a subvolume, siple do it 
with mv like you would for a directory or a file.


OK folks, do I have it correct?

Gene

--
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: moving a subvol

2013-12-13 Thread Gene Czarcinski

On 12/13/2013 01:02 PM, Chris Murphy wrote:


On Dec 13, 2013, at 10:37 AM, Cobin Bluth cbl...@gmail.com wrote:

That seems a little less intuitive than one would think. I wonder if there 
would an argument to specify read-write for btrfs-receive.


I'm going to guess it's on purpose to prevent writes from happening in the 
subvolume while it's still being received. The send file is a stream so my 
interpretation of what's going on is that subvolume's file system isn't really 
in a state to be modified until it's completely done being written. And for 
that matter, it's the same thing with sending. The wiki says send requires 
subvolumes to be ro, and all of the examples there are ro subvolumes.

I don't know that this is an apt analogy, but think of dd'ing a partition that 
contains a live mounted volume. Oops - not a good idea right? Because as you dd 
the first part, the uncopied portion is being modified and is now inconsistent.



Seems to have worked fine.  What more could I ask for.

With Fedora 20 a go for gold, I decided to update to Fedora 20 on almost 
all of my systems.  At the same time I decided to do some consolidation 
and restructuring of my disk layouts to put almost all of it under some 
BTRFS volumes.


I really did not want to install Fedora 19 again and just want to move 
the F19 rootfs from one volume to a newer other volume.  It required 
some editing of /etc/fstab to use the  new UUIDs and also some manual 
editing (ugh) of grub.cfg so that it had the correct UUIDs for the 
volume with subvol=root4.


Next it is to delete the old BTRFS volume, use fdisk to increase the 
size of the partition and then attempt to increate the size of this new 
volume.  I hope I don't get bit in the rear end with this.


Gene

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


btrfs fi show

2013-11-16 Thread Gene Czarcinski
I am on Fedora 20-Beta and we just updated to btrfs-progs 
0.20.rc1-20131114git9f0c53f


Previously, when you did a btrfs fi show, you got a list with one output 
for each btrfs storage volume whether it was a single device or 
multi-device volume.


Now, I get multiple outputs for each storage volume.  For example, I 
have a system with two SSDs as one btrfs storage volume and two USB 
round-and-brown disks as a second btrfs storage volume.  Each has three 
subvols defined and mounted.


Previously, I got two outputs; one for each volume.

Now I get three outputs for the SSD storage volume and SIX outputs for 
the out volume.


Is this a bug or a feature?  If it is a feature, what is it telling me?

Gene
--
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 pull request for coverity fixes

2013-02-06 Thread Gene Czarcinski

On 02/05/2013 07:49 PM, Zach Brown wrote:

Hi gang,

Eric and I went through the warnings that a Coverity scan raised against
the reasonably recent btrfs-progs that's in Fedora.  We tried to tackle
the lowest hanging fruit: these are the most obvious and least risky
fixes.

If you ran your tests against the btrfs-progs in Fedora 18 then your 
tests may not have found problems fixed by the valgrind patch on F18.  
This patch is not applied to the current David Sterba's integration 
branches.


If you have the time, it might be useful (my opinion) to run your tests 
against Sterba's integration-02130201 branch ... some of the problems 
may be fixed and other not but you also may find some additional 
problems.  IMO, this branch (or something similar) will be the basis for 
a future v0.20 btrfs-progs ... at least that is what I am using/testing 
with.  There are over 80 commits in this branch over what is the baseis 
for the package in Fedora 18.


Gene
--
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 print more informative error when we fail to open a device

2013-02-04 Thread Gene Czarcinski
I believe that this patch may have been lost in the noise and I felt
it made a very small but meaningful change so I shuffled some
test around and made sure it applied to integration-20120201

This patch simply prints more informative message when
we fail to open a device.

Eric Sandeen (1):
  Btrfs-progs print more informative error when we fail to open a device
 utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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


[PATCH] Btrfs-progs print more informative error when we fail to open a device

2013-02-04 Thread Gene Czarcinski
From: Eric Sandeen sand...@redhat.com

print more informative error when we fail to open a device

If open() fails, we should let the user know why it failed.

Signed-off-by: Eric Sandeen sand...@redhat.com
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/utils.c b/utils.c
index d92f317..b560a49 100644
--- a/utils.c
+++ b/utils.c
@@ -1212,7 +1212,8 @@ scan_again:
 
fd = open(fullpath, O_RDONLY);
if (fd  0) {
-   fprintf(stderr, failed to read %s\n, fullpath);
+   fprintf(stderr, failed to open %s: %s\n,
+   fullpath, strerror(errno));
continue;
}
ret = btrfs_scan_one_device(fd, fullpath, tmp_devices,
-- 
1.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 1/3] Btrfs-progs: move path modification to filters

2013-01-30 Thread Gene Czarcinski
Ignoring for the moment whether these patches are a good idea or not, 
what is the base upon which these patches were built.  You might want to 
consider rebasing them to David Sterba's integration-20130130


Gene

On 01/30/2013 08:32 AM, Lukáš Czerner wrote:

On Thu, 10 Jan 2013, Lukáš Czerner wrote:


Date: Thu, 10 Jan 2013 13:02:42 +0100 (CET)
From: Lukáš Czerner lczer...@redhat.com
To: Lukas Czerner lczer...@redhat.com
Cc: linux-btrfs@vger.kernel.org, chris.ma...@fusionio.com, cwi...@cwillu.com
Subject: Re: [PATCH 1/3] Btrfs-progs: move path modification to filters

On Tue, 11 Dec 2012, Lukas Czerner wrote:


Date: Tue, 11 Dec 2012 15:24:58 +0100
From: Lukas Czerner lczer...@redhat.com
To: linux-btrfs@vger.kernel.org
Cc: chris.ma...@fusionio.com, cwi...@cwillu.com,
 Lukas Czerner lczer...@redhat.com
Subject: [PATCH 1/3] Btrfs-progs: move path modification to filters

Commit 8e8e019e910f20947fea7eff5da40753639d8870 introduces -a option
which will list all subvolumes with distinguishing between relative and
absolute by prepending absolute patch with FS_TREE.

This commit moves the path modification to a filter code rather than
doing so in path construction in resolve_root(). This gives us more
flexibility in formatting path output.

ping

any comments on this ?

-Lukas

ping


Signed-off-by: Lukas Czerner lczer...@redhat.com
---
  btrfs-list.c |   32 +++-
  btrfs-list.h |1 +
  cmds-subvolume.c |   11 +--
  man/btrfs.8.in   |3 ++-
  4 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/btrfs-list.c b/btrfs-list.c
index e5f0f96..77d99f8 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -628,15 +628,6 @@ static int resolve_root(struct root_lookup *rl, struct 
root_info *ri,
}
  
  		if (next == BTRFS_FS_TREE_OBJECTID) {

-   char p[] = FS_TREE;
-   add_len = strlen(p);
-   len = strlen(full_path);
-   tmp = malloc(len + add_len + 2);
-   memcpy(tmp + add_len + 1, full_path, len);
-   tmp[add_len] = '/';
-   memcpy(tmp, p, add_len);
-   free(full_path);
-   full_path = tmp;
ri-top_id = next;
break;
}
@@ -1176,6 +1167,28 @@ static int filter_topid_equal(struct root_info *ri, u64 
data)
return ri-top_id == data;
  }
  
+static int filter_full_path(struct root_info *ri, u64 data)

+{
+   if (ri-full_path  ri-top_id != data) {
+   char *tmp;
+   char p[] = FS_TREE;
+   int add_len = strlen(p);
+   int len = strlen(ri-full_path);
+
+   tmp = malloc(len + add_len + 2);
+   if (!tmp) {
+   fprintf(stderr, memory allocation failed\n);
+   exit(1);
+   }
+   memcpy(tmp + add_len + 1, ri-full_path, len);
+   tmp[add_len] = '/';
+   memcpy(tmp, p, add_len);
+   free(ri-full_path);
+   ri-full_path = tmp;
+   }
+   return 1;
+}
+
  static btrfs_list_filter_func all_filter_funcs[] = {
[BTRFS_LIST_FILTER_ROOTID]  = filter_by_rootid,
[BTRFS_LIST_FILTER_SNAPSHOT_ONLY]   = filter_snapshot,
@@ -1187,6 +1200,7 @@ static btrfs_list_filter_func all_filter_funcs[] = {
[BTRFS_LIST_FILTER_CGEN_LESS]   = filter_cgen_less,
[BTRFS_LIST_FILTER_CGEN_EQUAL]  = filter_cgen_equal,
[BTRFS_LIST_FILTER_TOPID_EQUAL] = filter_topid_equal,
+   [BTRFS_LIST_FILTER_FULL_PATH]   = filter_full_path,
  };
  
  struct btrfs_list_filter_set *btrfs_list_alloc_filter_set(void)

diff --git a/btrfs-list.h b/btrfs-list.h
index cde4b3c..f7fbea6 100644
--- a/btrfs-list.h
+++ b/btrfs-list.h
@@ -71,6 +71,7 @@ enum btrfs_list_filter_enum {
BTRFS_LIST_FILTER_CGEN_LESS,
BTRFS_LIST_FILTER_CGEN_MORE,
BTRFS_LIST_FILTER_TOPID_EQUAL,
+   BTRFS_LIST_FILTER_FULL_PATH,
BTRFS_LIST_FILTER_MAX,
  };
  
diff --git a/cmds-subvolume.c b/cmds-subvolume.c

index ac39f7b..37cb8cc 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -277,7 +277,9 @@ static const char * const cmd_subvol_list_usage[] = {
List subvolumes (and snapshots),
,
-p   print parent ID,
-   -a   print all the subvolumes in the filesystem.,
+   -a   print all the subvolumes in the filesystem and,
+distinguish absolute and relative path with respect,
+to the given path,
-u   print the uuid of subvolumes (and snapshots),
-t   print the result as a table,
-s   list snapshots only in the filesystem,
@@ -400,7 +402,12 @@ static int cmd_subvol_list(int argc, char **argv)
}
  
  	top_id = btrfs_list_get_path_rootid(fd);


Re: [PATCH] Btrfs-progs: v2 Fix minor problems in btrfslabel.c

2013-01-28 Thread Gene Czarcinski

On 01/28/2013 11:16 AM, David Sterba wrote:

On Sat, Jan 26, 2013 at 01:09:56PM -0500, Gene Czarcinski wrote:

Fixed indentation, replace spaces with tabs.
Signed-off-by: Danny Kukawka danny.kuka...@bisect.de

Rebased; fixed compiler warnings; added space after if
Signed-off-by: Gene Czarcinski g...@czarc.net
---
  btrfslabel.c | 57 +

Jeff Liu has sent a series that updates the code and also fixes the
formatting. And I'd prefer to take his series as a more extensive
update.

Also, btrfslabel.c is another file to be removed and its contents placed
into the right locations, like cmds-filesystem.c or util.[ch] . I didn't
realize that during reviewing the label series.

Jeff, I suggest to add a new patch that moves the functions out of
btrfslabel.c, so you don't have to rework the whole series again.

thanks,
david

No problem.   I was just going over what was integration-20130126-fix1 
and this seemed missing and also trivial.


My suggestion/recommendation is that the current set be integrated into 
stable btrfs-progs and labeled v0.20-rc2 and after 2/3/4/5 weeks if 
there is nothing major it should become v0.20.  There will always be 
more good patches but we need some additional points in btrfs-progs stable.


Then the next set of updates to be integrated can proceed with that as a 
base ... patches such as su show and getting rid of the 
legacy/deprecated programs.


Gene
--
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] [RFC] Add static compile target

2013-01-27 Thread Gene Czarcinski

On 01/25/2013 07:09 PM, Ian Kumlien wrote:

Sometimes, when you least expect it, a static binary is what you need to
rescue your data... Or just get a good enough handle on things to make
it work again ;)
You certainly have a good point.  I took q quick look on Fedora 18 and 
e2fsprogs has a separate static package but xfsprogs, jfsutils, and 
reiserfs-utils do not.  On the other hand, those without a separate 
static package may be only static.


I guess it depends how much bloat there would be with static only. For 
e2fsprogs, the static package only contains the static (.a) 
libraries.  I believe your patch makes all of the binaries static linked.


Is this necessary?  1) Btrfs fixes a lot of stuff on-the fly.  2) If you 
need to recover standalone, rescue has btrfs.


I did a quick check and most of the btrfs binaries are less than 200K 
bytes whereas the static versions are around 1.2M bytes.  I know that 
disk space is cheap these days but does this solve a real problem?


Gene


make static is a gift to you, dear user with filesystem problems!
---
  Makefile | 4 
  1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index 4894903..9148d0b 100644
--- a/Makefile
+++ b/Makefile
@@ -117,4 +117,8 @@ install: $(progs) install-man
$(INSTALL) -m755 -d $(DESTDIR)$(bindir)
$(INSTALL) $(progs) $(DESTDIR)$(bindir)
  
+static: CFLAGS += -static

+static: LIBS += -lpthread
+static: all
+
  -include .*.d


--
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: v2 Fix minor problems in btrfslabel.c

2013-01-26 Thread Gene Czarcinski
Fixed indentation, replace spaces with tabs.
Signed-off-by: Danny Kukawka danny.kuka...@bisect.de

Rebased; fixed compiler warnings; added space after if
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 btrfslabel.c | 57 +
 1 file changed, 29 insertions(+), 28 deletions(-)

diff --git a/btrfslabel.c b/btrfslabel.c
index 88a5196..5a91fc4 100644
--- a/btrfslabel.c
+++ b/btrfslabel.c
@@ -48,42 +48,43 @@
 
 static int change_label_unmounted(char *dev, char *nLabel)
 {
-   struct btrfs_root *root;
-   struct btrfs_trans_handle *trans;
-
-   /* Open the super_block at the default location
-* and as read-write.
-*/
-   root = open_ctree(dev, 0, 1);
-   if (!root) /* errors are printed by open_ctree() */
- return;
-
-   trans = btrfs_start_transaction(root, 1);
-   strncpy(root-fs_info-super_copy.label, nLabel, BTRFS_LABEL_SIZE);
-   root-fs_info-super_copy.label[BTRFS_LABEL_SIZE-1] = 0;
-   btrfs_commit_transaction(trans, root);
-
-   /* Now we close it since we are done. */
-   close_ctree(root);
+   struct btrfs_root *root;
+   struct btrfs_trans_handle *trans;
+
+   /* Open the super_block at the default location
+* and as read-write.
+*/
+   root = open_ctree(dev, 0, 1);
+   if (!root) /* errors are printed by open_ctree() */
+ return -1;
+
+   trans = btrfs_start_transaction(root, 1);
+   strncpy(root-fs_info-super_copy.label, nLabel, BTRFS_LABEL_SIZE);
+   root-fs_info-super_copy.label[BTRFS_LABEL_SIZE-1] = 0;
+   btrfs_commit_transaction(trans, root);
+
+   /* Now we close it since we are done. */
+   close_ctree(root);
+   return 0;
 }
 
 int get_label_unmounted(char *dev)
 {
-   struct btrfs_root *root;
+   struct btrfs_root *root;
 
-   /* Open the super_block at the default location
-* and as read-only.
-*/
-   root = open_ctree(dev, 0, 0);
+   /* Open the super_block at the default location
+* and as read-only.
+*/
+   root = open_ctree(dev, 0, 0);
 
-   if(!root)
- return -1;
+   if (!root)
+ return -1;
 
-   fprintf(stdout, %s\n, root-fs_info-super_copy.label);
+   fprintf(stdout, %s\n, root-fs_info-super_copy.label);
 
-   /* Now we close it since we are done. */
-   close_ctree(root);
-   return 0;
+   /* Now we close it since we are done. */
+   close_ctree(root);
+   return 0;
 }
 
 int get_label(char *btrfs_dev)
-- 
1.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


[PATCH] Btrfs-progs: Fix trival compiler error in cmds-qgroup.c

2013-01-26 Thread Gene Czarcinski
The compiler does not realize that usage() never returns.
Initializing the variable keeps it quiet.
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 cmds-qgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 70019d0..3ac2e14 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -338,7 +338,7 @@ static int cmd_qgroup_limit(int argc, char **argv)
int ret = 0;
int fd;
int e;
-   char *path;
+   char *path = NULL;
struct btrfs_ioctl_qgroup_limit_args args;
unsigned long long size;
int compressed = 0;
-- 
1.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: Integration branch of btrfs-progs 2013-01-26 [not to be pulled]

2013-01-26 Thread Gene Czarcinski

On 01/26/2013 06:14 AM, David Sterba wrote:

On Sat, Jan 26, 2013 at 01:55:25AM +0100, David Sterba wrote:

Eric Sandeen (2):
   btrfs-progs pretty/quiet build

This patch ended up mismerged, I'll fix it here but the branch will
diverge and is not suitable for pull now.


David, you appear to have done a fine job of integration and your 
selection of patches appears spot-on to me.


There are to trivial patches I just submitted to fix some formatting and 
a couple of compiler errors:

http://article.gmane.org/gmane.comp.file-systems.btrfs/22669
http://article.gmane.org/gmane.comp.file-systems.btrfs/22668

BTW, what was wrong with the quiet-build patch?

I am almost completely rebased and plan to begin testing later today.

Gene

Gene
--
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: Exit if not running as root

2013-01-25 Thread Gene Czarcinski
This patch hits a lot of files but adds little code.  It
could be considered a bugfix,  Currently, when one of the
btrfs user-space programs is executed by a regular user,
the result if oftem a number of strange error messages
which do not indicate the real problem.  This patch changes
that situation.

A test is performed as to whether the program is running
as root.  If it is not, issue an error message and exit.
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 btrfs-corrupt-block.c | 5 +
 btrfs-image.c | 5 +
 btrfs-map-logical.c   | 5 +
 btrfs-select-super.c  | 5 +
 btrfs-show-super.c| 5 +
 btrfs-show.c  | 5 +
 btrfs-vol.c   | 5 +
 btrfs-zero-log.c  | 5 +
 btrfs.c   | 6 ++
 btrfsck.c | 5 +
 btrfsctl.c| 5 +
 btrfstune.c   | 5 +
 calc-size.c   | 5 +
 convert.c | 6 ++
 debug-tree.c  | 5 +
 dir-test.c| 5 +
 find-root.c   | 5 +
 ioctl-test.c  | 6 ++
 mkfs.c| 5 +
 quick-test.c  | 6 ++
 restore.c | 5 +
 21 files changed, 109 insertions(+)

diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index b57e757..083fd50 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -296,6 +296,11 @@ int main(int ac, char **av)
 
srand(128);
 
+   if (geteuid() != 0) {
+   fprintf(stderr,Error: %s must run as root\n, argv[0]);
+   exit(1);
+   }
+
while(1) {
int c;
c = getopt_long(ac, av, l:c:b:eEk, long_options,
diff --git a/btrfs-image.c b/btrfs-image.c
index 7dc131d..fd9b28a 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -831,6 +831,11 @@ int main(int argc, char *argv[])
int ret;
FILE *out;
 
+   if (geteuid() != 0) {
+   fprintf(stderr,Error: %s must run as root\n, argv[0]);
+   exit(1);
+   }
+
while (1) {
int c = getopt(argc, argv, rc:t:);
if (c  0)
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index fa4fb3f..59f2f0e 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -116,6 +116,11 @@ int main(int ac, char **av)
int out_fd = 0;
int err;
 
+   if (geteuid() != 0) {
+   fprintf(stderr,Error: %s must run as root\n, av[0]);
+   exit(1);
+   }
+
while(1) {
int c;
c = getopt_long(ac, av, l:c:o:b:, long_options,
diff --git a/btrfs-select-super.c b/btrfs-select-super.c
index 0c4f5c0..049379d 100644
--- a/btrfs-select-super.c
+++ b/btrfs-select-super.c
@@ -46,6 +46,11 @@ int main(int ac, char **av)
int num;
u64 bytenr = 0;
 
+   if (geteuid() != 0) {
+   fprintf(stderr,Error: %s must run as root\n, argv[0]);
+   exit(1);
+   }
+
while(1) {
int c;
c = getopt(ac, av, s:);
diff --git a/btrfs-show-super.c b/btrfs-show-super.c
index a9e2524..2fa4776 100644
--- a/btrfs-show-super.c
+++ b/btrfs-show-super.c
@@ -63,6 +63,11 @@ int main(int argc, char **argv)
int arg, i;
u64 sb_bytenr = btrfs_sb_offset(0);
 
+   if (geteuid() != 0) {
+   fprintf(stderr,Error: %s must run as root\n, argv[0]);
+   exit(1);
+   }
+
while ((opt = getopt(argc, argv, ai:)) != -1) {
switch (opt) {
case 'i':
diff --git a/btrfs-show.c b/btrfs-show.c
index 8210fd2..6b3b91a 100644
--- a/btrfs-show.c
+++ b/btrfs-show.c
@@ -122,6 +122,11 @@ int main(int ac, char **av)
** Please consider to switch to the btrfs utility\n
**\n);
 
+   if (geteuid() != 0) {
+   fprintf(stderr,Error: %s must run as root\n, av[0]);
+   exit(1);
+   }
+
while(1) {
int c;
c = getopt_long(ac, av, , long_options,
diff --git a/btrfs-vol.c b/btrfs-vol.c
index ad824bd..7e02f72 100644
--- a/btrfs-vol.c
+++ b/btrfs-vol.c
@@ -83,6 +83,11 @@ int main(int ac, char **av)
** Please consider to switch to the btrfs utility\n
**\n);
 
+   if (geteuid() != 0) {
+   fprintf(stderr,Error: %s must run as root\n, av[0]);
+   exit(1);
+   }
+
while(1) {
int c;
c = getopt_long(ac, av, a:br:, long_options,
diff --git a/btrfs-zero-log.c b/btrfs-zero-log.c
index 1ea867b..80e4e38 100644
--- a/btrfs-zero-log.c
+++ b/btrfs-zero-log.c
@@ -45,6 +45,11 @@ int main(int ac, char **av)
struct btrfs_trans_handle *trans;
int ret;
 
+   if (geteuid() != 0) {
+   fprintf(stderr,Error: %s must run as root\n, av[0]);
+   exit(1);
+   }
+
if (ac != 2)
print_usage();
 
diff --git a/btrfs.c b/btrfs.c
index 687acec..328966b 100644
--- a/btrfs.c

Re: [PATCH] Btrfs-progs: remove btrfsctl, btrfs-show and btrfs-vol from default build

2013-01-25 Thread Gene Czarcinski

On 06/08/2012 02:00 PM, Stefan Behrens wrote:

Remove btrfsctl, btrfs-show and btrfs-vol from all target of Makefile.

Signed-off-by: Stefan Behrens sbehr...@giantdisaster.de
---
  Makefile |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index aaf1381..79e7a56 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ bindir = $(prefix)/bin
  LIBS=-luuid
  RESTORE_LIBS=-lz

-progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck \
+progs = mkfs.btrfs btrfs-debug-tree btrfsck \
btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \
btrfs-find-root btrfs-restore btrfstune


I agree.  It is time to remove these old programs; they serve no useful 
purpose; and they complicate maintenance.


Gene
--
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: Exit if not running as root

2013-01-25 Thread Gene Czarcinski

On 01/25/2013 06:41 AM, Stefan Behrens wrote:

On Fri, 25 Jan 2013 06:32:30 -0500, Gene Czarcinski wrote:

This patch hits a lot of files but adds little code.  It
could be considered a bugfix,  Currently, when one of the
btrfs user-space programs is executed by a regular user,
the result if oftem a number of strange error messages
which do not indicate the real problem.  This patch changes
that situation.

A test is performed as to whether the program is running
as root.  If it is not, issue an error message and exit.
Signed-off-by: Gene Czarcinski g...@czarc.net
---
  btrfs-corrupt-block.c | 5 +
  btrfs-image.c | 5 +
  btrfs-map-logical.c   | 5 +
  btrfs-select-super.c  | 5 +
  btrfs-show-super.c| 5 +
  btrfs-show.c  | 5 +
  btrfs-vol.c   | 5 +
  btrfs-zero-log.c  | 5 +
  btrfs.c   | 6 ++
  btrfsck.c | 5 +
  btrfsctl.c| 5 +
  btrfstune.c   | 5 +
  calc-size.c   | 5 +
  convert.c | 6 ++
  debug-tree.c  | 5 +
  dir-test.c| 5 +
  find-root.c   | 5 +
  ioctl-test.c  | 6 ++
  mkfs.c| 5 +
  quick-test.c  | 6 ++
  restore.c | 5 +
  21 files changed, 109 insertions(+)

diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index b57e757..083fd50 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -296,6 +296,11 @@ int main(int ac, char **av)
  
  	srand(128);
  
+	if (geteuid() != 0) {

+   fprintf(stderr,Error: %s must run as root\n, argv[0]);
+   exit(1);
+   }
+
while(1) {
int c;
c = getopt_long(ac, av, l:c:b:eEk, long_options,
diff --git a/btrfs-image.c b/btrfs-image.c
index 7dc131d..fd9b28a 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -831,6 +831,11 @@ int main(int argc, char *argv[])
int ret;
FILE *out;
  
+	if (geteuid() != 0) {

+   fprintf(stderr,Error: %s must run as root\n, argv[0]);
+   exit(1);
+   }
+
while (1) {
int c = getopt(argc, argv, rc:t:);
if (c  0)
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index fa4fb3f..59f2f0e 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -116,6 +116,11 @@ int main(int ac, char **av)
int out_fd = 0;
int err;
  
+	if (geteuid() != 0) {

+   fprintf(stderr,Error: %s must run as root\n, av[0]);
+   exit(1);
+   }
+
while(1) {
int c;
c = getopt_long(ac, av, l:c:o:b:, long_options,
diff --git a/btrfs-select-super.c b/btrfs-select-super.c
index 0c4f5c0..049379d 100644
--- a/btrfs-select-super.c
+++ b/btrfs-select-super.c
@@ -46,6 +46,11 @@ int main(int ac, char **av)
int num;
u64 bytenr = 0;
  
+	if (geteuid() != 0) {

+   fprintf(stderr,Error: %s must run as root\n, argv[0]);
+   exit(1);
+   }
+
while(1) {
int c;
c = getopt(ac, av, s:);
diff --git a/btrfs-show-super.c b/btrfs-show-super.c
index a9e2524..2fa4776 100644
--- a/btrfs-show-super.c
+++ b/btrfs-show-super.c
@@ -63,6 +63,11 @@ int main(int argc, char **argv)
int arg, i;
u64 sb_bytenr = btrfs_sb_offset(0);
  
+	if (geteuid() != 0) {

+   fprintf(stderr,Error: %s must run as root\n, argv[0]);
+   exit(1);
+   }
+
while ((opt = getopt(argc, argv, ai:)) != -1) {
switch (opt) {
case 'i':
diff --git a/btrfs-show.c b/btrfs-show.c
index 8210fd2..6b3b91a 100644
--- a/btrfs-show.c
+++ b/btrfs-show.c
@@ -122,6 +122,11 @@ int main(int ac, char **av)
** Please consider to switch to the btrfs utility\n
**\n);
  
+	if (geteuid() != 0) {

+   fprintf(stderr,Error: %s must run as root\n, av[0]);
+   exit(1);
+   }
+
while(1) {
int c;
c = getopt_long(ac, av, , long_options,
diff --git a/btrfs-vol.c b/btrfs-vol.c
index ad824bd..7e02f72 100644
--- a/btrfs-vol.c
+++ b/btrfs-vol.c
@@ -83,6 +83,11 @@ int main(int ac, char **av)
** Please consider to switch to the btrfs utility\n
**\n);
  
+	if (geteuid() != 0) {

+   fprintf(stderr,Error: %s must run as root\n, av[0]);
+   exit(1);
+   }
+
while(1) {
int c;
c = getopt_long(ac, av, a:br:, long_options,
diff --git a/btrfs-zero-log.c b/btrfs-zero-log.c
index 1ea867b..80e4e38 100644
--- a/btrfs-zero-log.c
+++ b/btrfs-zero-log.c
@@ -45,6 +45,11 @@ int main(int ac, char **av)
struct btrfs_trans_handle *trans;
int ret;
  
+	if (geteuid() != 0) {

+   fprintf(stderr,Error: %s must run as root\n, av[0]);
+   exit(1);
+   }
+
if (ac != 2

Re: [PATCH] Btrfs-progs: Exit if not running as root

2013-01-25 Thread Gene Czarcinski

On 01/25/2013 06:55 AM, Roman Mamedov wrote:

On Fri, 25 Jan 2013 06:32:30 -0500
Gene Czarcinski g...@czarc.net wrote:


This patch hits a lot of files but adds little code.  It
could be considered a bugfix,  Currently, when one of the
btrfs user-space programs is executed by a regular user,
the result if oftem a number of strange error messages
which do not indicate the real problem.  This patch changes
that situation.

A test is performed as to whether the program is running
as root.  If it is not, issue an error message and exit.
Signed-off-by: Gene Czarcinski g...@czarc.net

$ ls -la /dev/sda
brw-rw---T 1 root disk 8, 0 Jan 15 12:11 /dev/sda

The user does not have to be root, they can be a member of the group disk to
manage this device.

Also some or all of the tools accept not just a block device, but also a
regular file as their parameter.

Wouldn't it be better to check whether or not the running user has
*write access* to the device or file to be operated on, before failing?
I knew there would be corner cases where root was not required for 
execution.  After all, I do not need to be root to execute btrfs 
--version.  Now, is it worth the effort to determine the corner cases 
and do you have a proposed solution as to determining what privileges 
are needed when?  I can understand when it could be a regular file but 
is it all that common for users to be part of group disk?


If there is a case where it is difficult to figure out if root is 
needed, then my solution would be to turn it into a warning message and 
remove the exit for that specific program.


However, I believe the real answer is to use sudo.

Gene



---
  btrfs-corrupt-block.c | 5 +
  btrfs-image.c | 5 +
  btrfs-map-logical.c   | 5 +
  btrfs-select-super.c  | 5 +
  btrfs-show-super.c| 5 +
  btrfs-show.c  | 5 +
  btrfs-vol.c   | 5 +
  btrfs-zero-log.c  | 5 +
  btrfs.c   | 6 ++
  btrfsck.c | 5 +
  btrfsctl.c| 5 +
  btrfstune.c   | 5 +
  calc-size.c   | 5 +
  convert.c | 6 ++
  debug-tree.c  | 5 +
  dir-test.c| 5 +
  find-root.c   | 5 +
  ioctl-test.c  | 6 ++
  mkfs.c| 5 +
  quick-test.c  | 6 ++
  restore.c | 5 +
  21 files changed, 109 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


Re: [PATCH] btrfs-progs pretty/quiet build

2013-01-25 Thread Gene Czarcinski

On 01/24/2013 06:32 PM, Eric Sandeen wrote:

A quieter build makes warnings more obvious.

This could probably be improved, but just to see
if people like this or if they hate it.  :)

make V=1 overrides it and gets you the full
glory again.

# make
 [CC] ctree.o
 [CC] disk-io.o
 [CC] radix-tree.o
 [CC] extent-tree.o
 ...

Signed-off-by: Eric Sandeen sand...@redhat.com
---
  Makefile |   92 +-
  man/Makefile |   29 +++---
  2 files changed, 76 insertions(+), 45 deletions(-)

diff --git a/Makefile b/Makefile
index 4894903..73657bf 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,21 @@ bindir = $(prefix)/bin
  LIBS=-luuid -lm
  RESTORE_LIBS=-lz
  
+ifeq ($(origin V), command line)

+  BUILD_VERBOSE = $(V)
+endif
+ifndef BUILD_VERBOSE
+  BUILD_VERBOSE = 0
+endif
+
+ifeq ($(BUILD_VERBOSE),1)
+  Q =
+else
+  Q = @
+endif
+
+MAKEOPTS = --no-print-directory Q=$(Q)
+
  progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck \
btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \
btrfs-find-root btrfs-restore btrfstune
@@ -28,90 +43,113 @@ progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show 
btrfs-vol btrfsck \
  ifdef C
check = sparse $(CHECKFLAGS)
  else
-   check = ls
+   check = true
  endif
  
  .c.o:

-   $(check) $
-   $(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $
+   $(Q)$(check) $
+   @echo [CC] $@
+   $(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $
  
  
  all: version $(progs) manpages
  
  version:

-   bash version.sh
+   $(Q)bash version.sh
  
  btrfs: $(objects) btrfs.o help.o common.o $(cmds_objects)

-   $(CC) $(CFLAGS) -o btrfs btrfs.o help.o common.o $(cmds_objects) \
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o help.o common.o $(cmds_objects) \
$(objects) $(LDFLAGS) $(LIBS) -lpthread
  
  calc-size: $(objects) calc-size.o

-   $(CC) $(CFLAGS) -o calc-size calc-size.o $(objects) $(LDFLAGS) $(LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o calc-size calc-size.o $(objects) $(LDFLAGS) 
$(LIBS)
  
  btrfs-find-root: $(objects) find-root.o

-   $(CC) $(CFLAGS) -o btrfs-find-root find-root.o $(objects) $(LDFLAGS) 
$(LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o btrfs-find-root find-root.o $(objects) 
$(LDFLAGS) $(LIBS)
  
  btrfs-restore: $(objects) restore.o

-   $(CC) $(CFLAGS) -o btrfs-restore restore.o $(objects) $(LDFLAGS) 
$(LIBS) $(RESTORE_LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o btrfs-restore restore.o $(objects) $(LDFLAGS) 
$(LIBS) $(RESTORE_LIBS)
  
  btrfsctl: $(objects) btrfsctl.o

-   $(CC) $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS)
  
  btrfs-vol: $(objects) btrfs-vol.o

-   $(CC) $(CFLAGS) -o btrfs-vol btrfs-vol.o $(objects) $(LDFLAGS) $(LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o btrfs-vol btrfs-vol.o $(objects) $(LDFLAGS) 
$(LIBS)
  
  btrfs-show: $(objects) btrfs-show.o

-   $(CC) $(CFLAGS) -o btrfs-show btrfs-show.o $(objects) $(LDFLAGS) $(LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o btrfs-show btrfs-show.o $(objects) $(LDFLAGS) 
$(LIBS)
  
  btrfsck: $(objects) btrfsck.o

-   $(CC) $(CFLAGS) -o btrfsck btrfsck.o $(objects) $(LDFLAGS) $(LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o btrfsck btrfsck.o $(objects) $(LDFLAGS) $(LIBS)
  
  mkfs.btrfs: $(objects) mkfs.o

-   $(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)
  
  btrfs-debug-tree: $(objects) debug-tree.o

-   $(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) 
$(LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o 
$(LDFLAGS) $(LIBS)
  
  btrfs-zero-log: $(objects) btrfs-zero-log.o

-   $(CC) $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o 
$(LDFLAGS) $(LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o 
$(LDFLAGS) $(LIBS)
  
  btrfs-select-super: $(objects) btrfs-select-super.o

-   $(CC) $(CFLAGS) -o btrfs-select-super $(objects) btrfs-select-super.o 
$(LDFLAGS) $(LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o btrfs-select-super $(objects) 
btrfs-select-super.o $(LDFLAGS) $(LIBS)
  
  btrfstune: $(objects) btrfstune.o

-   $(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS)
+   @echo [LD] $@
+   $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) 
$(LIBS)
  
  btrfs-map-logical: $(objects) btrfs-map-logical.o

-   $(CC) 

Re: [PATCH] Btrfs-progs: Exit if not running as root

2013-01-25 Thread Gene Czarcinski

On 01/25/2013 07:17 AM, Stefan Behrens wrote:

On Fri, 25 Jan 2013 07:03:19 -0500, Gene Czarcinski wrote:

On 01/25/2013 06:41 AM, Stefan Behrens wrote:

On Fri, 25 Jan 2013 06:32:30 -0500, Gene Czarcinski wrote:

This patch hits a lot of files but adds little code.  It
could be considered a bugfix,  Currently, when one of the
btrfs user-space programs is executed by a regular user,
the result if oftem a number of strange error messages
which do not indicate the real problem.  This patch changes
that situation.

A test is performed as to whether the program is running
as root.  If it is not, issue an error message and exit.
Signed-off-by: Gene Czarcinski g...@czarc.net
---
   btrfs-corrupt-block.c | 5 +
   btrfs-image.c | 5 +
   btrfs-map-logical.c   | 5 +
   btrfs-select-super.c  | 5 +
   btrfs-show-super.c| 5 +
   btrfs-show.c  | 5 +
   btrfs-vol.c   | 5 +
   btrfs-zero-log.c  | 5 +
   btrfs.c   | 6 ++
   btrfsck.c | 5 +
   btrfsctl.c| 5 +
   btrfstune.c   | 5 +
   calc-size.c   | 5 +
   convert.c | 6 ++
   debug-tree.c  | 5 +
   dir-test.c| 5 +
   find-root.c   | 5 +
   ioctl-test.c  | 6 ++
   mkfs.c| 5 +
   quick-test.c  | 6 ++
   restore.c | 5 +
   21 files changed, 109 insertions(+)

diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index b57e757..083fd50 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -296,6 +296,11 @@ int main(int ac, char **av)
 srand(128);
   +if (geteuid() != 0) {
+fprintf(stderr,Error: %s must run as root\n, argv[0]);
+exit(1);
+}
+
   while(1) {
   int c;
   c = getopt_long(ac, av, l:c:b:eEk, long_options,
diff --git a/btrfs-image.c b/btrfs-image.c
index 7dc131d..fd9b28a 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -831,6 +831,11 @@ int main(int argc, char *argv[])
   int ret;
   FILE *out;
   +if (geteuid() != 0) {
+fprintf(stderr,Error: %s must run as root\n, argv[0]);
+exit(1);
+}
+
   while (1) {
   int c = getopt(argc, argv, rc:t:);
   if (c  0)
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index fa4fb3f..59f2f0e 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -116,6 +116,11 @@ int main(int ac, char **av)
   int out_fd = 0;
   int err;
   +if (geteuid() != 0) {
+fprintf(stderr,Error: %s must run as root\n, av[0]);
+exit(1);
+}
+
   while(1) {
   int c;
   c = getopt_long(ac, av, l:c:o:b:, long_options,
diff --git a/btrfs-select-super.c b/btrfs-select-super.c
index 0c4f5c0..049379d 100644
--- a/btrfs-select-super.c
+++ b/btrfs-select-super.c
@@ -46,6 +46,11 @@ int main(int ac, char **av)
   int num;
   u64 bytenr = 0;
   +if (geteuid() != 0) {
+fprintf(stderr,Error: %s must run as root\n, argv[0]);
+exit(1);
+}
+
   while(1) {
   int c;
   c = getopt(ac, av, s:);
diff --git a/btrfs-show-super.c b/btrfs-show-super.c
index a9e2524..2fa4776 100644
--- a/btrfs-show-super.c
+++ b/btrfs-show-super.c
@@ -63,6 +63,11 @@ int main(int argc, char **argv)
   int arg, i;
   u64 sb_bytenr = btrfs_sb_offset(0);
   +if (geteuid() != 0) {
+fprintf(stderr,Error: %s must run as root\n, argv[0]);
+exit(1);
+}
+
   while ((opt = getopt(argc, argv, ai:)) != -1) {
   switch (opt) {
   case 'i':
diff --git a/btrfs-show.c b/btrfs-show.c
index 8210fd2..6b3b91a 100644
--- a/btrfs-show.c
+++ b/btrfs-show.c
@@ -122,6 +122,11 @@ int main(int ac, char **av)
   ** Please consider to switch to the btrfs utility\n
   **\n);
   +if (geteuid() != 0) {
+fprintf(stderr,Error: %s must run as root\n, av[0]);
+exit(1);
+}
+
   while(1) {
   int c;
   c = getopt_long(ac, av, , long_options,
diff --git a/btrfs-vol.c b/btrfs-vol.c
index ad824bd..7e02f72 100644
--- a/btrfs-vol.c
+++ b/btrfs-vol.c
@@ -83,6 +83,11 @@ int main(int ac, char **av)
   ** Please consider to switch to the btrfs utility\n
   **\n);
   +if (geteuid() != 0) {
+fprintf(stderr,Error: %s must run as root\n, av[0]);
+exit(1);
+}
+
   while(1) {
   int c;
   c = getopt_long(ac, av, a:br:, long_options,
diff --git a/btrfs-zero-log.c b/btrfs-zero-log.c
index 1ea867b..80e4e38 100644
--- a/btrfs-zero-log.c
+++ b/btrfs-zero-log.c
@@ -45,6 +45,11 @@ int main(int ac, char **av)
   struct btrfs_trans_handle *trans;
   int ret;
   +if (geteuid() != 0) {
+fprintf(stderr,Error: %s must run as root\n, av[0]);
+exit(1);
+}
+
   if (ac != 2)
   print_usage();
   diff --git a/btrfs.c b/btrfs.c
index 687acec..328966b 100644
--- a/btrfs.c
+++ b

Re: [PATCH] Btrfs-progs: Exit if not running as root

2013-01-25 Thread Gene Czarcinski
OK, I think I have gotten the message that this is a bad idea as 
implemented and that it should be dropped as such.  I believe that there 
are some things (btrfs fi show comes to mind) which will need root and 
I am going to explore doing something for that case.  And it also might 
be reasonable for some situations to issue the message about root if 
something errors-out.


Anyway, this approach is dead and I will continue to give this some thought.

Comments?

Gene



On 01/25/2013 06:32 AM, Gene Czarcinski wrote:

This patch hits a lot of files but adds little code.  It
could be considered a bugfix,  Currently, when one of the
btrfs user-space programs is executed by a regular user,
the result if oftem a number of strange error messages
which do not indicate the real problem.  This patch changes
that situation.

A test is performed as to whether the program is running
as root.  If it is not, issue an error message and exit.
Signed-off-by: Gene Czarcinskig...@czarc.net
---
  btrfs-corrupt-block.c | 5 +
  btrfs-image.c | 5 +
  btrfs-map-logical.c   | 5 +
  btrfs-select-super.c  | 5 +
  btrfs-show-super.c| 5 +
  btrfs-show.c  | 5 +
  btrfs-vol.c   | 5 +
  btrfs-zero-log.c  | 5 +
  btrfs.c   | 6 ++
  btrfsck.c | 5 +
  btrfsctl.c| 5 +
  btrfstune.c   | 5 +
  calc-size.c   | 5 +
  convert.c | 6 ++
  debug-tree.c  | 5 +
  dir-test.c| 5 +
  find-root.c   | 5 +
  ioctl-test.c  | 6 ++
  mkfs.c| 5 +
  quick-test.c  | 6 ++
  restore.c | 5 +
  21 files changed, 109 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


Re: [PATCH] Btrfs-progs: Exit if not running as root

2013-01-25 Thread Gene Czarcinski

On 01/25/2013 10:04 AM, Gene Czarcinski wrote:
OK, I think I have gotten the message that this is a bad idea as 
implemented and that it should be dropped as such.  I believe that 
there are some things (btrfs fi show comes to mind) which will need 
root and I am going to explore doing something for that case.  And it 
also might be reasonable for some situations to issue the message 
about root if something errors-out.


Anyway, this approach is dead and I will continue to give this some 
thought.


Comments?

Gene



On 01/25/2013 06:32 AM, Gene Czarcinski wrote:

This patch hits a lot of files but adds little code.  It
could be considered a bugfix,  Currently, when one of the
btrfs user-space programs is executed by a regular user,
the result if oftem a number of strange error messages
which do not indicate the real problem.  This patch changes
that situation.

A test is performed as to whether the program is running
as root.  If it is not, issue an error message and exit.
Signed-off-by: Gene Czarcinskig...@czarc.net
---
  btrfs-corrupt-block.c | 5 +
  btrfs-image.c | 5 +
  btrfs-map-logical.c   | 5 +
  btrfs-select-super.c  | 5 +
  btrfs-show-super.c| 5 +
  btrfs-show.c  | 5 +
  btrfs-vol.c   | 5 +
  btrfs-zero-log.c  | 5 +
  btrfs.c   | 6 ++
  btrfsck.c | 5 +
  btrfsctl.c| 5 +
  btrfstune.c   | 5 +
  calc-size.c   | 5 +
  convert.c | 6 ++
  debug-tree.c  | 5 +
  dir-test.c| 5 +
  find-root.c   | 5 +
  ioctl-test.c  | 6 ++
  mkfs.c| 5 +
  quick-test.c  | 6 ++
  restore.c | 5 +
  21 files changed, 109 insertions(+)


BTW, I want to thank all of you who commented.  I have seen far too many 
submitted patches land with a thump and nothing more ... no comments ... 
either good or bad.


Gene
--
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/10] Btrfs-progs: move open_file_or_dir() to utils.c

2013-01-25 Thread Gene Czarcinski

On 01/25/2013 11:48 AM, Hugo Mills wrote:

On Fri, Jan 25, 2013 at 10:14:06AM -0600, Eric Sandeen wrote:

On 1/24/13 4:09 PM, Goffredo Baroncelli wrote:

On 01/24/2013 08:42 PM, Eric Sandeen wrote:

On 1/24/13 11:57 AM, Goffredo Baroncelli wrote:

On 01/24/2013 10:23 AM, Stefan Behrens wrote:

On Wed, 23 Jan 2013 22:39:29 -0600, Eric Sandeen wrote:

instead of renaming   keeping the btrfsctl.c copy

There is a new momentum to improve the Btrfs-progs quality :)

IMO, one step is to get rid of the legacy tools and sources. It
wastes time to maintain them and these old tools cause confusion.
btrfsctl.c, btrfs-vol.c and btrfs-show.c are not needed anymore.
Please correct me if there are plans to use these old tools in
future Linux distributions. The btrfs tool replaces the legacy
btrfsctl, btrfs-vol and btrfs-show tools. Below, the usage
text of the old tools is quoted. All these tasks are also offered
in the btrfs tool, and this tool is the newer one.

I fully agree: btrfsctl, btrfs-vol, btrfs-show are perfectly
replaced by by btrfs. Moreover time to time the patches are more
complex than the needing because exists these legacy programs.

I checked the debian package, and to me seems that there is no need
of {btrfsctl,btrfs-vol,btrfs-show}

Hm, they are shipped in the Fedora package.

The same is true for the debian package, but are these used in Fedora ?


For backwards compat, could those be turned into shell scripts which
invoke the btrfs tool?

I don't see any gain to maintains a script bash (which has to be
written from scratch) instead of maintains the current C code.

It should be a trivial bash script to convert the calls, and it should
require very little maintenance.  Much less than the hundreds of lines
of duplicated C code, I think.

If nobody needs them, though, no reason for even a bash script.

David, Suse may be using them now, but probably can adapt?
Anaconda said it could drop the use of btrfsctl.  :)

I've just asked someone I know at Canonical, and he says there's no
use of these tools in the Ubuntu installer. (Disclaimer: it's not
entirely his area, and there's probably other places to look, like
udev rules, but on a cursory glance, it should be OK).

I've also checked with the Debian installer people, and they're not
using the deprecated tools either. Further, these searches:

http://codesearch.debian.net/search?q=btrfs-show
http://codesearch.debian.net/search?q=btrfs-vol
http://codesearch.debian.net/search?q=btrfsctl

suggest that there's very little impact over the rest of the system as
well.

Hugo.

I took a look at Stefan's patch to Makefile and only the building and 
installation of the legacy apps has been eliminated.


This is a good first step so that if someone does need one of these 
apps, they can still be made.  Then, at some later time, remove the 
targets in Makefile and delete the source files.


Or, do it all now? [my preference]

Comments?

Gene
--
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: Fix minor problems with btrfslabel.c

2013-01-24 Thread Gene Czarcinski
Fixed indentation, replace spaces with tabs.
Signed-off-by: Danny Kukawka danny.kuka...@bisect.de

Rebased, also fixed compiler warnings
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 btrfslabel.c | 57 +
 1 file changed, 29 insertions(+), 28 deletions(-)

diff --git a/btrfslabel.c b/btrfslabel.c
index 88a5196..bea1f89 100644
--- a/btrfslabel.c
+++ b/btrfslabel.c
@@ -48,42 +48,43 @@
 
 static int change_label_unmounted(char *dev, char *nLabel)
 {
-   struct btrfs_root *root;
-   struct btrfs_trans_handle *trans;
-
-   /* Open the super_block at the default location
-* and as read-write.
-*/
-   root = open_ctree(dev, 0, 1);
-   if (!root) /* errors are printed by open_ctree() */
- return;
-
-   trans = btrfs_start_transaction(root, 1);
-   strncpy(root-fs_info-super_copy.label, nLabel, BTRFS_LABEL_SIZE);
-   root-fs_info-super_copy.label[BTRFS_LABEL_SIZE-1] = 0;
-   btrfs_commit_transaction(trans, root);
-
-   /* Now we close it since we are done. */
-   close_ctree(root);
+   struct btrfs_root *root;
+   struct btrfs_trans_handle *trans;
+
+   /* Open the super_block at the default location
+* and as read-write.
+*/
+   root = open_ctree(dev, 0, 1);
+   if (!root) /* errors are printed by open_ctree() */
+ return -1;
+
+   trans = btrfs_start_transaction(root, 1);
+   strncpy(root-fs_info-super_copy.label, nLabel, BTRFS_LABEL_SIZE);
+   root-fs_info-super_copy.label[BTRFS_LABEL_SIZE-1] = 0;
+   btrfs_commit_transaction(trans, root);
+
+   /* Now we close it since we are done. */
+   close_ctree(root);
+   return 0;
 }
 
 int get_label_unmounted(char *dev)
 {
-   struct btrfs_root *root;
+   struct btrfs_root *root;
 
-   /* Open the super_block at the default location
-* and as read-only.
-*/
-   root = open_ctree(dev, 0, 0);
+   /* Open the super_block at the default location
+* and as read-only.
+*/
+   root = open_ctree(dev, 0, 0);
 
-   if(!root)
- return -1;
+   if(!root)
+ return -1;
 
-   fprintf(stdout, %s\n, root-fs_info-super_copy.label);
+   fprintf(stdout, %s\n, root-fs_info-super_copy.label);
 
-   /* Now we close it since we are done. */
-   close_ctree(root);
-   return 0;
+   /* Now we close it since we are done. */
+   close_ctree(root);
+   return 0;
 }
 
 int get_label(char *btrfs_dev)
-- 
1.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 00/10] add show sub-command for btrfs subvol cli

2013-01-24 Thread Gene Czarcinski

On 01/23/2013 03:12 AM, Anand Jain wrote:

Please accept this patch set which is on top of
   git://repo.or.cz/btrfs-progs-unstable/devel.git for-chris

to add 'show' sub-command feature for the btrfs subvol cli
as in an example below..
OK, in spite of saying that these patches did not apply clean, it was 
not terribly difficult to refit what did not apply.  I did this in two 
steps:


1. I created the equivalent of the for-chris branch.  This did not apply 
clean which surprised me.  However, minor things easily handled manually 
in the first patch for utils.c and utils.h plus btrfs-lists.c in a later 
patch.


2. After creating a new set of patches from the above effort, I then 
moved to my working branch with includes all of the patches in the 
integration-20130121 branch [careful, patch 0023 has a conflict in 
mkfs.c] please others.  This time it was a very small problem in 
cmds-qgroup.c.  I am running it now.


Gene
--
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 00/13] Btrfs-progs: more patches for integration (integration-20130121)

2013-01-24 Thread Gene Czarcinski

On 01/24/2013 01:13 PM, David Sterba wrote:

On Tue, Jan 22, 2013 at 03:14:35PM -0500, Gene Czarcinski wrote:

On 01/21/2013 01:40 PM, David Sterba wrote:

On Sun, Jan 20, 2013 at 04:04:05PM -0500, Gene Czarcinski wrote:

I have done some additional scraping of the mailing list to
identify some low hanging fruit which I consider should
be merged into the btrfs-progs repository.

Thanks, I went through them and put together into an integration branch

   git://repo.or.cz/btrfs-progs-unstable/devel.git integration-20130121

There is a problem with one of the patches:
 detect if the disk we are formatting is a ssd

The commit comments appear to come from the patch I submitted. However, as I
said in the submission, the patch for mkfs.c has to be refitted because of
a conflict.  The conflict is a result of the patch:
 Fix compiler warnings on PPC64
which relocated the include kerncompat.h to a different line in the mkfs.c
file.

These merge conflicts are inevitable and normal (though sometimes not
that trivial). My initial aim was to build one linear branch only with
fixes and git-merge the patches that add features, but this will not be
easy to merge for much longer, so I'm going to do a linear integration
branch so others can take them as checkpoint to base the various
patchsets.

Yes, trying to merge branches with lots of changes are effectively 
impossible (impractical?) as far as I am concerned.  Unless it is simple 
I I understand exactly what is happening, I have found it easier/better 
to apply a set of patches one at a time and resolve problems manually.


I just got the subvol show patches applied.  I tried putting it into a 
separate branch and then doing a merge but I could not trust my results 
when I ran mergetool.  And, BTW they subvol show patches to apply with 
not very many problems.  My working branch currently has 44 commits over 
91d9eec and subvol show added another ten.


Gene
--
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 Add make archive

2013-01-23 Thread Gene Czarcinski

On 01/22/2013 04:52 PM, Mike Fleetwood wrote:

On 22 January 2013 17:22, Gene Czarcinskig...@czarc.net  wrote:

This adds the archive target to the Makefile which simply executes
do-archive.sh.  It also adds the remove of btrfs-progs.spec.in to

I think you mean btrfs-progs.spec without the .in as that's the generated file.


You are correct.
--
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/13] btrfs-progs: btrfs-image.c: Added NULL pointer check.

2013-01-23 Thread Gene Czarcinski

On 01/21/2013 10:56 AM, David Sterba wrote:

On Sun, Jan 20, 2013 at 04:04:06PM -0500, Gene Czarcinski wrote:

From: Nageswara R Sastrynasas...@in.ibm.com

Check for the return value of 'open_ctree()' before dereferencing it.

--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -491,6 +491,7 @@ static int create_metadump(const char *input, FILE *out, 
int num_threads,
int ret;
  
  	root = open_ctree(input, 0, 0);

+   BUG_ON(!root);

Bug_on is not the right fix here, I prefer a more extensive fix

http://permalink.gmane.org/gmane.comp.file-systems.btrfs/15305

which prints a message and exits.

The above patch is 1 of 4 that were submitted.  Should those other three 
be included also.  I did a couple of spot checks and the changes were 
not picked up in another patch.


A couple of things bother me about these 4 patches.  First of all, 
nobody commented about them on this mailing list --- either good or 
bad.  Second, if the descriptions and code is at all accurate, why were 
these patches not included in the flury of patches applied later in 
the year to bring btrfs-progs more up-to-date?


These patches may look good but almost none of the changes will apply 
to integration-20130121 or 91d9eec.
So some effort will be needed to refit/rebase these patches.  I am 
willing to do that if there is some agreement that this should be done.  
Of the 4 patches, the one addressing segfaults is the most serious.  The 
others deal with simple problems including one which changes spaces to 
tab characters.


Gene
--
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 00/10] add show sub-command for btrfs subvol cli

2013-01-23 Thread Gene Czarcinski

On 01/23/2013 03:12 AM, Anand Jain wrote:

David, Gene

Please accept this patch set which is on top of
   git://repo.or.cz/btrfs-progs-unstable/devel.git for-chris
Oops.  I am sorry to rain on your parade but the patches need another 
rebasing.  The ones in for-chris are the original set of patches David 
pulled together.  The bigger list is in the integration-20130121 
branch and your current version does not apply.


However, you may want to wait a bit as David has a few more patches he  
is working on.  Also, one of the new (not in for-chris) patches has a 
conflict with another patch in the first set.


Gene


to add 'show' sub-command feature for the btrfs subvol cli
as in an example below..

eg:
btrfs su list /mnt
ID 256 gen 54 top level 5 path sv1
ID 278 gen 56 top level 5 path sv1/snap1
ID 279 gen 54 top level 5 path sv2
ID 280 gen 41 top level 5 path sv2/snap1

btrfs su show /mnt/sv1
/mnt/sv1
Name:   sv1
uuid:   3a914db2-8a40-1e49-9382-126c595e9abf
Parent uuid:-
Creation time:  2013-01-10 12:16:18
Object ID:  256
Generation (Gen):   54
Gen at creation:5
Parent: 5
Top Level:  5
Snapshot(s):
snap1
FS_TREE/sv2/snap_sv1

Anand Jain (10):
   Btrfs-progs: move open_file_or_dir() to utils.c
   Btrfs-progs: move printing subvol list outside of btrfs_list_subvols
   Btrfs-progs: add parent uuid for snapshots
   Btrfs-progs: move struct root_info to btrfs-list.h
   Btrfs-progs: add function btrfs_get_subvol to get root_info of a
 subvol
   Btrfs-progs: add method to filter snapshots by parent uuid
   Btrfs-progs: put find_mount_root() in commands.h
   Btrfs-progs: make printing subvol extensible to newer layouts
   Btrfs-progs: make get_subvol_name non cmds-send specific
   Btrfs-progs: add show subcommand to subvol cli

  Makefile |   4 +-
  btrfs-list.c | 190 +---
  btrfs-list.h |  58 +++-
  btrfsctl.c   |   7 +-
  cmds-balance.c   |   1 +
  cmds-inspect.c   |   1 +
  cmds-qgroup.c|   1 +
  cmds-quota.c |   1 +
  cmds-send.c  |  12 ++--
  cmds-subvolume.c | 200 +--
  commands.h   |   7 +-
  common.c |  46 -
  man/btrfs.8.in   |   6 ++
  utils.c  |  30 -
  utils.h  |   3 +
  15 files changed, 428 insertions(+), 139 deletions(-)
  delete mode 100644 common.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


[PATCH 0/3] Btrfs-progs Add spec file template and script to create tarball

2013-01-22 Thread Gene Czarcinski
This series of patches adds an rpm spec file template for btrfs-progs and
a script to create an archive/tarball which includes an updated spec file.

The optional second patch adds make archive which executes do-archve.sh.

The optional third patch changes version.sh and btrfs-progs.spec.in
to handle future updates when the version changes.

Gene Czarcinski (3):
  Btrfs-progs Add rpm spec template and create tarball
  Btrfs-progs Add make archive
  Btrfs-progs Change rpm spec file to be handle version This
optional patch changes version.sh and the rpm spec file to
handle changes in the version and still work properly.  The
default version in version.sh is changed to VERSION and
v=$VERSION. The rpm spec file now update \$VERSION which will
not change. Signed-off-by: Gene Czarcinski g...@czarc.net

 Makefile|  6 +-
 btrfs-progs.spec.in | 46 +++
 do-archive.sh   | 62 +
 version.sh  |  3 ++-
 4 files changed, 115 insertions(+), 2 deletions(-)
 create mode 100644 btrfs-progs.spec.in
 create mode 100644 do-archive.sh

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


[PATCH 1/3] Btrfs-progs Add rpm spec template and create tarball

2013-01-22 Thread Gene Czarcinski
This patch adds a rpm spec file template for btrfs-progs.

The do-archive.sh script creates/updates the rpm spec file
and creates an archive of the current branch if the btrfs-progs
git repository does not have uncommitted changes.  The created
archive/tarball is of the form:
  btrfs-progs-git20130122.tar.gz
where the version is git appended with the date.  The version
is also plugged into the rpm spec file.  Additionally, the result of
  git describe --tags
is plugged into the rpm spec file so that version.sh will be
updated with the current version just like it would be
if created in the git repository.  See the comments in the
do-archive.sh file for additional information.
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 btrfs-progs.spec.in | 46 +++
 do-archive.sh   | 62 +
 2 files changed, 108 insertions(+)
 create mode 100644 btrfs-progs.spec.in
 create mode 100644 do-archive.sh

diff --git a/btrfs-progs.spec.in b/btrfs-progs.spec.in
new file mode 100644
index 000..b64e404
--- /dev/null
+++ b/btrfs-progs.spec.in
@@ -0,0 +1,46 @@
+Name:  btrfs-progs
+Version:   @VERSION@
+Release:   0
+Epoch: 1
+# Use epoch to override distribution packages
+%definereal_version @REALVERSION@
+URL:http://btrfs.wiki.kernel.org/index.php/Main_Page
+Summary:   Btrfs File System Utilities: %{real_version}
+License:   GPL v2 or later
+Group:  System Environment/Base
+
+Source0:   %{name}-%{version}.tar.gz
+
+BuildRoot:  %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires:  e2fsprogs-devel, libuuid-devel, zlib-devel, libacl-devel, 
libblkid-devel
+
+%define _root_sbindir /sbin
+
+%description
+The btrfs-progs package provides all the userpsace programs needed to create,
+check, modify and correct any inconsistencies in the btrfs filesystem.
+
+%prep
+%setup -q -c
+sed -i s/v0.20-rc1/%{real_version}/g 
$RPM_BUILD_DIR/%{name}-%{version}/version.sh
+
+%build
+make CFLAGS=$RPM_OPT_FLAGS %{?_smp_mflags}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make mandir=%{_mandir} bindir=%{_sbindir} install DESTDIR=$RPM_BUILD_ROOT
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc COPYING INSTALL
+%{_sbindir}/*
+%{_mandir}/man8/*
+
+%changelog
+* Mon Jan 22 2013 Gene Czarcinski g...@czarc.net
+- Initial generic rpm spec file.
+- note that much of this is from the Fedora 18 spec file.
diff --git a/do-archive.sh b/do-archive.sh
new file mode 100644
index 000..640c824
--- /dev/null
+++ b/do-archive.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+#
+# update btrfs-progs.spec and create archive
+#
+# Released under the GNU GPLv2
+# Tue 22 Jan 2013 10:21:07 EST GC
+#
+# The purpose of the script is to update a btrfs rpm spec file
+# and create an archive (tarball) with the spec file included.
+#
+# This tarball can be used as any other btrfs-progs tarball
+# would be used as well as to be used to create a binary
+# rpm with the following with the following examples:
+#
+#$ rpmbuild -ts btrfs-progs-git20130121.tar.gz
+#$ rpm -ivh SRPMS/btrfs-progs-git20130121.src.rpm
+#$ rpmbuild -ba --clean btrfs-progs-git20130121/btrfs-progs.spec
+# or
+#$ rpmbuild -ts btrfs-progs-git20130121.tar.gz
+#$ mock SRPMS/btrfs-progs-git20130121.src.rpm
+#
+# Portions of version.h are included (duplicated) here.
+# Spec file creation and archive creation are kept together
+# to ensure consistency as possible.
+
+VERSION=`date +%Y%m%d`
+VERSION=git$VERSION
+
+which git  /dev/null
+if [ $? == 0 -a -d .git ]; then
+   if ! tag=`git describe --tags 2/dev/null`; then
+   echo error getting tags, exiting do-archive-sh
+   exit 1
+   fi
+
+# Are there uncommitted changes?
+unmerged=`git update-index --refresh --unmerged`
+   if [ -n $unmerged ]; then
+   echo $unmerged
+echo uncommitted changes exist, exiting do-archive-sh
+   exit 1
+fi
+else
+   echo no git or not git repository, exiting do-archive-sh
+   exit 1
+fi
+
+if [ -e btrfs-progs.spec.in ]; then
+   sed -e s/@VERSION@/$VERSION/g \
+   -e s/@REALVERSION@/$tag/g \
+   btrfs-progs.spec.in btrfs-progs.spec
+fi
+
+git archive --format=tar -o btrfs-progs-$VERSION.tar HEAD
+if [ -e btrfs-progs.spec ]; then
+   tar --owner=root --group=root -rf \
+   btrfs-progs-$VERSION.tar btrfs-progs.spec
+fi
+rm -f btrfs-progs-$VERSION.tar.gz
+gzip -9 btrfs-progs-$VERSION.tar
+echo btrfs-progs-$VERSION.tar.gz created
+exit 0
-- 
1.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


[PATCH 2/3] Btrfs-progs Add make archive

2013-01-22 Thread Gene Czarcinski
This adds the archive target to the Makefile which simply executes
do-archive.sh.  It also adds the remove of btrfs-progs.spec.in to
make clean.
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 Makefile | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index d524f69..6812258 100644
--- a/Makefile
+++ b/Makefile
@@ -111,9 +111,13 @@ manpages:
 install-man:
cd man; $(MAKE) install
 
+archive:
+   bash do-archive.sh
+
 clean :
rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image 
btrfs-select-super \
- btrfs-zero-log btrfstune dir-test ioctl-test quick-test version.h
+ btrfs-zero-log btrfstune dir-test ioctl-test quick-test version.h 
\
+ btrfs-progs.spec
cd man; $(MAKE) clean
 
 install: $(progs) install-man
-- 
1.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


[PATCH 3/3] Btrfs-progs Change rpm spec file to be handle version This optional patch changes version.sh and the rpm spec file to handle changes in the version and still work properly. The default

2013-01-22 Thread Gene Czarcinski
---
 btrfs-progs.spec.in | 2 +-
 version.sh  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/btrfs-progs.spec.in b/btrfs-progs.spec.in
index b64e404..882efc7 100644
--- a/btrfs-progs.spec.in
+++ b/btrfs-progs.spec.in
@@ -22,7 +22,7 @@ check, modify and correct any inconsistencies in the btrfs 
filesystem.
 
 %prep
 %setup -q -c
-sed -i s/v0.20-rc1/%{real_version}/g 
$RPM_BUILD_DIR/%{name}-%{version}/version.sh
+sed -i s/\$VERSION/%{real_version}/g 
$RPM_BUILD_DIR/%{name}-%{version}/version.sh
 
 %build
 make CFLAGS=$RPM_OPT_FLAGS %{?_smp_mflags}
diff --git a/version.sh b/version.sh
index b81040e..84513a3 100644
--- a/version.sh
+++ b/version.sh
@@ -6,7 +6,8 @@
 # Copyright 2008, Oracle
 # Released under the GNU GPLv2
  
-v=v0.20-rc1
+VERSION=v0.20-rc1
+v=$VERSION
 
 which git  /dev/null
 if [ $? == 0 -a -d .git ]; then
-- 
1.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 01/13] btrfs-progs: btrfs-image.c: Added NULL pointer check.

2013-01-22 Thread Gene Czarcinski

On 01/21/2013 10:56 AM, David Sterba wrote:

On Sun, Jan 20, 2013 at 04:04:06PM -0500, Gene Czarcinski wrote:

From: Nageswara R Sastry nasas...@in.ibm.com

Check for the return value of 'open_ctree()' before dereferencing it.

--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -491,6 +491,7 @@ static int create_metadump(const char *input, FILE *out, 
int num_threads,
int ret;
  
  	root = open_ctree(input, 0, 0);

+   BUG_ON(!root);

Bug_on is not the right fix here, I prefer a more extensive fix

http://permalink.gmane.org/gmane.comp.file-systems.btrfs/15305

which prints a message and exits.


BUG_ON(root-nodesize != root-leafsize);
  
  	ret = metadump_init(metadump, root, out, num_threads,
I missed this better fix because I only started looking for outstanding 
patches starting in June/July 2012.


Besides, I suspect you are a lot more knowledgeable to make the judgment 
as to a good fix.


Gene
--
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 06/13] btrfs-show-super.c

2013-01-22 Thread Gene Czarcinski

On 01/21/2013 11:46 AM, David Sterba wrote:

On Sun, Jan 20, 2013 at 04:04:11PM -0500, Gene Czarcinski wrote:

remove extra blank line at EOF

The patch contents and description do not match.
First of all, this patch should have been 2 separate patches. Too late 
to fix that.


The patch which created btrfs-show-super.c had an extra line at the end 
and I got annoyed at git-am complaining about it.  This first patch 
fixes that.  This should have been a separate commit.


The other patch (which should have been its own commit) addresses this 
problem:

http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg19264.html

I could not see that it did any harm and it helped on at least one 
system type


I am not sure how it happened that I combined them.  If you want, I will 
resubmit them the way it should be ... two separate patches with two 
separate commits.


Gene



--- a/man/Makefile
+++ b/man/Makefile
@@ -1,4 +1,4 @@
-GZIP=gzip
+GZIPCMD=gzip

I'm not sure if this change is needed, does it stick to some well-known
or established style in makefiles?

david




--
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 00/13] Btrfs-progs: more patches for integration (integration-20130121)

2013-01-22 Thread Gene Czarcinski
Thanks.  I am currently running with all of my submissions and 
everything is working.  I will pull your integration branch and switch 
to that instead of 13 patch set so I can test them.  This will be on top 
of the original two sets of patches.


Gene

On 01/21/2013 01:40 PM, David Sterba wrote:

On Sun, Jan 20, 2013 at 04:04:05PM -0500, Gene Czarcinski wrote:

I have done some additional scraping of the mailing list to
identify some low hanging fruit which I consider should
be merged into the btrfs-progs repository.

Thanks, I went through them and put together into an integration branch

   git://repo.or.cz/btrfs-progs-unstable/devel.git integration-20130121

I've modified the signed-off-by lines when I knew who was the author or
contributed to the patch. Please let me know if I've messed the credits
and fame attribution.

There are three more patches that I've picked from my distro patch queue (and
were sent to the list long ago) they're placed at the top of the shortlog.

Arne Jansen (1):
   Btrfs-progs: bugfix for scrubbing single devices

Wang Sheng-Hui (1):
   btrfs-progs: add malloc check in transaction.h/btrfs_start_transaction

Goffredo Baroncelli (1):
   Ignore the error ENXIO and ENOMEDIUM during a devs scan

Arvin Schnell (1):
   btrfs-progs: initialize data before send ioctl

Danny Kukawka (1):
   btrfs-progs: Handle errors returned from open_ctree

Jan Schmidt (2):
   Btrfs-progs: correcting misnamed parameter options for btrfs send
   Btrfs-progs: bugfix for subvolume parent determination in btrfs send

Josef Bacik (2):
   Btrfs-progs: detect if the disk we are formatting is a ssd
   Btrfs-progs: add btrfs device ready command

Nirbheek Chauhan (1):
   Btrfs-progs: fix resolving of loop devices

Stefan Behrens (1):
   btrfs-progs: Add btrfs-show-super

Ulrik (1):
   Btrfs-progs: correct btrfs receive usage string

Wang Shilong (3):
   Btrfs-progs: fix arg parsing for btrfs qgroup limit commands
   Btrfs-progs: clean up reduplicate parse_qgroupid() and replace atoi with 
strtoull
   Btrfs-progs: check the relation of two group by real level numbers

david




--
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 13/13] trivial patch for btrfs-progs

2013-01-22 Thread Gene Czarcinski

On 01/21/2013 12:40 PM, David Sterba wrote:

On Sun, Jan 20, 2013 at 04:04:18PM -0500, Gene Czarcinski wrote:

From: Arvin Schnell aschn...@suse.de

Hi,

please find attached a trivial patch for btrfs-progs. Likely not
strictly needed but I noticed valgrind complaining about
uninitialised memory in the ioctl call.

Regards,
   Arvin

Signed-off-by: Gene Czarcinski g...@czarc.net

I've updated the changelog to say
---
 btrfs-progs: initialize data before send ioctl

 Likely not strictly needed but I noticed valgrind complaining about
 uninitialised memory in the ioctl call.

 Signed-off-by: Arvin Schnell aschn...@suse.de
---

is it ok for both of you?

david

Of course.  It is usually a good thing to not make assumptions where you 
do not have to.


Gene
--
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] Fix Makefile for gzip

2013-01-22 Thread Gene Czarcinski
This is the patch that 6 of 13 should have been and was not.

Here is the original posting:
http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg19264.html

Christian Hesse (1):
  fix btrfs-progs build

 man/Makefile | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

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


[PATCH] fix btrfs-progs build

2013-01-22 Thread Gene Czarcinski
From: Christian Hesse l...@eworm.de

Hello everybody,

man pages for btrfs-progs are compressed by gzip by default. In Makefile the
variable GZIP is use, this evaluates to 'gzip gzip' on my system. From man
gzip:

 The environment variable GZIP can hold a set of default options for gzip.
 These options are interpreted first and can be overwritten by explicit
 command line parameters.

So using any other variable name fixes this. Patch is attached.

Signed-off-by: Gene Czarcinski g...@czarc.net
---
 man/Makefile | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/man/Makefile b/man/Makefile
index 4a90b75..f7b57f7 100644
--- a/man/Makefile
+++ b/man/Makefile
@@ -1,4 +1,4 @@
-GZIP=gzip
+GZIPCMD=gzip
 INSTALL= install
 
 prefix ?= /usr/local
@@ -12,22 +12,22 @@ MANPAGES = mkfs.btrfs.8.gz btrfsctl.8.gz btrfsck.8.gz 
btrfs-image.8.gz \
 all: $(MANPAGES)
 
 mkfs.btrfs.8.gz: mkfs.btrfs.8.in
-   $(GZIP) -n -c mkfs.btrfs.8.in  mkfs.btrfs.8.gz
+   $(GZIPCMD) -n -c mkfs.btrfs.8.in  mkfs.btrfs.8.gz
 
 btrfs.8.gz: btrfs.8.in
-   $(GZIP) -n -c btrfs.8.in  btrfs.8.gz
+   $(GZIPCMD) -n -c btrfs.8.in  btrfs.8.gz
 
 btrfsctl.8.gz: btrfsctl.8.in
-   $(GZIP) -n -c btrfsctl.8.in  btrfsctl.8.gz
+   $(GZIPCMD) -n -c btrfsctl.8.in  btrfsctl.8.gz
 
 btrfsck.8.gz: btrfsck.8.in
-   $(GZIP) -n -c btrfsck.8.in  btrfsck.8.gz
+   $(GZIPCMD) -n -c btrfsck.8.in  btrfsck.8.gz
 
 btrfs-image.8.gz: btrfs-image.8.in
-   $(GZIP) -n -c btrfs-image.8.in  btrfs-image.8.gz
+   $(GZIPCMD) -n -c btrfs-image.8.in  btrfs-image.8.gz
 
 btrfs-show.8.gz: btrfs-show.8.in
-   $(GZIP) -n -c btrfs-show.8.in  btrfs-show.8.gz
+   $(GZIPCMD) -n -c btrfs-show.8.in  btrfs-show.8.gz
 
 clean :
rm -f $(MANPAGES)
-- 
1.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 2/6] Fedora 18 - build-fixes.patch

2013-01-22 Thread Gene Czarcinski

I believe that this if the likely source of this patch:
http://article.gmane.org/gmane.comp.file-systems.btrfs/4547

I do wonder how much this is still applicable.  However, it has been in 
the btrfs-progs package for Fedora 15, 16, 17, and 18 plus likely some 
versions of RHEL.


On 01/19/2013 01:06 PM, Gene Czarcinski wrote:

Signed-off-by: Gene Czarcinski g...@czarc.net
---
  btrfsck.c | 2 ++
  mkfs.c| 4 ++--
  2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/btrfsck.c b/btrfsck.c
index a851008..6274ff7 100644
--- a/btrfsck.c
+++ b/btrfsck.c
@@ -22,7 +22,9 @@
  #include stdlib.h
  #include unistd.h
  #include fcntl.h
+#include sys/types.h
  #include sys/stat.h
+#include unistd.h
  #include getopt.h
  #include kerncompat.h
  #include ctree.h
diff --git a/mkfs.c b/mkfs.c
index fbf8319..d123d5f 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1206,7 +1206,7 @@ int main(int ac, char **av)
u64 alloc_start = 0;
u64 metadata_profile = 0;
u64 data_profile = 0;
-   u32 leafsize = getpagesize();
+   u32 leafsize = sysconf(_SC_PAGESIZE);
u32 sectorsize = 4096;
u32 nodesize = leafsize;
u32 stripesize = 4096;
@@ -1282,7 +1282,7 @@ int main(int ac, char **av)
print_usage();
}
}
-   sectorsize = max(sectorsize, (u32)getpagesize());
+   sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE));
if (check_leaf_or_node_size(leafsize, sectorsize))
exit(1);
if (check_leaf_or_node_size(nodesize, sectorsize))


--
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/6] Fedora 18 - fix-labels.patch

2013-01-22 Thread Gene Czarcinski

Here is the source of this patch:
http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg01850.html

and  the update that is the current patch:
http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg01851.html

Gene

On 01/19/2013 01:06 PM, Gene Czarcinski wrote:

Signed-off-by: Gene Czarcinski g...@czarc.net
---
  mkfs.c | 7 ---
  1 file changed, 7 deletions(-)

diff --git a/mkfs.c b/mkfs.c
index d123d5f..8c291c9 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -352,7 +352,6 @@ static u64 parse_profile(char *s)
  
  static char *parse_label(char *input)

  {
-   int i;
int len = strlen(input);
  
  	if (len = BTRFS_LABEL_SIZE) {

@@ -360,12 +359,6 @@ static char *parse_label(char *input)
BTRFS_LABEL_SIZE - 1);
exit(1);
}
-   for (i = 0; i  len; i++) {
-   if (input[i] == '/' || input[i] == '\\') {
-   fprintf(stderr, invalid label %s\n, input);
-   exit(1);
-   }
-   }
return strdup(input);
  }
  


--
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 4/6] Fedora 18 - modified valgrind.patch

2013-01-22 Thread Gene Czarcinski

Finally, here is the source for this patch:
http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg02659.html

On 01/19/2013 01:06 PM, Gene Czarcinski wrote:

A small part of this patch proved unnecessary because it was
already corrected by the plug a memory leak reported by cppcheck
patch.

Signed-off-by: Gene Czarcinski g...@czarc.net
---
  disk-io.c  | 16 +++-
  extent-cache.c | 11 +++
  extent-cache.h |  1 +
  extent-tree.c  | 10 ++
  volumes.c  | 16 +++-
  volumes.h  |  1 +
  6 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/disk-io.c b/disk-io.c
index c4d4631..5b6c6b1 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -631,7 +631,7 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const 
char *path,
struct btrfs_root *chunk_root = malloc(sizeof(struct btrfs_root));
struct btrfs_root *dev_root = malloc(sizeof(struct btrfs_root));
struct btrfs_root *csum_root = malloc(sizeof(struct btrfs_root));
-   struct btrfs_fs_info *fs_info = malloc(sizeof(*fs_info));
+   struct btrfs_fs_info *fs_info = malloc(sizeof(struct btrfs_fs_info));
int ret;
struct btrfs_super_block *disk_super;
struct btrfs_fs_devices *fs_devices = NULL;
@@ -655,7 +655,7 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const 
char *path,
goto out;
}
  
-	memset(fs_info, 0, sizeof(*fs_info));

+   memset(fs_info, 0, sizeof(struct btrfs_fs_info));
fs_info-tree_root = tree_root;
fs_info-extent_root = extent_root;
fs_info-chunk_root = chunk_root;
@@ -1084,15 +1084,19 @@ static int close_all_devices(struct btrfs_fs_info 
*fs_info)
  {
struct list_head *list;
struct list_head *next;
+   struct list_head *tmp;
struct btrfs_device *device;
  
-	return 0;

-
list = fs_info-fs_devices-devices;
-   list_for_each(next, list) {
+   list_for_each_safe(next, tmp, list) {
device = list_entry(next, struct btrfs_device, dev_list);
close(device-fd);
+   list_del(device-dev_list);
+   free(device-name);
+   free(device-label);
+   free(device);
}
+   free(fs_info-fs_devices);
return 0;
  }
  
@@ -1142,12 +1146,14 @@ int close_ctree(struct btrfs_root *root)

extent_io_tree_cleanup(fs_info-pinned_extents);
extent_io_tree_cleanup(fs_info-pending_del);
extent_io_tree_cleanup(fs_info-extent_ins);
+   btrfs_mapping_tree_free(fs_info-mapping_tree);
  
  	free(fs_info-tree_root);

free(fs_info-extent_root);
free(fs_info-chunk_root);
free(fs_info-dev_root);
free(fs_info-csum_root);
+   free(fs_info-log_root_tree);
free(fs_info);
  
  	return 0;

diff --git a/extent-cache.c b/extent-cache.c
index 3dd6434..84d4bbc 100644
--- a/extent-cache.c
+++ b/extent-cache.c
@@ -168,3 +168,14 @@ void remove_cache_extent(struct cache_tree *tree,
rb_erase(pe-rb_node, tree-root);
  }
  
+void free_cache_tree(struct cache_tree *tree)

+{
+   struct rb_node *node;
+   struct cache_extent *cache;
+
+   while ((node = rb_last(tree-root)) != NULL) {
+   cache = rb_entry(node, struct cache_extent, rb_node);
+   remove_cache_extent(tree, cache);
+   free(cache);
+   }
+}
diff --git a/extent-cache.h b/extent-cache.h
index 7f2f2a6..1696bc2 100644
--- a/extent-cache.h
+++ b/extent-cache.h
@@ -43,6 +43,7 @@ struct cache_extent *find_cache_extent(struct cache_tree 
*tree,
  int insert_cache_extent(struct cache_tree *tree, u64 start, u64 size);
  int insert_existing_cache_extent(struct cache_tree *tree,
 struct cache_extent *pe);
+void free_cache_tree(struct cache_tree *tree);
  
  static inline int cache_tree_empty(struct cache_tree *tree)

  {
diff --git a/extent-tree.c b/extent-tree.c
index 20cdffa..d644d9a 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2999,6 +2999,7 @@ out:
  
  int btrfs_free_block_groups(struct btrfs_fs_info *info)

  {
+   struct btrfs_space_info *space_info;
u64 start;
u64 end;
u64 ptr;
@@ -3022,6 +3023,15 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
clear_extent_dirty(info-free_space_cache, start,
   end, GFP_NOFS);
}
+
+   while (!list_empty(info-space_info)) {
+   space_info = list_entry(info-space_info.next,
+   struct btrfs_space_info,
+   list);
+   list_del(space_info-list);
+   kfree(space_info);
+   }
+
return 0;
  }
  
diff --git a/volumes.c b/volumes.c

index 581c298..37b0074 100644
--- a/volumes.c
+++ b/volumes.c
@@ -959,6 +959,20 @@ void btrfs_mapping_init(struct btrfs_mapping_tree *tree)
cache_tree_init(tree-cache_tree);
  }
  
+void

Re: [PATCH 1/6] Fedora 18 - btrfs-init-dev-list.patch

2013-01-22 Thread Gene Czarcinski

I could not find a source for this patch on the mailing list

On 01/19/2013 01:06 PM, Gene Czarcinski wrote:

Signed-off-by: Gene Czarcinski g...@czarc.net
---
  utils.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/utils.c b/utils.c
index 938f9a5..51b78d5 100644
--- a/utils.c
+++ b/utils.c
@@ -477,7 +477,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
u64 num_devs;
int ret;
  
-	device = kmalloc(sizeof(*device), GFP_NOFS);

+   device = kzalloc(sizeof(*device), GFP_NOFS);
if (!device)
return -ENOMEM;
buf = kmalloc(sectorsize, GFP_NOFS);
@@ -503,6 +503,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
device-bytes_used = 0;
device-total_ios = 0;
device-dev_root = root-fs_info-dev_root;
+   INIT_LIST_HEAD(device-dev_list);
  
  	ret = btrfs_add_device(trans, root, device);

BUG_ON(ret);


--
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 12/13] Btrfs-progs: disable qgroupid 0 for quota_tree

2013-01-21 Thread Gene Czarcinski
At the request of the patch's author, this should be dropped as it has 
been addressed by a patch to the kernel.


On 01/20/2013 04:04 PM, Gene Czarcinski wrote:

From: Wang Shilong wangsl-f...@cn.fujitsu.com

In kernel, qgroupid 0 is a special number when we run the quota group limit 
command.

So, we should not be able to create a quota group whose id is 0, otherwise the 
kernel
can't deal with it. Fix it.

Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com
Signed-off-by: Miao Xie mi...@cn.fujitsu.com
Signed-off-by: Gene Czarcinski g...@czarc.net
---
  cmds-qgroup.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 70019d0..dfff1b9 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -86,6 +86,10 @@ static int qgroup_create(int create, int argc, char **argv)
args.create = create;
args.qgroupid = parse_qgroupid(argv[1]);
  
+	if (!args.qgroupid) {

+   fprintf(stderr, ERROR: qgroup 0 is not supported\n);
+   return 30;
+   }
fd = open_file_or_dir(path);
if (fd  0) {
fprintf(stderr, ERROR: can't access '%s'\n, path);


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


[PATCH 00/13] Btrfs-progs: more patches for integration

2013-01-20 Thread Gene Czarcinski
I have done some additional scraping of the mailing list to
identify some low hanging fruit which I consider should
be merged into the btrfs-progs repository.

All of the patches below were applied on top of the 19 bugfix
patches pulled together by David Sterba and the 6 patches
now part of the Fedora 18 btrfs-progs package.  All of this
compiles but further testing is obviously needed.

For the most part, these patches are bugfixes and they all
appeared resonable but inspection by other eyes would
be appreciated.  There is also one simple function
addition in the form or the btrfs-show-super command.

Arvin Schnell (1):
  trivial patch for btrfs-progs

Chen Yang (1):
  Btrfs-progs: Fix a segmentation fault in btrfstune when device is
invalid.

Gene Czarcinski (1):
  btrfs-show-super.c

Goffredo Baroncelli (1):
  Add btrfs-show-super

Jan Schmidt (2):
  Btrfs-progs: correcting misnamed parameter options for btrfs send
  Btrfs-progs: bugfix for subvolume parent determination in btrfs send

Nageswara R Sastry (1):
  btrfs-progs: btrfs-image.c: Added NULL pointer check.

Nirbheek Chauhan (1):
  Btrfs-progs: fix resolving of loop devices

Ulrik (1):
  Btrfs-progs: correct btrfs receive usage string

Wang Shilong (4):
  Btrfs-progs: fix arg parsing for btrfs qgroup limit commands
  Btrfs-progs: clean up reduplicate parse_qgroupid() and replace atoi
with strtoull
  Btrfs-progs: check the relation of two group by real level numbers
  Btrfs-progs: disable qgroupid 0 for quota_tree

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


[PATCH 01/13] btrfs-progs: btrfs-image.c: Added NULL pointer check.

2013-01-20 Thread Gene Czarcinski
From: Nageswara R Sastry nasas...@in.ibm.com

Check for the return value of 'open_ctree()' before dereferencing it.

Signed-off-by: Nageswara R Sastry nasas...@in.ibm.com
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 btrfs-image.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/btrfs-image.c b/btrfs-image.c
index f2bbcc8..2a33a55 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -491,6 +491,7 @@ static int create_metadump(const char *input, FILE *out, 
int num_threads,
int ret;
 
root = open_ctree(input, 0, 0);
+   BUG_ON(!root);
BUG_ON(root-nodesize != root-leafsize);
 
ret = metadump_init(metadump, root, out, num_threads,
-- 
1.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


[PATCH 06/13] btrfs-show-super.c

2013-01-20 Thread Gene Czarcinski
remove extra blank line at EOF
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 btrfs-show-super.c |  1 -
 man/Makefile   | 14 +++---
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/btrfs-show-super.c b/btrfs-show-super.c
index a9e2524..7c66d84 100644
--- a/btrfs-show-super.c
+++ b/btrfs-show-super.c
@@ -281,4 +281,3 @@ static void dump_superblock(struct btrfs_super_block *sb)
printf(dev_item.generation\t%llu\n, (unsigned long long)
   btrfs_stack_device_generation(sb-dev_item));
 }
-
diff --git a/man/Makefile b/man/Makefile
index 4a90b75..f7b57f7 100644
--- a/man/Makefile
+++ b/man/Makefile
@@ -1,4 +1,4 @@
-GZIP=gzip
+GZIPCMD=gzip
 INSTALL= install
 
 prefix ?= /usr/local
@@ -12,22 +12,22 @@ MANPAGES = mkfs.btrfs.8.gz btrfsctl.8.gz btrfsck.8.gz 
btrfs-image.8.gz \
 all: $(MANPAGES)
 
 mkfs.btrfs.8.gz: mkfs.btrfs.8.in
-   $(GZIP) -n -c mkfs.btrfs.8.in  mkfs.btrfs.8.gz
+   $(GZIPCMD) -n -c mkfs.btrfs.8.in  mkfs.btrfs.8.gz
 
 btrfs.8.gz: btrfs.8.in
-   $(GZIP) -n -c btrfs.8.in  btrfs.8.gz
+   $(GZIPCMD) -n -c btrfs.8.in  btrfs.8.gz
 
 btrfsctl.8.gz: btrfsctl.8.in
-   $(GZIP) -n -c btrfsctl.8.in  btrfsctl.8.gz
+   $(GZIPCMD) -n -c btrfsctl.8.in  btrfsctl.8.gz
 
 btrfsck.8.gz: btrfsck.8.in
-   $(GZIP) -n -c btrfsck.8.in  btrfsck.8.gz
+   $(GZIPCMD) -n -c btrfsck.8.in  btrfsck.8.gz
 
 btrfs-image.8.gz: btrfs-image.8.in
-   $(GZIP) -n -c btrfs-image.8.in  btrfs-image.8.gz
+   $(GZIPCMD) -n -c btrfs-image.8.in  btrfs-image.8.gz
 
 btrfs-show.8.gz: btrfs-show.8.in
-   $(GZIP) -n -c btrfs-show.8.in  btrfs-show.8.gz
+   $(GZIPCMD) -n -c btrfs-show.8.in  btrfs-show.8.gz
 
 clean :
rm -f $(MANPAGES)
-- 
1.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


[PATCH 05/13] Add btrfs-show-super

2013-01-20 Thread Gene Czarcinski
From: Goffredo Baroncelli kreij...@inwind.it

Signed-off-by: Goffredo Baroncelli kreij...@inwind.it
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 Makefile   |   5 +-
 btrfs-show-super.c | 284 +
 2 files changed, 288 insertions(+), 1 deletion(-)
 create mode 100644 btrfs-show-super.c

diff --git a/Makefile b/Makefile
index c7fd97d..d524f69 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ RESTORE_LIBS=-lz
 
 progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck \
btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \
-   btrfs-find-root btrfs-restore btrfstune
+   btrfs-find-root btrfs-restore btrfstune btrfs-show-super
 
 # make C=1 to enable sparse
 ifdef C
@@ -75,6 +75,9 @@ btrfs-debug-tree: $(objects) debug-tree.o
 btrfs-zero-log: $(objects) btrfs-zero-log.o
$(CC) $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o 
$(LDFLAGS) $(LIBS)
 
+btrfs-show-super: $(objects) btrfs-show-super.o
+   $(CC) $(CFLAGS) -o btrfs-show-super $(objects) btrfs-show-super.o 
$(LDFLAGS) $(LIBS)
+
 btrfs-select-super: $(objects) btrfs-select-super.o
$(CC) $(CFLAGS) -o btrfs-select-super $(objects) btrfs-select-super.o 
$(LDFLAGS) $(LIBS)
 
diff --git a/btrfs-show-super.c b/btrfs-show-super.c
new file mode 100644
index 000..a9e2524
--- /dev/null
+++ b/btrfs-show-super.c
@@ -0,0 +1,284 @@
+/*
+ * Copyright (C) 2012 STRATO AG.  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 v2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will 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 to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ */
+
+#define _XOPEN_SOURCE 500
+#define _GNU_SOURCE 1
+#include stdio.h
+#include stdlib.h
+#include unistd.h
+#include fcntl.h
+#include sys/stat.h
+#include ctype.h
+#include uuid/uuid.h
+#include errno.h
+
+#include kerncompat.h
+#include ctree.h
+#include disk-io.h
+#include print-tree.h
+#include transaction.h
+#include list.h
+#include version.h
+#include utils.h
+#include crc32c.h
+
+static void print_usage(void);
+static void dump_superblock(struct btrfs_super_block *sb);
+int main(int argc, char **argv);
+static int load_and_dump_sb(char *, int fd, u64 sb_bytenr);
+
+
+static void print_usage(void)
+{
+   fprintf(stderr,
+   usage: btrfs-show-super [-i super_mirror|-a] dev [dev..]\n);
+   fprintf(stderr, \tThe super_mirror number is between 0 and %d.\n,
+   BTRFS_SUPER_MIRROR_MAX - 1);
+   fprintf(stderr, \tIf -a is passed all the superblocks are showed.\n,
+   BTRFS_SUPER_MIRROR_MAX - 1);
+   fprintf(stderr, %s\n, BTRFS_BUILD_VERSION);
+}
+
+int main(int argc, char **argv)
+{
+   int opt;
+   int all = 0;
+   char *filename;
+   int fd = -1;
+   int arg, i;
+   u64 sb_bytenr = btrfs_sb_offset(0);
+
+   while ((opt = getopt(argc, argv, ai:)) != -1) {
+   switch (opt) {
+   case 'i':
+   arg = atoi(optarg);
+
+   if (arg  0 || arg = BTRFS_SUPER_MIRROR_MAX) {
+   fprintf(stderr,
+   Illegal super_mirror %d\n,
+   arg);
+   print_usage();
+   exit(1);
+   }
+   sb_bytenr = btrfs_sb_offset(arg);
+   break;
+
+   case 'a':
+   all = 1;
+   break;
+
+   default:
+   print_usage();
+   exit(1);
+   }
+   }
+
+   if (argc  optind + 1) {
+   print_usage();
+   exit(1);
+   }
+
+   for (i = optind ; i  argc ; i++) {
+   filename = argv[i];
+   fd = open(filename, O_RDONLY, 0666);
+   if (fd  0) {
+   fprintf(stderr, Could not open %s\n, filename);
+   close(fd);
+   exit(1);
+   }
+
+   if (all) {
+   int idx;
+   for (idx = 0 ; idx  BTRFS_SUPER_MIRROR_MAX ; idx++) {
+   sb_bytenr = btrfs_sb_offset(idx);
+   if (load_and_dump_sb(filename, fd, sb_bytenr)) {
+   close(fd);
+   exit(1

[PATCH 12/13] Btrfs-progs: disable qgroupid 0 for quota_tree

2013-01-20 Thread Gene Czarcinski
From: Wang Shilong wangsl-f...@cn.fujitsu.com

In kernel, qgroupid 0 is a special number when we run the quota group limit 
command.

So, we should not be able to create a quota group whose id is 0, otherwise the 
kernel
can't deal with it. Fix it.

Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com
Signed-off-by: Miao Xie mi...@cn.fujitsu.com
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 cmds-qgroup.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 70019d0..dfff1b9 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -86,6 +86,10 @@ static int qgroup_create(int create, int argc, char **argv)
args.create = create;
args.qgroupid = parse_qgroupid(argv[1]);
 
+   if (!args.qgroupid) {
+   fprintf(stderr, ERROR: qgroup 0 is not supported\n);
+   return 30;
+   }
fd = open_file_or_dir(path);
if (fd  0) {
fprintf(stderr, ERROR: can't access '%s'\n, path);
-- 
1.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


[PATCH 13/13] trivial patch for btrfs-progs

2013-01-20 Thread Gene Czarcinski
From: Arvin Schnell aschn...@suse.de

Hi,

please find attached a trivial patch for btrfs-progs. Likely not
strictly needed but I noticed valgrind complaining about
uninitialised memory in the ioctl call.

Regards,
  Arvin

Signed-off-by: Gene Czarcinski g...@czarc.net
---
 cmds-send.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cmds-send.c b/cmds-send.c
index b33c802..595a5d0 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -273,6 +273,7 @@ static int do_send(struct btrfs_send *send, u64 root_id, 
u64 parent_root)
goto out;
}
 
+   memset(io_send, 0, sizeof(io_send));
io_send.send_fd = pipefd[1];
send-send_fd = pipefd[0];
 
-- 
1.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


[PATCH 11/13] Btrfs-progs: check the relation of two group by real level numbers

2013-01-20 Thread Gene Czarcinski
From: Wang Shilong wangsl-f...@cn.fujitsu.com

Comparing qgroupid is not good way to check the relationship of two groups,
the right way is to compare the real level numbers.

Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com
Signed-off-by: Miao Xie mi...@cn.fujitsu.com
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 cmds-qgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index c4122bf..70019d0 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -50,7 +50,7 @@ static int qgroup_assign(int assign, int argc, char **argv)
/*
 * FIXME src should accept subvol path
 */
-   if (args.src = args.dst) {
+   if ((args.src  48) = (args.dst  48)) {
fprintf(stderr, ERROR: bad relation requested '%s'\n, path);
return 12;
}
-- 
1.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


[PATCH 09/13] Btrfs-progs: fix arg parsing for btrfs qgroup limit commands

2013-01-20 Thread Gene Czarcinski
From: Wang Shilong wangsl-f...@cn.fujitsu.com

We can use this command in two ways.
1. btrfs qgroup limit size qgroupid path
2. btrfs qgroup limit size path

Before applying this patch, we differentiate them by check the parsing result
of the second argument. It is not so good because it may make some mistakes,
For example:
  btrfs qgroup limit 1M 123456
^ It is a subvolume name.

In fact, we can differentiate them just by the number of arguments, so fix it
by this way.

Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com
Signed-off-by: Miao Xie mi...@cn.fujitsu.com
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 cmds-qgroup.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 1525c11..129a4f0 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -383,7 +383,6 @@ static int cmd_qgroup_limit(int argc, char **argv)
}
 
memset(args, 0, sizeof(args));
-   args.qgroupid = parse_qgroupid(argv[optind + 1]);
if (size) {
if (compressed)
args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
@@ -397,9 +396,8 @@ static int cmd_qgroup_limit(int argc, char **argv)
}
}
 
-   if (args.qgroupid == 0) {
-   if (check_argc_exact(argc - optind, 2))
-   usage(cmd_qgroup_limit_usage);
+   if (argc - optind == 2) {
+   args.qgroupid = 0;
path = argv[optind + 1];
ret = test_issubvolume(path);
if (ret  0) {
@@ -415,11 +413,11 @@ static int cmd_qgroup_limit(int argc, char **argv)
 * keep qgroupid at 0, this indicates that the subvolume the
 * fd refers to is to be limited
 */
-   } else {
-   if (check_argc_exact(argc - optind, 3))
-   usage(cmd_qgroup_limit_usage);
+   } else if (argc - optind == 3) {
+   args.qgroupid = parse_qgroupid(argv[optind + 1]);
path = argv[optind + 2];
-   }
+   } else
+   usage(cmd_qgroup_limit_usage);
 
fd = open_file_or_dir(path);
if (fd  0) {
-- 
1.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


[PATCH 10/13] Btrfs-progs: clean up reduplicate parse_qgroupid() and replace atoi with strtoull

2013-01-20 Thread Gene Czarcinski
From: Wang Shilong wangsl-f...@cn.fujitsu.com

1. parse_qgroupid() is implemented twice, clean up the reduplicate code.
2. atoi() can not detect errors, so use strtoull() instead of it.

Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com
Signed-off-by: Miao Xie mi...@cn.fujitsu.com
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 cmds-qgroup.c | 15 +--
 qgroup.c  | 22 ++
 qgroup.h  |  2 ++
 3 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 129a4f0..c4122bf 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -24,26 +24,13 @@
 #include ioctl.h
 
 #include commands.h
+#include qgroup.h
 
 static const char * const qgroup_cmd_group_usage[] = {
btrfs qgroup command [options] path,
NULL
 };
 
-static u64 parse_qgroupid(char *p)
-{
-   char *s = strchr(p, '/');
-   u64 level;
-   u64 id;
-
-   if (!s)
-   return atoll(p);
-   level = atoll(p);
-   id = atoll(s + 1);
-
-   return (level  48) | id;
-}
-
 static int qgroup_assign(int assign, int argc, char **argv)
 {
int ret = 0;
diff --git a/qgroup.c b/qgroup.c
index 4083b57..dafde12 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -22,15 +22,29 @@
 u64 parse_qgroupid(char *p)
 {
char *s = strchr(p, '/');
+   char *ptr_src_end = p + strlen(p);
+   char *ptr_parse_end = NULL;
u64 level;
u64 id;
 
-   if (!s)
-   return atoll(p);
-   level = atoll(p);
-   id = atoll(s + 1);
+   if (!s) {
+   id = strtoull(p, ptr_parse_end, 10);
+   if (ptr_parse_end != ptr_src_end)
+   goto err;
+   return id;
+   }
+   level = strtoull(p, ptr_parse_end, 10);
+   if (ptr_parse_end != s)
+   goto err;
+
+   id = strtoull(s+1, ptr_parse_end, 10);
+   if (ptr_parse_end != ptr_src_end)
+   goto  err;
 
return (level  48) | id;
+err:
+   fprintf(stderr, ERROR:invalid qgroupid\n);
+   exit(-1);
 }
 
 int qgroup_inherit_size(struct btrfs_qgroup_inherit *p)
diff --git a/qgroup.h b/qgroup.h
index f7af8c5..ad14c88 100644
--- a/qgroup.h
+++ b/qgroup.h
@@ -20,7 +20,9 @@
 #define _BTRFS_QGROUP_H
 
 #include ioctl.h
+#include kerncompat.h
 
+u64 parse_qgroupid(char *p);
 int qgroup_inherit_size(struct btrfs_qgroup_inherit *p);
 int qgroup_inherit_realloc(struct btrfs_qgroup_inherit **inherit,
   int incgroups, int inccopies);
-- 
1.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


[PATCH 08/13] Btrfs-progs: bugfix for subvolume parent determination in btrfs send

2013-01-20 Thread Gene Czarcinski
From: Jan Schmidt list.bt...@jan-o-sch.net

We missed to add the default subvolume, because it has no ROOT_BACKREF_ITEM.
This made get_parent always fail for direct decendants of the default
subvolume, resulting in lots of full streams where incremental streams were
requested.

Signed-off-by: Jan Schmidt list.bt...@jan-o-sch.net
Reviewed-by: Alexander Block abloc...@googlemail.com
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 send-utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/send-utils.c b/send-utils.c
index fcde5c2..d8d3972 100644
--- a/send-utils.c
+++ b/send-utils.c
@@ -240,7 +240,8 @@ int subvol_uuid_search_init(int mnt_fd, struct 
subvol_uuid_search *s)
memcpy(root_item, root_item_ptr,
sizeof(root_item));
root_item_valid = 1;
-   } else if (sh-type == BTRFS_ROOT_BACKREF_KEY) {
+   } else if (sh-type == BTRFS_ROOT_BACKREF_KEY ||
+  root_item_valid) {
if (!root_item_valid)
goto skip;
 
@@ -274,7 +275,6 @@ int subvol_uuid_search_init(int mnt_fd, struct 
subvol_uuid_search *s)
subvol_uuid_search_add(s, si);
root_item_valid = 0;
} else {
-   root_item_valid = 0;
goto skip;
}
 
-- 
1.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


[PATCH 04/13] Btrfs-progs: Fix a segmentation fault in btrfstune when device is invalid.

2013-01-20 Thread Gene Czarcinski
From: Chen Yang chenyang.f...@cn.fujitsu.com

When open_ctree(device, ...) failed, the return value should be checked.

Signed-off-by: Cheng Yang chenyang.f...@cn.fujitsu.com
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 btrfstune.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/btrfstune.c b/btrfstune.c
index 47830c5..07648d5 100644
--- a/btrfstune.c
+++ b/btrfstune.c
@@ -107,6 +107,8 @@ int main(int argc, char *argv[])
}
 
root = open_ctree(device, 0, 1);
+   if (!root)
+   return 1;
 
if (seeding_flag) {
ret = update_seeding_flag(root, seeding_value);
-- 
1.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


[PATCH 07/13] Btrfs-progs: correcting misnamed parameter options for btrfs send

2013-01-20 Thread Gene Czarcinski
From: Jan Schmidt list.bt...@jan-o-sch.net

Unfortunately, the command line options for btrfs send were misnamed. The
-i option should not be used to give clone sources, we'll be using -c
instead.

Compatibily note: -i option was broken anyway, which makes it less critical
renaming it. For potential users of the old option style, we emit a fatal
warning if the -i option is used.

Signed-off-by: Jan Schmidt list.bt...@jan-o-sch.net
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 cmds-send.c | 74 +++--
 1 file changed, 42 insertions(+), 32 deletions(-)

diff --git a/cmds-send.c b/cmds-send.c
index 9b47e70..3e2fcbe 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -234,7 +234,7 @@ out:
return ERR_PTR(ret);
 }
 
-static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root)
+static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root_id)
 {
int ret;
pthread_t t_read;
@@ -286,7 +286,7 @@ static int do_send(struct btrfs_send *send, u64 root_id, 
u64 parent_root)
 
io_send.clone_sources = (__u64*)send-clone_sources;
io_send.clone_sources_count = send-clone_sources_count;
-   io_send.parent_root = parent_root;
+   io_send.parent_root = parent_root_id;
ret = ioctl(subvol_fd, BTRFS_IOC_SEND, io_send);
if (ret) {
ret = -errno;
@@ -423,16 +423,17 @@ int cmd_send_start(int argc, char **argv)
char *snapshot_parent = NULL;
u64 root_id;
u64 parent_root_id = 0;
+   int full_send = 1;
 
memset(send, 0, sizeof(send));
send.dump_fd = fileno(stdout);
 
-   while ((c = getopt(argc, argv, vf:i:p:)) != -1) {
+   while ((c = getopt(argc, argv, vc:f:i:p:)) != -1) {
switch (c) {
case 'v':
g_verbose++;
break;
-   case 'i': {
+   case 'c':
subvol = realpath(optarg, NULL);
if (!subvol) {
ret = -errno;
@@ -454,12 +455,16 @@ int cmd_send_start(int argc, char **argv)
}
add_clone_source(send, root_id);
free(subvol);
+   full_send = 0;
break;
-   }
case 'f':
outname = optarg;
break;
case 'p':
+   if (snapshot_parent) {
+   fprintf(stderr, ERROR: you cannot have more 
than one parent (-p)\n);
+   return 1;
+   }
snapshot_parent = realpath(optarg, NULL);
if (!snapshot_parent) {
ret = -errno;
@@ -467,7 +472,12 @@ int cmd_send_start(int argc, char **argv)
%s\n, optarg, strerror(-ret));
goto out;
}
+   full_send = 0;
break;
+   case 'i':
+   fprintf(stderr,
+   ERROR: -i was removed, use -c instead\n);
+   return 1;
case '?':
default:
fprintf(stderr, ERROR: send args invalid.\n);
@@ -573,10 +583,13 @@ int cmd_send_start(int argc, char **argv)
goto out;
}
 
-   if (!parent_root_id) {
+   if (!full_send  !parent_root_id) {
ret = find_good_parent(send, root_id, parent_root_id);
-   if (ret  0)
-   parent_root_id = 0;
+   if (ret  0) {
+   fprintf(stderr, ERROR: parent determination 
failed for %lld\n,
+   root_id);
+   goto out;
+   }
}
 
ret = is_subvol_ro(send, subvol);
@@ -597,6 +610,7 @@ int cmd_send_start(int argc, char **argv)
add_clone_source(send, root_id);
 
parent_root_id = 0;
+   full_send = 0;
free(subvol);
}
 
@@ -614,32 +628,28 @@ static const char * const send_cmd_group_usage[] = {
 };
 
 static const char * const cmd_send_usage[] = {
-   btrfs send [-v] [-i subvol] [-p parent] subvol,
+   btrfs send [-v] [-p parent] [-c clone-src] subvol,
Send the subvolume to stdout.,
Sends the subvolume specified by subvol to stdout.,
-   By default, this will send the whole subvolume. To do,
-   an incremental send, one or multiple '-i clone_source',
-   arguments have to be specified. A 'clone source' is,
-   a subvolume that is known to exist on the receiving,
-   side in exactly the same state

[PATCH 03/13] Btrfs-progs: correct btrfs receive usage string

2013-01-20 Thread Gene Czarcinski
From: Ulrik ulrik.sverd...@gmail.com

Fix the usage string to specify the correct '-f' option for input file,
not '-i'.

Signed-off-by: Ulrik Sverdrup ulrik.sverd...@gmail.com
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 cmds-receive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmds-receive.c b/cmds-receive.c
index 37d07db..2fae299 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -882,7 +882,7 @@ static const char * const receive_cmd_group_usage[] = {
 };
 
 static const char * const cmd_receive_usage[] = {
-   btrfs receive [-v] [-i infile] mount,
+   btrfs receive [-v] [-f infile] mount,
Receive subvolumes from stdin.,
Receives one or more subvolumes that were previously ,
sent with btrfs send. The received subvolumes are stored,
-- 
1.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


[PATCH 02/13] Btrfs-progs: fix resolving of loop devices

2013-01-20 Thread Gene Czarcinski
From: Nirbheek Chauhan nirbheek.chau...@collabora.co.uk

The LOOP_GET_STATUS ioctl truncates filenames to 64 characters. We should get
the backing file for a given loop device from /sys/. This is how losetup does it
as well.

Signed-off-by: Gene Czarcinski g...@czarc.net
---
 utils.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/utils.c b/utils.c
index 51b78d5..7953ef9 100644
--- a/utils.c
+++ b/utils.c
@@ -20,6 +20,7 @@
 #define __USE_XOPEN2K
 #include stdio.h
 #include stdlib.h
+#include string.h
 #ifndef __CHECKER__
 #include sys/ioctl.h
 #include sys/mount.h
@@ -653,21 +654,22 @@ int is_loop_device (const char* device) {
  * the associated file (e.g. /images/my_btrfs.img) */
 int resolve_loop_device(const char* loop_dev, char* loop_file, int max_len)
 {
-   int loop_fd;
-   int ret_ioctl;
-   struct loop_info loopinfo;
+   int ret;
+   FILE *f;
+   char fmt[20];
+   char p[PATH_MAX];
+   char real_loop_dev[PATH_MAX];
 
-   if ((loop_fd = open(loop_dev, O_RDONLY))  0)
+   if (!realpath(loop_dev, real_loop_dev))
+   return -errno;
+   snprintf(p, PATH_MAX, /sys/block/%s/loop/backing_file, 
strrchr(real_loop_dev, '/'));
+   if (!(f = fopen(p, r)))
return -errno;
 
-   ret_ioctl = ioctl(loop_fd, LOOP_GET_STATUS, loopinfo);
-   close(loop_fd);
-
-   if (ret_ioctl == 0) {
-   strncpy(loop_file, loopinfo.lo_name, max_len);
-   if (max_len  0)
-   loop_file[max_len-1] = 0;
-   } else
+   snprintf(fmt, 20, %%%i[^\n], max_len-1);
+   ret = fscanf(f, fmt, loop_file);
+   fclose(f);
+   if (ret == EOF)
return -errno;
 
return 0;
-- 
1.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 07/13] Btrfs-progs: correcting misnamed parameter options for btrfs send

2013-01-20 Thread Gene Czarcinski

Bad patch ... working on fix

On 01/20/2013 04:04 PM, Gene Czarcinski wrote:

From: Jan Schmidt list.bt...@jan-o-sch.net

Unfortunately, the command line options for btrfs send were misnamed. The
-i option should not be used to give clone sources, we'll be using -c
instead.

Compatibily note: -i option was broken anyway, which makes it less critical
renaming it. For potential users of the old option style, we emit a fatal
warning if the -i option is used.

Signed-off-by: Jan Schmidt list.bt...@jan-o-sch.net
Signed-off-by: Gene Czarcinski g...@czarc.net


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] Btrfs-progs: correcting misnamed parameter options for btrfs send

2013-01-20 Thread Gene Czarcinski
This is a hand refit of the patch but otherwise the same.

Unfortunately, the command line options for btrfs send were misnamed. The
-i option should not be used to give clone sources, we'll be using -c
instead.

Compatibily note: -i option was broken anyway, which makes it less critical
renaming it. For potential users of the old option style, we emit a fatal
warning if the -i option is used.

Signed-off-by: Jan Schmidt list.bt...@jan-o-sch.net
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 cmds-send.c | 74 +++--
 1 file changed, 42 insertions(+), 32 deletions(-)

diff --git a/cmds-send.c b/cmds-send.c
index 5607f2a..d2f7691 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -236,7 +236,7 @@ out:
return ERR_PTR(ret);
 }
 
-static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root)
+static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root_id)
 {
int ret;
pthread_t t_read;
@@ -289,7 +289,7 @@ static int do_send(struct btrfs_send *send, u64 root_id, 
u64 parent_root)
 
io_send.clone_sources = (__u64*)send-clone_sources;
io_send.clone_sources_count = send-clone_sources_count;
-   io_send.parent_root = parent_root;
+   io_send.parent_root = parent_root_id;
ret = ioctl(subvol_fd, BTRFS_IOC_SEND, io_send);
if (ret) {
ret = -errno;
@@ -426,6 +426,7 @@ int cmd_send_start(int argc, char **argv)
char *snapshot_parent = NULL;
u64 root_id;
u64 parent_root_id = 0;
+   int full_send = 1;
 
memset(send, 0, sizeof(send));
send.dump_fd = fileno(stdout);
@@ -435,12 +436,12 @@ int cmd_send_start(int argc, char **argv)
return 1;
}
 
-   while ((c = getopt(argc, argv, vf:i:p:)) != -1) {
+   while ((c = getopt(argc, argv, vc:f:i:p:)) != -1) {
switch (c) {
case 'v':
g_verbose++;
break;
-   case 'i': {
+   case 'c':
subvol = realpath(optarg, NULL);
if (!subvol) {
ret = -errno;
@@ -462,12 +463,16 @@ int cmd_send_start(int argc, char **argv)
}
add_clone_source(send, root_id);
free(subvol);
+   full_send = 0;
break;
-   }
case 'f':
outname = optarg;
break;
case 'p':
+   if (snapshot_parent) {
+   fprintf(stderr, ERROR: you cannot have more 
than one parent (-p)\n);
+   return 1;
+   }
snapshot_parent = realpath(optarg, NULL);
if (!snapshot_parent) {
ret = -errno;
@@ -475,7 +480,12 @@ int cmd_send_start(int argc, char **argv)
%s\n, optarg, strerror(-ret));
goto out;
}
+   full_send = 0;
break;
+   case 'i':
+   fprintf(stderr,
+   ERROR: -i was removed, use -c instead\n);
+   return 1;
case '?':
default:
fprintf(stderr, ERROR: send args invalid.\n);
@@ -581,10 +591,13 @@ int cmd_send_start(int argc, char **argv)
goto out;
}
 
-   if (!parent_root_id) {
+   if (!full_send  !parent_root_id) {
ret = find_good_parent(send, root_id, parent_root_id);
-   if (ret  0)
-   parent_root_id = 0;
+   if (ret  0) {
+   fprintf(stderr, ERROR: parent determination 
failed for %lld\n,
+   root_id);
+   goto out;
+   }
}
 
ret = is_subvol_ro(send, subvol);
@@ -605,6 +618,7 @@ int cmd_send_start(int argc, char **argv)
add_clone_source(send, root_id);
 
parent_root_id = 0;
+   full_send = 0;
free(subvol);
}
 
@@ -622,32 +636,28 @@ static const char * const send_cmd_group_usage[] = {
 };
 
 static const char * const cmd_send_usage[] = {
-   btrfs send [-v] [-i subvol] [-p parent] subvol,
+   btrfs send [-v] [-p parent] [-c clone-src] subvol,
Send the subvolume to stdout.,
Sends the subvolume specified by subvol to stdout.,
-   By default, this will send the whole subvolume. To do,
-   an incremental send, one or multiple '-i clone_source',
-   arguments have to be specified. A 'clone

Re: [PATCH 00/11 V3] add show command to the subvol sub command

2013-01-20 Thread Gene Czarcinski

On 01/10/2013 06:41 AM, Anand Jain wrote:

This is an attempt to make btrfs cli more end user friendly.
And adds show subcommand to display all known (as of now)
information of the given subvol including its snapshot(s).

The below patch:
  Btrfs-progs: accommodate different layout for printing subvol list
obsoletes the previosuly submitted patch
  Btrfs-progs: make provision to print subvol list tree format

Please provide your review comments. Thanks.

An example output:

First list out all the subvols/snapshots using the list subcommand.

btrfs su list /btrfs
ID 256 gen 10 top level 5 path sv1
ID 259 gen 6 top level 5 path sv1/snap
ID 260 gen 7 top level 5 path snap
ID 261 gen 8 top level 5 path sv2
ID 262 gen 9 top level 5 path sv1/snap2
ID 263 gen 10 top level 5 path sv1/snap3

Then use show subcommand to know all known information about the
given subvol.

btrfs su show /btrfs/sv1
/btrfs/sv1
uuid:   508b12a5-ed2a-3942-af63-830967201070
Parent uuid:-
Creation time:  2013-01-07 13:53:30
Object ID:  256
Generation (Gen):   10
Gen at creation:5
Parent: 5
Top Level:  5
Snapshot(s):
sv1/snap
sv1/snap2
sv1/snap3


v2-v3: List snapshots of the given subvol if any.
 Uses a more simple approach to obtain the snapshots.


You have certainly been busy.  However, your patches need to be rebased 
considering some of the patch-sets currently sent to the mailing list.  
If nothing else, I would appreciate it if you could rebase to David 
Sterba's set.  And then there are the two patch-sets I submitted.


BTW, I do not claim anything except for the effort to scrapes these off 
the list to attempt getting btrfs-progs a bit more current with respect 
to bugfixes.  I was going to include su show but your latest 
submission is a bit too much for now.


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


[PATCH 2/4] Fedora 18 - build-fixes.patch

2013-01-19 Thread Gene Czarcinski
---
 btrfsck.c | 2 ++
 mkfs.c| 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/btrfsck.c b/btrfsck.c
index a851008..6274ff7 100644
--- a/btrfsck.c
+++ b/btrfsck.c
@@ -22,7 +22,9 @@
 #include stdlib.h
 #include unistd.h
 #include fcntl.h
+#include sys/types.h
 #include sys/stat.h
+#include unistd.h
 #include getopt.h
 #include kerncompat.h
 #include ctree.h
diff --git a/mkfs.c b/mkfs.c
index fbf8319..d123d5f 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1206,7 +1206,7 @@ int main(int ac, char **av)
u64 alloc_start = 0;
u64 metadata_profile = 0;
u64 data_profile = 0;
-   u32 leafsize = getpagesize();
+   u32 leafsize = sysconf(_SC_PAGESIZE);
u32 sectorsize = 4096;
u32 nodesize = leafsize;
u32 stripesize = 4096;
@@ -1282,7 +1282,7 @@ int main(int ac, char **av)
print_usage();
}
}
-   sectorsize = max(sectorsize, (u32)getpagesize());
+   sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE));
if (check_leaf_or_node_size(leafsize, sectorsize))
exit(1);
if (check_leaf_or_node_size(nodesize, sectorsize))
-- 
1.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


[PATCH 1/4] Fedora 18 - btrfs-init-dev-list.patch

2013-01-19 Thread Gene Czarcinski
---
 utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/utils.c b/utils.c
index 938f9a5..51b78d5 100644
--- a/utils.c
+++ b/utils.c
@@ -477,7 +477,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
u64 num_devs;
int ret;
 
-   device = kmalloc(sizeof(*device), GFP_NOFS);
+   device = kzalloc(sizeof(*device), GFP_NOFS);
if (!device)
return -ENOMEM;
buf = kmalloc(sectorsize, GFP_NOFS);
@@ -503,6 +503,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
device-bytes_used = 0;
device-total_ios = 0;
device-dev_root = root-fs_info-dev_root;
+   INIT_LIST_HEAD(device-dev_list);
 
ret = btrfs_add_device(trans, root, device);
BUG_ON(ret);
-- 
1.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


[PATCH 4/4] Fedora 18 - modified valgrind.patch

2013-01-19 Thread Gene Czarcinski
A small part of this patch proved unnecessary because it was
already corrected by the plug a memory leak reported by cppcheck
patch.
---
 disk-io.c  | 16 +++-
 extent-cache.c | 11 +++
 extent-cache.h |  1 +
 extent-tree.c  | 10 ++
 volumes.c  | 16 +++-
 volumes.h  |  1 +
 6 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/disk-io.c b/disk-io.c
index c4d4631..5b6c6b1 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -631,7 +631,7 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const 
char *path,
struct btrfs_root *chunk_root = malloc(sizeof(struct btrfs_root));
struct btrfs_root *dev_root = malloc(sizeof(struct btrfs_root));
struct btrfs_root *csum_root = malloc(sizeof(struct btrfs_root));
-   struct btrfs_fs_info *fs_info = malloc(sizeof(*fs_info));
+   struct btrfs_fs_info *fs_info = malloc(sizeof(struct btrfs_fs_info));
int ret;
struct btrfs_super_block *disk_super;
struct btrfs_fs_devices *fs_devices = NULL;
@@ -655,7 +655,7 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const 
char *path,
goto out;
}
 
-   memset(fs_info, 0, sizeof(*fs_info));
+   memset(fs_info, 0, sizeof(struct btrfs_fs_info));
fs_info-tree_root = tree_root;
fs_info-extent_root = extent_root;
fs_info-chunk_root = chunk_root;
@@ -1084,15 +1084,19 @@ static int close_all_devices(struct btrfs_fs_info 
*fs_info)
 {
struct list_head *list;
struct list_head *next;
+   struct list_head *tmp;
struct btrfs_device *device;
 
-   return 0;
-
list = fs_info-fs_devices-devices;
-   list_for_each(next, list) {
+   list_for_each_safe(next, tmp, list) {
device = list_entry(next, struct btrfs_device, dev_list);
close(device-fd);
+   list_del(device-dev_list);
+   free(device-name);
+   free(device-label);
+   free(device);
}
+   free(fs_info-fs_devices);
return 0;
 }
 
@@ -1142,12 +1146,14 @@ int close_ctree(struct btrfs_root *root)
extent_io_tree_cleanup(fs_info-pinned_extents);
extent_io_tree_cleanup(fs_info-pending_del);
extent_io_tree_cleanup(fs_info-extent_ins);
+   btrfs_mapping_tree_free(fs_info-mapping_tree);
 
free(fs_info-tree_root);
free(fs_info-extent_root);
free(fs_info-chunk_root);
free(fs_info-dev_root);
free(fs_info-csum_root);
+   free(fs_info-log_root_tree);
free(fs_info);
 
return 0;
diff --git a/extent-cache.c b/extent-cache.c
index 3dd6434..84d4bbc 100644
--- a/extent-cache.c
+++ b/extent-cache.c
@@ -168,3 +168,14 @@ void remove_cache_extent(struct cache_tree *tree,
rb_erase(pe-rb_node, tree-root);
 }
 
+void free_cache_tree(struct cache_tree *tree)
+{
+   struct rb_node *node;
+   struct cache_extent *cache;
+
+   while ((node = rb_last(tree-root)) != NULL) {
+   cache = rb_entry(node, struct cache_extent, rb_node);
+   remove_cache_extent(tree, cache);
+   free(cache);
+   }
+}
diff --git a/extent-cache.h b/extent-cache.h
index 7f2f2a6..1696bc2 100644
--- a/extent-cache.h
+++ b/extent-cache.h
@@ -43,6 +43,7 @@ struct cache_extent *find_cache_extent(struct cache_tree 
*tree,
 int insert_cache_extent(struct cache_tree *tree, u64 start, u64 size);
 int insert_existing_cache_extent(struct cache_tree *tree,
 struct cache_extent *pe);
+void free_cache_tree(struct cache_tree *tree);
 
 static inline int cache_tree_empty(struct cache_tree *tree)
 {
diff --git a/extent-tree.c b/extent-tree.c
index 20cdffa..d644d9a 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2999,6 +2999,7 @@ out:
 
 int btrfs_free_block_groups(struct btrfs_fs_info *info)
 {
+   struct btrfs_space_info *space_info;
u64 start;
u64 end;
u64 ptr;
@@ -3022,6 +3023,15 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
clear_extent_dirty(info-free_space_cache, start,
   end, GFP_NOFS);
}
+
+   while (!list_empty(info-space_info)) {
+   space_info = list_entry(info-space_info.next,
+   struct btrfs_space_info,
+   list);
+   list_del(space_info-list);
+   kfree(space_info);
+   }
+
return 0;
 }
 
diff --git a/volumes.c b/volumes.c
index 581c298..37b0074 100644
--- a/volumes.c
+++ b/volumes.c
@@ -959,6 +959,20 @@ void btrfs_mapping_init(struct btrfs_mapping_tree *tree)
cache_tree_init(tree-cache_tree);
 }
 
+void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree)
+{
+   struct cache_extent *cache;
+   struct rb_node *node;
+   struct map_lookup *map;
+
+   while ((node = rb_last(tree-cache_tree.root)) != NULL) {
+ 

[PATCH 0/6] patches from Fedora 18 (resubmitted)

2013-01-19 Thread Gene Czarcinski
These are the patches from the Fedora 18 btrfs-progs package.

This is resubmitted to pickup the other two patches by
Josef Bacik.  One of them had to be refitted/rebased
because of changes to mkfs.c but only the original Josef
changes are included.

I claim no authorship and am simply passing these on to the
btrfs mailing list.  There are only six patches.  The 
btrfs-init-dev-list.patch and the two Bacik patches are new to 18.
The others all date back to at least Fedora 15 in early 2011.

These patches were applied on top of the 19 patches
assembled by David Sterba.  The valgrind patch  needed to be
change to remove a small part which had already been fixed 
by the plug a memory leak reported by cppcheck patch.

Gene Czarcinski (5):
  Fedora 18 - btrfs-init-dev-list.patch
  Fedora 18 - build-fixes.patch
  Fedora 18 - fix-labels.patch
  Fedora 18 - modified valgrind.patch
  Btrfs-progs: detect if the disk we are formatting is a ssd

Josef Bacik (1):
  Btrfs-progs: add btrfs device ready command

 Makefile|  2 +-
 btrfsck.c   |  2 ++
 cmds-device.c   | 35 +
 disk-io.c   | 16 
 extent-cache.c  | 11 
 extent-cache.h  |  1 +
 extent-tree.c   | 10 
 ioctl.h |  2 ++
 man/mkfs.btrfs.8.in |  5 +++-
 mkfs.c  | 74 -
 utils.c |  3 ++-
 volumes.c   | 16 +++-
 volumes.h   |  1 +
 13 files changed, 157 insertions(+), 21 deletions(-)

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


[PATCH 4/6] Fedora 18 - modified valgrind.patch

2013-01-19 Thread Gene Czarcinski
A small part of this patch proved unnecessary because it was
already corrected by the plug a memory leak reported by cppcheck
patch.

Signed-off-by: Gene Czarcinski g...@czarc.net
---
 disk-io.c  | 16 +++-
 extent-cache.c | 11 +++
 extent-cache.h |  1 +
 extent-tree.c  | 10 ++
 volumes.c  | 16 +++-
 volumes.h  |  1 +
 6 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/disk-io.c b/disk-io.c
index c4d4631..5b6c6b1 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -631,7 +631,7 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const 
char *path,
struct btrfs_root *chunk_root = malloc(sizeof(struct btrfs_root));
struct btrfs_root *dev_root = malloc(sizeof(struct btrfs_root));
struct btrfs_root *csum_root = malloc(sizeof(struct btrfs_root));
-   struct btrfs_fs_info *fs_info = malloc(sizeof(*fs_info));
+   struct btrfs_fs_info *fs_info = malloc(sizeof(struct btrfs_fs_info));
int ret;
struct btrfs_super_block *disk_super;
struct btrfs_fs_devices *fs_devices = NULL;
@@ -655,7 +655,7 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const 
char *path,
goto out;
}
 
-   memset(fs_info, 0, sizeof(*fs_info));
+   memset(fs_info, 0, sizeof(struct btrfs_fs_info));
fs_info-tree_root = tree_root;
fs_info-extent_root = extent_root;
fs_info-chunk_root = chunk_root;
@@ -1084,15 +1084,19 @@ static int close_all_devices(struct btrfs_fs_info 
*fs_info)
 {
struct list_head *list;
struct list_head *next;
+   struct list_head *tmp;
struct btrfs_device *device;
 
-   return 0;
-
list = fs_info-fs_devices-devices;
-   list_for_each(next, list) {
+   list_for_each_safe(next, tmp, list) {
device = list_entry(next, struct btrfs_device, dev_list);
close(device-fd);
+   list_del(device-dev_list);
+   free(device-name);
+   free(device-label);
+   free(device);
}
+   free(fs_info-fs_devices);
return 0;
 }
 
@@ -1142,12 +1146,14 @@ int close_ctree(struct btrfs_root *root)
extent_io_tree_cleanup(fs_info-pinned_extents);
extent_io_tree_cleanup(fs_info-pending_del);
extent_io_tree_cleanup(fs_info-extent_ins);
+   btrfs_mapping_tree_free(fs_info-mapping_tree);
 
free(fs_info-tree_root);
free(fs_info-extent_root);
free(fs_info-chunk_root);
free(fs_info-dev_root);
free(fs_info-csum_root);
+   free(fs_info-log_root_tree);
free(fs_info);
 
return 0;
diff --git a/extent-cache.c b/extent-cache.c
index 3dd6434..84d4bbc 100644
--- a/extent-cache.c
+++ b/extent-cache.c
@@ -168,3 +168,14 @@ void remove_cache_extent(struct cache_tree *tree,
rb_erase(pe-rb_node, tree-root);
 }
 
+void free_cache_tree(struct cache_tree *tree)
+{
+   struct rb_node *node;
+   struct cache_extent *cache;
+
+   while ((node = rb_last(tree-root)) != NULL) {
+   cache = rb_entry(node, struct cache_extent, rb_node);
+   remove_cache_extent(tree, cache);
+   free(cache);
+   }
+}
diff --git a/extent-cache.h b/extent-cache.h
index 7f2f2a6..1696bc2 100644
--- a/extent-cache.h
+++ b/extent-cache.h
@@ -43,6 +43,7 @@ struct cache_extent *find_cache_extent(struct cache_tree 
*tree,
 int insert_cache_extent(struct cache_tree *tree, u64 start, u64 size);
 int insert_existing_cache_extent(struct cache_tree *tree,
 struct cache_extent *pe);
+void free_cache_tree(struct cache_tree *tree);
 
 static inline int cache_tree_empty(struct cache_tree *tree)
 {
diff --git a/extent-tree.c b/extent-tree.c
index 20cdffa..d644d9a 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2999,6 +2999,7 @@ out:
 
 int btrfs_free_block_groups(struct btrfs_fs_info *info)
 {
+   struct btrfs_space_info *space_info;
u64 start;
u64 end;
u64 ptr;
@@ -3022,6 +3023,15 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
clear_extent_dirty(info-free_space_cache, start,
   end, GFP_NOFS);
}
+
+   while (!list_empty(info-space_info)) {
+   space_info = list_entry(info-space_info.next,
+   struct btrfs_space_info,
+   list);
+   list_del(space_info-list);
+   kfree(space_info);
+   }
+
return 0;
 }
 
diff --git a/volumes.c b/volumes.c
index 581c298..37b0074 100644
--- a/volumes.c
+++ b/volumes.c
@@ -959,6 +959,20 @@ void btrfs_mapping_init(struct btrfs_mapping_tree *tree)
cache_tree_init(tree-cache_tree);
 }
 
+void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree)
+{
+   struct cache_extent *cache;
+   struct rb_node *node;
+   struct map_lookup *map;
+
+   while ((node

[PATCH 2/6] Fedora 18 - build-fixes.patch

2013-01-19 Thread Gene Czarcinski
Signed-off-by: Gene Czarcinski g...@czarc.net
---
 btrfsck.c | 2 ++
 mkfs.c| 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/btrfsck.c b/btrfsck.c
index a851008..6274ff7 100644
--- a/btrfsck.c
+++ b/btrfsck.c
@@ -22,7 +22,9 @@
 #include stdlib.h
 #include unistd.h
 #include fcntl.h
+#include sys/types.h
 #include sys/stat.h
+#include unistd.h
 #include getopt.h
 #include kerncompat.h
 #include ctree.h
diff --git a/mkfs.c b/mkfs.c
index fbf8319..d123d5f 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1206,7 +1206,7 @@ int main(int ac, char **av)
u64 alloc_start = 0;
u64 metadata_profile = 0;
u64 data_profile = 0;
-   u32 leafsize = getpagesize();
+   u32 leafsize = sysconf(_SC_PAGESIZE);
u32 sectorsize = 4096;
u32 nodesize = leafsize;
u32 stripesize = 4096;
@@ -1282,7 +1282,7 @@ int main(int ac, char **av)
print_usage();
}
}
-   sectorsize = max(sectorsize, (u32)getpagesize());
+   sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE));
if (check_leaf_or_node_size(leafsize, sectorsize))
exit(1);
if (check_leaf_or_node_size(nodesize, sectorsize))
-- 
1.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: [GIT PULL] btrfs-progs: more bugfixes for 0.20-rc1

2013-01-18 Thread Gene Czarcinski

On 01/17/2013 12:47 PM, David Sterba wrote:

Hi Chris,

please pull a few more fixes to the 0.20-rc series. I have reviewed and
verified them where possible. There are the long awaited ARM fixes, help
updates and unsorted code fixes.

   git://repo.or.cz/btrfs-progs-unstable/devel.git for-chris

Based on top of master commit
91d9eec1ff044394f2b98ee7fcb76713dd33b994

Thanks.
david

---
  btrfs-list.c  |   69 
+-
  btrfsck.c |3 +-
  cmds-filesystem.c |   26 
  cmds-inspect.c|5 ++-
  cmds-receive.c|4 ++-
  cmds-scrub.c  |4 ++-
  cmds-send.c   |9 ++-
  convert.c |5 +++
  ctree.h   |8 --
  debug-tree.c  |   10 +++
  disk-io.c |   13 --
  kerncompat.h  |   12 +
  man/btrfs.8.in|4 ---
  mkfs.c|   35 ++-
  restore.c |7 +++--
  utils.c   |   48 +
  utils.h   |2 +
  version.sh|2 -
  volumes.c |8 +++---
  19 files changed, 159 insertions(+), 115 deletions(-)
---
Alex Lyakas (1):
   btrfs-progs: Receive: preserve ownership for symlinks, by using 'lchown'

Arne Jansen (1):
   Btrfs-progs: fix unaligned accesses

David Sterba (2):
   btrfs-progs: do not send stream into a terminal
   btrfs-progs: ignore -a option in mkfs

Goffredo Baroncelli (3):
   Move parse_size() to utils.[hc]
   parse_size(): replace atoll() with strtoull()
   parse_size(): add new suffixes

Kenji Okimoto (3):
   btrfs-progs: plug a memory leak reported by cppcheck
   btrfs-progs: check malloc() result
   btrfs-progs: plug memory leaks in btrfs_scan_one_dir() reported by 
cppcheck.

Lluis Batlle i Rossell (1):
   btrfs-progs: Fix getopt on arm platforms

Sergei Trofimovich (1):
   version.sh: fix version when built from tarball
While you are about it, how about adding in this fix from Dieter Ries to 
fix version a little more:

http://article.gmane.org/gmane.comp.file-systems.btrfs/20069


Simon Xu (2):
   btrfs-progs: remove device show from btrfs man page
   btrfs-progs: remove '-h' from btrfs man page

Wade Cline (1):
   Btrfs-progs: Fix compiler warnings on PPC64

Wang Sheng-Hui (3):
   btrfs-progs: add -V description in print_usage
   btrfs-progs: update usage description for debug-tree.c
   btrfs-progs: print the right mount checking info in restore.c

Zach Brown (1):
   btrfs-progs: fix 32bit int/pointer cast warnings



--
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: [GIT PULL] btrfs-progs: more bugfixes for 0.20-rc1

2013-01-18 Thread Gene Czarcinski

On 01/17/2013 12:47 PM, David Sterba wrote:

Hi Chris,

please pull a few more fixes to the 0.20-rc series. I have reviewed and
verified them where possible. There are the long awaited ARM fixes, help
updates and unsorted code fixes.

   git://repo.or.cz/btrfs-progs-unstable/devel.git for-chris

Based on top of master commit
91d9eec1ff044394f2b98ee7fcb76713dd33b994

Thanks.
david

---
  btrfs-list.c  |   69 
+-
  btrfsck.c |3 +-
  cmds-filesystem.c |   26 
  cmds-inspect.c|5 ++-
  cmds-receive.c|4 ++-
  cmds-scrub.c  |4 ++-
  cmds-send.c   |9 ++-
  convert.c |5 +++
  ctree.h   |8 --
  debug-tree.c  |   10 +++
  disk-io.c |   13 --
  kerncompat.h  |   12 +
  man/btrfs.8.in|4 ---
  mkfs.c|   35 ++-
  restore.c |7 +++--
  utils.c   |   48 +
  utils.h   |2 +
  version.sh|2 -
  volumes.c |8 +++---
  19 files changed, 159 insertions(+), 115 deletions(-)
---
Alex Lyakas (1):
   btrfs-progs: Receive: preserve ownership for symlinks, by using 'lchown'

Arne Jansen (1):
   Btrfs-progs: fix unaligned accesses

David Sterba (2):
   btrfs-progs: do not send stream into a terminal
   btrfs-progs: ignore -a option in mkfs

Goffredo Baroncelli (3):
   Move parse_size() to utils.[hc]
   parse_size(): replace atoll() with strtoull()
   parse_size(): add new suffixes

Kenji Okimoto (3):
   btrfs-progs: plug a memory leak reported by cppcheck
   btrfs-progs: check malloc() result
   btrfs-progs: plug memory leaks in btrfs_scan_one_dir() reported by 
cppcheck.

Lluis Batlle i Rossell (1):
   btrfs-progs: Fix getopt on arm platforms

Sergei Trofimovich (1):
   version.sh: fix version when built from tarball

Simon Xu (2):
   btrfs-progs: remove device show from btrfs man page
   btrfs-progs: remove '-h' from btrfs man page

Wade Cline (1):
   Btrfs-progs: Fix compiler warnings on PPC64

Wang Sheng-Hui (3):
   btrfs-progs: add -V description in print_usage
   btrfs-progs: update usage description for debug-tree.c
   btrfs-progs: print the right mount checking info in restore.c

Zach Brown (1):
   btrfs-progs: fix 32bit int/pointer cast warnings



David, first of all let me thank you for pulling these together.  I do 
not believe I am alone in wondering what was happening to the 
btrfs-progs patches on the mailing list.


I would like to recommend some additional patches for inclusion since 
they are currently part of the Fedora 18 btrfs-tools package.


Josef Bacik:  detect if the disk we are formatting is a ssd V2
http://article.gmane.org/gmane.comp.file-systems.btrfs/18749

This one may be a little more of a problem since the suggested man 
update is missing and there is a second part for the kernel (status 
unknown).

Josef Bacik:  add btrfs device ready command
http://article.gmane.org/gmane.comp.file-systems.btrfs/18129
Since Fedora uses a stock a kernel as possible, I suspect the 
corresponding patch is applied.


There are two or three other patches that appear to make sense but I 
have no idea if they have been submitted.


Gene
--
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: [GIT PULL] btrfs-progs: more bugfixes for 0.20-rc1

2013-01-18 Thread Gene Czarcinski

On 01/18/2013 09:44 AM, David Sterba wrote:

On Fri, Jan 18, 2013 at 09:16:00AM -0500, Gene Czarcinski wrote:

Sergei Trofimovich (1):
   version.sh: fix version when built from tarball

While you are about it, how about adding in this fix from Dieter Ries to fix
version a little more:
http://article.gmane.org/gmane.comp.file-systems.btrfs/20069

I did not notice it before, but Dieter's patch does not work when progs
are built from .git repository

-echo #define BTRFS_BUILD_VERSION \Btrfs $v\  .build-version.h
+echo #define BTRFS_BUILD_VERSION \$v\  .build-version.h

$v is set with the git tag, so the Btrfs string does not appear in the
output (eg. mkfs.btrfs).

Technically, $v should always contain some sort of a tag, Sergei's patch
hardcodes it to the latest one for the non-git case. This is IMHO the
right approach.

OK, I see what you mean.  However, the current situation when btrfs is 
built from a tarball results in:


btrfs  --version
Btrfs Btrfs v0.19

and

mkfs.btrfs  -V
mkfs.btrfs, part of Btrfs Btrfs v0.19

There must be a way to reliably just have one Btrfs and I will look 
into it.


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


scrub questtion

2013-01-15 Thread Gene Czarcinski

When you start btrfs scrub and point at one subvolume, what is scrubbed?

Just that subvolume or the entire volume?

Gene
--
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: /boot as a btrfs subvolume

2013-01-07 Thread Gene Czarcinski

On 01/06/2013 09:00 PM, Chris Murphy wrote:

On Jan 6, 2013, at 1:05 PM, Gene Czarcinski g...@czarc.net wrote:


On 01/06/2013 02:17 PM, Swâmi Petaramesh wrote:

Le 06/01/2013 20:11, Chris Murphy a écrit :

If you use UUID, and you use subvol=, and you don't rename/move your subvolume, 
it's perfectly safe. Nevertheless, GRUB becoming subvolid aware seems like a 
good idea to me, but I have no idea what's involved in that.

I actually run several machines on which I have /boot in a separate
BTRFS subvol, without any issue. I have a multiboot between several
different distros (typically Ubuntu, Mint, LMDE, Bodhi... All Ubuntu
derivatives except for LMDE which is Debian-based...) sharing the same
BTRFS container and using different subvols i.e. UBUNTU/@boot,
LMDE/@boot etc...

Works just great.


I assume you have a grub partition (or its equivalent) with a grub.cfg file 
having menuentry definitions [pointing to the different grub.cfg file for each system ... 
that seems to work well (at least for me).  Currently, os-prober does not support btrfs.

I have taken a little look at the grub2 source code and there is some mention 
of both btrfs and zfs (and also btrfs subvolumes) in the changelogs.  However, 
it is not clear to me (and I have not had the time yet) to explore exactly what 
the source code is doing or not doing.

Well, at least with the f18 version of GRUB 2 2.00, whether alternative Btrfs 
bootable systems are mounted or not, -mkconfig isn't searching/finding for the 
/etc/fstab and /etc/default/grub of the other system like it appears to do with 
other file systems. I don't get any additional entries other than the currently 
booted Btrfs system.

So it looks like I'd need to manually add a configfile menu entry, pointing to 
each Btrfs bootable system. Chainloading from one grub to another is not 
useful. Better if they're all on the same GRUB, and use configfile.

There appear to be two situations where you have multiple software 
systems installed on the same hardware (real or virtual) -- root on a 
btrfs subvolume or /boot installed on an LV.


I worked up a patch to os-prober and a small update to grub2 which 
addresses the root on a btrfs subvolume -- see 
https://bugzilla.redhat.com/show_bug.cgi?id=888341


I have not looked into the /boot in a LV so it may involve os-prober 
also and I am also not sure that it will work with /boot on a btrfs 
subvolume.


Since developing those patches, I have had second thoughts about how 
multiboot should be done and now believe that it should involve a grub 
partition with a simple grub.cfg file and os-prober disabled. The simple 
grub.cfg file had menuentry definitions which point to the real 
grub.cfg file for each system.


One of these simple definitions would look like:

menuentry F18 on BTRFS {
 insmod  part_msdos
 insmod  btrfs
 set  root='hd0,msdos5'
 configfile  /boot1/grub2/grub.cfg
}

where /boot is on btrfs subvol boot1

I do not actually use a grub partition but, instead, a minimal system 
with grub2 and installation into the MBR.


Gene
--
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: /boot as a btrfs subvolume

2013-01-07 Thread Gene Czarcinski

On 01/07/2013 01:42 PM, Chris Murphy wrote:

On Jan 7, 2013, at 8:42 AM, Gene Czarcinski g...@czarc.net wrote:


On 01/06/2013 09:00 PM, Chris Murphy wrote:

On Jan 6, 2013, at 1:05 PM, Gene Czarcinski g...@czarc.net wrote:


On 01/06/2013 02:17 PM, Swâmi Petaramesh wrote:

Le 06/01/2013 20:11, Chris Murphy a écrit :

If you use UUID, and you use subvol=, and you don't rename/move your subvolume, 
it's perfectly safe. Nevertheless, GRUB becoming subvolid aware seems like a 
good idea to me, but I have no idea what's involved in that.

I actually run several machines on which I have /boot in a separate
BTRFS subvol, without any issue. I have a multiboot between several
different distros (typically Ubuntu, Mint, LMDE, Bodhi... All Ubuntu
derivatives except for LMDE which is Debian-based...) sharing the same
BTRFS container and using different subvols i.e. UBUNTU/@boot,
LMDE/@boot etc...

Works just great.


I assume you have a grub partition (or its equivalent) with a grub.cfg file 
having menuentry definitions [pointing to the different grub.cfg file for each system ... 
that seems to work well (at least for me).  Currently, os-prober does not support btrfs.

I have taken a little look at the grub2 source code and there is some mention 
of both btrfs and zfs (and also btrfs subvolumes) in the changelogs.  However, 
it is not clear to me (and I have not had the time yet) to explore exactly what 
the source code is doing or not doing.

Well, at least with the f18 version of GRUB 2 2.00, whether alternative Btrfs 
bootable systems are mounted or not, -mkconfig isn't searching/finding for the 
/etc/fstab and /etc/default/grub of the other system like it appears to do with 
other file systems. I don't get any additional entries other than the currently 
booted Btrfs system.

So it looks like I'd need to manually add a configfile menu entry, pointing to 
each Btrfs bootable system. Chainloading from one grub to another is not 
useful. Better if they're all on the same GRUB, and use configfile.


There appear to be two situations where you have multiple software systems 
installed on the same hardware (real or virtual) -- root on a btrfs subvolume 
or /boot installed on an LV.

I'm unclear on the use case. If /boot is on its own LV, why not just use ext4? 
If Btrfs, then I'd expect boot to be included in one Btrfs volume, along with 
home and rootfs. If that's on an LV, the use cases I'm envisioning for that the 
boot loader wouldn't be aware of the LV (e.g. VM, iSCSI, etc).

Oops.  It is me that was not clear.

Case 1: You have multiple systems installed on one piece of real or 
virtual hardware.  These could be different releases or even different 
distributions.  At least one of these systems has root installed on a 
btrfs subvolume.  When grub2-mkconfig is run on that system everything 
is OK.  Now you are on a different system and you run grub2-mkconfig 
with os-prober enabled so it will look for other systems that could be 
booted.  It will not see the system with root on the btrfs subvolume.  
That is because os-prober does not understand btrfs.


Case2: This is similar to the above situation except that you have /boot 
installed in an LV rather than a regular partition with the LV formated 
with ext4.  Similar to the above, if, from a different installed system 
you run grub2-mkconfig with os-prober enabled, the system with the /boot 
in the LV will not be seen.  I have not looked into this one so it may 
be os-prober or grub2 itself.


Seeing this convinced me to avoid using os-prober and simply have a 
boot director with simple menuentry definitions pointing to the 
various grub.cfg files for each system.



Since developing those patches, I have had second thoughts about how multiboot should be 
done and now believe that it should involve a grub partition with a simple grub.cfg file 
and os-prober disabled. The simple grub.cfg file had menuentry definitions which point to 
the real grub.cfg file for each system.

It's messy without agreement on how to boot all distributions. I've also thought of this 
primary/public grub.cfg, and secondary/private grub.cfg. The first forwards 
to the grub.cfg for each distribution using configfile or legacyconfigfile. However, that 
primary GRUB instance necessarily would need to contain the entry for Windows, etc.

So each distribution's grub-mkconfig would need to know to write out a 
distribution specific grub.cfg which is based on os-prober disabled; but then 
also be capable of updating the primary grub.cfg - not merely write out a new 
one.

And then if a distribution is deleted from the system, how is this discovered, 
and the old entry in the primary grub.cfg removed? Messy.
The hardware systems have four or five software systems on each.  It is 
not so much of deleting an distribution as much as just ignoring it.  
Disk space really is pretty inexpensive these days.



I do not actually use a grub partition but, instead, a minimal system with 
grub2

Re: /boot as a btrfs subvolume

2013-01-06 Thread Gene Czarcinski

On 01/05/2013 04:32 PM, Chris Murphy wrote:

On Jan 5, 2013, at 2:17 PM, Gene Czarcinski g...@czarc.net wrote:


As of the latest updates to anaconda and grub2 for Fedora 18, it is now possible to 
install with /boot as a btrfs subvolume.  The way that grub2 is handling this is the 
reach down to the files it needs as if the subvolume was a directory.

Also for what it's worth, it also works for multiple device Btrfs volumes, all 
profiles supported by GRUB2. For me GRUB fails to navigate Btrfs for RAID0 if 
there are 5+ devices. Single still works, oddly RAID10 still works. So some 
regression is needed to figure out what's going on there. May be a bug, but 
honestly it's still pretty cool.

Also to test is if installing grub to each device, in a multiple device raid1 
or raid10 volume, still allows it to be bootable with any one device removed 
from the volume. I think it'll work.

There is also issues with btrfs and os-prober for multiboot ... it does 
not currently work.  I hacked up a patch to get it to work but have 
since had second thoughts about how multiboot should be handled.  I now 
prefer a separate grub partition, os-prober disabled, and a grub.cfg 
file which points to the grub.cfg for each individual system.


BTW, although you can install and boot boot installed in a logical 
volume, that system is not supported in os-prober multiboot.


Gene
--
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: /boot as a btrfs subvolume

2013-01-06 Thread Gene Czarcinski

On 01/05/2013 04:27 PM, Chris Murphy wrote:

On Jan 5, 2013, at 2:17 PM, Gene Czarcinski g...@czarc.net wrote:


As of the latest updates to anaconda and grub2 for Fedora 18, it is now possible to 
install with /boot as a btrfs subvolume.  The way that grub2 is handling this is the 
reach down to the files it needs as if the subvolume was a directory.

Is this OK?

Mostly, but getting GRUB2 to handle subvolid I think would be better, because 
then subvols can be moved/renamed and things still would work.

Small problem currently is Fedora 18 still depends on grubby to make grub.cfg 
changes, and grubby is being kinda dumb about updating grub.cfg when /boot is 
on a boot subvol - ergo there's an error and it doesn't update the grub.cfg 
correctly.
https://bugzilla.redhat.com/show_bug.cgi?id=864198
Work around after any kernel update is to run grub2-mkconfig -o 
/boot/grub2/grub.cfg manually, and then the grub.cfg is correct.


At this point I am not worried about snapshots or any other complexities.  If the 
subvolume name is known. should grub2 be able to reliably reach down as if 
that subvolume was a directory?  It needs some of its configuration files and, of course, 
the linux kernel.

It's two parts. GRUB's core.img code works as you describe. But grub-install 
and grub-mkconfig depend on /etc/fstab. If I use subvolid= in /etc/fstab and 
update either core.img or grub.cfg (with -install or -mkconfig), then the 
system is no longer bootable.
So, I conclude from the above that the safe thing to do is to keep 
/boot as a separate ext2/3/4 partition.


Gene
--
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: /boot as a btrfs subvolume

2013-01-06 Thread Gene Czarcinski

On 01/06/2013 02:17 PM, Swâmi Petaramesh wrote:

Le 06/01/2013 20:11, Chris Murphy a écrit :

If you use UUID, and you use subvol=, and you don't rename/move your subvolume, 
it's perfectly safe. Nevertheless, GRUB becoming subvolid aware seems like a 
good idea to me, but I have no idea what's involved in that.

I actually run several machines on which I have /boot in a separate
BTRFS subvol, without any issue. I have a multiboot between several
different distros (typically Ubuntu, Mint, LMDE, Bodhi... All Ubuntu
derivatives except for LMDE which is Debian-based...) sharing the same
BTRFS container and using different subvols i.e. UBUNTU/@boot,
LMDE/@boot etc...

Works just great.

I assume you have a grub partition (or its equivalent) with a grub.cfg 
file having menuentry definitions [pointing to the different grub.cfg 
file for each system ... that seems to work well (at least for me).  
Currently, os-prober does not support btrfs.


I have taken a little look at the grub2 source code and there is some 
mention of both btrfs and zfs (and also btrfs subvolumes) in the 
changelogs.  However, it is not clear to me (and I have not had the time 
yet) to explore exactly what the source code is doing or not doing.


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


/boot as a btrfs subvolume

2013-01-05 Thread Gene Czarcinski
As of the latest updates to anaconda and grub2 for Fedora 18, it is now 
possible to install with /boot as a btrfs subvolume.  The way that grub2 
is handling this is the reach down to the files it needs as if the 
subvolume was a directory.


Is this OK?

At this point I am not worried about snapshots or any other 
complexities.  If the subvolume name is known. should grub2 be able to 
reliably reach down as if that subvolume was a directory?  It needs 
some of its configuration files and, of course, the linux kernel.


Point:   it seems to work OK so far ;}

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


Another novice question comment

2012-12-27 Thread Gene Czarcinski
OK, this is from inside a shell.  I have a btrfs volume or a btrfs 
subvolume on some arbitrary mount mount.  Is there some way to tell if 
it is a btrfs volume or a btrfs subvolume that is mounted?


Comment:  It sure would be nice if the btrfs man page corresponded 
better to the btrfs code.  Example, the man page says there is a btrfs 
subvolume show command.  The code disagrees and so does btrfs --help


Gene
--
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: Another novice question comment

2012-12-27 Thread Gene Czarcinski

On 12/27/2012 11:07 AM, Chris Murphy wrote:

On Dec 27, 2012, at 7:29 AM, Gene Czarcinski g...@czarc.net wrote:


OK, this is from inside a shell.  I have a btrfs volume or a btrfs subvolume on 
some arbitrary mount mount.  Is there some way to tell if it is a btrfs volume 
or a btrfs subvolume that is mounted?

cat /proc/self/mountinfo | grep btrfs

That will show you what subvol is mounted and where, subvol is the 4th column, 
mountpoint is the fifth.

Thank you.  That is just what I needed.

Gene
--
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: Another novice question comment

2012-12-27 Thread Gene Czarcinski

On 12/27/2012 11:55 AM, Chris Murphy wrote:

On Dec 27, 2012, at 9:47 AM, Swâmi Petaramesh sw...@petaramesh.org wrote:


Le 27/12/2012 16:03, Hugo Mills a écrit :

   Right now, no, there isn't any way of telling which subvolume is
mounted at a given location.

Er... Check subvol= here...

root@tethys:/# mount | grep btrfs
/dev/mapper/VG1-BTR_POOL on / type btrfs
(rw,relatime,subvol=UBUNTU/@,autodefrag,compress=lzo)
/dev/mapper/VG1-BTR_POOL on /tmp type btrfs
(rw,relatime,subvol=UBUNTU/@tmp,compress=lzo)
/dev/sda2 on /boot type btrfs (rw,relatime,subvol=UBUNTU/@boot,autodefrag)
/dev/mapper/VG1-BTR_POOL on /home type btrfs
(rw,relatime,subvol=UBUNTU/@home,autodefrag,compress=lzo)
/dev/mapper/VG1-BTR_POOL on /storage type btrfs
(rw,relatime,subvol=STORAGE,autodefrag,compress=lzo)
/dev/mapper/VG1-BTR_POOL on /data/BIG type btrfs
(rw,noatime,subvol=DATA/BIG,compress=lzo)


That would only seem to work with btrfs on LVM which I'd think is uncommon and 
complicated.


Oh thanks for that little reminder that you can put btrfs on an LV.

I am trying to see if I can get grub2 and os-prober to handle btrfs.  
There are a couple of patches out there but they do little if anything.  
The btrfs volumes and subvolumes are not your father's filesystem 8-)


I have a little of what is needed working but, the more I look at 
things, the more it looks like some real kludgy hack is going to be 
needed to have something which works with /dev/whatever to now use 
UUID=xxx,subvol=name


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


Determining subvolumes

2012-12-26 Thread Gene Czarcinski
I know that I can find out what btrfs volumes are on a system with the 
command:

 btrfs  fi  show

I can also check if a partition of disk is a btrfs volume with the command:
 blkid  -o value -s TYPE /dev/disk|partition

And, if I mount that btrfs volume with something like:
 mount -t btrfs /dev/btrfs  /mnt/btrfs

The, I can get a list of btrfs subvolumes on that volume with the command:
 btrfs  subvolume  list  /mnt/btrfs

My question:  Is there a way of finding out what subvolumes are defined 
on a btrfs volume without mounting the volume?


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


fsck.btrfs

2012-12-22 Thread Gene Czarcinski
I am new to btrfs and have begun exploring and testing it.  One of these 
tests is to install Fedora 18 into a btrfs volume only leaving /boot and 
swap on regular partitions.  BTW, this is on qemu/kvm/libvirt virtuals.


I discovered an error was occurring during bootup because systemd was 
attempting to start fsck.btrfs and it was missing.


1. Would btrfsck be the appropriate program to run at bootup?  If it is, 
with what parameters?


2.  Should there be a fsck.btrfs but it has not been written yet?

3. Does btrfs even need a fsck.btrfs?

I get the distinct impression that btrfs is not your father's 
filesystem and thus need to be looked at very differently.


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


add, remove; how about merge?

2012-12-21 Thread Gene Czarcinski

I am new at this btrfs stuff!

As I understand it, you can add a physical disk or partition and have 
data spread into the new space.  You can also move data off a disk or 
partition and then remove it.


Has any though  been given to being able merge to existing (separate) 
btrfs volumes into a single volume?


Alternatively, how about at tool for transfering a subvolume from one 
pool to another?  I tried using fsarchiver but that did not work out too 
well.


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


subvolume show

2012-12-12 Thread Gene Czarcinski
I was looking through some of the archives and notice a patch submitted 
to implement:

  btrfs  subvolume  show  path-to-subvolume
command.

I also noticed that is does not appear to be in the git.

This looks like a useful capability.  I was trying to find out what the 
UUID was for a newly created subvolume and have not found out how to do 
that.


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