[RESEND] [PATCH] btrfs-progs: avoid memory leak in btrfs_close_devices

2013-06-25 Thread Wang Sheng-Hui


Three kind of structures need to be freed on close:
* All struct btrfs_device managed by fs_devices
* The name field for each struct btrfs_device
* fs_devices structure itself

The same ones for seed_devices.


Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 volumes.c |   16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/volumes.c b/volumes.c
index d6f81f8..257b740 100644
--- a/volumes.c
+++ b/volumes.c
@@ -153,6 +153,16 @@ static int device_list_add(const char *path,
return 0;
 }

+static void btrfs_close_device(struct btrfs_device *device)
+{
+   close(device-fd);
+   device-fd = -1;
+   device-writeable = 0;
+   if (device-name)
+   kfree(device-name);
+   kfree(device);
+}
+
 int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
 {
struct btrfs_fs_devices *seed_devices;
@@ -161,17 +171,17 @@ int btrfs_close_devices(struct btrfs_fs_devices 
*fs_devices)
 again:
list_for_each(cur, fs_devices-devices) {
device = list_entry(cur, struct btrfs_device, dev_list);
-   close(device-fd);
-   device-fd = -1;
-   device-writeable = 0;
+   btrfs_close_device(device);
}

seed_devices = fs_devices-seed;
fs_devices-seed = NULL;
if (seed_devices) {
+   kfree(fs_devices);
fs_devices = seed_devices;
goto again;
}
+   kfree(fs_devices);

return 0;
 }
--
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] btrfs-progs: remove unused var *prev in extent-cache.c/find_cache_extent

2013-06-24 Thread Wang Sheng-Hui

var *prev is not used in function find_cache_extent. Remove it.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 extent-cache.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/extent-cache.c b/extent-cache.c
index 3dd6434..6d86c33 100644
--- a/extent-cache.c
+++ b/extent-cache.c
@@ -117,10 +117,9 @@ int insert_cache_extent(struct cache_tree *tree, u64 
start, u64 size)
 struct cache_extent *find_cache_extent(struct cache_tree *tree,
   u64 start, u64 size)
 {
-   struct rb_node *prev;
struct rb_node *ret;
struct cache_extent *entry;
-   ret = __tree_search(tree-root, start, size, prev);
+   ret = __tree_search(tree-root, start, size, NULL);
if (!ret)
return NULL;

--
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] btrfs-progs: fix the comment for extent_io.c/clear_extent_bits

2013-06-24 Thread Wang Sheng-Hui

It should be 'clear', not 'set'.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 extent_io.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/extent_io.c b/extent_io.c
index 5093aeb..8f51250 100644
--- a/extent_io.c
+++ b/extent_io.c
@@ -197,7 +197,7 @@ static int clear_state_bit(struct extent_io_tree *tree,
 }

 /*
- * set some bits on a range in the tree.
+ * clear some bits on a range in the tree.
  */
 int clear_extent_bits(struct extent_io_tree *tree, u64 start,
  u64 end, int bits, gfp_t mask)
--
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] xfstests: add 'check -btrfs' support

2013-06-19 Thread Wang Sheng-Hui

Currently we can specify the testing filesytems like 'check -xfs', but
btrfs is not support in this kind of command option. Add the option
'check -btrfs' support.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 check |2 ++
 1 file changed, 2 insertions(+)

diff --git a/check b/check
index ff8fbcf..9c40615 100755
--- a/check
+++ b/check
@@ -74,6 +74,7 @@ usage()

 check options
 -xfstest XFS (default)
+-btrfs  test Btrfs
 -udftest UDF
 -nfstest NFS
 -l line mode diff
@@ -162,6 +163,7 @@ while [ $# -gt 0 ]; do
-udf)   FSTYP=udf ;;
-xfs)   FSTYP=xfs ;;
-nfs)   FSTYP=nfs ;;
+   -btrfs) FSTYP=btrfs ;;

-g) group=$2 ; shift ;
group_list=$(get_group_list $group)
--
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] Btrfs: fix the comment typo for btrfs_attach_transaction_barrier

2013-06-14 Thread Wang Sheng-Hui
The comment is for btrfs_attach_transaction_barrier, not for
btrfs_attach_transaction. Fix the typo.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/transaction.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 0544587..6d4c595 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -490,7 +490,7 @@ struct btrfs_trans_handle
*btrfs_attach_transaction(struct btrfs_root *root)
 }

 /*
- * btrfs_attach_transaction() - catch the running transaction
+ * btrfs_attach_transaction_barrier() - catch the running transaction
  *
  * It is similar to the above function, the differentia is this one
  * will wait for all the inactive transactions until they fully
-- 
1.7.12.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: [PATCH] xfstests 276: use _require_no_large_scratch_dev instead of the removed _require_nobigloopfs

2013-03-24 Thread Wang Sheng-Hui

On 2013年03月21日 14:13, Wang Sheng-Hui wrote:

_require_nobigloopfs has been removed.
We should use _require_no_large_scratch_dev in the test script.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
  276 |3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/276 b/276
index 40b30cf..87363ca 100755
--- a/276
+++ b/276
@@ -58,8 +58,7 @@ _need_to_be_root
  _supported_fs btrfs
  _supported_os Linux
  _require_scratch
-
-_require_nobigloopfs
+_require_no_large_scratch_dev
  _require_btrfs inspect-internal
  _require_command /usr/sbin/filefrag



Does anyone notice this?
I use the upstream xfstests and failed this case for the already-removed 
function.
I think someone patched in but mixed the old function.
I've send out this patch for days, but seems no one cares about it.

If I'm wrong, please let me know.

Thanks,


--
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] xfstests 276: use _require_no_large_scratch_dev instead of the removed _require_nobigloopfs

2013-03-21 Thread Wang Sheng-Hui

_require_nobigloopfs has been removed.
We should use _require_no_large_scratch_dev in the test script.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 276 |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/276 b/276
index 40b30cf..87363ca 100755
--- a/276
+++ b/276
@@ -58,8 +58,7 @@ _need_to_be_root
 _supported_fs btrfs
 _supported_os Linux
 _require_scratch
-
-_require_nobigloopfs
+_require_no_large_scratch_dev
 _require_btrfs inspect-internal
 _require_command /usr/sbin/filefrag

--
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: [PATCH] xfstests 276: fix error 'FIBMAP: Invalid argument'

2013-02-27 Thread Wang Sheng-Hui

On 2013年02月28日 07:04, Dave Chinner wrote:

On Wed, Feb 27, 2013 at 03:15:16PM +0800, Wang Sheng-Hui wrote:

Btrfs doesn't support FIEMAP_FLAG_XATTR, which is enabled by
-x option of filefrag, and will fail with
'FIBMAP: Invalid argument'
for 'filefrag -vx'. 'filefrag -vx' fails on btrfs with
 'FIEMAP failed with unsupported flags 2'
Remove the '-x' option.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com


I can see that this changes what gets dumped into the $seq.full
file, but it seems to me that also changes the extent list returned
to the checking functions. So either the test previously worked and
now it fails with this change, or the test never worked and now it
does, or perhaps something else?

IOWs, I can't tell why you want to change this from the patch
description, hence I don't know if the original behaviour was
intentional or not.  Can you say describe what the overall effect of
the change is in the commit description?


Hi Dave,

I run xfstests for btrfs against SLES11SP2, not upstream kernel.
In the seq.full, I can get the messages
'FIEMAP failed with unsupported flags 2'

Then I found that the test will run 'filefrag -vx' on btrfs, and
'-v' will run FIEMAP_FLAG_XATTR, which is not supported by btrfs
yet, at least in 3.8 kernel.

Without the patch, I failed the testcase and got:
=
276 8s ... - output mismatch (see 276.out.bad)
--- 276.out 2013-02-25 19:08:58.0 -0600
+++ 276.out.bad 2013-02-27 17:59:48.0 -0600
@@ -1,4 +1,867 @@
 QA output created by 276
 *** test backref walking
+FIBMAP: Invalid argument
+FIBMAP: Invalid argument
+FIBMAP: Invalid argument
+FIBMAP: Invalid argument
+FIBMAP: Invalid argument
 ...
 (Run 'diff -u 276.out 276.out.bad' to see the entire diff)
Ran: 276
Failures: 276
Failed 1 of 1 tests

In the 276.full, I got something like:
=
# filefrag -vx /mnt/scratch/snap1/p0/d4/d21/d4a/f58
Filesystem type is: 9123683e
File size of /mnt/scratch/snap1/p0/d4/d21/d4a/f58 is 2125615 (33 blocks, 
blocksize 65536)
FIEMAP failed with unsupported flags 2


With the patch, I can pass the testcase:
=
276 8s ... 7s
Ran: 276
Passed all 1 tests




Cheers,

Dave.



--
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] xfstests 276: fix error 'FIBMAP: Invalid argument'

2013-02-27 Thread Wang Sheng-Hui

On 2013年02月28日 08:25, Dave Chinner wrote:

On Thu, Feb 28, 2013 at 08:02:52AM +0800, Wang Sheng-Hui wrote:

On 2013年02月28日 07:04, Dave Chinner wrote:

On Wed, Feb 27, 2013 at 03:15:16PM +0800, Wang Sheng-Hui wrote:

Btrfs doesn't support FIEMAP_FLAG_XATTR, which is enabled by
-x option of filefrag, and will fail with
'FIBMAP: Invalid argument'
for 'filefrag -vx'. 'filefrag -vx' fails on btrfs with
 'FIEMAP failed with unsupported flags 2'
Remove the '-x' option.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com


I can see that this changes what gets dumped into the $seq.full
file, but it seems to me that also changes the extent list returned
to the checking functions. So either the test previously worked and
now it fails with this change, or the test never worked and now it
does, or perhaps something else?

IOWs, I can't tell why you want to change this from the patch
description, hence I don't know if the original behaviour was
intentional or not.  Can you say describe what the overall effect of
the change is in the commit description?


Hi Dave,

I run xfstests for btrfs against SLES11SP2, not upstream kernel.
In the seq.full, I can get the messages
'FIEMAP failed with unsupported flags 2'

Then I found that the test will run 'filefrag -vx' on btrfs, and
'-v' will run FIEMAP_FLAG_XATTR, which is not supported by btrfs
yet, at least in 3.8 kernel.


Sure, I understand that. I'm not asking about how it fails - that
much is obvious. What I am asking is:

- did it ever work?
- if it did, why did it start failing?
- how long has it been broken for?


With the patch, I can pass the testcase:
=
276 8s ... 7s
Ran: 276
Passed all 1 tests


Great, but why did it break in the first place? That's the
information that needs to be in the commit message. Indeed, Eric has
pointed out to us *exactly* the information that shoul dbe in the
commit message. i.e. a description along the lines of:

Commit 05dadc0 (Btrfs: add fiemap's flag check) added validity
checks to the fiemap flags and hence invalid flags are now being
rejected. Test 276 passes an invalid fiemap flag to btrfs, and so
that test fails since this commit was added.

That tells us exactly why the test failed, why the change is
necessary, and how long the test has been broken for. Seen another
way, it makes me wonder how often anyone runs xfstests on a btrfs
dev tree or regression tests their own changes.

Cheers,

Dave.



Modify the commit message.


Per Eric, Commit 05dadc0 (Btrfs: add fiemap's flag check) added
validity checks to the fiemap flags and hence invalid flags are now
being rejected. Test 276 passes an invalid fiemap flag to btrfs, and
so that test fails since this commit was added.

Btrfs doesn't support FIEMAP_FLAG_XATTR, which is enabled by -x option
of filefrag, and will fail with
'FIBMAP: Invalid argument'
for 'filefrag -vx'. 'filefrag -vx' fails on btrfs with
'FIEMAP failed with unsupported flags 2'
Remove the '-x' option.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 276 |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/276 b/276
index 082f943..f2b17c9 100755
--- a/276
+++ b/276
@@ -75,7 +75,7 @@ _filter_extents()

 _check_file_extents()
 {
-   cmd=filefrag -vx $1
+   cmd=filefrag -v $1
echo # $cmd  $seq.full
out=`$cmd | _filter_extents`
if [ -z $out ]; then
--
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] xfstests 276: fix error 'FIBMAP: Invalid argument'

2013-02-26 Thread Wang Sheng-Hui

Btrfs doesn't support FIEMAP_FLAG_XATTR, which is enabled by
-x option of filefrag, and will fail with
'FIBMAP: Invalid argument'
for 'filefrag -vx'. 'filefrag -vx' fails on btrfs with
'FIEMAP failed with unsupported flags 2'
Remove the '-x' option.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 276 |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/276 b/276
index 082f943..f2b17c9 100755
--- a/276
+++ b/276
@@ -75,7 +75,7 @@ _filter_extents()

 _check_file_extents()
 {
-   cmd=filefrag -vx $1
+   cmd=filefrag -v $1
echo # $cmd  $seq.full
out=`$cmd | _filter_extents`
if [ -z $out ]; then
--
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] Btrfs: cleanup for btrfs_extend_item

2013-01-22 Thread Wang Sheng-Hui

Two cleanups:
* The data_size is the new added size, not the new size after extend.
  Make the description more clear.
* The var data_end is not used anymore after the data shift.
  Remove the useless assignment.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/ctree.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index eea5da7..c4f295e 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -4376,7 +4376,8 @@ void btrfs_truncate_item(struct btrfs_trans_handle *trans,
 }

 /*
- * make the item pointed to by the path bigger, data_size is the new size.
+ * make the item pointed to by the path bigger.
+ * data_size is the to be extended size.
  */
 void btrfs_extend_item(struct btrfs_trans_handle *trans,
   struct btrfs_root *root, struct btrfs_path *path,
@@ -4432,7 +4433,6 @@ void btrfs_extend_item(struct btrfs_trans_handle *trans,
  data_end - data_size, btrfs_leaf_data(leaf) +
  data_end, old_data - data_end);

-   data_end = old_data;
old_size = btrfs_item_size_nr(leaf, slot);
item = btrfs_item_nr(leaf, slot);
btrfs_set_item_size(leaf, item, old_size + data_size);
--
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: [PATCH] Btrfs: make sure fs_info is not null before its field is used in __btrfs_panic

2012-12-08 Thread Wang Sheng-Hui
On 2012年12月08日 18:10, Li Zefan wrote:
 On 2012/12/7 23:42, Wang Sheng-Hui wrote:
 We should make sure fs_info is not null before we refer to its field.
 Add simple check here.
 Why? Is there any caller passing NULL @fs_info to this function?

At least for code clean now.

In __btrfs_panic, we have:
276 if (fs_info)
277 s_id = fs_info-sb-s_id;
So for the -mount_opt field access, we'd better do the check first.

 Signed-off-by: Wang Sheng-Hui shh...@gmail.com
 ---
  fs/btrfs/super.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
 index 915ac14..c6a3633 100644
 --- a/fs/btrfs/super.c
 +++ b/fs/btrfs/super.c
 @@ -280,7 +280,7 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const 
 char *function,
  vaf.va = args;
  
  errstr = btrfs_decode_error(fs_info, errno, nbuf);
 -if (fs_info-mount_opt  BTRFS_MOUNT_PANIC_ON_FATAL_ERROR)
 +if (fs_info  (fs_info-mount_opt  BTRFS_MOUNT_PANIC_ON_FATAL_ERROR))
  panic(KERN_CRIT BTRFS panic (device %s) in %s:%d: %pV (%s)\n,
  s_id, function, line, vaf, errstr);
  


--
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: make sure fs_info is not null before its field is used in __btrfs_panic

2012-12-07 Thread Wang Sheng-Hui
We should make sure fs_info is not null before we refer to its field.
Add simple check here.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/super.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 915ac14..c6a3633 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -280,7 +280,7 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const 
char *function,
vaf.va = args;
 
errstr = btrfs_decode_error(fs_info, errno, nbuf);
-   if (fs_info-mount_opt  BTRFS_MOUNT_PANIC_ON_FATAL_ERROR)
+   if (fs_info  (fs_info-mount_opt  BTRFS_MOUNT_PANIC_ON_FATAL_ERROR))
panic(KERN_CRIT BTRFS panic (device %s) in %s:%d: %pV (%s)\n,
s_id, function, line, vaf, errstr);
 
-- 
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: [PATCH] Btrfs: remove warning check in io_ctl_map_page

2012-11-30 Thread Wang Sheng-Hui
On 2012年11月30日 17:02, Liu Bo wrote:

 On Fri, Nov 30, 2012 at 02:02:26PM +0800, shh...@gmail.com wrote:
 From: Wang Sheng-Hui shh...@gmail.com

 io_ctl_map_page is called by many functions in free-space-cache.
 In some scenarios, the -cur is not null, e.g. io_ctl_add_entry.
 Remove the check here.
 
 Hi Wang,
 
 Seems to be impossible according to the code, even in io_ctl_add_entry().
 
 So have you seen such a warning in your flight running?  If you do,
 maybe you can post it here and we can figure out the whys.
 


Hi Liu Bo,

I just walked through the code. reread io_ctl_add_entry, and just noticed
that io_ctl_set_crc is called before io_ctl_map_page, which can guarantee
the -cur is set to null before map.

Thanks for helping me understand the code.

Regards,
Sheng-Hui


 thanks,
 liubo
 

 Signed-off-by: Wang Sheng-Hui shh...@gmail.com
 ---
  fs/btrfs/free-space-cache.c |1 -
  1 files changed, 0 insertions(+), 1 deletions(-)

 diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
 index c3318cb..4ea66d4 100644
 --- a/fs/btrfs/free-space-cache.c
 +++ b/fs/btrfs/free-space-cache.c
 @@ -307,7 +307,6 @@ static void io_ctl_unmap_page(struct io_ctl *io_ctl)
  
  static void io_ctl_map_page(struct io_ctl *io_ctl, int clear)
  {
 -WARN_ON(io_ctl-cur);
  BUG_ON(io_ctl-index = io_ctl-num_pages);
  io_ctl-page = io_ctl-pages[io_ctl-index++];
  io_ctl-cur = kmap(io_ctl-page);
 -- 
 1.6.0.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


--
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: do not warn_on io_ctl-cur in io_ctl_map_page

2012-11-22 Thread Wang Sheng-Hui
io_ctl_map_page is called by many functions in free-space-cache.
In most scenarios, the -cur is not null, e.g. io_ctl_add_entry.
I think we'd better remove the warn_on here.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/free-space-cache.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 1027b85..31fcf24 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -307,7 +307,6 @@ static void io_ctl_unmap_page(struct io_ctl *io_ctl)

 static void io_ctl_map_page(struct io_ctl *io_ctl, int clear)
 {
-   WARN_ON(io_ctl-cur);
BUG_ON(io_ctl-index = io_ctl-num_pages);
io_ctl-page = io_ctl-pages[io_ctl-index++];
io_ctl-cur = kmap(io_ctl-page);
-- 
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-progs: print the right mount checking info in restore.c

2012-11-19 Thread Wang Sheng-Hui
The mount status is checked against the arg device (argv[optind]),
not the directory. Correct the info printed on device mounted.

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

diff --git a/restore.c b/restore.c
index b9e5381..a7580f8 100644
--- a/restore.c
+++ b/restore.c
@@ -827,7 +827,7 @@ int main(int argc, char **argv)
strerror(ret));
return ret;
} else if (ret) {
-   fprintf(stderr, %s is currently mounted.  Aborting.\n, 
argv[optind + 1]);
+   fprintf(stderr, %s is currently mounted.  Aborting.\n, 
argv[optind]);
return -EBUSY;
}

-- 
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 1/2] btrfs-progs: update options in find-root.c

2012-11-17 Thread Wang Sheng-Hui
Remove the useless option -v and add the option -o in
the description of usage.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 find-root.c |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/find-root.c b/find-root.c
index c0f38b8..2fb40e5 100644
--- a/find-root.c
+++ b/find-root.c
@@ -35,13 +35,12 @@
 #include utils.h
 #include crc32c.h

-static int verbose = 0;
 static u16 csum_size = 0;
 static u64 search_objectid = BTRFS_ROOT_TREE_OBJECTID;

 static void usage()
 {
-   fprintf(stderr, Usage: find-roots [-v] device\n);
+   fprintf(stderr, Usage: find-roots [-o search_objectid] device\n);
 }

 int csum_block(void *buf, u32 len)
@@ -414,11 +413,8 @@ int main(int argc, char **argv)
int opt;
int ret;

-   while ((opt = getopt(argc, argv, vo:)) != -1) {
+   while ((opt = getopt(argc, argv, o:)) != -1) {
switch(opt) {
-   case 'v':
-   verbose++;
-   break;
case 'o':
errno = 0;
search_objectid = (u64)strtoll(optarg, NULL,
-- 
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 2/2] btrfs-progs: rename find-root.c to btrfs-find-root.c

2012-11-17 Thread Wang Sheng-Hui
Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 Makefile  |4 +-
 btrfs-find-root.c |  454 +
 find-root.c   |  454 -
 3 files changed, 456 insertions(+), 456 deletions(-)
 create mode 100644 btrfs-find-root.c
 delete mode 100644 find-root.c

diff --git a/Makefile b/Makefile
index f4bb782..833dddf 100644
--- a/Makefile
+++ b/Makefile
@@ -48,8 +48,8 @@ btrfs: $(objects) btrfs.o help.o common.o $(cmds_objects)
 calc-size: $(objects) calc-size.o
$(CC) $(CFLAGS) -o calc-size calc-size.o $(objects) $(LDFLAGS) $(LIBS)

-btrfs-find-root: $(objects) find-root.o
-   $(CC) $(CFLAGS) -o btrfs-find-root find-root.o $(objects) $(LDFLAGS) 
$(LIBS)
+btrfs-find-root: $(objects) btrfs-find-root.o
+   $(CC) $(CFLAGS) -o btrfs-find-root btrfs-find-root.o $(objects) 
$(LDFLAGS) $(LIBS)

 btrfs-restore: $(objects) restore.o
$(CC) $(CFLAGS) -o btrfs-restore restore.o $(objects) $(LDFLAGS) 
$(LIBS) $(RESTORE_LIBS)
diff --git a/btrfs-find-root.c b/btrfs-find-root.c
new file mode 100644
index 000..2fb40e5
--- /dev/null
+++ b/btrfs-find-root.c
@@ -0,0 +1,454 @@
+/*
+ * Copyright (C) 2011 Red Hat.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License v2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ */
+
+#define _XOPEN_SOURCE 500
+#define _GNU_SOURCE 1
+#include stdio.h
+#include stdlib.h
+#include unistd.h
+#include fcntl.h
+#include sys/stat.h
+#include zlib.h
+#include kerncompat.h
+#include ctree.h
+#include disk-io.h
+#include print-tree.h
+#include transaction.h
+#include list.h
+#include version.h
+#include volumes.h
+#include utils.h
+#include crc32c.h
+
+static u16 csum_size = 0;
+static u64 search_objectid = BTRFS_ROOT_TREE_OBJECTID;
+
+static void usage()
+{
+   fprintf(stderr, Usage: find-roots [-o search_objectid] device\n);
+}
+
+int csum_block(void *buf, u32 len)
+{
+   char *result;
+   u32 crc = ~(u32)0;
+   int ret = 0;
+
+   result = malloc(csum_size * sizeof(char));
+   if (!result) {
+   fprintf(stderr, No memory\n);
+   return 1;
+   }
+
+   len -= BTRFS_CSUM_SIZE;
+   crc = crc32c(crc, buf + BTRFS_CSUM_SIZE, len);
+   btrfs_csum_final(crc, result);
+
+   if (memcmp(buf, result, csum_size))
+   ret = 1;
+   free(result);
+   return ret;
+}
+
+static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
+   u32 stripesize, struct btrfs_root *root,
+   struct btrfs_fs_info *fs_info, u64 objectid)
+{
+   root-node = NULL;
+   root-commit_root = NULL;
+   root-sectorsize = sectorsize;
+   root-nodesize = nodesize;
+   root-leafsize = leafsize;
+   root-stripesize = stripesize;
+   root-ref_cows = 0;
+   root-track_dirty = 0;
+
+   root-fs_info = fs_info;
+   root-objectid = objectid;
+   root-last_trans = 0;
+   root-highest_inode = 0;
+   root-last_inode_alloc = 0;
+
+   INIT_LIST_HEAD(root-dirty_list);
+   memset(root-root_key, 0, sizeof(root-root_key));
+   memset(root-root_item, 0, sizeof(root-root_item));
+   root-root_key.objectid = objectid;
+   return 0;
+}
+
+static int close_all_devices(struct btrfs_fs_info *fs_info)
+{
+   struct list_head *list;
+   struct list_head *next;
+   struct btrfs_device *device;
+
+   return 0;
+
+   list = fs_info-fs_devices-devices;
+   list_for_each(next, list) {
+   device = list_entry(next, struct btrfs_device, dev_list);
+   close(device-fd);
+   }
+   return 0;
+}
+
+static struct btrfs_root *open_ctree_broken(int fd, const char *device)
+{
+   u32 sectorsize;
+   u32 nodesize;
+   u32 leafsize;
+   u32 blocksize;
+   u32 stripesize;
+   u64 generation;
+   struct btrfs_root *tree_root = malloc(sizeof(struct btrfs_root));
+   struct btrfs_root *extent_root = malloc(sizeof(struct btrfs_root));
+   struct btrfs_root *chunk_root = malloc(sizeof(struct btrfs_root));
+   struct btrfs_root *dev_root = malloc(sizeof(struct btrfs_root));
+   struct btrfs_root *csum_root = malloc(sizeof(struct btrfs_root));
+   struct btrfs_fs_info *fs_info = malloc(sizeof(*fs_info));
+   int ret;
+   struct btrfs_super_block *disk_super;
+   struct

[PATCH] btrfs-progs: remove unnecessary assignment in btrfs-map-logical.c

2012-11-15 Thread Wang Sheng-Hui
The info_file is set to stdout by default, and we donot need to
reassign it to stdout if it's not changed to other values.

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

diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index fa4fb3f..2ecaabd 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -187,7 +187,6 @@ int main(int ac, char **av)
close(out_fd);
goto close;
}
-   info_file = stdout;
}
}

-- 
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 1/2] btrfs-progs: update usage description for debug-tree.c

2012-11-13 Thread Wang Sheng-Hui
There are more options than -e only.
Update the description for the usage.

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

diff --git a/debug-tree.c b/debug-tree.c
index 94ffd8e..f6bd5d8 100644
--- a/debug-tree.c
+++ b/debug-tree.c
@@ -30,7 +30,15 @@

 static int print_usage(void)
 {
-   fprintf(stderr, usage: debug-tree [ -e ] device\n);
+   fprintf(stderr, usage: btrfs-debug-tree [ -e ] [ -d ] [ -r ] [ -R 
]\n);
+   fprintf(stderr, [-b block_num ] device\n);
+   fprintf(stderr, \t-e : print detailed extents info\n);
+   fprintf(stderr, \t-d : print info of btrfs device and root tree dirs
+ only\n);
+   fprintf(stderr, \t-r : print info of roots only\n);
+   fprintf(stderr, \t-R : print info of roots and root backups\n);
+   fprintf(stderr, \t-b block_num : print info of the specified block
+ only\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


btrfs-progs: rename debug-tree.c to btrfs-debug-tree.c

2012-11-13 Thread Wang Sheng-Hui
Make the name more clear in Makefile and the usage description
of debug-tree.c

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 Makefile   |4 +-
 btrfs-debug-tree.c |  381 
 debug-tree.c   |  381 
 3 files changed, 383 insertions(+), 383 deletions(-)
 create mode 100644 btrfs-debug-tree.c
 delete mode 100644 debug-tree.c

diff --git a/Makefile b/Makefile
index 4894903..f4bb782 100644
--- a/Makefile
+++ b/Makefile
@@ -69,8 +69,8 @@ btrfsck: $(objects) btrfsck.o
 mkfs.btrfs: $(objects) mkfs.o
$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)

-btrfs-debug-tree: $(objects) debug-tree.o
-   $(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) 
$(LIBS)
+btrfs-debug-tree: $(objects) btrfs-debug-tree.o
+   $(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) btrfs-debug-tree.o 
$(LDFLAGS) $(LIBS)

 btrfs-zero-log: $(objects) btrfs-zero-log.o
$(CC) $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o 
$(LDFLAGS) $(LIBS)
diff --git a/btrfs-debug-tree.c b/btrfs-debug-tree.c
new file mode 100644
index 000..f6bd5d8
--- /dev/null
+++ b/btrfs-debug-tree.c
@@ -0,0 +1,381 @@
+/*
+ * Copyright (C) 2007 Oracle.  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.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include unistd.h
+#include uuid/uuid.h
+#include kerncompat.h
+#include radix-tree.h
+#include ctree.h
+#include disk-io.h
+#include print-tree.h
+#include transaction.h
+#include version.h
+
+static int print_usage(void)
+{
+   fprintf(stderr, usage: btrfs-debug-tree [ -e ] [ -d ] [ -r ] [ -R 
]\n);
+   fprintf(stderr, [-b block_num ] device\n);
+   fprintf(stderr, \t-e : print detailed extents info\n);
+   fprintf(stderr, \t-d : print info of btrfs device and root tree dirs
+ only\n);
+   fprintf(stderr, \t-r : print info of roots only\n);
+   fprintf(stderr, \t-R : print info of roots and root backups\n);
+   fprintf(stderr, \t-b block_num : print info of the specified block
+ only\n);
+   fprintf(stderr, %s\n, BTRFS_BUILD_VERSION);
+   exit(1);
+}
+
+static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
+{
+   int i;
+   u32 nr;
+   u32 size;
+
+   if (!eb)
+   return;
+
+   size = btrfs_level_size(root, btrfs_header_level(eb) - 1);
+   nr = btrfs_header_nritems(eb);
+   for (i = 0; i  nr; i++) {
+   struct extent_buffer *next = read_tree_block(root,
+btrfs_node_blockptr(eb, i),
+size,
+btrfs_node_ptr_generation(eb, i));
+   if (btrfs_is_leaf(next) 
+   btrfs_header_level(eb) != 1)
+   BUG();
+   if (btrfs_header_level(next) !=
+   btrfs_header_level(eb) - 1)
+   BUG();
+   print_extents(root, next);
+   free_extent_buffer(next);
+   }
+}
+
+static void print_old_roots(struct btrfs_super_block *super)
+{
+   struct btrfs_root_backup *backup;
+   int i;
+
+   for (i = 0; i  BTRFS_NUM_BACKUP_ROOTS; i++) {
+   backup = super-super_roots + i;
+   printf(btrfs root backup slot %d\n, i);
+   printf(\ttree root gen %llu block %llu\n,
+  (unsigned long long)btrfs_backup_tree_root_gen(backup),
+  (unsigned long long)btrfs_backup_tree_root(backup));
+
+   printf(\t\textent root gen %llu block %llu\n,
+  (unsigned long long)btrfs_backup_extent_root_gen(backup),
+  (unsigned long long)btrfs_backup_extent_root(backup));
+
+   printf(\t\tchunk root gen %llu block %llu\n,
+  (unsigned long long)btrfs_backup_chunk_root_gen(backup),
+  (unsigned long long)btrfs_backup_chunk_root(backup));
+
+   printf(\t\tdevice root gen %llu block %llu\n,
+  (unsigned long long)btrfs_backup_dev_root_gen(backup),
+  (unsigned long long)btrfs_backup_dev_root(backup

[PATCH 2/2] btrfs-progs: rename debug-tree.c to btrfs-debug-tree.c

2012-11-13 Thread Wang Sheng-Hui
Make the name more clear in Makefile and the usage description
of debug-tree.c

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 Makefile   |4 +-
 btrfs-debug-tree.c |  381 
 debug-tree.c   |  381 
 3 files changed, 383 insertions(+), 383 deletions(-)
 create mode 100644 btrfs-debug-tree.c
 delete mode 100644 debug-tree.c

diff --git a/Makefile b/Makefile
index 4894903..f4bb782 100644
--- a/Makefile
+++ b/Makefile
@@ -69,8 +69,8 @@ btrfsck: $(objects) btrfsck.o
 mkfs.btrfs: $(objects) mkfs.o
$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)

-btrfs-debug-tree: $(objects) debug-tree.o
-   $(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) 
$(LIBS)
+btrfs-debug-tree: $(objects) btrfs-debug-tree.o
+   $(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) btrfs-debug-tree.o 
$(LDFLAGS) $(LIBS)

 btrfs-zero-log: $(objects) btrfs-zero-log.o
$(CC) $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o 
$(LDFLAGS) $(LIBS)
diff --git a/btrfs-debug-tree.c b/btrfs-debug-tree.c
new file mode 100644
index 000..f6bd5d8
--- /dev/null
+++ b/btrfs-debug-tree.c
@@ -0,0 +1,381 @@
+/*
+ * Copyright (C) 2007 Oracle.  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.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include unistd.h
+#include uuid/uuid.h
+#include kerncompat.h
+#include radix-tree.h
+#include ctree.h
+#include disk-io.h
+#include print-tree.h
+#include transaction.h
+#include version.h
+
+static int print_usage(void)
+{
+   fprintf(stderr, usage: btrfs-debug-tree [ -e ] [ -d ] [ -r ] [ -R 
]\n);
+   fprintf(stderr, [-b block_num ] device\n);
+   fprintf(stderr, \t-e : print detailed extents info\n);
+   fprintf(stderr, \t-d : print info of btrfs device and root tree dirs
+ only\n);
+   fprintf(stderr, \t-r : print info of roots only\n);
+   fprintf(stderr, \t-R : print info of roots and root backups\n);
+   fprintf(stderr, \t-b block_num : print info of the specified block
+ only\n);
+   fprintf(stderr, %s\n, BTRFS_BUILD_VERSION);
+   exit(1);
+}
+
+static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
+{
+   int i;
+   u32 nr;
+   u32 size;
+
+   if (!eb)
+   return;
+
+   size = btrfs_level_size(root, btrfs_header_level(eb) - 1);
+   nr = btrfs_header_nritems(eb);
+   for (i = 0; i  nr; i++) {
+   struct extent_buffer *next = read_tree_block(root,
+btrfs_node_blockptr(eb, i),
+size,
+btrfs_node_ptr_generation(eb, i));
+   if (btrfs_is_leaf(next) 
+   btrfs_header_level(eb) != 1)
+   BUG();
+   if (btrfs_header_level(next) !=
+   btrfs_header_level(eb) - 1)
+   BUG();
+   print_extents(root, next);
+   free_extent_buffer(next);
+   }
+}
+
+static void print_old_roots(struct btrfs_super_block *super)
+{
+   struct btrfs_root_backup *backup;
+   int i;
+
+   for (i = 0; i  BTRFS_NUM_BACKUP_ROOTS; i++) {
+   backup = super-super_roots + i;
+   printf(btrfs root backup slot %d\n, i);
+   printf(\ttree root gen %llu block %llu\n,
+  (unsigned long long)btrfs_backup_tree_root_gen(backup),
+  (unsigned long long)btrfs_backup_tree_root(backup));
+
+   printf(\t\textent root gen %llu block %llu\n,
+  (unsigned long long)btrfs_backup_extent_root_gen(backup),
+  (unsigned long long)btrfs_backup_extent_root(backup));
+
+   printf(\t\tchunk root gen %llu block %llu\n,
+  (unsigned long long)btrfs_backup_chunk_root_gen(backup),
+  (unsigned long long)btrfs_backup_chunk_root(backup));
+
+   printf(\t\tdevice root gen %llu block %llu\n,
+  (unsigned long long)btrfs_backup_dev_root_gen(backup),
+  (unsigned long long)btrfs_backup_dev_root(backup

[PATCH] btrfs-progs: avoid memory leak in find_and_setup_log_root

2012-10-24 Thread Wang Sheng-Hui
In find_and_setup_log_root, the malloced log_root would be leaked
if we have bytenr = 0, which would happen at our mkfs stage.

Move the memory allocation after the bytenr check, and add allocation
failure check.

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

diff --git a/disk-io.c b/disk-io.c
index 0395205..3a80284 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -456,11 +456,15 @@ static int find_and_setup_log_root(struct btrfs_root 
*tree_root,
 {
u32 blocksize;
u64 blocknr = btrfs_super_log_root(disk_super);
-   struct btrfs_root *log_root = malloc(sizeof(struct btrfs_root));
+   struct btrfs_root *log_root = NULL;

if (blocknr == 0)
return 0;

+   log_root = malloc(sizeof(struct btrfs_root));
+   if (!log_root)
+   return -ENOMEM;
+
blocksize = btrfs_level_size(tree_root,
 btrfs_super_log_root_level(disk_super));

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


Re: Questions about mkfs -A option

2012-10-24 Thread Wang Sheng-Hui
On 2012年10月24日 17:44, Alex Lyakas wrote:

 Hi Wang,
 if you just look at the code in find_free_dev_extent():
 u64 search_start = 0;
 ...
 search_start = max((u64)1024 * 1024, search_start);
 if (root-fs_info-alloc_start + num_bytes = device-total_bytes)
   search_start = max(root-fs_info-alloc_start, search_start);
 ...
 key.objectid = device-devid;
 key.offset = search_start;
 key.type = BTRFS_DEV_EXTENT_KEY;
 
 You see that it will search for DEV_EXTENTs (when allocating chunks)
 that begin after the value you specified. So it will not use some
 space at the beginning of the device for allocations. Same behavior in
 the kernel can be caused by using alloc_start=X mount option.
 What is the purpose of this I don't know, but what it does looks pretty clear.
 The (first copy of the) superblock, though, is always written to
 BTRFS_SUPER_INFO_OFFSET, as you mentioned.
 
 Alex.
 
 


Thanks, Alex.

 
 
 On Wed, Oct 24, 2012 at 2:48 AM, Wang Sheng-Hui shh...@gmail.com wrote:
 On 2012年10月23日 01:49, Alex Lyakas wrote:

 Wang,
 I would say that zeroing is done to prevent from seeing some other 
 superblock (besides btrfs) there.


 That make sense.


 Alex.




 But I still confused by the -A option?

 In mkfs, we always write the sb info into BTRFS_SUPER_INFO_OFFSET.
 From the -A comment, I think btrfs would be places after the -A value.
 What would happen if we specify a -A value larger than it?


 Thanks,
 Sheng-Hui


--
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: Questions about mkfs -A option

2012-10-23 Thread Wang Sheng-Hui
On 2012年10月23日 01:49, Alex Lyakas wrote:

 Wang,
 I would say that zeroing is done to prevent from seeing some other superblock 
 (besides btrfs) there.


That make sense.

 
 Alex.
 
 


But I still confused by the -A option?

In mkfs, we always write the sb info into BTRFS_SUPER_INFO_OFFSET.
From the -A comment, I think btrfs would be places after the -A value.
What would happen if we specify a -A value larger than it?


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


Questions about mkfs -A option

2012-10-17 Thread Wang Sheng-Hui
Hi,

I'm reading the mkfs code, and confused by its -A option.
From its comments, the value specified by -A should be regarded as
the start of the filesystem. But mkfs will always zero some area
at the beginning of the first dev, regardless -r specified or not.

My question is:
Why mkfs zeros the beginning of the first dev? Is that expected?
And any use case for -A option?


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


[PATCH] Btrfs: remove repeated eb-pages check in, disk-io.c/csum_dirty_buffer

2012-10-08 Thread Wang Sheng-Hui
In csum_dirty_buffer, we first get eb from page-private.
Then we check if the page is the first page of eb. Later
we check it again. Remove the repeated check here.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/disk-io.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 22e98e0..8919c56 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -432,14 +432,12 @@ static int csum_dirty_buffer(struct btrfs_root *root, 
struct page *page)
tree = BTRFS_I(page-mapping-host)-io_tree;

eb = (struct extent_buffer *)page-private;
-   if (page != eb-pages[0])
-   return 0;
-   found_start = btrfs_header_bytenr(eb);
-   if (found_start != start) {
+   if (page != eb-pages[0]) {
WARN_ON(1);
return 0;
}
-   if (eb-pages[0] != page) {
+   found_start = btrfs_header_bytenr(eb);
+   if (found_start != start) {
WARN_ON(1);
return 0;
}
-- 
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


Re: [PATCH 4/4] Btrfs: tivial cleanup: add space between = and the rest code

2012-09-24 Thread Wang Sheng-Hui
On 2012年09月24日 21:15, David Sterba wrote:
 On Mon, Sep 24, 2012 at 08:47:33AM +0800, Wang Sheng-Hui wrote:
 trivial code cleanup.
 
 -ret =btrfs_drop_snapshot(root, NULL, 1, 0);
 +ret = btrfs_drop_snapshot(root, NULL, 1, 0);
 
 Sorry but this is too trivial.
 
 Unless it really bugs you when you're going through code, I don't think
 that cleanups at this level are necessary. Reading through commit
 history of some code via 'git blame' and seeing such cleanups is not
 welcome.
 

Got it. Thanks,

 I have a patchet in testing that updates a few things around snapshot
 cleaning and this line will get fixed, so it'll not stay forever.
 
 david

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


Re: Btrfs: check range early in map_private_extent_buffer

2012-09-24 Thread Wang Sheng-Hui
On 2012年09月25日 00:17, David Sterba wrote:
 On Mon, Sep 24, 2012 at 12:38:07PM +0800, Wang Sheng-Hui wrote:
 Check range early to avoid further check/compute in case
 of range error.

 Signed-off-by: Wang Sheng-Hui shh...@gmail.com
 ---
  fs/btrfs/extent_io.c |   16 
  1 files changed, 8 insertions(+), 8 deletions(-)

 diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
 index 4c87847..9250cf5 100644
 --- a/fs/btrfs/extent_io.c
 +++ b/fs/btrfs/extent_io.c
 @@ -4643,6 +4643,14 @@ int map_private_extent_buffer(struct extent_buffer 
 *eb, unsigned long start,
  unsigned long end_i = (start_offset + start + min_len - 1) 
  PAGE_CACHE_SHIFT;
  
 +if (start + min_len  eb-len) {
 +printk(KERN_ERR btrfs bad mapping eb start %llu len %lu, 
 +   wanted %lu %lu\n, (unsigned long long)eb-start,
 +   eb-len, start, min_len);
 +WARN_ON(1);
 +return -EINVAL;
 +}
 +
  if (i != end_i)
  return -EINVAL;
 
 4665 unsigned long i = (start_offset + start)  PAGE_CACHE_SHIFT;
 4666 unsigned long end_i = (start_offset + start + min_len - 1) 
 4667 PAGE_CACHE_SHIFT;
 
 so the check above effectively verifies that
 
   min_len - 1  PAGE_CACHE_SIZE
 AND
   is within the same page
 
 The other check
 
   if (start + min_len  eb-len) {
 
 looks if the requested data do not lie out of the bounds of the extent
 buffer, where min_len is filled with sizeof(something).
 
 So, both the checks look for corrupted metadata, I don't see the need to
 swap them.

Reread the code and it really does the check.
Got it. Thanks for your explanation.

 
 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 1/4] Btrfs: cleanup: return the ret value of __btrfs_end_transaction directly in btrfs_end_transaction_

2012-09-23 Thread Wang Sheng-Hui
No need to use specific var to record the return value of
__btrfs_end_transaction and check if it is not zero.
Just return the result directly as btrfs_end_transaction_dmeta.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/transaction.c |   21 +++--
 1 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 27c2600..8fcc501 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -602,34 +602,19 @@ static int __btrfs_end_transaction(struct 
btrfs_trans_handle *trans,
 int btrfs_end_transaction(struct btrfs_trans_handle *trans,
  struct btrfs_root *root)
 {
-   int ret;
-
-   ret = __btrfs_end_transaction(trans, root, 0, 1);
-   if (ret)
-   return ret;
-   return 0;
+   return __btrfs_end_transaction(trans, root, 0, 1);
 }
 
 int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans,
   struct btrfs_root *root)
 {
-   int ret;
-
-   ret = __btrfs_end_transaction(trans, root, 1, 1);
-   if (ret)
-   return ret;
-   return 0;
+   return __btrfs_end_transaction(trans, root, 1, 1);
 }
 
 int btrfs_end_transaction_nolock(struct btrfs_trans_handle *trans,
 struct btrfs_root *root)
 {
-   int ret;
-
-   ret = __btrfs_end_transaction(trans, root, 0, 0);
-   if (ret)
-   return ret;
-   return 0;
+   return __btrfs_end_transaction(trans, root, 0, 0);
 }
 
 int btrfs_end_transaction_dmeta(struct btrfs_trans_handle *trans,
-- 
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 2/4] Btrfs: trivial cleanup: setup ret with 0 directly in btrfs_wait_for_commit

2012-09-23 Thread Wang Sheng-Hui
trivial code cleanup.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/transaction.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 8fcc501..469a8b6 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -420,9 +420,8 @@ static noinline void wait_for_commit(struct btrfs_root 
*root,
 int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid)
 {
struct btrfs_transaction *cur_trans = NULL, *t;
-   int ret;
+   int ret = 0;
 
-   ret = 0;
if (transid) {
if (transid = root-fs_info-last_trans_committed)
goto out;
-- 
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 3/4] Btrfs: remove unnecessary cur_trans set before goto loop in join_transaction

2012-09-23 Thread Wang Sheng-Hui
In the big loop, cur_trans will be set fs_info-running_transaction
before it's used. And after kmem_cache_free it and goto loop, it will
be setup again. No need to setup it immediately after freed.

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

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 469a8b6..675d813 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -98,7 +98,6 @@ loop:
 * to redo the trans_no_join checks above
 */
kmem_cache_free(btrfs_transaction_cachep, cur_trans);
-   cur_trans = fs_info-running_transaction;
goto loop;
} else if (fs_info-fs_state  BTRFS_SUPER_FLAG_ERROR) {
spin_unlock(fs_info-trans_lock);
-- 
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 4/4] Btrfs: tivial cleanup: add space between = and the rest code

2012-09-23 Thread Wang Sheng-Hui
trivial code cleanup.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/transaction.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 675d813..3279df2 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1619,7 +1619,7 @@ int btrfs_clean_old_snapshots(struct btrfs_root *root)
BTRFS_MIXED_BACKREF_REV)
ret = btrfs_drop_snapshot(root, NULL, 0, 0);
else
-   ret =btrfs_drop_snapshot(root, NULL, 1, 0);
+   ret = btrfs_drop_snapshot(root, NULL, 1, 0);
BUG_ON(ret  0);
}
return 0;
-- 
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


Btrfs: check range early in map_private_extent_buffer

2012-09-23 Thread Wang Sheng-Hui
Check range early to avoid further check/compute in case
of range error.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/extent_io.c |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 4c87847..9250cf5 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4643,6 +4643,14 @@ int map_private_extent_buffer(struct extent_buffer *eb, 
unsigned long start,
unsigned long end_i = (start_offset + start + min_len - 1) 
PAGE_CACHE_SHIFT;
 
+   if (start + min_len  eb-len) {
+   printk(KERN_ERR btrfs bad mapping eb start %llu len %lu, 
+  wanted %lu %lu\n, (unsigned long long)eb-start,
+  eb-len, start, min_len);
+   WARN_ON(1);
+   return -EINVAL;
+   }
+
if (i != end_i)
return -EINVAL;
 
@@ -4654,14 +4662,6 @@ int map_private_extent_buffer(struct extent_buffer *eb, 
unsigned long start,
*map_start = ((u64)i  PAGE_CACHE_SHIFT) - start_offset;
}
 
-   if (start + min_len  eb-len) {
-   printk(KERN_ERR btrfs bad mapping eb start %llu len %lu, 
-  wanted %lu %lu\n, (unsigned long long)eb-start,
-  eb-len, start, min_len);
-   WARN_ON(1);
-   return -EINVAL;
-   }
-
p = extent_buffer_page(eb, i);
kaddr = page_address(p);
*map = kaddr + offset;
-- 
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] Btrfs: small fix the commment for the action flags in delayed-ref.h

2012-09-20 Thread Wang Sheng-Hui
The action has been merged into struct btrfs_delayed_ref_node,
and no struct btrfs_delayed_ref is available now.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/delayed-ref.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
index ab53005..c9d7036 100644
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
@@ -18,7 +18,7 @@
 #ifndef __DELAYED_REF__
 #define __DELAYED_REF__
 
-/* these are the possible values of struct btrfs_delayed_ref-action */
+/* these are the possible values of struct btrfs_delayed_ref_node-action */
 #define BTRFS_ADD_DELAYED_REF1 /* add one backref to the tree */
 #define BTRFS_DROP_DELAYED_REF   2 /* delete one backref from the tree */
 #define BTRFS_ADD_DELAYED_EXTENT 3 /* record a full extent allocation */
-- 
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


[RESEND][PATCH] Btrfs: small fix the commment for the action flags in delayed-ref.h

2012-09-20 Thread Wang Sheng-Hui
The action field has been merged into struct btrfs_delayed_ref_node,
and no struct btrfs_delayed_ref is available now.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/delayed-ref.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
index ab53005..c9d7036 100644
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
@@ -18,7 +18,7 @@
 #ifndef __DELAYED_REF__
 #define __DELAYED_REF__
 
-/* these are the possible values of struct btrfs_delayed_ref-action */
+/* these are the possible values of struct btrfs_delayed_ref_node-action */
 #define BTRFS_ADD_DELAYED_REF1 /* add one backref to the tree */
 #define BTRFS_DROP_DELAYED_REF   2 /* delete one backref from the tree */
 #define BTRFS_ADD_DELAYED_EXTENT 3 /* record a full extent allocation */
-- 
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] btrfs: fix disk-io.c/btrfs_read_dev_super with BTRFS_SUPER_MIRROR_MAX to control the loops

2012-09-10 Thread Wang Sheng-Hui
To check the duplicated super blocks, use BTRFS_SUPER_MIRROR_MAX
as the loops limit.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/disk-io.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 22e98e0..a431144 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2723,7 +2723,7 @@ struct buffer_head *btrfs_read_dev_super(struct 
block_device *bdev)
 * So, we need to add a special mount option to scan for
 * later supers, using BTRFS_SUPER_MIRROR_MAX instead
 */
-   for (i = 0; i  1; i++) {
+   for (i = 0; i  BTRFS_SUPER_MIRROR_MAX; i++) {
bytenr = btrfs_sb_offset(i);
if (bytenr + 4096 = i_size_read(bdev-bd_inode))
break;
-- 
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 1/3] btrfs: remove unnecessary -ENOMEM BUG_ON check in extent-tree.c/exclude_super_stripes

2012-09-06 Thread Wang Sheng-Hui
The memory allocation failure is BUG_ON in add_excluded_extent (following
the code path) and btrfs_rmap_block. No need to BUG_ON -ENOMEM inside
exclude_super_stripes itself.

Its return value is always 0, and useless for its callers. Set it as void
instead 0-returned.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/extent-tree.c |   20 +++-
 1 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index ba58024..95492cc 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -234,39 +234,33 @@ static void free_excluded_extents(struct btrfs_root *root,
  start, end, EXTENT_UPTODATE, GFP_NOFS);
 }
 
-static int exclude_super_stripes(struct btrfs_root *root,
+static void exclude_super_stripes(struct btrfs_root *root,
 struct btrfs_block_group_cache *cache)
 {
u64 bytenr;
u64 *logical;
int stripe_len;
-   int i, nr, ret;
+   int i, nr;
 
if (cache-key.objectid  BTRFS_SUPER_INFO_OFFSET) {
stripe_len = BTRFS_SUPER_INFO_OFFSET - cache-key.objectid;
cache-bytes_super += stripe_len;
-   ret = add_excluded_extent(root, cache-key.objectid,
- stripe_len);
-   BUG_ON(ret); /* -ENOMEM */
+   add_excluded_extent(root, cache-key.objectid, stripe_len);
}
 
for (i = 0; i  BTRFS_SUPER_MIRROR_MAX; i++) {
bytenr = btrfs_sb_offset(i);
-   ret = btrfs_rmap_block(root-fs_info-mapping_tree,
-  cache-key.objectid, bytenr,
-  0, logical, nr, stripe_len);
-   BUG_ON(ret); /* -ENOMEM */
+   btrfs_rmap_block(root-fs_info-mapping_tree,
+cache-key.objectid, bytenr,
+0, logical, nr, stripe_len);
 
while (nr--) {
cache-bytes_super += stripe_len;
-   ret = add_excluded_extent(root, logical[nr],
- stripe_len);
-   BUG_ON(ret); /* -ENOMEM */
+   add_excluded_extent(root, logical[nr], stripe_len);
}
 
kfree(logical);
}
-   return 0;
 }
 
 static struct btrfs_caching_control *
-- 
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 2/3] btrfs: remove unnecessary -ENOMEM BUG_ON check in extent-tree.c/btrfs_alloc_logged_file_extent

2012-09-06 Thread Wang Sheng-Hui
The memory allocation failure is BUG_ON in add_excluded_extent
(following the code path). No need to BUG_ON -ENOMEM inside
btrfs_alloc_logged_file_extent.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/extent-tree.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 95492cc..9b9a6fa 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6207,8 +6207,7 @@ int btrfs_alloc_logged_file_extent(struct 
btrfs_trans_handle *trans,
mutex_lock(caching_ctl-mutex);
 
if (start = caching_ctl-progress) {
-   ret = add_excluded_extent(root, start, num_bytes);
-   BUG_ON(ret); /* -ENOMEM */
+   add_excluded_extent(root, start, num_bytes);
} else if (start + num_bytes = caching_ctl-progress) {
ret = btrfs_remove_free_space(block_group,
  start, num_bytes);
@@ -6222,8 +6221,7 @@ int btrfs_alloc_logged_file_extent(struct 
btrfs_trans_handle *trans,
start = caching_ctl-progress;
num_bytes = ins-objectid + ins-offset -
caching_ctl-progress;
-   ret = add_excluded_extent(root, start, num_bytes);
-   BUG_ON(ret); /* -ENOMEM */
+   add_excluded_extent(root, start, num_bytes);
}
 
mutex_unlock(caching_ctl-mutex);
-- 
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 3/3] btrfs: set extent-tree.c/add_excluded_extent as void

2012-09-06 Thread Wang Sheng-Hui
The memory allocation failure will be catched in set_extent_bits.
Always return 0 is useless for its callers.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/extent-tree.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 9b9a6fa..3a295ff 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -209,7 +209,7 @@ block_group_cache_tree_search(struct btrfs_fs_info *info, 
u64 bytenr,
return ret;
 }
 
-static int add_excluded_extent(struct btrfs_root *root,
+static void add_excluded_extent(struct btrfs_root *root,
   u64 start, u64 num_bytes)
 {
u64 end = start + num_bytes - 1;
@@ -217,7 +217,6 @@ static int add_excluded_extent(struct btrfs_root *root,
start, end, EXTENT_UPTODATE, GFP_NOFS);
set_extent_bits(root-fs_info-freed_extents[1],
start, end, EXTENT_UPTODATE, GFP_NOFS);
-   return 0;
 }
 
 static void free_excluded_extents(struct btrfs_root *root,
-- 
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 1/3] btrfs: remove unnecessary -ENOMEM BUG_ON check in extent-tree.c/exclude_super_stripes

2012-09-06 Thread Wang Sheng-Hui
On 2012年09月06日 18:09, David Sterba wrote:
 On Thu, Sep 06, 2012 at 02:40:41PM +0800, Wang Sheng-Hui wrote:
 The memory allocation failure is BUG_ON in add_excluded_extent (following
 the code path) and btrfs_rmap_block. No need to BUG_ON -ENOMEM inside
 exclude_super_stripes itself.
 
 No please.
 
 Its return value is always 0, and useless for its callers. Set it as void
 instead 0-returned.
 
 btrfs_rmap_block itself contains a BUG_ON:
 
 3980 int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree,
 3981  u64 chunk_start, u64 physical, u64 devid,
 3982  u64 **logical, int *naddrs, int *stripe_len)
 3983 {
 3984 struct extent_map_tree *em_tree = map_tree-map_tree;
 3985 struct extent_map *em;
 3986 struct map_lookup *map;
 3987 u64 *buf;
 3988 u64 bytenr;
 3989 u64 length;
 3990 u64 stripe_nr;
 3991 int i, j, nr = 0;
 3992
 3993 read_lock(em_tree-lock);
 3994 em = lookup_extent_mapping(em_tree, chunk_start, 1);
 3995 read_unlock(em_tree-lock);
 3996
 3997 BUG_ON(!em || em-start != chunk_start);
 
 And this should be turned into an 'return error', thus giving a non-zero 
 return
 code that should be handled in the callers.
 
 Eg. this patch attempts to do that
 http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg15470.html
 
 but has not been merged due to incorrect fix inside exclude_super_stripes
 (introduced in the patch).
 
 The same objection for return code cleanups will hold for any function that
 returns 0 but is full of BUG_ONs.
 
 
 david

Got it. Thanks, David!

Regards,
Sheng-Hui
--
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 malloc check in transaction.h/btrfs_start_transaction

2012-08-16 Thread Wang Sheng-Hui
For malloc may fail, we should check it before assign
values to the fields of struct btrfs_trans_handle *h.

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

diff --git a/transaction.h b/transaction.h
index a1070e0..d4e42a1 100644
--- a/transaction.h
+++ b/transaction.h
@@ -32,7 +32,12 @@ static inline struct btrfs_trans_handle *
 btrfs_start_transaction(struct btrfs_root *root, int num_blocks)
 {
struct btrfs_fs_info *fs_info = root-fs_info;
+
struct btrfs_trans_handle *h = malloc(sizeof(*h));
+   if (!h) {
+   BUG();
+   return NULL;
+   }
 
BUG_ON(root-commit_root);
BUG_ON(fs_info-running_transaction);
-- 
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] btrfs-progs: add malloc check in transaction.h/btrfs_start_transaction

2012-08-16 Thread Wang Sheng-Hui
On 2012年08月16日 16:55, Jie Liu wrote:
 On 08/16/12 16:03, Arne Jansen wrote:
 On 16.08.2012 09:57, Wang Sheng-Hui wrote:
 For malloc may fail, we should check it before assign
 values to the fields of struct btrfs_trans_handle *h.

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

 diff --git a/transaction.h b/transaction.h
 index a1070e0..d4e42a1 100644
 --- a/transaction.h
 +++ b/transaction.h
 @@ -32,7 +32,12 @@ static inline struct btrfs_trans_handle *
  btrfs_start_transaction(struct btrfs_root *root, int num_blocks)
  {
 struct btrfs_fs_info *fs_info = root-fs_info;
 +
 Why move down a blank line?
 struct btrfs_trans_handle *h = malloc(sizeof(*h));
 Skip a line here would looks a bit neat.
 +   if (!h) {
 +   BUG();
 +   return NULL;
 +   }
 a more simple way would be to write
 BUG_ON(!h);

  
 BUG_ON(root-commit_root);
 BUG_ON(fs_info-running_transaction);
 --
 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 regenerated. Please check it. Thanks,

From 5a265e252e87a8a456a6615affd57dfb49900c64 Mon Sep 17 00:00:00 2001
From: Wang Sheng-Hui shh...@gmail.com
Date: Thu, 16 Aug 2012 20:14:32 +0800
Subject: [PATCH] btrfs-progs: add malloc check in 
transaction.h/btrfs_start_transaction

For malloc may fail, we should check it before assign
values to the struct btrfs_trans_handle *h.

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

diff --git a/transaction.h b/transaction.h
index a1070e0..e8610b1 100644
--- a/transaction.h
+++ b/transaction.h
@@ -34,6 +34,7 @@ btrfs_start_transaction(struct btrfs_root *root, int 
num_blocks)
struct btrfs_fs_info *fs_info = root-fs_info;
struct btrfs_trans_handle *h = malloc(sizeof(*h));
 
+   BUG_ON(!h);
BUG_ON(root-commit_root);
BUG_ON(fs_info-running_transaction);
fs_info-running_transaction = h;
-- 
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] btrfs-progs: trivial code style fix in root-tree.c

2012-08-16 Thread Wang Sheng-Hui
Add code indent to the bad styled statements.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 root-tree.c |   10 --
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/root-tree.c b/root-tree.c
index 782472c..39cfef6 100644
--- a/root-tree.c
+++ b/root-tree.c
@@ -182,12 +182,10 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
if (ret  0)
goto out;
if (ret) {
-btrfs_print_leaf(root, path-nodes[0]);
-printk(failed to del %llu %u %llu\n,
-   (unsigned long long)key-objectid,
-   key-type,
-   (unsigned long long)key-offset);
-
+   btrfs_print_leaf(root, path-nodes[0]);
+   printk(failed to del %llu %u %llu\n,
+   (unsigned long long)key-objectid, key-type,
+   (unsigned long long)key-offset);
}
BUG_ON(ret != 0);
leaf = path-nodes[0];
-- 
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] btrfs-progs: trivial code style fix in root-tree.c

2012-08-16 Thread Wang Sheng-Hui
On 2012年08月16日 21:23, Arne Jansen wrote:
 On 16.08.2012 15:17, Wang Sheng-Hui wrote:
 Add code indent to the bad styled statements.

 Signed-off-by: Wang Sheng-Hui shh...@gmail.com
 ---
  root-tree.c |   10 --
  1 files changed, 4 insertions(+), 6 deletions(-)

 diff --git a/root-tree.c b/root-tree.c
 index 782472c..39cfef6 100644
 --- a/root-tree.c
 +++ b/root-tree.c
 @@ -182,12 +182,10 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, 
 struct btrfs_root *root,
  if (ret  0)
  goto out;
  if (ret) {
 -btrfs_print_leaf(root, path-nodes[0]);
 -printk(failed to del %llu %u %llu\n,
 -(unsigned long long)key-objectid,
 -key-type,
 -(unsigned long long)key-offset);
 -
 
 I guess Alexander intentionally put in the bad indentation
 to remind him to remove this code before submitting the
 patch :)
 
 +btrfs_print_leaf(root, path-nodes[0]);
 +printk(failed to del %llu %u %llu\n,
 +(unsigned long long)key-objectid, key-type,
 +(unsigned long long)key-offset);
  }

When I saw the BUG_ON, I wonder do we still need the above branch statement.
It looks just to be helpful for debug - give out some info, right? 

  BUG_ON(ret != 0);
  leaf = path-nodes[0];
 

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


Re: [PATCH] btrfs-progs: trivial code style fix in root-tree.c

2012-08-16 Thread Wang Sheng-Hui
On 2012年08月16日 21:30, Arne Jansen wrote:
 On 16.08.2012 15:26, Wang Sheng-Hui wrote:
 On 2012年08月16日 21:23, Arne Jansen wrote:
 On 16.08.2012 15:17, Wang Sheng-Hui wrote:
 Add code indent to the bad styled statements.

 Signed-off-by: Wang Sheng-Hui shh...@gmail.com
 ---
  root-tree.c |   10 --
  1 files changed, 4 insertions(+), 6 deletions(-)

 diff --git a/root-tree.c b/root-tree.c
 index 782472c..39cfef6 100644
 --- a/root-tree.c
 +++ b/root-tree.c
 @@ -182,12 +182,10 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, 
 struct btrfs_root *root,
if (ret  0)
goto out;
if (ret) {
 -btrfs_print_leaf(root, path-nodes[0]);
 -printk(failed to del %llu %u %llu\n,
 -  (unsigned long long)key-objectid,
 -  key-type,
 -  (unsigned long long)key-offset);
 -

 I guess Alexander intentionally put in the bad indentation
 to remind him to remove this code before submitting the
 patch :)

 +  btrfs_print_leaf(root, path-nodes[0]);
 +  printk(failed to del %llu %u %llu\n,
 +  (unsigned long long)key-objectid, key-type,
 +  (unsigned long long)key-offset);
}

 When I saw the BUG_ON, I wonder do we still need the above branch statement.
 It looks just to be helpful for debug - give out some info, right? 
 
 Yes. So either we delete it completely or we move the BUG_ON
 into the block as a BUG_ON(1) and add a Btrfs: -prefix to the
 printk.
 On the other hand, I just saw this is progs, so I think it can
 just be deleted.
 

BUG_ON(ret != 0);
leaf = path-nodes[0];


 

Patch regenerated. Please check it. Thanks,

From 2150cb3a3f75416b56a5eb9311fd0d4aa5aaaed5 Mon Sep 17 00:00:00 2001
From: Wang Sheng-Hui shh...@gmail.com
Date: Thu, 16 Aug 2012 22:23:07 +0800
Subject: [PATCH] btrfs-progs: code cleanup for root-tree.c/btrfs_del_root

Remove the redundant if check on the condition ret  0.
Leave BUG_ON check here.

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

diff --git a/root-tree.c b/root-tree.c
index 782472c..4578514 100644
--- a/root-tree.c
+++ b/root-tree.c
@@ -181,14 +181,6 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
ret = btrfs_search_slot(trans, root, key, path, -1, 1);
if (ret  0)
goto out;
-   if (ret) {
-btrfs_print_leaf(root, path-nodes[0]);
-printk(failed to del %llu %u %llu\n,
-   (unsigned long long)key-objectid,
-   key-type,
-   (unsigned long long)key-offset);
-
-   }
BUG_ON(ret != 0);
leaf = path-nodes[0];
ri = btrfs_item_ptr(leaf, path-slots[0], struct btrfs_root_item);
-- 
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] btrfs: fix trivial typo for the comment of BTRFS_FREE_INO_OBJECTID

2012-08-16 Thread Wang Sheng-Hui
It should be storing.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/ctree.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 4bab807..f9289db 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -116,7 +116,7 @@ struct btrfs_ordered_sum;
 #define BTRFS_FREE_SPACE_OBJECTID -11ULL
 
 /*
- * The inode number assigned to the special inode for sotring
+ * The inode number assigned to the special inode for storing
  * free ino cache
  */
 #define BTRFS_FREE_INO_OBJECTID -12ULL
-- 
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] btrfs-progs: fix trivial typo for the comment of BTRFS_FREE_INO_OBJECTID

2012-08-16 Thread Wang Sheng-Hui
It should be storing.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 ctree.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ctree.h b/ctree.h
index d218b88..8f3cd7e 100644
--- a/ctree.h
+++ b/ctree.h
@@ -86,7 +86,7 @@ struct btrfs_trans_handle;
 #define BTRFS_FREE_SPACE_OBJECTID -11ULL
 
 /*
- * The inode number assigned to the special inode for sotring
+ * The inode number assigned to the special inode for storing
  * free ino cache
  */
 #define BTRFS_FREE_INO_OBJECTID -12ULL
-- 
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] btrfs: fix trivial typo for the comment of BTRFS_FREE_INO_OBJECTID

2012-08-16 Thread Wang Sheng-Hui
On 2012年08月16日 23:18, Liu Bo wrote:
 On 08/16/2012 10:53 PM, Wang Sheng-Hui wrote:
 It should be storing.

 
 Please cc these typo fixes to triv...@kernel.org.
 
 thanks,
 liubo

OK.

 
 Signed-off-by: Wang Sheng-Hui shh...@gmail.com
 ---
  fs/btrfs/ctree.h |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
 index 4bab807..f9289db 100644
 --- a/fs/btrfs/ctree.h
 +++ b/fs/btrfs/ctree.h
 @@ -116,7 +116,7 @@ struct btrfs_ordered_sum;
  #define BTRFS_FREE_SPACE_OBJECTID -11ULL
  
  /*
 - * The inode number assigned to the special inode for sotring
 + * The inode number assigned to the special inode for storing
   * free ino cache
   */
  #define BTRFS_FREE_INO_OBJECTID -12ULL

 

--
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: correct the comment for extent_io.c/clear_extent_bits

2012-08-14 Thread Wang Sheng-Hui
It should be clear instead of set for clear_extent_bits.

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

diff --git a/extent_io.c b/extent_io.c
index ebb35b2..638ee0e 100644
--- a/extent_io.c
+++ b/extent_io.c
@@ -195,7 +195,7 @@ static int clear_state_bit(struct extent_io_tree *tree,
 }
 
 /*
- * set some bits on a range in the tree.
+ * clear some bits on a range in the tree.
  */
 int clear_extent_bits(struct extent_io_tree *tree, u64 start,
  u64 end, int bits, gfp_t mask)
-- 
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] btrfs-progs: remove redundant value set to path-reada in ctree.c/btrfs_alloc_path

2012-08-13 Thread Wang Sheng-Hui
btrfs_init_path has init the path to 0s.
No need to set -reada 0 after path init.

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

diff --git a/ctree.c b/ctree.c
index 2d86b1e..a04e0da 100644
--- a/ctree.c
+++ b/ctree.c
@@ -43,10 +43,9 @@ struct btrfs_path *btrfs_alloc_path(void)
 {
struct btrfs_path *path;
path = kmalloc(sizeof(struct btrfs_path), GFP_NOFS);
-   if (path) {
+   if (path)
btrfs_init_path(path);
-   path-reada = 0;
-   }
+
return path;
 }
 
-- 
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] btrfs-progs: remove redundant value set to path-reada in ctree.c/btrfs_alloc_path

2012-08-13 Thread Wang Sheng-Hui
btrfs_init_path has init the path to 0s.
No need to set -reada 0 after path init.

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

diff --git a/ctree.c b/ctree.c
index 2d86b1e..a04e0da 100644
--- a/ctree.c
+++ b/ctree.c
@@ -43,10 +43,9 @@ struct btrfs_path *btrfs_alloc_path(void)
 {
struct btrfs_path *path;
path = kmalloc(sizeof(struct btrfs_path), GFP_NOFS);
-   if (path) {
+   if (path)
btrfs_init_path(path);
-   path-reada = 0;
-   }
+
return path;
 }
 
-- 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 1/4 RESEND] Btrfs: remove the useless assignment to *entry in function tree_insert of file extent_io.c

2012-04-06 Thread Wang Sheng-Hui
In tree_insert, var *entry is used in the loop only, and is useless
out of the loop. Remove the useless assignment after the loop.

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

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 8d904dd..7b679e2 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -186,7 +186,6 @@ static struct rb_node *tree_insert(struct rb_root *root, 
u64 offset,
return parent;
}
 
-   entry = rb_entry(node, struct tree_entry, rb_node);
rb_link_node(node, parent, p);
rb_insert_color(node, root);
return NULL;
-- 
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 2/4 RESEND] Btrfs: cleanup the comment for clear_state_bit in extent_io.c

2012-04-06 Thread Wang Sheng-Hui
No 'delete' arg is used for clear_state_bit.
Cleanup the comment.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/extent_io.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 7b679e2..5505356 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -403,8 +403,7 @@ static int split_state(struct extent_io_tree *tree, struct 
extent_state *orig,
 
 /*
  * utility function to clear some bits in an extent state struct.
- * it will optionally wake up any one waiting on this state (wake == 1), or
- * forcibly remove the state from the tree (delete == 1).
+ * it will optionally wake up any one waiting on this state (wake == 1).
  *
  * If no bits are set on the state struct after clearing things, the
  * struct is freed and removed from the tree
-- 
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 3/4 RESEND] Btrfs: fix btrfs_release_extent_buffer_page with the right usage of num_extent_pages

2012-04-06 Thread Wang Sheng-Hui
num_extent_pages returns the number of pages in the specific range, not
the index of the last page in the eb range.

btrfs_release_extent_buffer_page is called with start_idx set 0 in current
codes, so it's not a problem yet. But the logic is indeed wrong.

Fix it here.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/extent_io.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 5505356..ddfc1d5 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3975,11 +3975,13 @@ static void btrfs_release_extent_buffer_page(struct 
extent_buffer *eb,
unsigned long start_idx)
 {
unsigned long index;
+   unsigned long num_pages;
struct page *page;
 
BUG_ON(extent_buffer_under_io(eb));
 
-   index = num_extent_pages(eb-start, eb-len);
+   num_pages = num_extent_pages(eb-start, eb-len);
+   index = start_idx + num_pages;
if (start_idx = index)
return;
 
-- 
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 4/4] Btrfs: fix the comment for find_first_extent_bit

2012-04-06 Thread Wang Sheng-Hui
The return value of find_first_extent_bit is 1 or 0, no  0.
And if found something, return 0; if nothing was found, return 1.
Fix the comment.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/extent_io.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index ddfc1d5..26fbe1c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1288,7 +1288,7 @@ out:
  * returned if we find something, and *start_ret and *end_ret are
  * set to reflect the state struct that was found.
  *
- * If nothing was found, 1 is returned,  0 on error
+ * If nothing was found, 1 is returned. If found something, return 0.
  */
 int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
  u64 *start_ret, u64 *end_ret, int bits)
-- 
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] btrfs/extent_io.c: return -ENOMEM instead of BUG_ON on allocation failure in set_extent_bit if __GFP_WAIT is set in the mask

2012-04-04 Thread Wang Sheng-Hui
On 2012年04月04日 21:29, Jeff Mahoney wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On 03/31/2012 03:25 AM, Wang Sheng-Hui wrote:
 If __GFP_WAIT is set in the mask, set_extent_bit should return 
 -ENOMEM to its caller to decide what to do on allocation failure, 
 instead of BUG_ON.

 Signed-off-by: Wang Sheng-Hui shh...@gmail.com --- 
 fs/btrfs/extent_io.c |3 ++- 1 files changed, 2 insertions(+), 1
 deletions(-)

 diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index
 b67814c..fd2411e 100644 --- a/fs/btrfs/extent_io.c +++
 b/fs/btrfs/extent_io.c @@ -720,7 +720,8 @@ int
 set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, 
 again: if (!prealloc  (mask  __GFP_WAIT)) { prealloc =
 alloc_extent_state(mask); -  BUG_ON(!prealloc); +if 
 (!prealloc) +
 return -ENOMEM; }

 spin_lock(tree-lock);
 
 Hi Sheng-Hui -
 
 Do you have a follow-on series to this? With the exception of the
 set_extent_dirty call in end_bio_extent_readpage, every set_extent_bit
 caller uses GFP_NOFS, which includes __GFP_WAIT. If we return a
 failure here, we need to catch the failure in the call sites.
 Otherwise, the failure will just be ignored and we'll end up with an
 inconsistent extent state tree.
 
 - -Jeff
 

Hi Jeff,

I'll review the code and provide a list of patches later.
Currently we can skip it, I think.

Thanks,
Sheng-Hui

 - -- 
 Jeff Mahoney
 SUSE Labs
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v2.0.18 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
 iQIcBAEBAgAGBQJPfEzIAAoJEB57S2MheeWyqcoP/RagYePToMYOdgjjxVz2cwkf
 BLT5B0KWWaJa0KtEOpgQATmldmA4CCq6WmC7R/Omy1q9RD75rheKxaxuQY35NTFe
 czBSfVr3VeMy1A6dIK+wHOiAfheuT90xSgXJJMpdkjHmNjEA1g2nupAFltUE/L70
 +xFxotBuoYuTe8u++QES0JGqnw8YI6FW0z3Z4buyoqRhgiX7TukNfXXgx4c2HI0/
 cOkxyvYpDi2WF9EtESn/ekwf4Rjx9kNUX/9owmDWYgHD4MLjwSQsRbwZ7BrZEM3k
 aBe8yZGpgr3UuL9nGiPbWHsyBeAskvXaL6Y2YIczJSvsoP/DM+9SsHAwnqkVaBHv
 8qQiQqUhF1mrdl3GBSvKJarGczrSmbWZ5X94oYq4MCKyi3SeTN/bcJS+p5EV1Tvs
 LMRqqj26leHnl+bYKGWIfJqQRuYcfbkzTOADbn54iMYj2aG2raUjI9D53TUIInuV
 Csm2hhKJn+HDwu2+gZX1F99W0ehs1ps86oGfkT4WA/H7fTmugiEYxsM1Dk71Ti7/
 eadns62DYFZyzKk4/jP/8Rjygc4YM/T2F9qb+SX3hWGhIIZiz5qOxjgBZy91i+84
 W+DDUHjZPU+O14nNlKFA3INGS9823ENklRkzpNUhLx7ffrCLOAS73O2rzHcaSmtk
 FSDWO4EqxIAi4t3LoL14
 =Pxwh
 -END PGP SIGNATURE-

--
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/extent_io.c: fix btrfs_release_extent_buffer_page with the right usage of num_extent_pages

2012-04-01 Thread Wang Sheng-Hui

num_extent_pages returns the number of pages in the specific range, not
the index of the last page in the eb range. btrfs_release_extent_buffer_page
is called with start_idx set 0 in current codes, so it's not a problem yet.
But the logic is indeed wrong. Fix it with this patch.


Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/extent_io.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 6099261..941f0ea 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3976,11 +3976,13 @@ static void btrfs_release_extent_buffer_page(struct 
extent_buffer *eb,
unsigned long start_idx)
 {
unsigned long index;
+   unsigned long num_pages;
struct page *page;
 
BUG_ON(extent_buffer_under_io(eb));
 
-   index = num_extent_pages(eb-start, eb-len);
+   num_pages = num_extent_pages(eb-start, eb-len);
+   index = start_idx + num_pages;
if (start_idx = index)
return;
 
-- 
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] btrfs/extent_io.c: cleanup the comment for clear_state_bit

2012-03-31 Thread Wang Sheng-Hui
No 'delete' arg is used for clear_state_bit anymore.
Cleanup the comment.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/extent_io.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 2862454..b67814c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -394,8 +394,7 @@ static int split_state(struct extent_io_tree *tree, struct 
extent_state *orig,
 
 /*
  * utility function to clear some bits in an extent state struct.
- * it will optionally wake up any one waiting on this state (wake == 1), or
- * forcibly remove the state from the tree (delete == 1).
+ * it will optionally wake up any one waiting on this state (wake == 1).
  *
  * If no bits are set on the state struct after clearing things, the
  * struct is freed and removed from the tree
-- 
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] btrfs/extent_io.c: return -ENOMEM instead of BUG_ON on allocation failure in set_extent_bit if __GFP_WAIT is set in the mask

2012-03-31 Thread Wang Sheng-Hui
If __GFP_WAIT is set in the mask, set_extent_bit should return
-ENOMEM to its caller to decide what to do on allocation failure,
instead of BUG_ON.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/extent_io.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index b67814c..fd2411e 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -720,7 +720,8 @@ int set_extent_bit(struct extent_io_tree *tree, u64 start, 
u64 end,
 again:
if (!prealloc  (mask  __GFP_WAIT)) {
prealloc = alloc_extent_state(mask);
-   BUG_ON(!prealloc);
+   if (!prealloc)
+   return -ENOMEM;
}
 
spin_lock(tree-lock);
-- 
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] btrfs/extent_io.c: remove the useless assignment to entry in tree_insert

2012-03-31 Thread Wang Sheng-Hui
In tree_insert, entry is used in the loop only, and is useless
out of the loop. Remove the useless assignment after the loop.

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

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 9ed9d2c..6099261 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -186,7 +186,6 @@ static struct rb_node *tree_insert(struct rb_root *root, 
u64 offset,
return parent;
}
 
-   entry = rb_entry(node, struct tree_entry, rb_node);
rb_link_node(node, parent, p);
rb_insert_color(node, root);
return NULL;
-- 
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] btrfs/ctree.c: remove the unnecessary 'return -1;' at the end of bin_search

2012-03-30 Thread Wang Sheng-Hui
The code path should not reach there. Remove it.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/ctree.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 0639a55..c1be2da 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -829,20 +829,18 @@ static noinline int generic_bin_search(struct 
extent_buffer *eb,
 static int bin_search(struct extent_buffer *eb, struct btrfs_key *key,
  int level, int *slot)
 {
-   if (level == 0) {
+   if (level == 0)
return generic_bin_search(eb,
  offsetof(struct btrfs_leaf, items),
  sizeof(struct btrfs_item),
  key, btrfs_header_nritems(eb),
  slot);
-   } else {
+   else
return generic_bin_search(eb,
  offsetof(struct btrfs_node, ptrs),
  sizeof(struct btrfs_key_ptr),
  key, btrfs_header_nritems(eb),
  slot);
-   }
-   return -1;
 }
 
 int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key,
-- 
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] btrfs/async-thread: introduce macro BTRFS_WORKERS_IDLE_THRESH to replace the magic number 32 used for btrfs_workers-idle_thresh

2012-03-19 Thread Wang Sheng-Hui

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/async-thread.c |2 +-
 fs/btrfs/async-thread.h |8 +++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 5a7d756..2491096 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -445,7 +445,7 @@ void btrfs_init_workers(struct btrfs_workers *workers, char 
*name, int max,
spin_lock_init(workers-lock);
spin_lock_init(workers-order_lock);
workers-max_workers = max;
-   workers-idle_thresh = 32;
+   workers-idle_thresh = BTRFS_WORKERS_IDLE_THRESH;
workers-name = name;
workers-ordered = 0;
workers-atomic_start_pending = 0;
diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h
index f34cc31..9b9522e 100644
--- a/fs/btrfs/async-thread.h
+++ b/fs/btrfs/async-thread.h
@@ -60,6 +60,9 @@ struct btrfs_work {
struct list_head order_list;
 };
 
+/* default value for btrfs_workers-idle_thresh */
+#define BTRFS_WORKERS_IDLE_THRESH 32
+
 struct btrfs_workers {
/* current number of running workers */
int num_workers;
@@ -69,7 +72,10 @@ struct btrfs_workers {
/* max number of workers allowed.  changed by btrfs_start_workers */
int max_workers;
 
-   /* once a worker has this many requests or fewer, it is idle */
+   /*
+* once a worker has this many requests or fewer, it is idle.
+* default to BTRFS_WORKERS_IDLE_THRESH, which 32 is used currently.
+*/
int idle_thresh;
 
/* force completions in the order they were queued */
-- 
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] btrfs/async-thread.c: decrease workers-num_workers only on worker can be freed in btrfs_stop_workers

2012-03-15 Thread Wang Sheng-Hui
If the worker cannot be freed, decrease workers-num_workers can
corrupt the statistics. The workers-num_workers should be decreased
only when the worker can be stopped and freed in btrfs_stop_workers.


Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/async-thread.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 0cc20b3..5a7d756 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -413,9 +413,9 @@ int btrfs_stop_workers(struct btrfs_workers *workers)
worker_list);
 
atomic_inc(worker-refs);
-   workers-num_workers -= 1;
if (!list_empty(worker-worker_list)) {
list_del_init(worker-worker_list);
+   workers-num_workers--;
put_worker(worker);
can_stop = 1;
} else
-- 
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] btrfs/ctree.h: trivial fixup the comment for struct btrfs_dev_extent with the right fields' names

2012-03-13 Thread Wang Sheng-Hui

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/ctree.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 80b6486..a515e4e 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -597,9 +597,9 @@ struct btrfs_extent_ref_v0 {
 } __attribute__ ((__packed__));
 
 
-/* dev extents record free space on individual devices.  The owner
+/* dev extents record free space on individual devices.  The chunk_tree
  * field points back to the chunk allocation mapping tree that allocated
- * the extent.  The chunk tree uuid field is a way to double check the owner
+ * the extent.  The chunk_tree_uuid field is a way to double check the owner
  */
 struct btrfs_dev_extent {
__le64 chunk_tree;
-- 
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] btrfs/locking.c: minor fix on the comment for btrfs_try_tree_write_lock

2012-03-07 Thread Wang Sheng-Hui
btrfs_try_tree_write_lock is used for write lock, not for read lock.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 fs/btrfs/locking.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 5e178d8..4e4705c 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -142,7 +142,7 @@ int btrfs_try_tree_read_lock(struct extent_buffer *eb)
 }
 
 /*
- * returns 1 if we get the read lock and 0 if we don't
+ * returns 1 if we get the write lock and 0 if we don't
  * this won't wait for blocking writers or readers
  */
 int btrfs_try_tree_write_lock(struct extent_buffer *eb)
-- 
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] btrfs-progs: cleanup: remove the redundant BTRFS_CSUM_TYPE_CRC32 macro definition in ctree.h

2012-03-04 Thread Wang Sheng-Hui

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

diff --git a/ctree.h b/ctree.h
index 54748c8..1b17577 100644
--- a/ctree.h
+++ b/ctree.h
@@ -118,10 +118,6 @@ struct btrfs_trans_handle;
 /* csum types */
 #define BTRFS_CSUM_TYPE_CRC32  0
 
-
-/* csum types */
-#define BTRFS_CSUM_TYPE_CRC32  0
-
 static int btrfs_csum_sizes[] = { 4, 0 };
 
 /* four bytes for CRC32 */
-- 
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 3.0-rc7] btrfs: Update git repository links for btrfs utilities in Documentation/filesystems/btrfs.txt

2011-07-18 Thread Wang Sheng-Hui
On 2011年07月18日 14:06, Wanlong Gao wrote:
 On 07/18/2011 12:53 PM, Wang Sheng-Hui wrote:
 The patch is against 3.0-rc7 kernel.

 From d22497ac8c5dd55a2ef9a47de5f2ddee55f8ec50 Mon Sep 17 00:00:00 2001
 From: Wang Sheng-Huishh...@gmail.com
 Date: Sun, 17 Jul 2011 21:45:01 -0500
 Subject: [PATCH 3.0-rc7] btrfs: Update git repository links for btrfs 
 utilities in Documentation/filesystems/btrfs.txt

 git repository link for btrfs utilities
 http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git
 doesn't work, and git-clone can get failed as:
 $ git clone
 http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git
 Initialized empty Git repository in
 /home/crossover/dev/btrfs-progs-unstable/.git/
 fatal:
 http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git/info/refs
  not found: did you run git update-server-info on the server?

 Update git repository links for btrfs utilities to the latest ones
 in Documentation/filesystems/btrfs.txt

 Signed-off-by: Wang Sheng-Huishh...@gmail.com
 ---
   Documentation/filesystems/btrfs.txt |3 ++-
   1 files changed, 2 insertions(+), 1 deletions(-)

 diff --git a/Documentation/filesystems/btrfs.txt 
 b/Documentation/filesystems/btrfs.txt
 index 64087c3..b095261 100644
 --- a/Documentation/filesystems/btrfs.txt
 +++ b/Documentation/filesystems/btrfs.txt
 @@ -63,8 +63,9 @@ IRC network.
   Userspace tools for creating and manipulating Btrfs file systems are
   available from the git repository at the following location:

 - http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git
 It's the right git-web URL.

 git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git
 + 
 http://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git
 + 
 https://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git

   These include the following tools:

 
 

I rerun git clone on my 2 boxes, both failed:
$ git clone 
http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git 
Initialized empty Git repository in /home/crossover/btrfs-progs-unstable/.git/
fatal: 
http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git/info/refs
 not found: did you run git update-server-info on the server?

But I can open the link by browser.

My git version is:
$ git version
git version 1.7.1

However, I think we should update the links to the latest ones.
--
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-unstable: replace debug-tree to btrfs-debug-tree in INSTALL

2011-07-18 Thread Wang Sheng-Hui
From c04da1655df6d75db834ddbd3a3b4a58a0d9a0c9 Mon Sep 17 00:00:00 2001
From: Wang Sheng-Hui shh...@gmail.com
Date: Mon, 18 Jul 2011 02:17:31 -0500
Subject: [PATCH] btrfs-progs-unstable: replace debug-tree to btrfs-debug-tree 
in INSTALL

debug-tree doesn't exist after btrfs-progs installed.
Use btrfs-debug-tree to print FS metadata in text form,
not debug-tree.

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 INSTALL |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/INSTALL b/INSTALL
index 16b45a5..2db6d27 100644
--- a/INSTALL
+++ b/INSTALL
@@ -42,7 +42,7 @@ btrfsctl: control program to create snapshots and subvolumes:
 
 btrfsck: do a limited check of the FS extent trees./li
 
-debug-tree: print all of the FS metadata in text form.  Example:
+btrfs-debug-tree: print all of the FS metadata in text form.  Example:
 
-   debug-tree /dev/sda2  big_output_file
+   btrfs-debug-tree /dev/sda2  big_output_file
 
-- 
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 3.0-rc7] btrfs: Update git repository links for btrfs utilities in Documentation/filesystems/btrfs.txt

2011-07-17 Thread Wang Sheng-Hui
The patch is against 3.0-rc7 kernel.

From d22497ac8c5dd55a2ef9a47de5f2ddee55f8ec50 Mon Sep 17 00:00:00 2001
From: Wang Sheng-Hui shh...@gmail.com
Date: Sun, 17 Jul 2011 21:45:01 -0500
Subject: [PATCH 3.0-rc7] btrfs: Update git repository links for btrfs utilities 
in Documentation/filesystems/btrfs.txt

git repository link for btrfs utilities
   http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git
doesn't work, and git-clone can get failed as:
$ git clone
http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git
Initialized empty Git repository in
/home/crossover/dev/btrfs-progs-unstable/.git/
fatal:
http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git/info/refs
 not found: did you run git update-server-info on the server?

Update git repository links for btrfs utilities to the latest ones
in Documentation/filesystems/btrfs.txt

Signed-off-by: Wang Sheng-Hui shh...@gmail.com
---
 Documentation/filesystems/btrfs.txt |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Documentation/filesystems/btrfs.txt 
b/Documentation/filesystems/btrfs.txt
index 64087c3..b095261 100644
--- a/Documentation/filesystems/btrfs.txt
+++ b/Documentation/filesystems/btrfs.txt
@@ -63,8 +63,9 @@ IRC network.
 Userspace tools for creating and manipulating Btrfs file systems are
 available from the git repository at the following location:
 
- http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git
  git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git
+ http://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git
+ https://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git
 
 These include the following tools:
 
-- 
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