Re: [PATCH 0/2] Btrfs: quota rescan for 3.10

2013-04-06 Thread Wang Shilong
Hello Jan,

Would you please add more lines to the changelog(Just as what you have 
taught me~~)
It will be easier for us to review and test the patch before it comes into 3.10.


Thanks,
Wang
 The kernel side for rescan, which is needed if you want to enable qgroup
 tracking on a non-empty volume.
 
 User space patches to come.
 
 Jan Schmidt (2):
  Btrfs: rescan for qgroups
  Btrfs: automatic rescan after quota enable command
 
 fs/btrfs/ctree.h   |   17 ++-
 fs/btrfs/disk-io.c |6 +
 fs/btrfs/ioctl.c   |   83 +++--
 fs/btrfs/qgroup.c  |  281 ++--
 include/uapi/linux/btrfs.h |   11 ++-
 5 files changed, 364 insertions(+), 34 deletions(-)
 
 --
 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

--
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: [BUG?] Btrfs quota: overwritten space is counted twice

2013-04-06 Thread Arne Jansen
On 04/05/13 23:03, Koen De Wit wrote:
 When data in a file is overwritten, starting somewhere in the middle of
 the file, the overwritten space is counted twice against the space usage
 numbers. Is this a bug, or did I something wrong?

Neither. This is a result of how btrfs allocates and overwrites extents.
Your file is firstly allocated in one extent of 1000kB. When you
overwrite parts of it, the original extent is kept, and a new extent for
the overwritten part is allocated, resulting in another allocation of
1000kB. Once you overwrite the first 100kB (the part that is still in
use from the first extent), it should be freed.
So your file really allocates 2000kB on disk, and qgroups accounts
it correctly. You can verify it with btrfs-debug-tree.

-Arne

 
 This is what I did:
 
 I create a subvolume and limit it to 4 MB, and create a 1000 KB file in
 the subvol:
 
 # btrfs subvol create s
   Create subvolume './s'
 # btrfs qgroup limit 4m s
 # btrfs qgroup show ./ | grep 260
   0/260 4096 4096
 # dd if=/dev/zero of=s/file bs=1024 count=1000; sync
 # ls -lah s/file
   -rw-r--r--. 1 root root 1000K Apr  6 00:13 s/file
 # btrfs qgroup show ./ | grep 260
   0/260 1028096 1028096
 
 Then I overwrite the last 900 KB of the file, and add 100 KB of data,
 resulting in a 1.1 MB file. The space usage numbers shows 2 MB however:
 
 # dd if=/dev/zero of=s/file bs=1024 count=1000 seek=100; sync
 # ls -lah s/file
   -rw-r--r--. 1 root root 1.1M Apr  6 00:13 s/file
 # btrfs qgroup show ./ | grep 260
   0/260 2052096 2052096
 
 I repeat this twice, the file becomes 1.3 MB but the usage number goes
 to almost 4 MB:
 
 # dd if=/dev/zero of=s/file bs=1024 count=1000 seek=200; sync
 # dd if=/dev/zero of=s/file bs=1024 count=1000 seek=300; sync
 # ls -lah s/file
   -rw-r--r--. 1 root root 1.3M Apr  6 00:14 s/file
 # btrfs qgroup show ./ | grep 260
   0/260 4100096 4100096
 
 Doing the same again results in quota exceeded errors:
 
 # dd if=/dev/zero of=s/file bs=1024 count=1000 seek=400; sync
   dd: writing `s/file': Disk quota exceeded
   78+0 records in
   77+0 records out
   78848 bytes (79 kB) copied, 0.00138135 s, 57.1 MB/s
 # ls -lah s/file
   -rw-r--r--. 1 root root 477K Apr  6 00:15 s/file
 # btrfs qgroup show ./ | grep 260
   0/260 4182016 4182016
 # touch s/emptyfile
   touch: cannot touch `s/emptyfile': Disk quota exceeded
 
 Koen.
 -- 
 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

--
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] fsfreeze: manage kill signal when sb_start_write is called

2013-04-06 Thread Marco Stornelli
In every place where sb_start_write was called now we must manage
the error code and return -EINTR.

Signed-off-by: Marco Stornelli marco.storne...@gmail.com
---
 fs/btrfs/file.c|9 +++--
 fs/cifs/file.c |4 +++-
 fs/ext4/mmp.c  |3 ++-
 fs/ext4/super.c|4 +++-
 fs/fuse/file.c |4 +++-
 fs/namespace.c |8 ++--
 fs/ntfs/file.c |4 +++-
 fs/ocfs2/file.c|4 +++-
 fs/open.c  |8 ++--
 fs/splice.c|4 +++-
 fs/xfs/xfs_file.c  |4 +++-
 include/linux/fs.h |6 --
 mm/filemap.c   |4 +++-
 mm/filemap_xip.c   |4 +++-
 14 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index ade03e6..4891fda 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -329,7 +329,9 @@ static int __btrfs_run_defrag_inode(struct btrfs_fs_info 
*fs_info,
range.len = (u64)-1;
range.start = defrag-last_offset;
 
-   sb_start_write(fs_info-sb);
+   ret = sb_start_write(fs_info-sb);
+   if (ret)
+   goto cleanup;
num_defrag = btrfs_defrag_file(inode, NULL, range, defrag-transid,
   BTRFS_DEFRAG_BATCH);
sb_end_write(fs_info-sb);
@@ -1514,7 +1516,9 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
size_t count, ocount;
bool sync = (file-f_flags  O_DSYNC) || IS_SYNC(file-f_mapping-host);
 
-   sb_start_write(inode-i_sb);
+   err = sb_start_write(inode-i_sb);
+   if (err)
+   goto out2;
 
mutex_lock(inode-i_mutex);
 
@@ -1618,6 +1622,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
atomic_dec(BTRFS_I(inode)-sync_writers);
 out:
sb_end_write(inode-i_sb);
+out2:
current-backing_dev_info = NULL;
return num_written ? num_written : err;
 }
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 7a0dd99..1613eb9 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2520,7 +2520,9 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov,
 
BUG_ON(iocb-ki_pos != pos);
 
-   sb_start_write(inode-i_sb);
+   rc = sb_start_write(inode-i_sb);
+   if (rc)
+   return rc;
 
/*
 * We need to hold the sem to be sure nobody modifies lock list
diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
index f9b5515..dbdfc6d 100644
--- a/fs/ext4/mmp.c
+++ b/fs/ext4/mmp.c
@@ -48,7 +48,8 @@ static int write_mmp_block(struct super_block *sb, struct 
buffer_head *bh)
 * We protect against freezing so that we don't create dirty buffers
 * on frozen filesystem.
 */
-   sb_start_write(sb);
+   if (sb_start_write(sb))
+   return 1;
ext4_mmp_csum_set(sb, mmp);
mark_buffer_dirty(bh);
lock_buffer(bh);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 5d6d535..e6962be 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2712,7 +2712,9 @@ static int ext4_run_li_request(struct ext4_li_request 
*elr)
sb = elr-lr_super;
ngroups = EXT4_SB(sb)-s_groups_count;
 
-   sb_start_write(sb);
+   ret = sb_start_write(sb);
+   if (ret)
+   return 1;
for (group = elr-lr_next_group; group  ngroups; group++) {
gdp = ext4_get_group_desc(sb, group, NULL);
if (!gdp) {
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 34b80ba..57194eb 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -971,7 +971,9 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, 
const struct iovec *iov,
return err;
 
count = ocount;
-   sb_start_write(inode-i_sb);
+   err = sb_start_write(inode-i_sb);
+   if (err)
+   return err;
mutex_lock(inode-i_mutex);
 
/* We can write back this queue in page reclaim */
diff --git a/fs/namespace.c b/fs/namespace.c
index d581e45..2d2b054 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -343,7 +343,9 @@ int mnt_want_write(struct vfsmount *m)
 {
int ret;
 
-   sb_start_write(m-mnt_sb);
+   ret = sb_start_write(m-mnt_sb);
+   if (ret)
+   return ret;
ret = __mnt_want_write(m);
if (ret)
sb_end_write(m-mnt_sb);
@@ -403,7 +405,9 @@ int mnt_want_write_file(struct file *file)
 {
int ret;
 
-   sb_start_write(file-f_path.mnt-mnt_sb);
+   ret = sb_start_write(file-f_path.mnt-mnt_sb);
+   if (ret)
+   return ret;
ret = __mnt_want_write_file(file);
if (ret)
sb_end_write(file-f_path.mnt-mnt_sb);
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 5b2d4f0..a414c53 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -2129,7 +2129,9 @@ static ssize_t ntfs_file_aio_write(struct kiocb *iocb, 
const struct iovec *iov,
 
BUG_ON(iocb-ki_pos != pos);
 
-   sb_start_write(inode-i_sb);
+   ret = sb_start_write(inode-i_sb);
+   if (ret)
+   return ret;
   

[PATCH 3/4] fsfreeze: manage kill signal when sb_start_pagefault is called

2013-04-06 Thread Marco Stornelli
In every place where sb_start_pagefault was called now we must manage
the error code and return VM_FAULT_RETRY.

Signed-off-by: Marco Stornelli marco.storne...@gmail.com
---
 fs/btrfs/inode.c   |4 +++-
 fs/buffer.c|4 +++-
 fs/ext4/inode.c|4 +++-
 fs/f2fs/file.c |4 +++-
 fs/gfs2/file.c |4 +++-
 fs/nilfs2/file.c   |4 +++-
 fs/ocfs2/mmap.c|4 +++-
 include/linux/fs.h |6 --
 mm/filemap.c   |7 +--
 9 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 09c58a3..a6166f4 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7559,7 +7559,9 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct 
vm_fault *vmf)
u64 page_start;
u64 page_end;
 
-   sb_start_pagefault(inode-i_sb);
+   ret = sb_start_pagefault(inode-i_sb);
+   if (ret)
+   return VM_FAULT_RETRY;
ret  = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE);
if (!ret) {
ret = file_update_time(vma-vm_file);
diff --git a/fs/buffer.c b/fs/buffer.c
index b4dcb34..6d3d2cc 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2383,7 +2383,9 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct 
vm_fault *vmf,
int ret;
struct super_block *sb = file_inode(vma-vm_file)-i_sb;
 
-   sb_start_pagefault(sb);
+   ret = sb_start_pagefault(sb);
+   if (ret)
+   return VM_FAULT_RETRY;
 
/*
 * Update file times before taking page lock. We may end up failing the
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index b3a5213..efc47f6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5023,7 +5023,9 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct 
vm_fault *vmf)
get_block_t *get_block;
int retries = 0;
 
-   sb_start_pagefault(inode-i_sb);
+   ret = sb_start_pagefault(inode-i_sb);
+   if (ret)
+   return VM_FAULT_RETRY;
file_update_time(vma-vm_file);
/* Delalloc case is easy... */
if (test_opt(inode-i_sb, DELALLOC) 
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 958a46d..cce4147 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -37,7 +37,9 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma,
 
f2fs_balance_fs(sbi);
 
-   sb_start_pagefault(inode-i_sb);
+   err = sb_start_pagefault(inode-i_sb);
+   if (err)
+   return VM_FAULT_RETRY;
 
mutex_lock_op(sbi, DATA_NEW);
 
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index d79c2da..071e777 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -396,7 +396,9 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, 
struct vm_fault *vmf)
loff_t size;
int ret;
 
-   sb_start_pagefault(inode-i_sb);
+   ret = sb_start_pagefault(inode-i_sb);
+   if (ret)
+   return VM_FAULT_RETRY;
 
/* Update file times before taking page lock */
file_update_time(vma-vm_file);
diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c
index 08fdb77..1c7678a 100644
--- a/fs/nilfs2/file.c
+++ b/fs/nilfs2/file.c
@@ -74,7 +74,9 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, 
struct vm_fault *vmf)
if (unlikely(nilfs_near_disk_full(inode-i_sb-s_fs_info)))
return VM_FAULT_SIGBUS; /* -ENOSPC */
 
-   sb_start_pagefault(inode-i_sb);
+   ret = sb_start_pagefault(inode-i_sb);
+   if (ret)
+   return VM_FAULT_RETRY;
lock_page(page);
if (page-mapping != inode-i_mapping ||
page_offset(page) = i_size_read(inode) || !PageUptodate(page)) {
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
index 10d66c7..f0973ae 100644
--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -136,7 +136,9 @@ static int ocfs2_page_mkwrite(struct vm_area_struct *vma, 
struct vm_fault *vmf)
sigset_t oldset;
int ret;
 
-   sb_start_pagefault(inode-i_sb);
+   ret = sb_start_pagefault(inode-i_sb);
+   if (ret)
+   return VM_FAULT_RETRY;
ocfs2_block_signals(oldset);
 
/*
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 03921d6..550574e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1407,6 +1407,8 @@ static inline int sb_start_write_trylock(struct 
super_block *sb)
  * sb_start_pagefault - get write access to a superblock from a page fault
  * @sb: the super we write to
  *
+ * It returns zero when no error occured, the error code otherwise.
+ *
  * When a process starts handling write page fault, it should embed the
  * operation into sb_start_pagefault() - sb_end_pagefault() pair to get
  * exclusion against file system freezing. This is needed since the page fault
@@ -1422,9 +1424,9 @@ static inline int sb_start_write_trylock(struct 
super_block *sb)
  * mmap_sem
  *   - sb_start_pagefault
  */
-static inline void sb_start_pagefault(struct super_block *sb)
+static inline int sb_start_pagefault(struct 

Re: [PATCH 3/4] fsfreeze: manage kill signal when sb_start_pagefault is called

2013-04-06 Thread Matthew Wilcox
On Sat, Apr 06, 2013 at 12:05:52PM +0200, Marco Stornelli wrote:
 In every place where sb_start_pagefault was called now we must manage
 the error code and return VM_FAULT_RETRY.

Erm ... in patch 1/4:

 static inline void sb_start_pagefault(struct super_block *sb)
 {
-   __sb_start_write(sb, SB_FREEZE_PAGEFAULT, true);
+   __sb_start_write_wait(sb, SB_FREEZE_PAGEFAULT, false);
 }

  
 - sb_start_pagefault(inode-i_sb);
 + ret = sb_start_pagefault(inode-i_sb);
 + if (ret)
 + return VM_FAULT_RETRY;
   ret  = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE);

Does the compiler not warn that you're assigning void to 'ret'?  Or was
there some other SNAFU sending these patches?

-- 
Matthew Wilcox  Intel Open Source Technology Centre
Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step.
--
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/4] fsfreeze: manage kill signal when sb_start_write is called

2013-04-06 Thread Matthew Wilcox
On Sat, Apr 06, 2013 at 12:04:52PM +0200, Marco Stornelli wrote:
 In every place where sb_start_write was called now we must manage
 the error code and return -EINTR.

If we must manage the error code, then these functions should be marked
__must_check.

-- 
Matthew Wilcox  Intel Open Source Technology Centre
Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step.
--
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/4] fsfreeze: manage kill signal when sb_start_write is called

2013-04-06 Thread Marco Stornelli

Il 06/04/2013 15:17, Matthew Wilcox ha scritto:

On Sat, Apr 06, 2013 at 12:04:52PM +0200, Marco Stornelli wrote:

In every place where sb_start_write was called now we must manage
the error code and return -EINTR.


If we must manage the error code, then these functions should be marked
__must_check.



Yep, good point.

Marco
--
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/4] fsfreeze: manage kill signal when sb_start_pagefault is called

2013-04-06 Thread Marco Stornelli

Il 06/04/2013 15:20, Matthew Wilcox ha scritto:

On Sat, Apr 06, 2013 at 12:05:52PM +0200, Marco Stornelli wrote:

In every place where sb_start_pagefault was called now we must manage
the error code and return VM_FAULT_RETRY.


Erm ... in patch 1/4:

  static inline void sb_start_pagefault(struct super_block *sb)
  {
-   __sb_start_write(sb, SB_FREEZE_PAGEFAULT, true);
+   __sb_start_write_wait(sb, SB_FREEZE_PAGEFAULT, false);
  }



-   sb_start_pagefault(inode-i_sb);
+   ret = sb_start_pagefault(inode-i_sb);
+   if (ret)
+   return VM_FAULT_RETRY;
ret  = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE);


Does the compiler not warn that you're assigning void to 'ret'?  Or was
there some other SNAFU sending these patches?



I'm sorry, my fault :) As I said in 00 these patches are completely 
*not* tested, it was only a quick coding  review to understand if 
someone can see any problem to this kind of implementation, since I 
touched several points in the kernel. So there is still on-going work 
and I need to do several tests. Maybe I had to add the RFC tag, sorry again.


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


--mixed and --nodesize together

2013-04-06 Thread Hugo Mills
--mixed seems to prevent selection of alternative leaf/node/sector sizes:

$ sudo mkfs.btrfs --mixed -n 16384 -s 16384 -d single -m single 
/dev/mapper/ca-store
Created a data/metadata chunk of size 8388608
fs created label (null) on /dev/mapper/ca-store
nodesize 16384 leafsize 16384 sectorsize 16384 size 98.00MB

$ sudo mount /dev/mapper/ca-store /mnt
mount: /dev/mapper/ca-store already mounted or /mnt busy
 
Apr 6 17:59:36 s_all@ruthven kernel: [1842232.007361] device fsid 
8ca4524f-4cd4-45a6-855b-dc14b56652e3 devid 1 transid 4 /dev/mapper/ca-store
Apr 6 17:59:36 s_all@ruthven kernel: [1842232.117266] btrfs: disk space caching 
is enabled
Apr 6 17:59:36 s_all@ruthven kernel: [1842232.117271] btrfs flagging fs with 
big metadata feature
Apr 6 17:59:36 s_all@ruthven kernel: [1842232.117657] btrfs: Incompatible 
sector size(16384) found on dm-10
Apr 6 17:59:36 s_all@ruthven kernel: [1842232.118023] btrfs: open_ctree failed


$ sudo mkfs.btrfs --mixed -n 16384 -l 16384 -d single -m single 
/dev/mapper/ca-store
Created a data/metadata chunk of size 8388608
fs created label (null) on /dev/mapper/ca-store
nodesize 16384 leafsize 16384 sectorsize 4096 size 98.00MB

$ sudo mount /dev/mapper/ca-store /mnt
mount: /dev/mapper/ca-store already mounted or /mnt busy
 
Apr  6 18:06:37 s_all@ruthven kernel: [1842652.655610] device fsid 
70c12f3f-39af-41e2-afa5-8b807ae2e410 devid 1 transid 4 /dev/mapper/ca-store
Apr  6 18:06:37 s_all@ruthven kernel: [1842652.97] btrfs: disk space 
caching is enabled
Apr  6 18:06:37 s_all@ruthven kernel: [1842652.777806] btrfs flagging fs with 
big metadata feature
Apr  6 18:06:37 s_all@ruthven kernel: [1842652.777812] btrfs: unequal 
leaf/node/sector sizes are not allowed for mixed block groups on dm-10

   (It's not particularly important to me in this configuration -- I
can just use 4096, but I thought it should be published).

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 65E74AC0 from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
 --- Computer Science is not about computers,  any more than --- 
 astronomy is about telescopes.  


signature.asc
Description: Digital signature


btrfs-progs: re-add send-test

2013-04-06 Thread Eric Sandeen
From: Mark Fasheh mfas...@suse.de

btrfs-progs: re-add send-test

send-test.c links against libbtrfs and uses the send functionality provided
to decode and print a send stream to the console.

66819df btrfs-progs: add send-test contained this file when
submitted, but somehow got lost on commit.

[sand...@redhat.com: Resurrect lost send-test.c from original commit]

Signed-off-by: Mark Fasheh mfas...@suse.de
Signed-off-by: Eric Sandeen sand...@redhat.com
---

TBH I've not tested this, just bringing it back verbatim from the
original patch on the list.  We had the make target but not the C file!

-Eric

diff --git a/Makefile b/Makefile
index a270e9c..2275b97 100644
--- a/Makefile
+++ b/Makefile
@@ -194,7 +194,7 @@ ioctl-test: $(objects) $(libs) ioctl-test.o
@echo [LD] $@
$(Q)$(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) 
$(LIBS)
 
-send-test: $(objects) send-test.o
+send-test: $(objects) $(libs) send-test.o
@echo [LD] $@
$(Q)$(CC) $(CFLAGS) -o send-test $(objects) send-test.o $(LDFLAGS) 
$(LIBS) -lpthread
 
diff --git a/send-test.c b/send-test.c
new file mode 100644
index 000..8c14718
--- /dev/null
+++ b/send-test.c
@@ -0,0 +1,458 @@
+/*
+ * Copyright (C) 2013 SUSE.  All rights reserved.
+ *
+ * This code is adapted from cmds-send.c and cmds-receive.c,
+ * Both of which are:
+ *
+ * Copyright (C) 2012 Alexander Block.  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 _GNU_SOURCE
+
+#include unistd.h
+#include stdint.h
+#include dirent.h
+#include pthread.h
+#include math.h
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+#include sys/ioctl.h
+#include libgen.h
+#include mntent.h
+#include limits.h
+#include stdlib.h
+#include asm/types.h
+#include uuid/uuid.h
+
+/*
+ * This should be compilable without the rest of the btrfs-progs
+ * source distribution.
+ */
+#if BTRFS_FLAT_INCLUDES
+#include send-utils.h
+#include send-stream.h
+#else
+#include btrfs/send-utils.h
+#include btrfs/send-stream.h
+#endif /* BTRFS_FLAT_INCLUDES */
+
+static int pipefd[2];
+struct btrfs_ioctl_send_args io_send = {0, };
+static char *subvol_path;
+static char *root_path;
+
+struct recv_args {
+   char *full_subvol_path;
+   char *root_path;
+};
+
+void usage(int error)
+{
+   printf(send-test btrfs root subvol\n);
+   if (error)
+   exit(error);
+}
+
+static int print_subvol(const char *path, const u8 *uuid, u64 ctransid,
+   void *user)
+{
+   struct recv_args *r = user;
+   char uuid_str[128];
+
+   r-full_subvol_path = path_cat(r-root_path, path);
+   uuid_unparse(uuid, uuid_str);
+
+   printf(subvol\t%s\t%llu\t%s\n, uuid_str,
+  (unsigned long long)ctransid, r-full_subvol_path);
+
+   return 0;
+}
+
+static int print_snapshot(const char *path, const u8 *uuid, u64 ctransid,
+ const u8 *parent_uuid, u64 parent_ctransid,
+ void *user)
+{
+   struct recv_args *r = user;
+   char uuid_str[128];
+   char parent_uuid_str[128];
+
+   r-full_subvol_path = path_cat(r-root_path, path);
+   uuid_unparse(uuid, uuid_str);
+   uuid_unparse(parent_uuid, parent_uuid_str);
+
+   printf(snapshot\t%s\t%llu\t%s\t%llu\t%s\n, uuid_str,
+  (unsigned long long)ctransid, parent_uuid_str,
+  (unsigned long long)parent_ctransid, r-full_subvol_path);
+
+   return 0;
+}
+
+static int print_mkfile(const char *path, void *user)
+{
+   struct recv_args *r = user;
+   char *full_path = path_cat(r-full_subvol_path, path);
+
+   printf(mkfile\t%s\n, full_path);
+
+   free(full_path);
+   return 0;
+}
+
+static int print_mkdir(const char *path, void *user)
+{
+   struct recv_args *r = user;
+   char *full_path = path_cat(r-full_subvol_path, path);
+
+   printf(mkdir\t%s\n, full_path);
+
+   free(full_path);
+   return 0;
+}
+
+static int print_mknod(const char *path, u64 mode, u64 dev, void *user)
+{
+   struct recv_args *r = user;
+   char *full_path = path_cat(r-full_subvol_path, path);
+
+   printf(mknod\t%llo\t0x%llx\t%s\n, (unsigned long long)mode,
+  (unsigned long long)dev, full_path);
+
+   free(full_path);
+   return 0;
+}
+
+static int print_mkfifo(const char *path, void 

Re: [PATCH 2/4] fsfreeze: manage kill signal when sb_start_write is called

2013-04-06 Thread Al Viro
On Sat, Apr 06, 2013 at 12:04:52PM +0200, Marco Stornelli wrote:
 In every place where sb_start_write was called now we must manage
 the error code and return -EINTR.

Now go and look for callers of mnt_want_write() ;-/  The really
painful one is in do_last(), but kern_path_create() is not much
better; mq_open() would be bad too, had it not been about something
you are not going to freeze anyway...
--
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: undefined reference to `blkid_probe_get_wholedisk_devno'

2013-04-06 Thread Lin Ming
(Add list)

On Sun, Apr 7, 2013 at 9:38 AM, Lin Ming min...@gmail.com wrote:

 Hi,

 Build latest 
 git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git

 ~/btrfs-progs$ make
 [LD] mkfs.btrfs
 mkfs.o: In function `is_ssd':
 /home/mlin/btrfs-progs/mkfs.c:1234: undefined reference to 
 `blkid_probe_get_wholedisk_devno'

 any fix?

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


[BUG] btrfs.fsck failing to fix corrupted block

2013-04-06 Thread Shripad Ratnaparkhi
Hi there,
I am newbie and recently started using btrfs. Now facing a weird problem.

FWIW, I am on archlinux, kenel v3.8.0, having Btrfs v0.20-rc1.
After an abnormal reboot, getting these errors while boot:

systemd.fsck[289]: checking extents
systemd.fsck[289]: checking fs roots
systemd.fsck[289]: checking root refs
systemd.fsck[289]: found 23728128 bytes used err is 0
systemd.fsck[289]: total csum bytes: 23092
systemd.fsck[289]: total tree bytes: 81920
systemd.fsck[289]: total fs tree bytes: 24576
systemd.fsck[289]: btree space waste bytes: 38038
systemd.fsck[289]: file data blocks allocated: 23646208
systemd.fsck[289]: referenced 23646208
systemd.fsck[289]: Btrfs v0.20-rc1
[   OK   ]  Started File System Check on /dev/sda1.
   Mounting /boot...
systemd.fsck[289]: checking extents
[   OK   ] Mounted /boot.
[   OK   ] Reached target Sound Card.
systemd.fsck[289]: checking fs roots
systemd.fsck[289]: checking root refs
systemd.fsck[289]: extent buffer leak: start 206893056 len 4096
systemd.fsck[289]: *** Error in `fsck.btrfs`: corrupted double-linked
list: 0x02081d80 ***

and its not proceeding and stuck here.
I have the rescue disk handy, but not sure how can I fix this issue.
Any help please.

thanks,

--
~shripadr
--
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: [BUG] btrfs.fsck failing to fix corrupted block

2013-04-06 Thread Shripad Ratnaparkhi
[Replying to my own email]

Found a patch which seems to be discusses the fix in a patch provided here:
https://patchwork.kernel.org/patch/1946561/

Still now sure whether that is already there in v0.20-rc1 or
applicable to fix my issue.

thanks,
~shripadr

PS: BCC'ing the patch provider.

On Sun, Apr 7, 2013 at 7:16 AM, Shripad Ratnaparkhi
shripad.ratnapar...@gmail.com wrote:
 Hi there,
 I am newbie and recently started using btrfs. Now facing a weird problem.

 FWIW, I am on archlinux, kenel v3.8.0, having Btrfs v0.20-rc1.
 After an abnormal reboot, getting these errors while boot:

 systemd.fsck[289]: checking extents
 systemd.fsck[289]: checking fs roots
 systemd.fsck[289]: checking root refs
 systemd.fsck[289]: found 23728128 bytes used err is 0
 systemd.fsck[289]: total csum bytes: 23092
 systemd.fsck[289]: total tree bytes: 81920
 systemd.fsck[289]: total fs tree bytes: 24576
 systemd.fsck[289]: btree space waste bytes: 38038
 systemd.fsck[289]: file data blocks allocated: 23646208
 systemd.fsck[289]: referenced 23646208
 systemd.fsck[289]: Btrfs v0.20-rc1
 [   OK   ]  Started File System Check on /dev/sda1.
Mounting /boot...
 systemd.fsck[289]: checking extents
 [   OK   ] Mounted /boot.
 [   OK   ] Reached target Sound Card.
 systemd.fsck[289]: checking fs roots
 systemd.fsck[289]: checking root refs
 systemd.fsck[289]: extent buffer leak: start 206893056 len 4096
 systemd.fsck[289]: *** Error in `fsck.btrfs`: corrupted double-linked
 list: 0x02081d80 ***

 and its not proceeding and stuck here.
 I have the rescue disk handy, but not sure how can I fix this issue.
 Any help please.

 thanks,

 --
 ~shripadr
--
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: [BUG] btrfs.fsck failing to fix corrupted block

2013-04-06 Thread Harald Glatt
On Sun, Apr 7, 2013 at 3:56 AM, Shripad Ratnaparkhi
shripad.ratnapar...@gmail.com wrote:
 [Replying to my own email]

 Found a patch which seems to be discusses the fix in a patch provided here:
 https://patchwork.kernel.org/patch/1946561/

 Still now sure whether that is already there in v0.20-rc1 or
 applicable to fix my issue.

 thanks,
 ~shripadr

 PS: BCC'ing the patch provider.

 On Sun, Apr 7, 2013 at 7:16 AM, Shripad Ratnaparkhi
 shripad.ratnapar...@gmail.com wrote:
 Hi there,
 I am newbie and recently started using btrfs. Now facing a weird problem.

 FWIW, I am on archlinux, kenel v3.8.0, having Btrfs v0.20-rc1.
 After an abnormal reboot, getting these errors while boot:

 systemd.fsck[289]: checking extents
 systemd.fsck[289]: checking fs roots
 systemd.fsck[289]: checking root refs
 systemd.fsck[289]: found 23728128 bytes used err is 0
 systemd.fsck[289]: total csum bytes: 23092
 systemd.fsck[289]: total tree bytes: 81920
 systemd.fsck[289]: total fs tree bytes: 24576
 systemd.fsck[289]: btree space waste bytes: 38038
 systemd.fsck[289]: file data blocks allocated: 23646208
 systemd.fsck[289]: referenced 23646208
 systemd.fsck[289]: Btrfs v0.20-rc1
 [   OK   ]  Started File System Check on /dev/sda1.
Mounting /boot...
 systemd.fsck[289]: checking extents
 [   OK   ] Mounted /boot.
 [   OK   ] Reached target Sound Card.
 systemd.fsck[289]: checking fs roots
 systemd.fsck[289]: checking root refs
 systemd.fsck[289]: extent buffer leak: start 206893056 len 4096
 systemd.fsck[289]: *** Error in `fsck.btrfs`: corrupted double-linked
 list: 0x02081d80 ***

 and its not proceeding and stuck here.
 I have the rescue disk handy, but not sure how can I fix this issue.
 Any help please.

 thanks,

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

The version that you can get from btrfs doesn't say a whole lot sadly.
You can build the newest tools from git and try with the btrfsck
there.

Now this might not be entirely correct, but as far as I know the
btrfsck tool isn't ready to be used in the traditional fsck capacity
(automatically at bootup, etc). They don't symlink the tool on arch
and per default arch builds it's initrd without a fsck for btrfs
available. If you manually symlinked the tool to get rid of that error
message during initrd creation I'd suggestion removing that symlink
again and rebuilding your initrd without a btrfsck in place. As far as
I know the best and most reliable way at the moment to confirm or
repair errors is by btrfs scrub. Once you removed the startup fsck it
might boot normally. You can then start a scrub with 'btrfs scrub
start /' and see its status and progress via 'btrfs scrub status /'.
If the scrub reports no errors, or finds some but repairs them, that
is (as far as I know) a more reliable message than whatever btrfsck
thinks.
--
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: [BUG] btrfs.fsck failing to fix corrupted block

2013-04-06 Thread Shripad Ratnaparkhi
Yup, that is exactly the case.
I got to know about no support of fsck.btrfs at boot up, so symlinked
btrfsck and built the initrd.
I will try to re-build without btrfsck now and try.

Thanks for you quick reply and solution, Herald.

thanks,
~shripadr

On Sun, Apr 7, 2013 at 7:32 AM, Harald Glatt m...@hachre.de wrote:
 On Sun, Apr 7, 2013 at 3:56 AM, Shripad Ratnaparkhi
 shripad.ratnapar...@gmail.com wrote:
 [Replying to my own email]

 Found a patch which seems to be discusses the fix in a patch provided here:
 https://patchwork.kernel.org/patch/1946561/

 Still now sure whether that is already there in v0.20-rc1 or
 applicable to fix my issue.

 thanks,
 ~shripadr

 PS: BCC'ing the patch provider.

 On Sun, Apr 7, 2013 at 7:16 AM, Shripad Ratnaparkhi
 shripad.ratnapar...@gmail.com wrote:
 Hi there,
 I am newbie and recently started using btrfs. Now facing a weird problem.

 FWIW, I am on archlinux, kenel v3.8.0, having Btrfs v0.20-rc1.
 After an abnormal reboot, getting these errors while boot:

 systemd.fsck[289]: checking extents
 systemd.fsck[289]: checking fs roots
 systemd.fsck[289]: checking root refs
 systemd.fsck[289]: found 23728128 bytes used err is 0
 systemd.fsck[289]: total csum bytes: 23092
 systemd.fsck[289]: total tree bytes: 81920
 systemd.fsck[289]: total fs tree bytes: 24576
 systemd.fsck[289]: btree space waste bytes: 38038
 systemd.fsck[289]: file data blocks allocated: 23646208
 systemd.fsck[289]: referenced 23646208
 systemd.fsck[289]: Btrfs v0.20-rc1
 [   OK   ]  Started File System Check on /dev/sda1.
Mounting /boot...
 systemd.fsck[289]: checking extents
 [   OK   ] Mounted /boot.
 [   OK   ] Reached target Sound Card.
 systemd.fsck[289]: checking fs roots
 systemd.fsck[289]: checking root refs
 systemd.fsck[289]: extent buffer leak: start 206893056 len 4096
 systemd.fsck[289]: *** Error in `fsck.btrfs`: corrupted double-linked
 list: 0x02081d80 ***

 and its not proceeding and stuck here.
 I have the rescue disk handy, but not sure how can I fix this issue.
 Any help please.

 thanks,

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

 The version that you can get from btrfs doesn't say a whole lot sadly.
 You can build the newest tools from git and try with the btrfsck
 there.

 Now this might not be entirely correct, but as far as I know the
 btrfsck tool isn't ready to be used in the traditional fsck capacity
 (automatically at bootup, etc). They don't symlink the tool on arch
 and per default arch builds it's initrd without a fsck for btrfs
 available. If you manually symlinked the tool to get rid of that error
 message during initrd creation I'd suggestion removing that symlink
 again and rebuilding your initrd without a btrfsck in place. As far as
 I know the best and most reliable way at the moment to confirm or
 repair errors is by btrfs scrub. Once you removed the startup fsck it
 might boot normally. You can then start a scrub with 'btrfs scrub
 start /' and see its status and progress via 'btrfs scrub status /'.
 If the scrub reports no errors, or finds some but repairs them, that
 is (as far as I know) a more reliable message than whatever btrfsck
 thinks.
--
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: undefined reference to `blkid_probe_get_wholedisk_devno'

2013-04-06 Thread Lin Ming
Hi,

I already installed these packages.
sudo apt-get install uuid-dev libattr1-dev zlib1g-dev libacl1-dev
e2fslibs-dev libblkid-dev liblzo2-dev

Maybe my blkid library is too old.
Could you help to check if there is blkid_probe_get_wholedisk_devno
in your /usr/include/blkid/blkid.h?

Thanks,
Lin Ming

On Sun, Apr 7, 2013 at 9:59 AM, Wang Shilong wangshilong1...@gmail.com wrote:
 Hello Lin,

 Before compiling you'll need to get some dependencies:
 Maybe this url will help:
 https://btrfs.wiki.kernel.org/index.php/Btrfs_source_repositories


 Thanks,
 Wang

 On Sun, Apr 7, 2013 at 9:38 AM, Lin Ming min...@gmail.com wrote:

 Hi,

 Build latest 
 git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git

 ~/btrfs-progs$ make
[LD] mkfs.btrfs
 mkfs.o: In function `is_ssd':
 /home/mlin/btrfs-progs/mkfs.c:1234: undefined reference to 
 `blkid_probe_get_wholedisk_devno'

 any fix?

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

--
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: undefined reference to `blkid_probe_get_wholedisk_devno'

2013-04-06 Thread Wang Shilong
Hello,

 Hi,
 
 I already installed these packages.
 sudo apt-get install uuid-dev libattr1-dev zlib1g-dev libacl1-dev
 e2fslibs-dev libblkid-dev liblzo2-dev
 
 Maybe my blkid library is too old.
 Could you help to check if there is blkid_probe_get_wholedisk_devno

Yes i do have this..

Thanks,
Wang
 in your /usr/include/blkid/blkid.h?
 
 Thanks,
 Lin Ming
 
 On Sun, Apr 7, 2013 at 9:59 AM, Wang Shilong wangshilong1...@gmail.com 
 wrote:
 Hello Lin,
 
 Before compiling you'll need to get some dependencies:
 Maybe this url will help:
 https://btrfs.wiki.kernel.org/index.php/Btrfs_source_repositories
 
 
 Thanks,
 Wang
 
 On Sun, Apr 7, 2013 at 9:38 AM, Lin Ming min...@gmail.com wrote:
 
 Hi,
 
 Build latest 
 git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git
 
 ~/btrfs-progs$ make
   [LD] mkfs.btrfs
 mkfs.o: In function `is_ssd':
 /home/mlin/btrfs-progs/mkfs.c:1234: undefined reference to 
 `blkid_probe_get_wholedisk_devno'
 
 any fix?
 
 Thanks,
 Lin Ming
 --
 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
 

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