Re: basic questions regarding COW in Btrfs

2013-02-23 Thread Aastha Mehta
A gentle reminder on this one.

Thanks,
Aastha.

On 21 February 2013 18:32, Aastha Mehta aasth...@gmail.com wrote:
 Thanks a lot for the prompt response. I had seen that, but I am still
 not sure of where it really
 happens within fill_delalloc. Could you help me a little further in that path?

 Secondly, now I am confused between the btree_writepages and
 btrfs_writepages/btrfs_writepage
 methods. I thought btrfs_writepages was for writing the pages holding
 inodes and btree_writepages
 for writing the other indirect and leaf extents of the btree. Then, it
 seems that the write operations
 lead to update of the file system data structures in a top-down
 manner, i.e. first changing the inode
 and then the data extents. Is that correct?

 Thirdly, it seems that the old extents maybe dropped before the new
 extents are flushed to the disk.
 What would happen if the write fails before the disk commit? What am I
 missing here?

 Thanks,
 Aastha.

 On 20 February 2013 18:54, Josef Bacik jba...@fusionio.com wrote:
 On Wed, Feb 20, 2013 at 10:28:10AM -0700, Aastha Mehta wrote:
 Hello,

 I am trying to understand the COW mechanism in Btrfs. Is it correct to
 say that unless nodatacow option is specified, Btrfs always performs
 COW for all the data+metadata extents used in the system?


 So we always cow the metadata, but yes nodatacow means we don't cow the 
 actual
 data in the data extents.

 I saw that COWing is implemented in btrfs_cow_block() function, which
 is called at the time of searching a slot for a particular item, while
 inserting into a new slot, committing transactions, while creating
 pending snapshots and few other places.

 However, while tracing through the complete write path, I could not
 quite figure out when extents actually get COWed. Could you please
 point me to the place where COWing takes place? Is there any time
 when, for performance or any other reasons, the extents are not COWed
 but overwritten in place (apart from the explicit nodatacow flag being
 set during mount)?

 You'll want to look at the tree operation -fill_delalloc().  Thats where we 
 do
 cow_file_range().  We allocate new space and write.  When we finish the 
 ordered
 io we do btrfs_drop_extents() on the range we just wrote which will free up 
 any
 existing extents that exist, and then insert our new file extent.  Thanks,

 Josef



--
Aastha Mehta
MPI-SWS, Germany
E-mail: aasth...@mpi-sws.org
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2][BTRFS-PROGS] Enhance btrfs fi df with raid5/6 support

2013-02-23 Thread Goffredo Baroncelli
Hi all, 

I updates my previous patches [1] to add support for raid5/6.
These patches update the btrfs fi df command and add two new commands:
- btrfs filesystem disk-usage path
- btrfs device disk-usage path

The command btrfs filesystem df now shows only the disk usage/available.

$ sudo btrfs filesystem df /mnt/btrfs1/
Disk size:   400.00GB
Disk allocated:8.04GB
Disk unallocated:391.97GB
Used: 11.29MB
Free (Estimated):250.45GB   (Max: 396.99GB, min: 201.00GB)
Data to disk ratio:  63 %

The Free (Estimated) tries to give an estimation of the free space
on the basis of the chunks usage. Max and min are the maximum allowable
space (if the next chunk are allocated as SINGLE) or the minimum one (
if the next chunks are allocated as DUP/RAID1/RAID10).

The other two commands show the chunks in the disks.

$ sudo btrfs filesystem disk-usage /mnt/btrfs1/
Data,Single: Size:8.00MB, Used:0.00
   /dev/vdb 8.00MB

Data,RAID6: Size:2.00GB, Used:11.25MB
   /dev/vdb 1.00GB
   /dev/vdc 1.00GB
   /dev/vdd 1.00GB
   /dev/vde 1.00GB

Metadata,Single: Size:8.00MB, Used:0.00
   /dev/vdb 8.00MB

Metadata,RAID5: Size:3.00GB, Used:36.00KB
   /dev/vdb 1.00GB
   /dev/vdc 1.00GB
   /dev/vdd 1.00GB
   /dev/vde 1.00GB

System,Single: Size:4.00MB, Used:0.00
   /dev/vdb 4.00MB

System,RAID5: Size:12.00MB, Used:4.00KB
   /dev/vdb 4.00MB
   /dev/vdc 4.00MB
   /dev/vdd 4.00MB
   /dev/vde 4.00MB

Unallocated:
   /dev/vdb97.98GB
   /dev/vdc98.00GB
   /dev/vdd98.00GB
   /dev/vde98.00GB

or in tabular format

$ sudo ./btrfs filesystem disk-usage -t /mnt/btrfs1/
 Data   DataMetadata Metadata System System 
 Single RAID6   Single   RAID5Single RAID5   Unallocated

/dev/vdb 8.00MB  1.00GB   8.00MB   1.00GB 4.00MB  4.00MB 97.98GB
/dev/vdc  -  1.00GB-   1.00GB  -  4.00MB 98.00GB
/dev/vdd  -  1.00GB-   1.00GB  -  4.00MB 98.00GB
/dev/vde  -  1.00GB-   1.00GB  -  4.00MB 98.00GB
 == ===   == === ===
Total8.00MB  2.00GB   8.00MB   3.00GB 4.00MB 12.00MB391.97GB
Used   0.00 11.25MB 0.00  36.00KB   0.00  4.00KB

These are the most complete output, where it is possible to know which
disk a chunk uses and the usage of every chunk.

Finally the last command shows which chunks a disk hosts:

$ sudo ./btrfs device disk-usage /mnt/btrfs1/
/dev/vdb  100.00GB
   Data,Single:  8.00MB
   Data,RAID6:   1.00GB
   Metadata,Single:  8.00MB
   Metadata,RAID5:   1.00GB
   System,Single:4.00MB
   System,RAID5: 4.00MB
   Unallocated: 97.98GB

/dev/vdc  100.00GB
   Data,RAID6:   1.00GB
   Metadata,RAID5:   1.00GB
   System,RAID5: 4.00MB
   Unallocated: 98.00GB

/dev/vdd  100.00GB
   Data,RAID6:   1.00GB
   Metadata,RAID5:   1.00GB
   System,RAID5: 4.00MB
   Unallocated: 98.00GB

/dev/vde  100.00GB
   Data,RAID6:   1.00GB
   Metadata,RAID5:   1.00GB
   System,RAID5: 4.00MB
   Unallocated: 98.00GB

More or less are the same information above, only grouped by disk.
Unfortunately I don't have any information about the chunk usage per disk basis.

Comments are welcome.
The code is pullable from
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
branch
df-du-raid56

BR
G.Baroncelli

[1] http://permalink.gmane.org/gmane.comp.file-systems.btrfs/21071

Changelog:
v1 2013/02/18 First issue
v2 2013/02/23 Fix uncorrct not enough memory handling in patch #1.
  Thanks to Zac to highlight it.

-- 
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it
Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5 

--
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/8] Add some helpers to manage the strings allocation/deallocation.

2013-02-23 Thread Goffredo Baroncelli
From: Goffredo Baroncelli kreij...@inwind.it

This patch adds some helpers to manage the strings allocation and
deallocation.
The function string_list_add(char *) adds the passed string to a list;
the function string_list_free() frees all the strings together.

Signed-off-by: Goffredo Baroncelli kreij...@inwind.it
---
 Makefile  |3 ++-
 string_list.c |   63 +
 string_list.h |   23 +
 3 files changed, 88 insertions(+), 1 deletion(-)
 create mode 100644 string_list.c
 create mode 100644 string_list.h

diff --git a/Makefile b/Makefile
index 596bf93..0d6c43a 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,8 @@ objects = ctree.o disk-io.o radix-tree.o extent-tree.o 
print-tree.o \
  root-tree.o dir-item.o file-item.o inode-item.o \
  inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \
  volumes.o utils.o btrfs-list.o btrfslabel.o repair.o \
- send-stream.o send-utils.o qgroup.o raid6.o
+ send-stream.o send-utils.o qgroup.o raid6.o \
+ string_list.o
 cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
   cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
   cmds-quota.o cmds-qgroup.o cmds-replace.o
diff --git a/string_list.c b/string_list.c
new file mode 100644
index 000..8d8cc1f
--- /dev/null
+++ b/string_list.c
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include unistd.h
+
+/* To store the strings */
+static void **strings_to_free;
+static int count_string_to_free;
+
+/* 
+ * Add a string to the dynamic allocated string list
+ */
+char *string_list_add(char *s)
+{
+   int  size;
+
+   size = sizeof(void *) * ++count_string_to_free;
+   strings_to_free = realloc(strings_to_free, size);
+
+   /* if we don't have enough memory, we have more serius
+  problem than that a wrong handling of not enough memory */
+   if (!strings_to_free) {
+   fprintf(stderr, add_string_to_free(): Not enough memory\n);
+   count_string_to_free = 0;
+   return NULL;
+   }
+
+   strings_to_free[count_string_to_free-1] = s;
+   return s;
+}
+
+/*
+ * Free the dynamic allocated strings list
+ */
+void string_list_free()
+{
+   int i;
+   for (i = 0 ; i  count_string_to_free ; i++)
+   free(strings_to_free[i]);
+
+   free(strings_to_free);
+
+   strings_to_free = 0;
+   count_string_to_free = 0;
+}
+
+
diff --git a/string_list.h b/string_list.h
new file mode 100644
index 000..f974fbc
--- /dev/null
+++ b/string_list.h
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+#ifndef STRING_LIST_H
+#define STRING_LIST_H
+
+void string_list_add(char *s);
+void string_list_free();
+
+#endif
-- 
1.7.10.4

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


[PATCH 2/8] Enhance the command btrfs filesystem df.

2013-02-23 Thread Goffredo Baroncelli
From: Goffredo Baroncelli kreij...@inwind.it

Enhance the command btrfs filesystem df to show space usage information
for a mount point(s). It shows also an estimation of the space available,
on the basis of the current one used.

Signed-off-by: Goffredo Baroncelli kreij...@inwind.it
---
 Makefile |2 +-
 cmds-fi-disk_usage.c |  520 ++
 cmds-fi-disk_usage.h |   25 +++
 cmds-filesystem.c|  125 +---
 ctree.h  |   17 +-
 utils.c  |   14 ++
 utils.h  |2 +
 7 files changed, 579 insertions(+), 126 deletions(-)
 create mode 100644 cmds-fi-disk_usage.c
 create mode 100644 cmds-fi-disk_usage.h

diff --git a/Makefile b/Makefile
index 0d6c43a..bd792b6 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ objects = ctree.o disk-io.o radix-tree.o extent-tree.o 
print-tree.o \
  string_list.o
 cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
   cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
-  cmds-quota.o cmds-qgroup.o cmds-replace.o
+  cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-fi-disk_usage.o
 
 CHECKFLAGS= -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \
-Wuninitialized -Wshadow -Wundef
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
new file mode 100644
index 000..1e3589f
--- /dev/null
+++ b/cmds-fi-disk_usage.c
@@ -0,0 +1,520 @@
+/*
+ * 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.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include unistd.h
+#include sys/ioctl.h
+#include errno.h
+
+#include utils.h
+#include kerncompat.h
+#include ctree.h
+#include string_list.h
+
+#include commands.h
+
+#include version.h
+
+#define DF_HUMAN_UNIT  (10)
+
+/* 
+ * To store the size information about the chunks:
+ * the chunks info are grouped by the tuple (type, devid, num_stripes),
+ * i.e. if two chunks are of the same type (RAID1, DUP...), are on the
+ * same disk, have the same stripes then their sizes are grouped
+ */
+struct chunk_info {
+   u64 type;
+   u64 size;
+   u64 devid;
+   int num_stripes;
+};
+
+/*
+ * Pretty print the size
+ */
+static char *df_pretty_sizes(u64 size, int mode)
+{
+   char *s;
+
+   if (mode  DF_HUMAN_UNIT) {
+   s = pretty_sizes(size);
+   if (!s)
+   return NULL;
+   } else {
+   s = malloc(20);
+   if (!s)
+   return NULL;
+   sprintf(s, %llu, size);
+   }
+
+   string_list_add(s);
+   return s;
+}
+
+/*
+ * Add the chunk info to the chunk_info list
+ */
+static int add_info_to_list(struct chunk_info **info_ptr,
+   int *info_count,
+   struct btrfs_chunk *chunk)
+{
+
+   u64 type = btrfs_stack_chunk_type(chunk);
+   u64 size = btrfs_stack_chunk_length(chunk);
+   int num_stripes = btrfs_stack_chunk_num_stripes(chunk);
+   int j;
+
+   for (j = 0 ; j  num_stripes ; j++) {
+   int i;
+   struct chunk_info *p = 0;
+   struct btrfs_stripe *stripe;
+   u64devid;
+
+   stripe = btrfs_stripe_nr(chunk, j);
+   devid = btrfs_stack_stripe_devid(stripe);
+
+   for (i = 0 ; i  *info_count ; i++)
+   if ((*info_ptr)[i].type == type 
+   (*info_ptr)[i].devid == devid 
+   (*info_ptr)[i].num_stripes == num_stripes ) {
+   p = (*info_ptr) + i;
+   break;
+   }
+
+   if (!p) {
+   int size = sizeof(struct btrfs_chunk) * (*info_count+1);
+   struct chunk_info *res = realloc(*info_ptr, size);
+
+   if (!res) {
+   fprintf(stderr, ERROR: not enough memory\n);
+   return -1;
+   }
+
+   *info_ptr = res;
+   p = res + *info_count;
+   (*info_count)++;
+
+   p-devid = devid;
+   p-type = type;
+   p-size = 0;
+   p-num_stripes = 

[PATCH 4/8] Add helpers functions to handle the printing of data in tabular format.

2013-02-23 Thread Goffredo Baroncelli
From: Goffredo Baroncelli kreij...@inwind.it

This patch adds some functions to manage the printing of the data in
tabular format.

The function
struct string_table *table_create(int columns, int rows)
creates an (empty) table.

The functions
char *table_printf(struct string_table *tab, int column,
int row, char *fmt, ...)
char *table_vprintf(struct string_table *tab, int column,
int row, char *fmt, va_list ap)
populate the table with text. To align the text to the left, the text
shall be prefixed with '', otherwise the text shall be prefixed by a
''. If the first character is a '=', the the text is replace by a
sequence of '=' to fill the column width.

The function
void table_free(struct string_table *)
frees all the data associated to the table.

The function
void table_dump(struct string_table *tab)
prints the table on stdout.

Signed-off-by: Goffredo Baroncelli kreij...@inwind.it
---
 Makefile   |2 +-
 string_table.c |  157 
 string_table.h |   36 +
 3 files changed, 194 insertions(+), 1 deletion(-)
 create mode 100644 string_table.c
 create mode 100644 string_table.h

diff --git a/Makefile b/Makefile
index bd792b6..fd1b312 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ objects = ctree.o disk-io.o radix-tree.o extent-tree.o 
print-tree.o \
  inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \
  volumes.o utils.o btrfs-list.o btrfslabel.o repair.o \
  send-stream.o send-utils.o qgroup.o raid6.o \
- string_list.o
+ string_list.o string_table.o
 cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
   cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
   cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-fi-disk_usage.o
diff --git a/string_table.c b/string_table.c
new file mode 100644
index 000..9784422
--- /dev/null
+++ b/string_table.c
@@ -0,0 +1,157 @@
+/*
+ * 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.
+ */
+
+#include stdlib.h
+#include string.h
+#include stdio.h
+#include stdarg.h
+
+#include string_table.h
+
+/*
+ *  This function create an array of char * which will represent a table
+ */
+struct string_table *table_create(int columns, int rows)
+{
+   struct string_table *p;
+   int size;
+   
+   
+   size = sizeof( struct string_table ) + 
+   rows * columns* sizeof(char *);
+   p = calloc(1, size);
+
+   if (!p) return NULL;
+
+   p-ncols = columns;
+   p-nrows = rows;
+
+   return p;
+}
+
+/*
+ * This function is like a vprintf, but store the results in a cell of
+ * the table.
+ * If fmt  starts with '', the text is left aligned; if fmt starts with
+ * '' the text is right aligned. If fmt is equal to '=' the text will
+ * be replaced by a '=' dimensioned in the basis of the column width
+ */
+char *table_vprintf(struct string_table *tab, int column, int row,
+ char *fmt, va_list ap)
+{
+   int idx = tab-ncols*row+column;
+   char *msg = calloc(100, sizeof(char));
+
+   if (!msg)
+   return NULL;
+
+   if (tab-cells[idx])
+   free(tab-cells[idx]);
+   tab-cells[idx] = msg;
+   vsnprintf(msg, 99, fmt, ap);
+
+   return msg;
+}
+
+
+/*
+ * This function is like a printf, but store the results in a cell of
+ * the table.
+ */
+char *table_printf(struct string_table *tab, int column, int row,
+ char *fmt, ...)
+{
+   va_list ap;
+   char *ret;
+
+   va_start(ap, fmt);
+   ret = table_vprintf(tab, column, row, fmt, ap);
+   va_end(ap);
+
+   return ret;
+}
+
+/*
+ * This function dumps the table. Every = string will be replaced by
+ * a === length as the column
+ */
+void table_dump(struct string_table *tab)
+{
+   int sizes[tab-ncols];
+   int i, j;
+
+   for (i = 0 ; i  tab-ncols ; i++) {
+   sizes[i] = 0;
+   for (j = 0 ; j  tab-nrows ; j++) {
+   int idx = i + j*tab-ncols;
+   int s;
+
+   if (!tab-cells[idx])
+   continue;
+
+   s = strlen(tab-cells[idx]) - 1;
+   if (s  1 || 

[PATCH 3/8] Create the man page entry for the command btrfs fi df

2013-02-23 Thread Goffredo Baroncelli
From: Goffredo Baroncelli kreij...@inwind.it

Signed-off-by: Goffredo Baroncelli kreij...@inwind.it
---
 man/btrfs.8.in |   49 +
 1 file changed, 49 insertions(+)

diff --git a/man/btrfs.8.in b/man/btrfs.8.in
index 94f4ffe..e2f86ea 100644
--- a/man/btrfs.8.in
+++ b/man/btrfs.8.in
@@ -31,6 +31,8 @@ btrfs \- control a btrfs filesystem
 .PP
 \fBbtrfs\fP \fBfilesystem label\fP\fI dev [newlabel]\fP
 .PP
+\fBbtrfs\fP \fBfilesystem df\fP\fI [-b] \fIpath [path..]\fR\fP
+.PP
 \fBbtrfs\fP \fBfilesystem balance\fP\fI path \fP
 .PP
 \fBbtrfs\fP \fBdevice scan\fP\fI [--all-devices|device [device...]]\fP
@@ -266,6 +268,53 @@ NOTE: Currently there are the following limitations:
 - the filesystem should not have more than one device.
 .TP
 
+\fBfilesystem df\fP [-b] \fIpath [path..]\fR
+
+Show space usage information for a mount point.
+
+\fB-b\fP Set byte as unit
+
+The command \fBbtrfs filesystem df\fP is used to query how many space on the 
+disk(s) are used and an estimation of the free
+space of the filesystem.
+The output of the command \fBbtrfs filesystem df\fP shows:
+
+.RS
+.IP \fBDisk\ size\fP
+the total size of the disks which compose the filesystem.
+
+.IP \fBDisk\ allocated\fP
+the size of the area of the disks used by the chunks.
+
+.IP \fBDisk\ unallocated\fP 
+the size of the area of the disks which is free (i.e.
+the differences of the values above).
+
+.IP \fBUsed\fP
+the portion of the logical space used by the file and metadata.
+
+.IP \fBFree\ (estimated)\fP
+the estimated free space available: i.e. how many space can be used
+by the user. The evaluation 
+cannot be rigorous because it depends by the allocation policy (DUP, Single,
+RAID1...) of the metadata and data chunks. If every chunk is stored as
+Single the sum of the \fBfree (estimated)\fP space and the \fBused\fP 
+space  is equal to the \fBdisk size\fP.
+Otherwise if all the chunk are mirrored (raid1 or raid10) or duplicated
+the sum of the \fBfree (estimated)\fP space and the \fBused\fP space is
+half of the \fBdisk size\fP. Normally the \fBfree (estimated)\fP is between
+these two limits.
+
+.IP \fBData\ to\ disk\ ratio\fP
+the ratio betwen the \fBlogical size\fP (i.e. the space available by
+the chunks) and the \fBdisk allocated\fP (by the chunks). Normally it is 
+lower than 100% because the metadata is duplicated for security reasons.
+If all the data and metadata are duplicated (or have a profile like RAID1)
+the \fBData\ to\ disk\ ratio\fP could be 50%.
+
+.RE
+.TP
+
 \fBfilesystem show\fR [--all-devices|uuid|label]\fR
 Show the btrfs filesystem with some additional info. If no \fIUUID\fP or 
 \fIlabel\fP is passed, \fBbtrfs\fR show info of all the btrfs filesystem.
-- 
1.7.10.4

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


[PATCH 5/8] Add command btrfs filesystem disk-usage

2013-02-23 Thread Goffredo Baroncelli
From: Goffredo Baroncelli kreij...@inwind.it

Signed-off-by: Goffredo Baroncelli kreij...@inwind.it
---
 cmds-fi-disk_usage.c |  434 +-
 cmds-fi-disk_usage.h |2 +
 cmds-filesystem.c|2 +
 utils.c  |   58 +++
 utils.h  |3 +
 5 files changed, 498 insertions(+), 1 deletion(-)

diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 1e3589f..eea4168 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -20,11 +20,13 @@
 #include unistd.h
 #include sys/ioctl.h
 #include errno.h
+#include stdarg.h
 
 #include utils.h
 #include kerncompat.h
 #include ctree.h
 #include string_list.h
+#include string_table.h
 
 #include commands.h
 
@@ -42,7 +44,14 @@ struct chunk_info {
u64 type;
u64 size;
u64 devid;
-   int num_stripes;
+   u64 num_stripes;
+};
+
+/* to store information about the disks */
+struct disk_info {
+   u64 devid;
+   charpath[BTRFS_DEVICE_PATH_NAME_MAX];
+   u64 size;
 };
 
 /*
@@ -518,3 +527,426 @@ int cmd_filesystem_df(int argc, char **argv)
return 0;
 }
 
+/*
+ *  Helper to sort the disk_info structure
+ */
+static int cmp_disk_info(const void *a, const void *b)
+{
+   return strcmp(((struct disk_info *)a)-path,
+   ((struct disk_info *)b)-path);
+}
+
+/*
+ *  This function load the disk_info structure and put them in an array
+ */
+static int load_disks_info(int fd,
+  struct disk_info **disks_info_ptr,
+  int *disks_info_count)
+{
+
+   int ret, i, ndevs;
+   struct btrfs_ioctl_fs_info_args fi_args;
+   struct btrfs_ioctl_dev_info_args dev_info;
+   struct disk_info *info;
+
+   *disks_info_count = 0;
+   *disks_info_ptr = 0;
+
+   ret = ioctl(fd, BTRFS_IOC_FS_INFO, fi_args);
+   if (ret  0) {
+   fprintf(stderr, ERROR: cannot get filesystem info\n);
+   return -1;
+   }
+
+   info = malloc(sizeof(struct disk_info) * fi_args.num_devices);
+   if (!info) {
+   fprintf(stderr, ERROR: not enough memory\n);
+   return -1;
+   }
+
+   for (i = 0, ndevs = 0 ; i = fi_args.max_id ; i++) {
+
+   BUG_ON(ndevs = fi_args.num_devices);
+   ret = get_device_info(fd, i, dev_info);
+
+   if (ret == -ENODEV)
+   continue;
+   if (ret) {
+   fprintf(stderr,
+   ERROR: cannot get info about device devid=%d\n,
+   i);
+   free(info);
+   return -1;
+   }
+
+   info[ndevs].devid = dev_info.devid;
+   strcpy(info[ndevs].path, (char *)dev_info.path);
+   info[ndevs].size = get_partition_size((char *)dev_info.path);
+   ++ndevs;
+   }
+
+   BUG_ON(ndevs != fi_args.num_devices);
+   qsort(info, fi_args.num_devices,
+   sizeof(struct disk_info), cmp_disk_info);
+
+   *disks_info_count = fi_args.num_devices;
+   *disks_info_ptr = info;
+
+   return 0;
+
+}
+
+/*
+ *  This function computes the size of a chunk in a disk
+ */ 
+static u64 calc_chunk_size(struct chunk_info *ci)
+{
+   if (ci-type  BTRFS_BLOCK_GROUP_RAID0)
+   return ci-size / ci-num_stripes;
+   else if (ci-type  BTRFS_BLOCK_GROUP_RAID1)
+   return ci-size ;
+   else if (ci-type  BTRFS_BLOCK_GROUP_DUP)
+   return ci-size ;
+   else if (ci-type  BTRFS_BLOCK_GROUP_RAID5)
+   return ci-size / (ci-num_stripes -1);
+   else if (ci-type  BTRFS_BLOCK_GROUP_RAID6)
+   return ci-size / (ci-num_stripes -2);
+   else if (ci-type  BTRFS_BLOCK_GROUP_RAID10)
+   return ci-size / ci-num_stripes;
+   return ci-size;
+}
+
+/*
+ *  This function print the results of the command btrfs fi disk-usage
+ *  in tabular format
+ */
+static void _cmd_filesystem_disk_usage_tabular(int mode,
+   struct btrfs_ioctl_space_args *sargs,
+   struct chunk_info *chunks_info_ptr,
+   int chunks_info_count,
+   struct disk_info *disks_info_ptr,
+   int disks_info_count)
+{
+   int i;
+   u64 total_unused = 0;
+   struct string_table *matrix = 0;
+   int  ncols, nrows;
+   
+
+   ncols = sargs-total_spaces + 2;
+   nrows = 2 + 1 + disks_info_count + 1 + 2;
+
+   matrix = table_create(ncols, nrows);
+   if (!matrix) {
+   fprintf(stderr, ERROR: not enough memory\n);
+   return;
+   }
+
+   /* header */
+   for (i = 0; i  sargs-total_spaces; i++) {
+   const char *description;
+
+   u64 flags = 

[PATCH 6/8] Create entry in man page for btrfs filesystem disk-usage

2013-02-23 Thread Goffredo Baroncelli
From: Goffredo Baroncelli kreij...@inwind.it

Signed-off-by: Goffredo Baroncelli kreij...@inwind.it
---
 man/btrfs.8.in |   13 +
 1 file changed, 13 insertions(+)

diff --git a/man/btrfs.8.in b/man/btrfs.8.in
index e2f86ea..50dc510 100644
--- a/man/btrfs.8.in
+++ b/man/btrfs.8.in
@@ -29,6 +29,9 @@ btrfs \- control a btrfs filesystem
 .PP
 \fBbtrfs\fP \fBfilesystem resize\fP\fI [devid:][+/\-]size[gkm]|[devid:]max 
filesystem\fP
 .PP
+\fBbtrfs\fP \fBfilesystem filesystem disk-usage [-t][-b]\fP\fI path 
+[path..]\fP
+.PP
 \fBbtrfs\fP \fBfilesystem label\fP\fI dev [newlabel]\fP
 .PP
 \fBbtrfs\fP \fBfilesystem df\fP\fI [-b] \fIpath [path..]\fR\fP
@@ -251,6 +254,16 @@ it with the new desired size.  When recreating the 
partition make sure to use
 the same starting disk cylinder as before.
 .TP
 
+\fBfilesystem disk-usage\fP [-t][-b] \fIpath [path..]\fR
+
+Show in which disk the chunks are allocated.
+
+\fB-b\fP Set byte as unit
+
+\fB-t\fP Show data in tabular format
+
+.TP
+
 \fBfilesystem label\fP\fI dev [newlabel]\fP
 Show or update the label of a filesystem. \fIdev\fR is used to identify the
 filesystem. 
-- 
1.7.10.4

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


[PATCH 7/8] Add btrfs device disk-usage command

2013-02-23 Thread Goffredo Baroncelli
From: Goffredo Baroncelli kreij...@inwind.it

Signed-off-by: Goffredo Baroncelli kreij...@inwind.it
---
 cmds-device.c|3 ++
 cmds-fi-disk_usage.c |  141 ++
 cmds-fi-disk_usage.h |4 ++
 3 files changed, 148 insertions(+)

diff --git a/cmds-device.c b/cmds-device.c
index 198ad68..0dbc02c 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -27,6 +27,7 @@
 #include ctree.h
 #include ioctl.h
 #include utils.h
+#include cmds-fi-disk_usage.h
 
 #include commands.h
 
@@ -403,6 +404,8 @@ const struct cmd_group device_cmd_group = {
{ scan, cmd_scan_dev, cmd_scan_dev_usage, NULL, 0 },
{ ready, cmd_ready_dev, cmd_ready_dev_usage, NULL, 0 },
{ stats, cmd_dev_stats, cmd_dev_stats_usage, NULL, 0 },
+   { disk-usage, cmd_device_disk_usage,
+   cmd_device_disk_usage_usage, NULL, 0 },
{ 0, 0, 0, 0, 0 }
}
 };
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index eea4168..18350ce 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -949,4 +949,145 @@ int cmd_filesystem_disk_usage(int argc, char **argv)
return 0;
 }
 
+static void print_disk_chunks(int fd,
+   u64 devid,
+   u64 total_size,
+   struct chunk_info *chunks_info_ptr,
+   int chunks_info_count,
+   int mode)
+{
+   int i;
+   u64 allocated = 0;
+   char *s;
+
+   for (i = 0 ; i  chunks_info_count ; i++) {
+   const char *description;
+   const char *r_mode;
+   u64 flags;
+   u64 size;
+
+   if (chunks_info_ptr[i].devid != devid)
+   continue;
+
+   flags = chunks_info_ptr[i].type;
+
+   description = btrfs_flags2description(flags);
+   r_mode = btrfs_flags2profile(flags);
+   size = calc_chunk_size(chunks_info_ptr+i);
+   s = df_pretty_sizes(size, mode);
+   printf(   %s,%s:%*s%10s\n,
+   description,
+   r_mode,
+   (int)(20 - strlen(description) - strlen(r_mode)), ,
+   s);
+
+   allocated += size;
+
+   }
+   s = df_pretty_sizes(total_size - allocated, mode);
+   printf(   Unallocated: %*s%10s\n,
+   (int)(20 - strlen(Unallocated)), ,
+   s);
+
+}
+
+static int _cmd_device_disk_usage(int fd, char *path, int mode)
+{
+   int i;
+   int ret = 0;
+   int info_count = 0;
+   struct chunk_info *info_ptr = 0;
+   struct disk_info *disks_info_ptr = 0;
+   int disks_info_count = 0;
+
+   if (load_chunk_info(fd, info_ptr, info_count) ||
+   load_disks_info(fd, disks_info_ptr, disks_info_count)) {
+   ret = -1;
+   goto exit;
+   }
+
+   for (i = 0 ; i  disks_info_count ; i++) {
+   char *s;
+
+   s = df_pretty_sizes(disks_info_ptr[i].size, mode);
+   printf(%s\t%10s\n, disks_info_ptr[i].path, s);
+
+   print_disk_chunks(fd, disks_info_ptr[i].devid,
+   disks_info_ptr[i].size,
+   info_ptr, info_count,
+   mode);
+   printf(\n);
+
+   }
+
+
+exit:
+
+   string_list_free();
+   if (disks_info_ptr)
+   free(disks_info_ptr);
+   if (info_ptr)
+   free(info_ptr);
+
+   return ret;
+}
+
+const char * const cmd_device_disk_usage_usage[] = {
+   btrfs device disk-usage [-b] path [path..],
+   Show which chunks are in a device.,
+   ,
+   -b\tSet byte as unit,
+   NULL
+};
+
+int cmd_device_disk_usage(int argc, char **argv)
+{
+
+   int flags = DF_HUMAN_UNIT;
+   int i, more_than_one = 0;
+
+   optind = 1;
+   while (1) {
+   charc = getopt(argc, argv, b);
+
+   if (c  0)
+   break;
+
+   switch (c) {
+   case 'b':
+   flags = ~DF_HUMAN_UNIT;
+   break;
+   default:
+   usage(cmd_device_disk_usage_usage);
+   }
+   }
+
+   if (check_argc_min(argc - optind, 1)) {
+   usage(cmd_device_disk_usage_usage);
+   return 21;
+   }
+
+   for (i = optind; i  argc ; i++) {
+   int r, fd;
+   if (more_than_one)
+   printf(\n);
+
+   fd = open_file_or_dir(argv[i]);
+   if (fd  0) {
+   fprintf(stderr, ERROR: can't access to '%s'\n,
+   argv[1]);
+   return 12;
+   }
+   r = _cmd_device_disk_usage(fd, argv[i], flags);
+ 

[PATCH 8/8] Create a new entry in btrfs man page for btrfs device disk-usage.

2013-02-23 Thread Goffredo Baroncelli
From: Goffredo Baroncelli kreij...@inwind.it

Signed-off-by: Goffredo Baroncelli kreij...@inwind.it
---
 man/btrfs.8.in |8 
 1 file changed, 8 insertions(+)

diff --git a/man/btrfs.8.in b/man/btrfs.8.in
index 50dc510..e60c81f 100644
--- a/man/btrfs.8.in
+++ b/man/btrfs.8.in
@@ -46,6 +46,8 @@ btrfs \- control a btrfs filesystem
 .PP
 \fBbtrfs\fP \fBdevice delete\fP\fI device [device...] path \fP
 .PP
+\fBbtrfs\fP \fBdevice disk-usage\fP\fI [-b] path [path...] \fP
+.PP
 \fBbtrfs\fP \fBreplace start\fP \fI[-Bfr] srcdev|devid targetdev 
path\fP
 .PP
 \fBbtrfs\fP \fBreplace status\fP \fI[-1] path\fP
@@ -360,6 +362,12 @@ Add device(s) to the filesystem identified by \fIpath\fR.
 Remove device(s) from a filesystem identified by \fIpath\fR.
 .TP
 
+\fBdevice disk-usage\fR\fI [-b] path [path..] path\fR
+Show which chunks are in a device.
+
+\fB-b\fP set byte as unit.
+.TP
+
 \fBdevice scan\fR \fI[--all-devices|device [device...]\fR
 If one or more devices are passed, these are scanned for a btrfs filesystem. 
 If no devices are passed, \fBbtrfs\fR scans all the block devices listed
-- 
1.7.10.4

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


Re: collapse concurrent forced allocations

2013-02-23 Thread Alexandre Oliva
On Feb 22, 2013, Josef Bacik jba...@fusionio.com wrote:

 So I understand what you are getting at, but I think you are doing it wrong.  
 If
 we're calling with CHUNK_ALLOC_FORCE, but somebody has already started to
 allocate with CHUNK_ALLOC_NO_FORCE, we'll reset the space_info-force_alloc to
 our original caller's CHUNK_ALLOC_FORCE.

But that's ok, do_chunk_alloc will set space_info-force_alloc to
CHUNK_ALLOC_NO_FORCE at the end, when it succeeds allocating, and then
anyone else waiting on the mutex to try to allocate will load the
NO_FORCE from space_info.

 So we only really care about making sure a chunk is actually
 allocated, instead of doing this flag shuffling we should just do

 if (space_info-chunk_alloc) {
   spin_unlock(space_info-lock);
   wait_event(!space_info-chunk_alloc);
   return 0;
 }

Sorry, I don't follow.

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist  Red Hat Brazil Compiler Engineer
--
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


Changing node leaf size on live partition.

2013-02-23 Thread Tomasz Kusmierz

Hi,

Question is pretty simple:

How to change node size and leaf size on previously created partition?

Now, I know what most people will say: you should've be smarter while 
typing mkfs.btrfs. Well, I'm intending to convert in place ext4 
partition but there seems to be no option for leaf and node size in this 
tool. If it's not possible I guess I'll have to create / from scratch 
and copy all my content there.




BTW. To Chris and other who were involved - after fixing this static 
electricity from printer issue I've been running rock solid raid10 
since then! Great job guys, really appreciate.



Cheers, Tom.

--
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: copy on write misconception

2013-02-23 Thread Mike Power

On 02/22/2013 10:35 AM, cwillu wrote:

On Fri, Feb 22, 2013 at 11:41 AM, Mike Power dodts...@gmail.com wrote:

On 02/22/2013 09:16 AM, Hugo Mills wrote:

On Fri, Feb 22, 2013 at 09:11:28AM -0800, Mike Power wrote:

I think I have a misconception of what copy on write in btrfs means
for individual files.

I had originally thought that I could create a large file:
time dd if=/dev/zero of=10G bs=1G count=10
10+0 records in
10+0 records out
10737418240 bytes (11 GB) copied, 100.071 s, 107 MB/s

real1m41.082s
user0m0.000s
sys0m7.792s

Then if I copied this file no blocks would be copied until they are
written.  Hence the two files would use the same blocks underneath.
But specifically that copy would be fast.  Since it would only need
to write some metadata.  But when I copy the file:
time cp 10G 10G2

real3m38.790s
user0m0.124s
sys0m10.709s

Oddly enough it actually takes longer then the initial file
creation.  So I am guessing that the long duration copy of the file
is expected and that is not one of the virtues of btrfs copy on
write.  Does that sound right?

 You probably want cp --reflink=always, which makes a CoW copy of
the file's metadata only. The resulting files have the semantics of
two different files, but share their blocks until a part of one of
them is modified (at which point, the modified blocks are no longer
shared).

 Hugo.


I see, and it works great:
time cp --reflink=always 10G 10G3

real0m0.028s
user0m0.000s
sys0m0.000s

So from the user perspective I might say I want to opt out of this feature
not optin.  I want all copies by all applications done as a copy on write.
But if my understanding is correct that is up to the application being
called (in this case cp) and how it in turns makes calls to the system.

In short I can't remount the btrfs filesystem with some new args that says
always copy on write files because that is what it already.

There's no copy a file syscall; when a program copies a file, it
opens a new file, and writes all the bytes from the old to the new.
Converting this to a reflink would require btrfs to implement full
de-dup (which is rather expensive), and still wouldn't prevent the
program from reading and writing all 10gb (and so wouldn't be any
faster).

You can set an alias in your shell to make cp --reflink=auto the
default, but that won't affect other programs, nor other users.
Thanks for the help guys.  I learned that if I want some application to 
support this behavior they must specifically choose to implement it.

--
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: Changing node leaf size on live partition.

2013-02-23 Thread Hugo Mills
On Sat, Feb 23, 2013 at 03:14:56PM +, Tomasz Kusmierz wrote:
 Hi,
 
 Question is pretty simple:
 
 How to change node size and leaf size on previously created partition?

   Right now, I'm afraid we don't support it. It's one of the trickier
conversions to do, and I suspect that if it does happen, it'll be
offline only, and may not be implemented in the near future (if at all).

 Now, I know what most people will say: you should've be smarter
 while typing mkfs.btrfs. Well, I'm intending to convert in place
 ext4 partition but there seems to be no option for leaf and node
 size in this tool. If it's not possible I guess I'll have to create
 / from scratch and copy all my content there.

   Yeah, that's probably your best bet for the forseeable future, I'm
afraid. (But given that we recommend having backups anyway, it's not a
big problem to wipe it all and restore from them, right? ;) )

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
  --- Q: What goes, Pieces of seven! Pieces of seven!? A: ---  
A parroty error. 


signature.asc
Description: Digital signature


Is my btrfs filesystem definitely dead?

2013-02-23 Thread Sébastien Luttringer
Hello, after a crash with linux 3.8.0, I'm unable to mount my btrfs root
filesystem. I tried with a archlinux rescue cd with a linux 3.7.5, but I
got the following errors:

First trying to fix the fs:

# btrfsck
usage: btrfsck dev
Btrfs v0.20-rc1
# btrfsck /dev/sdd2
checking extents
checking fs roots
checking root refs
[1]1051 segmentation fault (core dumped)  btrfsck /dev/sdd2
# dmesg|grep 1051
[  956.804097] btrfsck[1051]: segfault at 7f563c319410 ip
7f56307c4c25 sp 7a7fbdf0 error 4 in
libc-2.17.so[7f563074a000+1a4000]


Trying to mount the FS i got a OOPS.
# mount /dev/sdd2 /new_root
[   60.602232] device label bitumefs devid 1 transid 40042 /dev/sdd2
[   60.603629] btrfs: disk space caching is enabled
[   60.615642] Btrfs detected SSD devices, enabling SSD mode
[   60.769651] [ cut here ]
[   60.769709] kernel BUG at fs/btrfs/free-space-cache.c:1553!
[   60.769764] invalid opcode:  [#1] PREEMPT SMP
[   60.769833] Modules linked in: raid456 async_raid6_recov async_memcpy
async_pq raid6_pq async_xor xor async_tx md_mod coretemp kvm_intel
iTCO_wdt iTCO_vendor_support gpio_ich acpi_cpufreq i2c_i801 mei mperf
kvm lpc_ich pcspkr processor evdev microcode nfs lockd sunrpc fscache
ext4 crc16 jbd2 mbcache dm_snapshot dm_mod squashfs loop isofs btrfs
libcrc32c zlib_deflate sr_mod cdrom usb_storage sd_mod i915 video
i2c_algo_bit ahci uhci_hcd crc32c_intel drm_kms_helper libahci xhci_hcd
ehci_hcd r8169 mii drm usbcore usb_common i2c_core sata_mv libata
scsi_mod intel_agp intel_gtt button
[   60.770686] CPU 0
[   60.770712] Pid: 515, comm: mount Not tainted 3.7.5-1-ARCH #1
Gigabyte Technology Co., Ltd. H55N-USB3/H55N-USB3
[   60.772551] RIP: 0010:[a03cd59f]  [a03cd59f]
remove_from_bitmap+0x16f/0x180 [btrfs]
[   60.774452] RSP: 0018:88010d231698  EFLAGS: 00010287
[   60.776343] RAX:  RBX: 88010e8238c0 RCX:
880110b433e4
[   60.778270] RDX: 0002019d6000 RSI: 8000 RDI:
00c0
[   60.780211] RBP: 88010d2316e8 R08: 880110031fe8 R09:
7f40
[   60.782139] R10:  R11: a037b428 R12:
88010d231710
[   60.784063] R13: 88010d231708 R14: 880110b433c0 R15:
000201c0
[   60.785998] FS:  7fbb73158780() GS:880117c0()
knlGS:
[   60.787971] CS:  0010 DS:  ES:  CR0: 8005003b
[   60.789952] CR2: 7fd73954ea30 CR3: 00010fa26000 CR4:
07f0
[   60.791962] DR0:  DR1:  DR2:

[   60.793991] DR3:  DR6: 0ff0 DR7:
0400
[   60.796043] Process mount (pid: 515, threadinfo 88010d23,
task 88010f0938e0)
[   60.798148] Stack:
[   60.800233]  88010d2318a3 880110b433e4 000201b48000
00021000
[   60.802404]  88010d231748 88010e8238c0 880110b433c0
fff5
[   60.804598]  880110b433e4 880111faa800 88010d231748
a03cf8f3
[   60.806813] Call Trace:
[   60.809009]  [a03cf8f3] btrfs_remove_free_space+0x53/0x260
[btrfs]
[   60.811262]  [a038309f]
btrfs_alloc_logged_file_extent+0x1bf/0x1e0 [btrfs]
[   60.813532]  [a036f1ea] ? btrfs_free_path+0x2a/0x40 [btrfs]
[   60.815815]  [a03c8990] replay_one_extent+0x620/0x690 [btrfs]
[   60.818095]  [a03aca29] ?
release_extent_buffer.isra.26+0xb9/0xe0 [btrfs]
[   60.820373]  [a03b30c3] ? read_extent_buffer+0xc3/0x120 [btrfs]
[   60.822662]  [a03c9a1b] replay_one_buffer+0x2db/0x3a0 [btrfs]
[   60.824982]  [a03b19bd] ? alloc_extent_buffer+0x9d/0x490
[btrfs]
[   60.827336]  [a03c63e2] walk_down_log_tree+0x212/0x400 [btrfs]
[   60.829689]  [a03c666d] walk_log_tree+0x9d/0x1f0 [btrfs]
[   60.832043]  [a03cc9eb] btrfs_recover_log_trees+0x21b/0x3a0
[btrfs]
[   60.834427]  [a03c9740] ? replay_one_dir_item+0xf0/0xf0 [btrfs]
[   60.836830]  [a03929d7] open_ctree+0x1587/0x1ba0 [btrfs]
[   60.839233]  [81255091] ? disk_name+0x61/0xc0
[   60.841637]  [a036bae3] btrfs_mount+0x633/0x770 [btrfs]
[   60.844056]  [8126a8f8] ? ida_get_new_above+0x218/0x2a0
[   60.846488]  [81188163] mount_fs+0x43/0x1b0
[   60.848896]  [81142e40] ? __alloc_percpu+0x10/0x20
[   60.851296]  [811a2974] vfs_kern_mount+0x74/0x110
[   60.853691]  [811a2ed4] do_kern_mount+0x54/0x110
[   60.856083]  [811a4b55] do_mount+0x315/0x8e0
[   60.858464]  [8113d776] ? memdup_user+0x46/0x80
[   60.860833]  [8113d80b] ? strndup_user+0x5b/0x80
[   60.863144]  [811a51ae] sys_mount+0x8e/0xe0
[   60.865399]  [814c111d] system_call_fastpath+0x1a/0x1f
[   60.867600] Code: 8e 0f 1f 00 31 c0 48 83 7b 20 00 75 d5 48 89 de 4c
89 f7 89 45 b0 e8 01 f8 ff ff 8b 45 b0 eb c2 0f 1f 40 00 b8 ea ff ff ff
eb b7 0f 0b 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 66 66 66 66
[   60.872568] RIP  

Changing node leaf size on live partition.

2013-02-23 Thread Tom Kusmierz

Hi,

Question is pretty simple:

How to change node size and leaf size on previously created partition?

Now, I know what most people will say: you should've be smarter while 
typing mkfs.btrfs. Well, I'm intending to convert in place ext4 
partition but there seems to be no option for leaf and node size in this 
tool. If it's not possible I guess I'll have to create / from scratch 
and copy all my content there.




BTW. To Chris and other who were involved - after fixing this static 
electricity from printer issue I've been running rock solid raid10 
since then! Great job guys, really appreciate.



Cheers, Tom.
--
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: Is my btrfs filesystem definitely dead?

2013-02-23 Thread Sébastien Luttringer
On 23/02/2013 23:48, Sébastien Luttringer wrote:
 Hello, after a crash with linux 3.8.0, I'm unable to mount my btrfs root
 filesystem. I tried with a archlinux rescue cd with a linux 3.7.5, but I
 got the following errors:
 
 ... 
 
 Trying to mount the FS i got a OOPS.
 
 Is there something I can do to fix my filesystem?
 
I (with help) found a great page[1] explaining how to handle this case.

# btrfs-zero-log /dev/sdd2
extent buffer leak: start 73207808 len 4096
*** Error in `btrfs-zero-log': corrupted double-linked list:
0x00ac5ff0 ***

I have the btrfs-image dump saved if a developer is interested.


[1]
https://btrfs.wiki.kernel.org/index.php/Problem_FAQ#I_can.27t_mount_my_filesystem.2C_and_I_get_a_kernel_oops.21


-- 
Sébastien Seblu Luttringer
https://www.seblu.net
GPG: 0x2072D77A

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


Changing node leaf size on live partition.

2013-02-23 Thread Tomasz Kusmierz

Hi,

Question is pretty simple:

How to change node size and leaf size on previously created partition?

Now, I know what most people will say: you should've be smarter while 
typing mkfs.btrfs. Well, I'm intending to convert in place ext4 
partition but there seems to be no option for leaf and node size in this 
tool. If it's not possible I guess I'll have to create / from scratch 
and copy all my content there.




BTW. To Chris and other who were involved - after fixing this static 
electricity from printer issue I've been running rock solid raid10 
since then! Great job guys, really appreciate.



Cheers, Tom.

--
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: Is my btrfs filesystem definitely dead?

2013-02-23 Thread Jan Steffens
On Sat, Feb 23, 2013 at 11:48 PM, Sébastien Luttringer se...@seblu.net wrote:
 Trying to mount the FS i got a OOPS.
 # mount /dev/sdd2 /new_root
 [   60.602232] device label bitumefs devid 1 transid 40042 /dev/sdd2
 [   60.603629] btrfs: disk space caching is enabled
 [   60.615642] Btrfs detected SSD devices, enabling SSD mode
 [   60.769651] [ cut here ]
 [   60.769709] kernel BUG at fs/btrfs/free-space-cache.c:1553!

The BUG_ON in question is this one:

/*
 * We need to search for bits in this bitmap.  We could only cover some
 * of the extent in this bitmap thanks to how we add space, so we need
 * to search for as much as it as we can and clear that amount, and then
 * go searching for the next bit.
 */
search_start = *offset;
search_bytes = ctl-unit;
search_bytes = min(search_bytes, end - search_start + 1);
ret = search_bitmap(ctl, bitmap_info, search_start, search_bytes);
BUG_ON(ret  0 || search_start != *offset); /* -- 1553 */

/* We may have found more bits than what we need */
search_bytes = min(search_bytes, *bytes);

Since the bug happens during log replay, I expect btrfs-zero-log will
get the partition mountable again, albeit with some data loss.

However, if you can, make an image of the affected partition first, to
further help debug this.
--
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