[PATCH] Btrfs-progs: make use of column_name

2012-10-16 Thread Anand jain
From: Anand Jain anand.j...@oracle.com

Signed-off-by: Anand Jain anand.j...@oracle.com
---
 btrfs-list.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/btrfs-list.c b/btrfs-list.c
index 74782b8..9cfdb35 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -1432,7 +1432,7 @@ static void print_all_volume_info_tab_head()
 
for (i = 0; i  BTRFS_LIST_ALL; i++) {
if (btrfs_list_columns[i].need_print)
-   printf(%s\t, btrfs_list_columns[i].name);
+   printf(%s\t, btrfs_list_columns[i].column_name);
 
if (i == BTRFS_LIST_ALL-1)
printf(\n);
@@ -1442,7 +1442,7 @@ static void print_all_volume_info_tab_head()
memset(barrier, 0, sizeof(barrier));
 
if (btrfs_list_columns[i].need_print) {
-   len = strlen(btrfs_list_columns[i].name);
+   len = strlen(btrfs_list_columns[i].column_name);
while (len--)
strcat(barrier, -);
 
-- 
1.7.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 V3] Btrfs-progs: add parent uuid for snapshots

2012-10-16 Thread Anand jain
From: Anand Jain anand.j...@oracle.com

Signed-off-by: Anand Jain anand.j...@oracle.com
---
 btrfs-list.c |   32 +++-
 btrfs-list.h |1 +
 cmds-subvolume.c |6 +-
 3 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/btrfs-list.c b/btrfs-list.c
index e5f0f96..5314ced 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -80,6 +80,7 @@ struct root_info {
time_t otime;
 
u8 uuid[BTRFS_UUID_SIZE];
+   u8 puuid[BTRFS_UUID_SIZE];
 
/* path from the subvol we live in to this root, including the
 * root's name.  This is null until we do the extra lookup ioctl.
@@ -128,6 +129,11 @@ struct {
.need_print = 0,
},
{
+   .name   = parent UUID,
+   .column_name= Parent UUID,
+   .need_print = 0,
+   },
+   {
.name   = uuid,
.column_name= UUID,
.need_print = 0,
@@ -435,7 +441,7 @@ static struct root_info *root_tree_search(struct 
root_lookup *root_tree,
 static int update_root(struct root_lookup *root_lookup,
   u64 root_id, u64 ref_tree, u64 root_offset, u64 flags,
   u64 dir_id, char *name, int name_len, u64 ogen, u64 gen,
-  time_t ot, void *uuid)
+  time_t ot, void *uuid, void *puuid)
 {
struct root_info *ri;
 
@@ -472,6 +478,8 @@ static int update_root(struct root_lookup *root_lookup,
ri-otime = ot;
if (uuid)
memcpy(ri-uuid, uuid, BTRFS_UUID_SIZE);
+   if (puuid)
+   memcpy(ri-puuid, puuid, BTRFS_UUID_SIZE);
 
return 0;
 }
@@ -489,17 +497,18 @@ static int update_root(struct root_lookup *root_lookup,
  * gen: the current generation of the root
  * ot: the original time(create time) of the root
  * uuid: uuid of the root
+ * puuid: uuid of the root parent if any
  */
 static int add_root(struct root_lookup *root_lookup,
u64 root_id, u64 ref_tree, u64 root_offset, u64 flags,
u64 dir_id, char *name, int name_len, u64 ogen, u64 gen,
-   time_t ot, void *uuid)
+   time_t ot, void *uuid, void *puuid)
 {
struct root_info *ri;
int ret;
 
ret = update_root(root_lookup, root_id, ref_tree, root_offset, flags,
- dir_id, name, name_len, ogen, gen, ot, uuid);
+ dir_id, name, name_len, ogen, gen, ot, uuid, puuid);
if (!ret)
return 0;
 
@@ -540,6 +549,9 @@ static int add_root(struct root_lookup *root_lookup,
if (uuid) 
memcpy(ri-uuid, uuid, BTRFS_UUID_SIZE);
 
+   if (puuid)
+   memcpy(ri-puuid, puuid, BTRFS_UUID_SIZE);
+
ret = root_tree_insert(root_lookup, ri);
if (ret) {
printf(failed to insert tree %llu\n, (unsigned long 
long)root_id);
@@ -1022,6 +1034,7 @@ static int __list_subvol_search(int fd, struct 
root_lookup *root_lookup)
int i;
time_t t;
u8 uuid[BTRFS_UUID_SIZE];
+   u8 puuid[BTRFS_UUID_SIZE];
 
root_lookup_init(root_lookup);
memset(args, 0, sizeof(args));
@@ -1075,7 +1088,7 @@ static int __list_subvol_search(int fd, struct 
root_lookup *root_lookup)
 
add_root(root_lookup, sh-objectid, sh-offset,
 0, 0, dir_id, name, name_len, 0, 0, 0,
-NULL);
+NULL, NULL);
} else if (sh-type == BTRFS_ROOT_ITEM_KEY) {
ri = (struct btrfs_root_item *)(args.buf + off);
gen = btrfs_root_generation(ri);
@@ -1085,15 +1098,17 @@ static int __list_subvol_search(int fd, struct 
root_lookup *root_lookup)
t = ri-otime.sec;
ogen = btrfs_root_otransid(ri);
memcpy(uuid, ri-uuid, BTRFS_UUID_SIZE);
+   memcpy(puuid, ri-parent_uuid, 
BTRFS_UUID_SIZE);
} else {
t = 0;
ogen = 0;
memset(uuid, 0, BTRFS_UUID_SIZE);
+   memset(puuid, 0, BTRFS_UUID_SIZE);
}
 
add_root(root_lookup, sh-objectid, 0,
 sh-offset, flags, 0, NULL, 0, ogen,
-gen, t, uuid);
+gen, t, uuid, puuid);
}
 
off += sh-len;
@@ -1347,6 +1362,13 @@ static void print_subvolume_column(struct root_info 
*subv,
  

[PATCH] Btrfs-progs: update man page for -u and -q option in subvol list

2012-10-16 Thread Anand jain
From: Anand Jain anand.j...@oracle.com

Signed-off-by: Anand Jain anand.j...@oracle.com
---
 man/btrfs.8.in |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/man/btrfs.8.in b/man/btrfs.8.in
index 57c25b0..91f2af2 100644
--- a/man/btrfs.8.in
+++ b/man/btrfs.8.in
@@ -11,7 +11,7 @@ btrfs \- control a btrfs filesystem
 .PP
 \fBbtrfs\fP \fBsubvolume create\fP\fI [dest/]name\fP
 .PP
-\fBbtrfs\fP \fBsubvolume list\fP\fI [-aprts] [-g [+|-]value] [-c [+|-]value] 
[--rootid=rootid,gen,ogen,path] path\fP
+\fBbtrfs\fP \fBsubvolume list\fP\fI [-apruqts] [-g [+|-]value] [-c [+|-]value] 
[--rootid=rootid,gen,ogen,path] path\fP
 .PP
 \fBbtrfs\fP \fBsubvolume set-default\fP\fI id path\fP
 .PP
@@ -110,7 +110,7 @@ Create a subvolume in \fIdest\fR (or in the current 
directory if
 \fIdest\fR is omitted).
 .TP
 
-\fBsubvolume list\fR\fI [-aprts][-g [+|-]value] [-c [+|-]value] 
[--sort=gen,ogen,rootid,path] path\fR
+\fBsubvolume list\fR\fI [-apruqts][-g [+|-]value] [-c [+|-]value] 
[--sort=gen,ogen,rootid,path] path\fR
 .RS
 List the subvolumes present in the filesystem \fIpath\fR. For every
 subvolume the following information is shown by default.
@@ -132,6 +132,10 @@ and top level. The parent's ID may be used at mount time 
via the
 
 \fB-s\fP only snapshot subvolumes in the filesystem will  be listed.
 
+\fB-u\fP print UUID of the subvolume.
+
+\fB-q\fP print parent UUID of the subvolume.
+
 \fB-g [+|-]value\fP
 list subvolumes in the filesystem that its generation is
 =, = or = value. '+' means = value, '-' means = value, If there is
-- 
1.7.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 V2] Btrfs-progs: add parent uuid for snapshots

2012-10-16 Thread Anand Jain



I agree. Thanks for the comments.
New patch has been sent out.

-Anand


On 09/10/12 23:44, David Sterba wrote:

On Fri, Oct 05, 2012 at 10:25:22AM +0800, Anand jain wrote:

@@ -128,6 +129,11 @@ struct {
.need_print = 0,
},
{
+   .name   = puuid,
+   .column_name= PUUID,


the capitalized 'P' looks like it's part of the UUID abbreviation. The
UUIDs are long, I think you can print 'parent UUID' in the header, the
name for command line argument 'puuid' is understable.


+   .need_print = 0,
+   },
+   {
.name   = uuid,
.column_name= UUID,
.need_print = 0,



--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -267,6 +267,7 @@ static const char * const cmd_subvol_list_usage[] = {
-p   print parent ID,
-a   print all the subvolumes in the filesystem.,
-u   print the uuid of subvolumes (and snapshots),
+   -P   print the parent uuid of snapshots,


This clashes with my efforts to make the options consistent so that we
can have a lowercase for column selection and uppercase for filter. In
case of the parent UUID,  it makes sense to filter by it, eg when we
have a hierarchy of subvolumes that keep the same structure but is
replicated several times.

I suggest to pick a different letter than 'P', say 'q'. (-q is usually
used for 'no verbose output' in utilities, but it does not make much
sense in context of 'subvol list' so I hope it's ok from the UI POV).


-t   print the result as a table,
-s   list snapshots only in the filesystem,
-r   list readonly subvolumes (including snapshots),


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


[PATCH] btrfs-progs: add -V description in print_usage

2012-10-16 Thread Wang Sheng-Hui
mkfs supports the option -V/--version.
Add its description to print_usage().

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 mkfs.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/mkfs.c b/mkfs.c
index 47f0c9c..2cc6051 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -349,6 +349,7 @@ static void print_usage(void)
fprintf(stderr, \t -s --sectorsize min block allocation\n);
fprintf(stderr, \t -r --rootdir the source directory\n);
fprintf(stderr, \t -K --nodiscard do not perform whole device TRIM\n);
+   fprintf(stderr, \t -V --version Print the mkfs.btrfs version and 
exit\n);
fprintf(stderr, %s\n, BTRFS_BUILD_VERSION);
exit(1);
 }
-- 
1.7.5.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] btrfs: Return EINVAL when length to trim is less than FSB

2012-10-16 Thread Lukas Czerner
Currently if len argument in btrfs_ioctl_fitrim() is smaller than
one FSB we will continue and finally return 0 bytes discarded.
However if the length to discard is smaller then file system block
we should really return EINVAL.

Signed-off-by: Lukas Czerner lczer...@redhat.com
---
 fs/btrfs/ioctl.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 6116880..3b8b509 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -343,7 +343,8 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, 
void __user *arg)
return -EOPNOTSUPP;
if (copy_from_user(range, arg, sizeof(range)))
return -EFAULT;
-   if (range.start  total_bytes)
+   if (range.start  total_bytes ||
+   range.len  fs_info-sb-s_blocksize)
return -EINVAL;
 
range.len = min(range.len, total_bytes - range.start);
-- 
1.7.7.6

--
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: fix deadlock caused by the nested chunk allocation

2012-10-16 Thread Miao Xie
Steps to reproduce:
 # mkfs.btrfs -m raid1 disk1 disk2
 # btrfstune -S 1 disk1
 # mount disk1 mnt
 # btrfs device add disk3 disk4 mnt
 # mount -o remount,rw mnt
 # dd if=/dev/zero of=mnt/tmpfile bs=1M count=1
 Deadlock happened.

It is because of the nested chunk allocation. When we wrote the data
into the filesystem, we would allocate the data chunk because there was
no data chunk in the filesystem. At the end of the data chunk allocation,
we should insert the metadata of the data chunk into the extent tree, but
there was no raid1 chunk, so we tried to lock the chunk allocation mutex to
allocate the new chunk, but we had held the mutex, the deadlock happened.

By rights, we would allocate the raid1 chunk when we added the second device
because the profile of the seed filesystem is raid1 and we had two devices.
But we didn't do that in fact. It is because the last step of the first device
insertion didn't commit the transaction. So when we added the second device,
we didn't cow the tree, and just inserted the relative metadata into the leaves
which were generated by the first device insertion, and its profile was dup.

So, I fix this problem by commiting the transaction at the end of the first
device insertion.

Signed-off-by: Miao Xie mi...@cn.fujitsu.com
---
 fs/btrfs/volumes.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index ed1ff1c..42127cc 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1814,6 +1814,13 @@ int btrfs_init_new_device(struct btrfs_root *root, char 
*device_path)
Failed to relocate sys chunks after 
device initialization. This can be fixed 
using the \btrfs balance\ command.);
+   trans = btrfs_attach_transaction(root);
+   if (IS_ERR(trans)) {
+   if (PTR_ERR(trans) == -ENOENT)
+   return 0;
+   return PTR_ERR(trans);
+   }
+   ret = btrfs_commit_transaction(trans, root);
}
 
return ret;
-- 
1.6.5.2
--
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/2] Btrfs: fix wrong comment in can_overcommit()

2012-10-16 Thread Miao Xie
The comment is not coincident with the code. Fix it.

Signed-off-by: Miao Xie mi...@cn.fujitsu.com
---
 fs/btrfs/extent-tree.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 7563db7..2cfcce2 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3668,9 +3668,9 @@ static int can_overcommit(struct btrfs_root *root,
avail = 1;
 
/*
-* If we aren't flushing don't let us overcommit too much, say
-* 1/8th of the space.  If we can flush, let it overcommit up to
-* 1/2 of the space.
+* If we aren't flushing all things, let us overcommit up to
+* 1/2th of the space. If we can flush, don't let us overcommit
+* too much, let it overcommit up to 1/8 of the space.
 */
if (flush)
avail = 3;
-- 
1.7.6.5
--
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/2] Btrfs: improve the noflush reservation

2012-10-16 Thread Miao Xie
In some places(such as: evicting inode), we just can not flush the reserved
space of delalloc, flushing the delayed directory index and delayed inode
is OK, but we don't try to flush those things and just go back when there is
no enough space to be reserved. This patch fixes this problem.

We defined 3 types of the flush operations: NO_FLUSH, FLUSH_LIMIT and FLUSH_ALL.
If we can in the transaction, we should not flush anything, or the deadlock
would happen, so use NO_FLUSH. If we flushing the reserved space of delalloc
would cause deadlock, use FLUSH_LIMIT. In the other cases, FLUSH_ALL is used,
and we will flush all things.

Signed-off-by: Miao Xie mi...@cn.fujitsu.com
---
 fs/btrfs/ctree.h |   26 -
 fs/btrfs/delayed-inode.c |6 ++-
 fs/btrfs/extent-tree.c   |   97 +++---
 fs/btrfs/inode-map.c |5 +-
 fs/btrfs/inode.c |5 +-
 fs/btrfs/relocation.c|   12 --
 fs/btrfs/transaction.c   |   30 +++
 fs/btrfs/transaction.h   |2 +-
 8 files changed, 97 insertions(+), 86 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 1630be8..00bd7ba 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2900,6 +2900,18 @@ void btrfs_create_pending_block_groups(struct 
btrfs_trans_handle *trans,
 u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags);
 u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data);
 void btrfs_clear_space_info_full(struct btrfs_fs_info *info);
+
+enum btrfs_reserve_flush_enum {
+   /* If we are in the transaction, we can't flush anything.*/
+   BTRFS_RESERVE_NO_FLUSH,
+   /*
+* Flushing delalloc may cause deadlock somewhere, in this
+* case, use FLUSH LIMIT
+*/
+   BTRFS_RESERVE_FLUSH_LIMIT,
+   BTRFS_RESERVE_FLUSH_ALL,
+};
+
 int btrfs_check_data_free_space(struct inode *inode, u64 bytes);
 void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes);
 void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
@@ -2919,19 +2931,13 @@ struct btrfs_block_rsv *btrfs_alloc_block_rsv(struct 
btrfs_root *root,
 void btrfs_free_block_rsv(struct btrfs_root *root,
  struct btrfs_block_rsv *rsv);
 int btrfs_block_rsv_add(struct btrfs_root *root,
-   struct btrfs_block_rsv *block_rsv,
-   u64 num_bytes);
-int btrfs_block_rsv_add_noflush(struct btrfs_root *root,
-   struct btrfs_block_rsv *block_rsv,
-   u64 num_bytes);
+   struct btrfs_block_rsv *block_rsv, u64 num_bytes,
+   enum btrfs_reserve_flush_enum flush);
 int btrfs_block_rsv_check(struct btrfs_root *root,
  struct btrfs_block_rsv *block_rsv, int min_factor);
 int btrfs_block_rsv_refill(struct btrfs_root *root,
- struct btrfs_block_rsv *block_rsv,
- u64 min_reserved);
-int btrfs_block_rsv_refill_noflush(struct btrfs_root *root,
-  struct btrfs_block_rsv *block_rsv,
-  u64 min_reserved);
+  struct btrfs_block_rsv *block_rsv, u64 min_reserved,
+  enum btrfs_reserve_flush_enum flush);
 int btrfs_block_rsv_migrate(struct btrfs_block_rsv *src_rsv,
struct btrfs_block_rsv *dst_rsv,
u64 num_bytes);
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index b26d2f9..c1b6ea8 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -651,7 +651,8 @@ static int btrfs_delayed_inode_reserve_metadata(
 */
if (!src_rsv || (!trans-bytes_reserved 
 src_rsv-type != BTRFS_BLOCK_RSV_DELALLOC)) {
-   ret = btrfs_block_rsv_add_noflush(root, dst_rsv, num_bytes);
+   ret = btrfs_block_rsv_add(root, dst_rsv, num_bytes,
+ BTRFS_RESERVE_NO_FLUSH);
/*
 * Since we're under a transaction reserve_metadata_bytes could
 * try to commit the transaction which will make it return
@@ -686,7 +687,8 @@ static int btrfs_delayed_inode_reserve_metadata(
 * reserve something strictly for us.  If not be a pain and try
 * to steal from the delalloc block rsv.
 */
-   ret = btrfs_block_rsv_add_noflush(root, dst_rsv, num_bytes);
+   ret = btrfs_block_rsv_add(root, dst_rsv, num_bytes,
+ BTRFS_RESERVE_NO_FLUSH);
if (!ret)
goto out;
 
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 2cfcce2..2136add 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3644,7 +3644,7 @@ out:
 
 static int can_overcommit(struct btrfs_root *root,
  

[PATCH] btrfs-progs: check non-digit character in the size value for mkfs options

2012-10-16 Thread Wang Sheng-Hui
When we run mkfs.btrfs, we can specify the size value for leafsize, etc.
Current the limit is 65536, and the lower limit is 4096. Also, the size
should be 4096 aligned. When we specify such value, parse_size just check
the tailing non-digit character, but doesn't check other characters.

For example, run mkfs.btrfs -l 40960b btrfs.img will get nodesize 40960,
leafsize 40960 and sectorsize 4096, which is expected. But if we typo
4096bb, mkfs.btrfs -l 4096bb btrfs.img, the result is nodesize 4096,
leafsize 4096 and sectorsize 4096, which maybe not what we want and what
we really want to type is 40960b.

Add check in parse_size to deal with the non-tailing non-digit characters.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 mkfs.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/mkfs.c b/mkfs.c
index 2cc6051..11e64d2 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -60,6 +60,7 @@ static u64 parse_size(char *s)
char c;
u64 mult = 1;
u64 ret;
+   int i;

s = strdup(s);

@@ -80,6 +81,16 @@ static u64 parse_size(char *s)
}
s[len - 1] = '\0';
}
+
+   len = strlen(s);
+   for (i = 0; i  len; i++) {
+   if (!isdigit(s[i])) {
+   fprintf(stderr, Illegal size value contains 
+   non-digit character %c\n, s[i]);
+   exit(1);
+   }
+   }
+
ret = atol(s) * mult;
free(s);
return ret;
-- 
1.7.5.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


Free space cache writeback issue

2012-10-16 Thread Jan Schmidt
Hi,

I've hit an issue with the free space cache. It looks like we miss writing
everything to disk on unmount under rough conditions.

Setup: git head cmason/master, /dev/sdv1 is a 55MB partition on an SSD. Run the
following script:

--
DEV=/dev/sdv1
MP=/mnt/scratch

umount $MP
mkfs.btrfs -M $DEV
mount -o inode_cache $DEV $MP

cat /dev/urandom | head -c 654321  $MP/1
mkdir $MP/2
mv $MP/1 $MP/2/1

btrfs subvol snap $MP $MP/@1
rm $MP/2/1

umount $MP
mount -o inode_cache $DEV $MP

cat /dev/urandom | head -c 654321  $MP/tempname-1

ls -li $MP/@1/2/1 $MP/tempname-1
--

Actual result:
 257 -rw-r--r-- 1 root root 654321 Oct 16 15:04 /mnt/scratch/@1/2/1
 259 -rw-r--r-- 1 root root 654321 Oct 16 15:04 /mnt/scratch/tempname-1

Expected result: Both files should have inode 257.

If I make any of the following changes, I get the expected results:
- omit umount/mount from the script
- replace SSD partition by spinning disk's partition of the same size
- use 266MB partition instead of a 55MB partition (still mixed mode)
- dump 554321 bytes into file 1 instead of 654321
- dump 7654321 bytes into file 1 instead of 654321

Despite being that fragile, with the above script the results are 100%
reproducible here. I wouldn't be surprised if on a different machine one would
need different parameter fine-tuning to trigger the problem. I'm happy to test
patches :-)

-Jan
--
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: problems with btrfs send / restore

2012-10-16 Thread Stefan Priebe - Profihost AG

Am 15.10.2012 22:14, schrieb Alex Lyakas:

Stefan,
the second issue you're seeing was discussed here:
http://www.spinics.net/lists/linux-btrfs/msg19672.html

You can apply the patch I sent there meanwhile, but as Miao pointed
out, I will need to make a better patch (hope will do it soon,
together with this one).


ah OK thanks. So i hope we'll see an updated btrfs-progs git repo soon ;-)

Thanks!

Stefan
--
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: Can not Mount btrfs No Space left

2012-10-16 Thread Shawn Dakin
Well, I mounted the volume ro and copied that data to another device.
Then I cleaned the junk out and then copied the data back to the
original device which I had wiped.
Total recovery time 4 hours.
Thanks for the hint Hugo, I don't know why it never occurred to me to
mount it read only.


On Mon, Oct 15, 2012 at 4:27 PM, Shawn Dakin
dakins...@staff.nctschools.org wrote:
 Hugo,
 Thanks, I had not thought of that.
 It does mount fine ro so I can access the files.
 Any ideas on getting access to delete a few log files or snapshots so
 I can mount the volume rw?
 If not I will just copy it off onto another, but that will be time consuming.


 On Mon, Oct 15, 2012 at 4:17 PM, Hugo Mills h...@carfax.org.uk wrote:
 On Mon, Oct 15, 2012 at 03:52:15PM -0400, Shawn Dakin wrote:
 I have a btrfs volume that will not mount due to No space on device
 I would gladly free up some space if I could only mount the volume.
 Does anyone have a trick to getting this volume back up and running?
 Any help would be great!!

Start with a 3.6 kernel (which has lots of ENOSPC fixes in it). Try
 mounting with -o ro, which won't allow you to modify anything but may
 show you if the FS is at least mountable in that state (and will give
 you the capability to copy the data elsewhere in extremis). If you're
 lucky, that mount may then allow you to mount it again without the -o
 ro.

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
--- Great oxymorons of the world, no. 6: Mature Student ---



 --
 Shawn Dakin (CNE)
 Director of Technology
 Newcomerstown Schools

 659 S. Beaver St.
 Newcomerstown Oh, 43832
 Office 740-498-4999
 Cell 740-227-0339



-- 
Shawn Dakin (CNE)
Director of Technology
Newcomerstown Schools

659 S. Beaver St.
Newcomerstown Oh, 43832
Office 740-498-4999
Cell 740-227-0339
--
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] Change the check for PageReadahead into an else-if

2012-10-16 Thread raghu . prabhu13
From: Raghavendra D Prabhu rpra...@wnohang.net

From 51daa88ebd8e0d437289f589af29d4b39379ea76, page_sync_readahead coalesces
async readahead into its readahead window, so another checking for that again is
not required.

Signed-off-by: Raghavendra D Prabhu rpra...@wnohang.net
---
 fs/btrfs/relocation.c | 10 --
 mm/filemap.c  |  3 +--
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 4da0865..6362003 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2996,12 +2996,10 @@ static int relocate_file_extent_cluster(struct inode 
*inode,
ret = -ENOMEM;
goto out;
}
-   }
-
-   if (PageReadahead(page)) {
-   page_cache_async_readahead(inode-i_mapping,
-  ra, NULL, page, index,
-  last_index + 1 - index);
+   } else if (PageReadahead(page)) {
+   page_cache_async_readahead(inode-i_mapping,
+   ra, NULL, page, index,
+   last_index + 1 - index);
}
 
if (!PageUptodate(page)) {
diff --git a/mm/filemap.c b/mm/filemap.c
index 3843445..d703224 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1113,8 +1113,7 @@ find_page:
page = find_get_page(mapping, index);
if (unlikely(page == NULL))
goto no_cached_page;
-   }
-   if (PageReadahead(page)) {
+   } else if (PageReadahead(page)) {
page_cache_async_readahead(mapping,
ra, filp, page,
index, last_index - index);
-- 
1.7.12.3

--
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 v2] Btrfs: extended inode refs support for send mechanism

2012-10-16 Thread Mark Fasheh
On Mon, Oct 15, 2012 at 10:30:45AM +0200, Jan Schmidt wrote:
 This adds support for the new extended inode refs to btrfs send.
 
 Signed-off-by: Jan Schmidt list.bt...@jan-o-sch.net
 ---
  fs/btrfs/backref.c |   22 -
  fs/btrfs/backref.h |4 ++
  fs/btrfs/send.c|  126 
 +---
  3 files changed, 94 insertions(+), 58 deletions(-)
 ---
 Changes for v2:
 - Re-understood how btrfs_search_slot_for_read works (3 places, reported
   by Alex Lyakas)
 - Fixed extref handling in get_first_ref (reported by Mark Fasheh)

Looks good to my eyes.

Reviewed-by: Mark Fasheh mfas...@suse.de
--Mark

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


filesystem in such a state that btrfsck crashes

2012-10-16 Thread Sami Haahtinen
Hi,

A few days ago I started experiencing some major slowdowns in my main
btrfs filesystem and when inspecting the errors I noticed an error
during balance:

btrfs: block rsv returned -28

After a while I started seeing worse and worse problems with the
filesystem. Eventually I was forced to revert to a LiveCD to attempt a
fix. I downloaded the latest version of btrfs-progs from git and ran
btrfsck against the filesystem and btrfsck dies with a segfault after
quite some time.

The kernel I started seeing the problems is 3.6.0 and I was on 3.6.2
during the few final moments. I have backups of the filesystem, but
I'm a bit curious what is causing this. I've seen mentions of other
segfault causing problems, so if there is anything I can do to help
debug the cause for the segfault, I'd be happy to help.

Filesystem info:

Label: none  uuid: 6dab592a-72a2-41bd-a773-c16614c56f51
Total devices 2 FS bytes used 843.64GB
devid2 size 1.80TB used 1.32TB path /dev/sdb2
devid1 size 1.80TB used 1.32TB path /dev/sda2

Data, RAID1: total=1.25TB, used=809.41GB
System, RAID1: total=32.00MB, used=196.00KB
System: total=4.00MB, used=0.00
Metadata, RAID1: total=74.00GB, used=34.23GB


Regards,
--
Sami Haahtinen
Bad Wolf Oy
+358443302775
root@sysresccd /root % btrfsck /dev/sda2
checking extents
ref mismatch on [282295177216 4096] extent item 12, found 8
Backref 282295177216 parent 276656304128 not referenced back 0x12076918
Backref 282295177216 parent 276656295936 not referenced back 0xc36b378
Backref 282295177216 parent 276743098368 not referenced back 0xbf808d8
Incorrect global backref count on 282295177216 found 11 wanted 8
backpointer mismatch on [282295177216 4096]
ref mismatch on [28930420 4096] extent item 2, found 1
Backref 28930420 parent 276453351424 not referenced back 0x82a56ea0
Incorrect global backref count on 28930420 found 2 wanted 1
backpointer mismatch on [28930420 4096]
ref mismatch on [289330163712 4096] extent item 2, found 1
Backref 289330163712 parent 276453351424 not referenced back 0x81b2e2e0
Incorrect global backref count on 289330163712 found 2 wanted 1
backpointer mismatch on [289330163712 4096]
ref mismatch on [289332174848 4096] extent item 2, found 1
Backref 289332174848 parent 276453351424 not referenced back 0x82c3b070
Incorrect global backref count on 289332174848 found 2 wanted 1
backpointer mismatch on [289332174848 4096]
ref mismatch on [289333620736 4096] extent item 2, found 1
Backref 289333620736 parent 276453351424 not referenced back 0x812fe950
Incorrect global backref count on 289333620736 found 2 wanted 1
backpointer mismatch on [289333620736 4096]
ref mismatch on [289334108160 4096] extent item 2, found 1
Backref 289334108160 parent 276656295936 not referenced back 0x85d1dde8
Incorrect global backref count on 289334108160 found 2 wanted 1
backpointer mismatch on [289334108160 4096]
ref mismatch on [289396117504 4096] extent item 5, found 4
Backref 289396117504 parent 276453339136 not referenced back 0xb243ca0
Incorrect global backref count on 289396117504 found 5 wanted 4
backpointer mismatch on [289396117504 4096]
ref mismatch on [289484378112 4096] extent item 2, found 1
Backref 289484378112 parent 276453339136 not referenced back 0x84014f20
Incorrect global backref count on 289484378112 found 2 wanted 1
backpointer mismatch on [289484378112 4096]
ref mismatch on [289488429056 4096] extent item 2, found 1
Backref 289488429056 parent 276453339136 not referenced back 0x82dd51b8
Incorrect global backref count on 289488429056 found 2 wanted 1
backpointer mismatch on [289488429056 4096]
ref mismatch on [289490132992 4096] extent item 2, found 1
Backref 289490132992 parent 276453339136 not referenced back 0x82810310
Incorrect global backref count on 289490132992 found 2 wanted 1
backpointer mismatch on [289490132992 4096]
ref mismatch on [289490591744 4096] extent item 2, found 1
Backref 289490591744 parent 276656304128 not referenced back 0x849310c8
Incorrect global backref count on 289490591744 found 2 wanted 1
backpointer mismatch on [289490591744 4096]
Errors found in extent allocation tree
checking fs roots
root 257 inode 1766316 errors 400
zsh: abort  btrfsck /dev/sda2
root@sysresccd /root %


Re: [PATCH] Change the check for PageReadahead into an else-if

2012-10-16 Thread Fengguang Wu
On Wed, Oct 17, 2012 at 12:28:05AM +0530, raghu.prabh...@gmail.com wrote:
 From: Raghavendra D Prabhu rpra...@wnohang.net
 
 From 51daa88ebd8e0d437289f589af29d4b39379ea76, page_sync_readahead coalesces
 async readahead into its readahead window, so another checking for that again 
 is
 not required.

 Signed-off-by: Raghavendra D Prabhu rpra...@wnohang.net
 ---
  fs/btrfs/relocation.c | 10 --
  mm/filemap.c  |  3 +--
  2 files changed, 5 insertions(+), 8 deletions(-)
 
 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
 index 4da0865..6362003 100644

 --- a/fs/btrfs/relocation.c
 +++ b/fs/btrfs/relocation.c
 @@ -2996,12 +2996,10 @@ static int relocate_file_extent_cluster(struct inode 
 *inode,
   ret = -ENOMEM;
   goto out;
   }
 - }
 -
 - if (PageReadahead(page)) {
 - page_cache_async_readahead(inode-i_mapping,
 -ra, NULL, page, index,
 -last_index + 1 - index);
 + } else if (PageReadahead(page)) {
 + page_cache_async_readahead(inode-i_mapping,
 + ra, NULL, page, index,
 + last_index + 1 - index);

That extra indent is not necessary.

Otherwise looks good to me. Thanks!

Reviewed-by: Fengguang Wu fengguang...@intel.com

   }
  
   if (!PageUptodate(page)) {
 diff --git a/mm/filemap.c b/mm/filemap.c
 index 3843445..d703224 100644
 --- a/mm/filemap.c
 +++ b/mm/filemap.c
 @@ -1113,8 +1113,7 @@ find_page:
   page = find_get_page(mapping, index);
   if (unlikely(page == NULL))
   goto no_cached_page;
 - }
 - if (PageReadahead(page)) {
 + } else if (PageReadahead(page)) {
   page_cache_async_readahead(mapping,
   ra, filp, page,
   index, last_index - index);
 -- 
 1.7.12.3
--
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] Change the check for PageReadahead into an else-if

2012-10-16 Thread KOSAKI Motohiro
On Tue, Oct 16, 2012 at 10:00 PM, Fengguang Wu fengguang...@intel.com wrote:
 On Wed, Oct 17, 2012 at 12:28:05AM +0530, raghu.prabh...@gmail.com wrote:
 From: Raghavendra D Prabhu rpra...@wnohang.net

 From 51daa88ebd8e0d437289f589af29d4b39379ea76, page_sync_readahead coalesces
 async readahead into its readahead window, so another checking for that 
 again is
 not required.

 Signed-off-by: Raghavendra D Prabhu rpra...@wnohang.net
 ---
  fs/btrfs/relocation.c | 10 --
  mm/filemap.c  |  3 +--
  2 files changed, 5 insertions(+), 8 deletions(-)

 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
 index 4da0865..6362003 100644

 --- a/fs/btrfs/relocation.c
 +++ b/fs/btrfs/relocation.c
 @@ -2996,12 +2996,10 @@ static int relocate_file_extent_cluster(struct inode 
 *inode,
   ret = -ENOMEM;
   goto out;
   }
 - }
 -
 - if (PageReadahead(page)) {
 - page_cache_async_readahead(inode-i_mapping,
 -ra, NULL, page, index,
 -last_index + 1 - index);
 + } else if (PageReadahead(page)) {
 + page_cache_async_readahead(inode-i_mapping,
 + ra, NULL, page, index,
 + last_index + 1 - 
 index);

 That extra indent is not necessary.

 Otherwise looks good to me. Thanks!

 Reviewed-by: Fengguang Wu fengguang...@intel.com

Hi Raghavendra,

Indentation breakage is now welcome. Please respin it. Otherwise

Acked-by: KOSAKI Motohiro kosaki.motoh...@jp.fujitsu.com
--
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