[PATCH 02/27] btrfs-progs: Convert man page for btrfs-subvolume

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-subvolume.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile|   2 +-
 Documentation/btrfs-subvolume.txt | 172 ++
 2 files changed, 173 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-subvolume.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index bf38617..15c1679 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -16,7 +16,7 @@ MAN8_TXT += btrfs.txt
 #MAN8_TXT += mkfs.btrfs.txt
 
 # Sub commands for btrfs
-#MAN8_TXT += btrfs-subvolume.txt
+MAN8_TXT += btrfs-subvolume.txt
 #MAN8_TXT += btrfs-filesystem.txt
 #MAN8_TXT += btrfs-balance.txt
 #MAN8_TXT += btrfs-device.txt
diff --git a/Documentation/btrfs-subvolume.txt 
b/Documentation/btrfs-subvolume.txt
new file mode 100644
index 000..7f32dbd
--- /dev/null
+++ b/Documentation/btrfs-subvolume.txt
@@ -0,0 +1,172 @@
+btrfs-subvolume(8)
+==
+
+NAME
+
+btrfs-subvolume - control btrfs subvolume(s)
+
+SYNOPSIS
+
+'btrfs subvolume' subcommand [args]
+
+DESCRIPTION
+---
+'btrfs subvolume' is used to control the filesystem to create/delete/list/show
+subvolumes and snapshots.
+
+SUBVOLUME AND SNAPSHOT
+--
+A subvolume in btrfs is not like an LVM logical volume, which is quite
+independent from each other, a btrfs subvolume has its hierarchy and relations
+between other subvolumes.
+
+A subvolume in btrfs can be accessed in two ways.
+
+1. From the parent subvolume +
+When accessing from the parent subvolume, the subvolume can be used just
+like a directory. It can have child subvolumes and its own files/directories.
+
+2. Separate mounted filesystem +
+When `mount`(8) using 'subvol' or 'subvolid' mount option, one can access
+files/directories/subvolumes inside it, but nothing in parent subvolumes.
+
+Also every btrfs filesystem has a default subvolume as its initially top-level
+subvolume, whose subvolume id is 5(FS_TREE).
+
+A btrfs snapshot is much like a subvolume, but shares its data(and metadata)
+with other subvolume/snapshot. Due to the capabilities of COW, modifications
+inside a snapshot will only show in a snapshot but not in its source subvolume.
+
+Although in btrfs, subvolumes/snapshots are treated as directories, only
+subvolume/snapshot can be the source of a snapshot, snapshot can not be made
+from normal directories.
+
+SUBCOMMAND
+---
+'create' [-i qgroupid] [dest]name::
+Create a subvolume name in dest.
++
+If dest is not given, subvolume name will be created in the currently
+directory.
++
+`Options`
++
+-i qgroupid
+Add the newly created subvolume to a qgroup. This option can be given multiple
+times.
+
+'delete' [options] subvolume [subvolume...]::
+Delete the subvolume(s) from the filesystem.
++
+If subvolume is not a subvolume, btrfs returns an error but continues if
+there are more arguments to process.
++
+The corresponding directory is removed instantly but the data blocks are
+removed later.  The deletion does not involve full commit by default due to
+performance reasons (as a consequence, the subvolume may appear again after a
+crash).  Use one of the '--commit' options to wait until the operation is 
safely
+stored on the media.
++
+`Options`
++
+-c|--commit-after
+wait for transaction commit at the end of the operation
++
+-C|--commit-each
+wait for transaction commit after delet each subvolume
+
+'list' [options] [-G [\+|-] values] [-C [+|-]value] 
[--sort=rootid,gen,ogen,path] path::
+List the subvolumes present in the filesystem path.
++
+For every subvolume the following information is shown by default. +
+ID ID top level ID path path +
+where path is the relative path of the subvolume to the top level subvolume.
+The subvolume's ID may be used by the subvolume set-default command,
+or at mount time via the subvolid= option.
+If `-p` is given, then parent ID is added to the output between ID
+and top level. The parent's ID may be used at mount time via the
+`subvolrootid=` option.
++
+`Options`
++
+-p
+print parent ID.
+-a
+print all the subvolumes in the filesystem and distinguish between
+absolute and relative path with respect to the given path.
+-c
+print the ogeneration of the subvolume, aliases: ogen or origin generation.
+-g
+print the generation of the subvolume.
+-o
+print only subvolumes bellow specified path.
+-u
+print the UUID of the subvolume.
+-q
+print the parent uuid of subvolumes (and snapshots).
+-t
+print the result as a table.
+-s
+only snapshot subvolumes in the filesystem will be listed.
+-r
+only readonly subvolumes in the filesystem will be listed.
+-G [+|-]value
+list subvolumes in the filesystem that its generation is
+=, \= or = value. \'\+' means = value, \'-' means \= value, If there is
+neither \'+' nor \'-', it means = value.
+-C [+|-]value
+list subvolumes in the filesystem that its ogeneration is
+=, \= or = value. 

[PATCH 05/27] btrfs-progs: Convert man page for btrfs-device subcommand.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-device subcommand.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile |  2 +-
 Documentation/btrfs-device.txt | 75 ++
 2 files changed, 76 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-device.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 4839b6d..79ae9de 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -19,7 +19,7 @@ MAN8_TXT += btrfs.txt
 MAN8_TXT += btrfs-subvolume.txt
 MAN8_TXT += btrfs-filesystem.txt
 MAN8_TXT += btrfs-balance.txt
-#MAN8_TXT += btrfs-device.txt
+MAN8_TXT += btrfs-device.txt
 #MAN8_TXT += btrfs-scrub.txt
 #MAN8_TXT += btrfs-check.txt
 #MAN8_TXT += btrfs-rescue.txt
diff --git a/Documentation/btrfs-device.txt b/Documentation/btrfs-device.txt
new file mode 100644
index 000..20d7bcd
--- /dev/null
+++ b/Documentation/btrfs-device.txt
@@ -0,0 +1,75 @@
+btrfs-device(8)
+===
+
+NAME
+
+btrfs-device - control btrfs devices
+
+SYNOPSIS
+
+'btrfs device' subcommand args
+
+DESCRIPTION
+---
+'btrfs device' is used to control the btrfs devices, since btrfs can be used
+across several devices, 'btrfs device' is used for multiple device management.
+
+SUBCOMMAND
+--
+'add' [-Kf] dev [dev...] path::
+Add device(s) to the filesystem identified by path.
++
+If applicable, a whole device discard (TRIM) operation is performed.
++
+`Options`
++
+-K|--nodiscard
+do not perform discard by default
+-f|--force
+force overwrite of existing filesystem on the given disk(s)
+
+'delete' dev [dev...] path::
+Remove device(s) from a filesystem identified by path.
+
+'scan' [(--all-devices|-d)|device [device...]]::
+Scan devices for a btrfs filesystem.
++
+If one or more devices are passed, these are scanned for a btrfs filesystem. 
+If no devices are passed, btrfs uses block devices containing btrfs
+filesystem as listed by blkid.
+Finally, if '--all-devices' or '-d' is passed, all the devices under /dev are 
+scanned.
+
+'disk-usage' [-b] path [path..]::
+Show which chunks are in a device.
++
+If '-b' is given, byte will be set as unit.
+
+'ready' device::
+Check device to see if it has all of it's devices in cache for mounting.
+
+'stats' [-z] path|device::
+Read and print the device IO stats for all devices of the filesystem
+identified by path or for a single device.
++
+`Options`
++
+-z
+Reset stats to zero after reading them.
+
+EXIT STATUS
+---
+'btrfs device' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
-- 
1.9.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 01/27] btrfs-progs: Introduce asciidoc based man page and btrfs man page.

2014-04-02 Thread Qu Wenruo
The old man page of btrfs will grow larger with new functions adding to
btrfs-progs and harder to maintain because the reader-unfriendly roff
grammar and one LARGE btrfs.in.

This patch will introduce the simplified Documentation directory mainly
'stolen' from git and include the first man page for 'btrfs(8)'.
This time, man page will be written in human-friendly asciidoc grammar
and each commands of btrfs will have a separate man page, which I hope
can reduce the effort to maintain the man page.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 .gitignore |   1 +
 Documentation/Makefile |  91 +
 Documentation/asciidoc.conf|  42 
 Documentation/btrfs.txt| 117 +
 Documentation/manpage-base.xsl |  35 ++
 Documentation/manpage-bold-literal.xsl |  17 +
 Documentation/manpage-normal.xsl   |  13 
 7 files changed, 316 insertions(+)
 create mode 100644 Documentation/Makefile
 create mode 100644 Documentation/asciidoc.conf
 create mode 100644 Documentation/btrfs.txt
 create mode 100644 Documentation/manpage-base.xsl
 create mode 100644 Documentation/manpage-bold-literal.xsl
 create mode 100644 Documentation/manpage-normal.xsl

diff --git a/.gitignore b/.gitignore
index ab8b81c..fc8c07a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
 version.h
 version
 man/*.gz
+Documentation/*.gz
 btrfs
 btrfs.static
 btrfs-debug-tree
diff --git a/Documentation/Makefile b/Documentation/Makefile
new file mode 100644
index 000..bf38617
--- /dev/null
+++ b/Documentation/Makefile
@@ -0,0 +1,91 @@
+# Guard against environment variables
+MAN8_TXT =
+
+# Top level commands
+MAN8_TXT += btrfs.txt
+#MAN8_TXT += btrfsck.txt
+#MAN8_TXT += btrfs-convert.txt
+#MAN8_TXT += btrfs-debug-tree.txt
+#MAN8_TXT += btrfs-find-root.txt
+#MAN8_TXT += btrfs-image.txt
+#MAN8_TXT += btrfs-map-logical.txt
+#MAN8_TXT += btrfs-show-super.txt
+#MAN8_TXT += btrfstune.txt
+#MAN8_TXT += btrfs-zero-log.txt
+#MAN8_TXT += fsck.btrfs.txt
+#MAN8_TXT += mkfs.btrfs.txt
+
+# Sub commands for btrfs
+#MAN8_TXT += btrfs-subvolume.txt
+#MAN8_TXT += btrfs-filesystem.txt
+#MAN8_TXT += btrfs-balance.txt
+#MAN8_TXT += btrfs-device.txt
+#MAN8_TXT += btrfs-scrub.txt
+#MAN8_TXT += btrfs-check.txt
+#MAN8_TXT += btrfs-rescue.txt
+#MAN8_TXT += btrfs-inspect-internal.txt
+#MAN8_TXT += btrfs-send.txt
+#MAN8_TXT += btrfs-receive.txt
+#MAN8_TXT += btrfs-quota.txt
+#MAN8_TXT += btrfs-replace.txt
+#MAN8_TXT += btrfs-dedup.txt
+
+MAN_TXT = $(MAN8_TXT)
+MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
+DOC_MAN8 = $(patsubst %.txt,%.8,$(MAN8_TXT))
+GZ_MAN8 = $(patsubst %.txt,%.8.gz,$(MAN8_TXT))
+
+mandir ?= $(prefix)/share/man
+man8dir = $(mandir)/man8
+
+ASCIIDOC = asciidoc
+ASCIIDOC_EXTRA =
+MANPAGE_XSL = manpage-normal.xsl
+XMLTO = xmlto
+XMLTO_EXTRA =
+XMLTO_EXTRA = -m manpage-bold-literal.xsl
+GZIP = gzip
+INSTALL ?= install
+RM ?= rm -f
+BTRFS_VERSION = $(shell sed -n 's/.*BTRFS_BUILD_VERSION Btrfs \(.*\)/\1/p'\
+ ../version.h)
+
+ifneq ($(findstring $(MAKEFLAGS),s),s)
+ifndef V
+   QUIET_ASCIIDOC  = @echo '   ' ASCIIDOC $@;
+   QUIET_XMLTO = @echo '   ' XMLTO $@;
+   QUIET_GZIP  = @echo '   ' GZIP $@;
+   QUIET_STDERR= 2 /dev/null
+   QUIET_SUBDIR0   = +@subdir=
+   QUIET_SUBDIR1   = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
+ $(MAKE) $(PRINT_DIR) -C $$subdir
+   export V
+endif
+endif
+
+all: man
+man: man8
+man8: $(GZ_MAN8)
+
+install: install-man
+
+install-man: man
+   $(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
+   $(INSTALL) -m 644 $(GZ_MAN8) $(DESTDIR)$(man8dir)
+
+clean:
+   $(RM) *.xml *.xml+ *.8 *.8.gz
+
+%.8.gz : %.8
+   $(QUIET_GZIP)$(GZIP) -n -c $  $@
+
+%.8 : %.xml 
+   $(QUIET_XMLTO)$(RM) $@  \
+   $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $
+
+%.xml : %.txt asciidoc.conf
+   $(QUIET_ASCIIDOC)$(RM) $@+ $@  \
+   $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
+   $(ASCIIDOC_EXTRA) -abtrfs_version=$(BTRFS_VERSION) \
+   -o $@+ $  \
+   mv $@+ $@
diff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf
new file mode 100644
index 000..313f185
--- /dev/null
+++ b/Documentation/asciidoc.conf
@@ -0,0 +1,42 @@
+## linkbtrfs: macro
+#
+# Usage: linkbtrfs:command[manpage-section]
+#
+# Note, {0} is the manpage section, while {target} is the command.
+#
+# Show Btrfslink as: command(section); if section is defined, else just 
show
+# the command.
+
+[macros]
+(?su)[\\]?(?Pnamelinkbtrfs):(?Ptarget\S*?)\[(?Pattrlist.*?)\]=
+
+[attributes]
+asterisk=#42;
+plus=#43;
+caret=#94;
+startsb=#91;
+endsb=#93;
+backslash=#92;
+tilde=#126;
+apostrophe=#39;
+backtick=#96;
+litdd=#45;#45;
+
+ifdef::doctype-manpage[]
+ifdef::backend-docbook[]
+[header]
+template::[header-declarations]
+refentry
+refmeta
+refentrytitle{mantitle}/refentrytitle

[PATCH 23/27] btrfs-progs: Convert man page for btrfstune.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfstune.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile  |  2 +-
 Documentation/btrfstune.txt | 47 +
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfstune.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 2013d65..e002d53 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -10,7 +10,7 @@ MAN8_TXT += btrfs-find-root.txt
 MAN8_TXT += btrfs-image.txt
 MAN8_TXT += btrfs-map-logical.txt
 MAN8_TXT += btrfs-show-super.txt
-#MAN8_TXT += btrfstune.txt
+MAN8_TXT += btrfstune.txt
 #MAN8_TXT += btrfs-zero-log.txt
 #MAN8_TXT += fsck.btrfs.txt
 #MAN8_TXT += mkfs.btrfs.txt
diff --git a/Documentation/btrfstune.txt b/Documentation/btrfstune.txt
new file mode 100644
index 000..bf4bfce
--- /dev/null
+++ b/Documentation/btrfstune.txt
@@ -0,0 +1,47 @@
+btrfstune(8)
+
+
+NAME
+
+btrfstune - tune various btrfs filesystem parameters
+
+SYNOPSIS
+
+'btrfstune' [options] dev [dev...]
+
+DESCRIPTION
+---
+'btrfstune' is used to tune various btrfs filesystem parameters,you can
+enable/disable some extended features for btrfs.
+
+OPTIONS
+---
+-S value::
+Updates the seeding value, it forces a fs readonly so that you can use it to
+build other filesystems.
+-r::
+Enable extended inode refs.
+-x::
+Enable skinny metadata extent refs.
+
+
+EXIT STATUS
+---
+'btrfstune' will return 0 if no error happened.
+If any problems happened, 1 will be returned.
+
+AUTHOR
+--
+Written by Shilong Wang and Wenruo Qu.
+
+COPYRIGHT
+-
+Copyright (C) 2013 FUJITSU LIMITED.
+
+License GPLv2: GNU GPL version 2 http://gnu.org/licenses/gpl.html.
+
+This is free software: you are free  to  change  and  redistribute  it. There 
is NO WARRANTY, to the extent permitted by law.
+
+SEE ALSO
+
+`mkfs.btrfs`(8)
-- 
1.9.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 21/27] btrfs-progs: Convert man page for btrfs-map-logical.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-map-logical.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile  |  2 +-
 Documentation/btrfs-map-logical.txt | 49 +
 2 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-map-logical.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 6954a51..d418681 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -8,7 +8,7 @@ MAN8_TXT += btrfs-convert.txt
 MAN8_TXT += btrfs-debug-tree.txt
 MAN8_TXT += btrfs-find-root.txt
 MAN8_TXT += btrfs-image.txt
-#MAN8_TXT += btrfs-map-logical.txt
+MAN8_TXT += btrfs-map-logical.txt
 #MAN8_TXT += btrfs-show-super.txt
 #MAN8_TXT += btrfstune.txt
 #MAN8_TXT += btrfs-zero-log.txt
diff --git a/Documentation/btrfs-map-logical.txt 
b/Documentation/btrfs-map-logical.txt
new file mode 100644
index 000..2a93fb0
--- /dev/null
+++ b/Documentation/btrfs-map-logical.txt
@@ -0,0 +1,49 @@
+btrfs-map-logical(8)
+
+
+NAME
+
+btrfs-map-logical - map btrfs logical extent to physical extent
+
+SYNOPSIS
+
+'btrfs-map-logical' options device
+
+DESCRIPTION
+---
+'btrfs-map-logical' can be used to find out what the physical offsets are
+on the mirrors, the result is dumped into stdout in default.
+
+Mainly used for debug purpose.
+
+OPTIONS
+---
+-l|--logical logical_num::
+Logical extent to map.
+-c|--copy copy::
+Copy of the extent to read(usually 1 or 2).
+-o|--output filename::
+Output file to hold the extent.
+-b|--bytes bytes::
+Number of bytes to read.
+
+EXIT STATUS
+---
+'btrfs-map-logical' will return 0 if no error happened.
+If any problems happened, 1 will be returned.
+
+AUTHOR
+--
+Written by Shilong Wang and Wenruo Qu.
+
+COPYRIGHT
+-
+Copyright (C) 2013 FUJITSU LIMITED.
+
+License GPLv2: GNU GPL version 2 http://gnu.org/licenses/gpl.html.
+
+This is free software: you are free  to  change  and  redistribute  it. There 
is NO WARRANTY, to the extent permitted by law.
+
+SEE ALSO
+
+`mkfs.btrfs`(8)
-- 
1.9.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 26/27] btrfs-progs: Convert man page for mkfs.btrfs.

2014-04-02 Thread Qu Wenruo
Convert man page for mkfs.btrfs.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile   |   2 +-
 Documentation/mkfs.btrfs.txt | 133 +++
 2 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/mkfs.btrfs.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 4100ddd..97a775a 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -13,7 +13,7 @@ MAN8_TXT += btrfs-show-super.txt
 MAN8_TXT += btrfstune.txt
 MAN8_TXT += btrfs-zero-log.txt
 MAN8_TXT += fsck.btrfs.txt
-#MAN8_TXT += mkfs.btrfs.txt
+MAN8_TXT += mkfs.btrfs.txt
 
 # Sub commands for btrfs
 MAN8_TXT += btrfs-subvolume.txt
diff --git a/Documentation/mkfs.btrfs.txt b/Documentation/mkfs.btrfs.txt
new file mode 100644
index 000..bafe065
--- /dev/null
+++ b/Documentation/mkfs.btrfs.txt
@@ -0,0 +1,133 @@
+mkfs.btrfs(8)
+=
+
+NAME
+
+mkfs.btrfs - create a btrfs filesystem
+
+SYNOPSIS
+
+'mkfs.btrfs'
+$$[-A|--alloc-start alloc-start]$$
+$$[-b|--byte-count byte-count]$$
+$$[-d|--data data-profile]$$
+$$[-f|--force]$$
+$$[-n|--nodesize nodesize]$$
+$$[-l|--leafsize leafsize]$$
+$$[-L|--label label]$$
+$$[-m|--metadata metadata profile]$$
+$$[-M|--mixed]$$
+$$[-s|--sectorsize sectorsize]$$
+$$[-r|--rootdir rootdir]$$
+$$[-K|--nodiscard]$$
+$$[-O|--features feature1[,feature2...]]$$
+$$[-h]$$
+$$[-V|--version]$$
+$$device [device...]$$
+
+DESCRIPTION
+---
+'mkfs.btrfs'
+is used to create a btrfs filesystem (usually in a disk partition, or an array
+of disk partitions).
+
+device
+is the special file corresponding to the device (e.g /dev/sdXX ).
+If multiple devices are specified, btrfs is created
+spanning across the specified  devices.
+
+OPTIONS
+---
+-A|--alloc-start offset::
+Specify the offset from the start of the device to start the btrfs filesystem. 
The default value is zero, or the start of the device.
+
+-b|--byte-count size::
+Specify the size of the resultant filesystem. If this option is not used,
+mkfs.btrfs uses all the available storage for the filesystem.
+
+-d|--data type::
+Specify how the data must be spanned across the devices specified. Valid
+values are 'raid0', 'raid1', 'raid5', 'raid6', 'raid10' or 'single'.
+
+-f|--force::
+Force overwrite when an existing filesystem is detected on the device.
+By default, mkfs.btrfs will not write to the device if it suspects that 
+there is a filesystem or partition table on the device already.
+
+-n|--nodesize size
++
+-l|--leafsize size::
+Specify the nodesize, the tree block size in which btrfs stores
+data. The default value is 16KB (16384) or the page size, whichever is
+bigger. Must be a multiple of the sectorsize, but not larger than
+65536. Leafsize always equals nodesize and the options are aliases.
+
+-L|--label name::
+Specify a label for the filesystem.
++
+NOTE: name should be less than 256 characters.
+
+
+-m|--metadata profile::
+Specify how metadata must be spanned across the devices specified. Valid
+values are 'raid0', 'raid1', 'raid5', 'raid6', 'raid10', 'single' or 'dup'.
++
+Single device
+will have dup set by default except in the case of SSDs which will default to
+single. This is because SSDs can remap blocks internally so duplicate blocks
+could end up in the same erase block which negates the benefits of doing
+metadata duplication.
+
+-M|--mixed::
+Mix data and metadata chunks together for more efficient space 
+utilization.  This feature incurs a performance penalty in
+larger filesystems.  It is recommended for use with filesystems
+of 1 GiB or smaller.
+
+-s|--sectorsize size::
+Specify the sectorsize, the minimum data block allocation unit.
++
+The default
+value is the page size. If the sectorsize differs from the page size, the
+created filesystem may not be mountable by current kernel. Therefore it is not
+recommended to use this option unless you are going to mount it on a system
+with the appropriate page size.
+
+-r|--rootdir rootdir::
+Specify a directory to copy into the newly created btrfs filesystem.
++
+NOTE: '-r' option is done completely in userland, and don't need root
+privilege to mount the filesystem.
+
+-K|--nodiscard::
+Do not perform whole device TRIM operation by default.
+
+-O|--features feature1[,feature2...]::
+A list of filesystem features turned on at mkfs time. Not all features are
+supported by old kernels.
++
+To see all features run
+mkfs.btrfs -O list-all
+
+-V|--version::
+Print the 'mkfs.btrfs' version and exit.
+
+-h::
+Print help.
+
+UNIT
+
+As default the unit is the byte, however it is possible to append a suffix
+to the arguments like 'k' for KBytes, 'm' for MBytes...
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+

[PATCH 22/27] btrfs-progs: Convert man page for btrfs-show-super.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-show-super.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile |  2 +-
 Documentation/btrfs-show-super.txt | 53 ++
 2 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-show-super.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index d418681..2013d65 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -9,7 +9,7 @@ MAN8_TXT += btrfs-debug-tree.txt
 MAN8_TXT += btrfs-find-root.txt
 MAN8_TXT += btrfs-image.txt
 MAN8_TXT += btrfs-map-logical.txt
-#MAN8_TXT += btrfs-show-super.txt
+MAN8_TXT += btrfs-show-super.txt
 #MAN8_TXT += btrfstune.txt
 #MAN8_TXT += btrfs-zero-log.txt
 #MAN8_TXT += fsck.btrfs.txt
diff --git a/Documentation/btrfs-show-super.txt 
b/Documentation/btrfs-show-super.txt
new file mode 100644
index 000..e8e17ab
--- /dev/null
+++ b/Documentation/btrfs-show-super.txt
@@ -0,0 +1,53 @@
+btrfs-show-super(8)
+
+
+NAME
+
+btrfs-show-super - show btrfs superblock information stored in devices
+
+SYNOPSIS
+
+'btrfs-show-super' [options] dev [dev...]
+
+DESCRIPTION
+---
+'btrfs-show-super' is used to print the information of superblock,
+you can specify which mirror to print out.
+
+By default, every device's first superblock will be printed out.
+
+Mainly used for debug purpose.
+
+OPTIONS
+---
+-a::
+Print all the superblock information.
++
+If this option is given, '-i' option will be ignored.
+
+-i super_mirror::
+Specify which mirror to print out.
++
+super_mirror is between 0 and 2.
+If several '-i super_mirror' are given, only the last one is valid.
+
+EXIT STATUS
+---
+'btrfs-show-super' will return 0 if no error happened.
+If any problems happened, 1 will be returned.
+
+AUTHOR
+--
+Written by Shilong Wang and Wenruo Qu.
+
+COPYRIGHT
+-
+Copyright (C) 2013 FUJITSU LIMITED.
+
+License GPLv2: GNU GPL version 2 http://gnu.org/licenses/gpl.html.
+
+This is free software: you are free  to  change  and  redistribute  it. There 
is NO WARRANTY, to the extent permitted by law.
+
+SEE ALSO
+
+`mkfs.btrfs`(8)
-- 
1.9.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 16/27] btrfs-progs: Convert man page for btrfsck

2014-04-02 Thread Qu Wenruo
Convert man page for btrfsck.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile|  2 +-
 Documentation/btrfsck.txt | 55 +++
 2 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfsck.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 4040951..b4d8281 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -3,7 +3,7 @@ MAN8_TXT =
 
 # Top level commands
 MAN8_TXT += btrfs.txt
-#MAN8_TXT += btrfsck.txt
+MAN8_TXT += btrfsck.txt
 #MAN8_TXT += btrfs-convert.txt
 #MAN8_TXT += btrfs-debug-tree.txt
 #MAN8_TXT += btrfs-find-root.txt
diff --git a/Documentation/btrfsck.txt b/Documentation/btrfsck.txt
new file mode 100644
index 000..751c4d0
--- /dev/null
+++ b/Documentation/btrfsck.txt
@@ -0,0 +1,55 @@
+btrfsck(8)
+==
+
+NAME
+
+btrfsck - check or repair a btrfs filesystem offline
+
+SYNOPSIS
+
+'btrfsck' [options] device
+
+DESCRIPTION
+---
+'btrfsck' is used to check and optionally repair of a Btrfs filesystem.
+
+Now, it can only be run on an unmounted FS.
+device is the device file where the filesystem is stored.
+
+'btrfsck' is just an alias of 'btrfs check' command.
+
+WARNING: Considering it is not well-tested in real-life situations yet.
+If you have a broken Btrfs filesystem, btrfsck may not repair but cause
+additional damages. 
+
+
+OPTIONS
+---
+-s|--support superblock::
+use superblockth superblock copy.
+--repair::
+try to repair the filesystem.
+--init-csum-tree::
+create a new CRC tree.
+--init-extent-tree::
+create a new extent tree.
+
+EXIT STATUS
+---
+'btrfsck' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
+`btrfs-scrub`(8),
+`btrfs-rescue`(8)
+`btrfs-check`(8)
-- 
1.9.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 25/27] btrfs-progs: Convert man page for fsck.btrfs.

2014-04-02 Thread Qu Wenruo
Convert man page for fsck.btrfs.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile   |  2 +-
 Documentation/fsck.btrfs.txt | 51 
 2 files changed, 52 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/fsck.btrfs.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index de06629..4100ddd 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -12,7 +12,7 @@ MAN8_TXT += btrfs-map-logical.txt
 MAN8_TXT += btrfs-show-super.txt
 MAN8_TXT += btrfstune.txt
 MAN8_TXT += btrfs-zero-log.txt
-#MAN8_TXT += fsck.btrfs.txt
+MAN8_TXT += fsck.btrfs.txt
 #MAN8_TXT += mkfs.btrfs.txt
 
 # Sub commands for btrfs
diff --git a/Documentation/fsck.btrfs.txt b/Documentation/fsck.btrfs.txt
new file mode 100644
index 000..52e8e4d
--- /dev/null
+++ b/Documentation/fsck.btrfs.txt
@@ -0,0 +1,51 @@
+fsck.btrfs(8)
+=
+
+NAME
+
+fsck.btrfs - do nothing, successfully
+
+SYNOPSIS
+
+'fsck.btrfs' [-aApy] [device...]
+
+DESCRIPTION
+---
+'fsck.btrfs' is a type of utility that should exist for any filesystem and is
+called during system setup when the corresponding `/etc/fstab` entries
+contain non-zero value for `fs_passno` , see `fstab`(5) for more.
+
+Traditional filesystems need to run their respective fsck utility in case the
+filesystem was not unmounted cleanly and the log needs to be replayed before
+mount. This is not needed for BTRFS. You should set fs_passno to 0.
+
+If you wish to check the consistency of a BTRFS filesystem or repair a damaged
+filesystem, see `btrfs-check`(8). By default the filesystem
+consistency is checked, the repair mode is enabled via '--repair' option (use
+with care!).
+
+OPTIONS
+---
+The options are all the same and detect if 'fsck.btrfs' is executed in
+non-interactive mode and exits with success,
+otherwise prints a message about btrfs check.
+
+EXIT STATUS
+---
+There are two possible exit code returned:
+
+0::
+No error
+
+8::
+Operational error, eg. device does not exist
+
+FILES
+-
+`/etc/fstab`
+
+SEE ALSO
+
+`btrfs`(8),
+`fsck`(8),
+`fstab`(5),
-- 
1.9.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 27/27] btrfs-progs: Switch to the new asciidoc Documentation.

2014-04-02 Thread Qu Wenruo
Since all man page are converted to the new asciidoc, the old man page
can be removed.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Makefile   |   4 +-
 man/Makefile   |  31 --
 man/btrfs-convert.8.in |  33 --
 man/btrfs-debug-tree.8.in  |  35 --
 man/btrfs-find-root.8.in   |  30 --
 man/btrfs-image.8.in   |  55 ---
 man/btrfs-map-logical.8.in |  33 --
 man/btrfs-show-super.8.in  |  30 --
 man/btrfs-zero-log.8.in|  23 --
 man/btrfs.8.in | 932 -
 man/btrfsck.8.in   |  29 --
 man/btrfstune.8.in |  31 --
 man/fsck.btrfs.8.in|  47 ---
 man/mkfs.btrfs.8.in| 105 -
 14 files changed, 2 insertions(+), 1416 deletions(-)
 delete mode 100644 man/Makefile
 delete mode 100644 man/btrfs-convert.8.in
 delete mode 100644 man/btrfs-debug-tree.8.in
 delete mode 100644 man/btrfs-find-root.8.in
 delete mode 100644 man/btrfs-image.8.in
 delete mode 100644 man/btrfs-map-logical.8.in
 delete mode 100644 man/btrfs-show-super.8.in
 delete mode 100644 man/btrfs-zero-log.8.in
 delete mode 100644 man/btrfs.8.in
 delete mode 100644 man/btrfsck.8.in
 delete mode 100644 man/btrfstune.8.in
 delete mode 100644 man/fsck.btrfs.8.in
 delete mode 100644 man/mkfs.btrfs.8.in

diff --git a/Makefile b/Makefile
index 636cbf0..70eaf57 100644
--- a/Makefile
+++ b/Makefile
@@ -56,7 +56,7 @@ btrfs_convert_libs = -lext2fs -lcom_err
 btrfs_image_libs = -lpthread
 btrfs_fragment_libs = -lgd -lpng -ljpeg -lfreetype
 
-SUBDIRS = man
+SUBDIRS = Documentation
 BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS))
 INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS))
 CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
@@ -221,7 +221,7 @@ send-test: $(objects) $(libs) send-test.o
$(Q)$(CC) $(CFLAGS) -o send-test $(objects) send-test.o $(LDFLAGS) 
$(LIBS) -lpthread
 
 manpages:
-   $(Q)$(MAKE) $(MAKEOPTS) -C man
+   $(Q)$(MAKE) $(MAKEOPTS) -C Documentation
 
 clean: $(CLEANDIRS)
@echo Cleaning
diff --git a/man/Makefile b/man/Makefile
deleted file mode 100644
index 552c9f7..000
--- a/man/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-GZIPCMD=gzip
-INSTALL= install
-
-prefix ?= /usr/local
-bindir = $(prefix)/bin
-mandir = $(prefix)/man
-man8dir = $(mandir)/man8
-
-# clear out all suffixes
-.SUFFIXES:
-# list only those we use
-.SUFFIXES: .in .gz
-
-MANPAGES = mkfs.btrfs.8.gz btrfsck.8.gz btrfs-image.8.gz btrfs.8.gz \
-  btrfs-debug-tree.8.gz btrfs-show-super.8.gz btrfs-find-root.8.gz \
-  btrfs-convert.8.gz btrfstune.8.gz btrfs-zero-log.8.gz 
btrfs-map-logical.8.gz \
-  fsck.btrfs.8.gz
-INFILES = ${MANPAGES:.in=.gz}
-
-all: $(MANPAGES)
-
-.in.gz :
-   @echo [MAN]$@
-   $(Q)$(GZIPCMD) -n -c $  $@
-
-clean :
-   $(Q)rm -f $(MANPAGES)
-
-install: $(MANPAGES)
-   $(INSTALL) -m755 -d $(DESTDIR)$(man8dir)
-   $(INSTALL) -m 644 $(MANPAGES) $(DESTDIR)$(man8dir)
diff --git a/man/btrfs-convert.8.in b/man/btrfs-convert.8.in
deleted file mode 100644
index 85cfa61..000
--- a/man/btrfs-convert.8.in
+++ /dev/null
@@ -1,33 +0,0 @@
-.TH BTRFS-CONVERT 8
-.SH NAME
-btrfs-convert \- convert ext2/3/4 to btrfs.
-.SH SYNOPSIS
-.B btrfs-convert [\fIoptions\fP] \fIdev\fP
-.SH DESCRIPTION
-\fBbtrfs-convert\fP is used to convert existed ext2/3/4 to btrfs filesystem, 
and the original filesystem image is accessible as from separate subvolume 
named ext2_subvol as file image.
-
-\fIOptions\fP
-.IP \fB-d\fP 5
-disable data checksum.
-.IP \fB-i\fP 5
-ignore xattrs and ACLs.
-.IP \fB-n\fP 5
-disable packing of small files.
-.IP \fB-r\fP 5
-roll back to ext2fs.
-
-.SH EXIT CODE
-\fBbtrfs-convert\fP will return 0 if no error happened.
-If any problems happened, 1 will be returned.
-
-.SH AUTHOR
-Written by Shilong Wang and Wenruo Qu.
-
-.SH COPYRIGHT
-Copyright \(co 2013 FUJITSU LIMITED.
-License GPLv2: GNU GPL version 2 http://gnu.org/licenses/gpl.html.
-.br
-This is free software: you are free  to  change  and  redistribute  it. There 
is NO WARRANTY, to the extent permitted by law.
-
-.SH SEE ALSO
-.BR mkfs.btrfs (8)
diff --git a/man/btrfs-debug-tree.8.in b/man/btrfs-debug-tree.8.in
deleted file mode 100644
index eed7097..000
--- a/man/btrfs-debug-tree.8.in
+++ /dev/null
@@ -1,35 +0,0 @@
-.TH BTRFS-DEBUG-TREE 8
-.SH NAME
-btrfs-debug-tree \- dump Btrfs filesystem metadata into stdout.
-.SH SYNOPSIS
-.B btrfs-debug-tree [\fIoptions\fP] \fIdevice\fP
-.SH DESCRIPTION
-\fBbtrfs-debug-tree\fP is used to dump the whole tree of the given device.
-This is maybe useful for analyzing filesystem state or inconsistence and has
-a positive educational effect on understanding the internal structure.
-\fIdevice\fP is the device file where the filesystem is stored.
-
-\fIOptions\fP
-.IP \fB-e\fP 5
-print detailed extents info.
-.IP \fB-d\fP 5
-print info of btrfs device and root tree dirs only.
-.IP \fB-r\fP 5
-print info of roots only.
-.IP \fB-b \fIblock_num\fP 5
-print info of the specified block only.
-

[PATCH 24/27] btrfs-progs: Convert man page for btrfs-zero-log

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-zero-log

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile   |  2 +-
 Documentation/btrfs-zero-log.txt | 39 +++
 2 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-zero-log.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index e002d53..de06629 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -11,7 +11,7 @@ MAN8_TXT += btrfs-image.txt
 MAN8_TXT += btrfs-map-logical.txt
 MAN8_TXT += btrfs-show-super.txt
 MAN8_TXT += btrfstune.txt
-#MAN8_TXT += btrfs-zero-log.txt
+MAN8_TXT += btrfs-zero-log.txt
 #MAN8_TXT += fsck.btrfs.txt
 #MAN8_TXT += mkfs.btrfs.txt
 
diff --git a/Documentation/btrfs-zero-log.txt b/Documentation/btrfs-zero-log.txt
new file mode 100644
index 000..e3041fa
--- /dev/null
+++ b/Documentation/btrfs-zero-log.txt
@@ -0,0 +1,39 @@
+btrfs-zero-log(8)
+=
+
+NAME
+
+btrfs-zero-log - clear out log tree
+
+SYNOPSIS
+
+'btrfs-zero-log' dev
+
+DESCRIPTION
+---
+'btrfs-zero-log' will remove the log tree if log tree is corrupt, which will
+allow you to mount the filesystem again.
+
+The common case where this happens has been fixed a long time ago,
+so it is unlikely that you will see this particular problem.
+
+EXIT STATUS
+---
+'btrfs-zero-log' will return 0 if no error happened.
+Other exit code means some problems happened.
+
+AUTHOR
+--
+Written by Shilong Wang and Wenruo Qu.
+
+COPYRIGHT
+-
+Copyright (C) 2013 FUJITSU LIMITED.
+
+License GPLv2: GNU GPL version 2 http://gnu.org/licenses/gpl.html.
+
+This is free software: you are free  to  change  and  redistribute  it. There 
is NO WARRANTY, to the extent permitted by law.
+
+SEE ALSO
+
+`mkfs.btrfs`(8)
-- 
1.9.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 20/27] btrfs-progs: Convert man page for btrfs-image.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-image.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile|  2 +-
 Documentation/btrfs-image.txt | 70 +++
 2 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-image.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 7a38df9..6954a51 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -7,7 +7,7 @@ MAN8_TXT += btrfsck.txt
 MAN8_TXT += btrfs-convert.txt
 MAN8_TXT += btrfs-debug-tree.txt
 MAN8_TXT += btrfs-find-root.txt
-#MAN8_TXT += btrfs-image.txt
+MAN8_TXT += btrfs-image.txt
 #MAN8_TXT += btrfs-map-logical.txt
 #MAN8_TXT += btrfs-show-super.txt
 #MAN8_TXT += btrfstune.txt
diff --git a/Documentation/btrfs-image.txt b/Documentation/btrfs-image.txt
new file mode 100644
index 000..bd74a86
--- /dev/null
+++ b/Documentation/btrfs-image.txt
@@ -0,0 +1,70 @@
+btrfs-image(8)
+==
+
+NAME
+
+btrfs-image - create/restore an image of the filesystem
+
+SYNOPSIS
+
+'btrfs-image' [options] source target
+
+DESCRIPTION
+---
+'btrfs-image' is used to create an image of a btrfs filesystem.
+All data will be zeroed, but metadata and the like is preserved.
+
+Mainly used for debug purpose.
+
+OPTIONS
+---
+-r::
+Restore metadump image. By default, this fixes super's chunk tree, by
+using 1 stripe pointing to primary device, so that file system can be
+restored by running tree log reply if possible. To restore without
+changing number of stripes in chunk tree check -o option.
+
+-c value::
+Compression level (0 ~ 9).
+
+-t value::
+Number of threads (1 ~ 32) to be used to process the image dump or restore.
+
+-o::
+Use the old restore method, this does not fixup the chunk tree so the restored
+file system will not be able to be mounted.
+
+-s::
+Sanitize the file names when generating the image. One -s means just
+generate random garbage, which means that the directory indexes won't match up
+since the hashes won't match with the garbage filenames. Using -ss will
+calculate a collision for the filename so that the hashes match, and if it
+can't calculate a collision then it will just generate garbage.  The collision
+calculator is very time and CPU intensive so only use it if you are having
+problems with your file system tree and need to have it mostly working.
+
+-w::
+Walk all the trees manually and copy any blocks that are referenced. Use this
+option if your extent tree is corrupted to make sure that all of the metadata 
is
+captured.
+
+EXIT STATUS
+---
+'btrfs-image' will return 0 if no error happened.
+If any problems happened, 1 will be returned.
+
+AUTHOR
+--
+Written by Shilong Wang and Wenruo Qu.
+
+COPYRIGHT
+-
+Copyright (C) 2013 FUJITSU LIMITED.
+
+License GPLv2: GNU GPL version 2 http://gnu.org/licenses/gpl.html.
+
+This is free software: you are free  to  change  and  redistribute  it. There 
is NO WARRANTY, to the extent permitted by law.
+
+SEE ALSO
+
+`mkfs.btrfs`(8)
-- 
1.9.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 14/27] btrfs-progs: Convert man page for btrfs-replace.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-replace.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile  |  2 +-
 Documentation/btrfs-replace.txt | 76 +
 2 files changed, 77 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-replace.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 84a4859..a4f7ef0 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -28,7 +28,7 @@ MAN8_TXT += btrfs-send.txt
 MAN8_TXT += btrfs-receive.txt
 MAN8_TXT += btrfs-quota.txt
 MAN8_TXT += btrfs-qgroup.txt
-#MAN8_TXT += btrfs-replace.txt
+MAN8_TXT += btrfs-replace.txt
 #MAN8_TXT += btrfs-dedup.txt
 
 MAN_TXT = $(MAN8_TXT)
diff --git a/Documentation/btrfs-replace.txt b/Documentation/btrfs-replace.txt
new file mode 100644
index 000..8c5dcc4
--- /dev/null
+++ b/Documentation/btrfs-replace.txt
@@ -0,0 +1,76 @@
+btrfs-replace(8)
+===
+
+NAME
+
+btrfs-replace - replace devices managed by btrfs with other device.
+
+SYNOPSIS
+
+'btrfs replace' subcommand args
+
+DESCRIPTION
+---
+'btrfs replace' is used to replace btrfs managed devices with other device.
+
+SUBCOMMAND
+--
+'start' [-Bfr] srcdev|devid targetdev path::
+Replace device of a btrfs filesystem.
++
+On a live filesystem, duplicate the data to the target device which
+is currently stored on the source device.
+If the source device is not available anymore, or if the -r option is set,
+the data is built only using the RAID redundancy mechanisms.
+After completion of the operation, the source device is removed from the
+filesystem.
+If the srcdev is a numerical value, it is assumed to be the device id
+of the filesystem which is mounted at path, otherwise is is
+the path to the source device. If the source device is disconnected,
+from the system, you have to use the devid parameter format.
+The targetdev needs to be same size or larger than the srcdev.
++
+`Options`
++
+-r
+only read from srcdev if no other zero-defect mirror exists.
+(enable this if your drive has lots of read errors, the access would be very
+slow)
+-f
+force using and overwriting targetdev even if it looks like
+containing a valid btrfs filesystem.
++
+A valid filesystem is assumed if a btrfs superblock is found which contains a
+correct checksum. Devices which are currently mounted are
+never allowed to be used as the targetdev.
+-B
+no background replace.
+
+'status' [-1] mount_point::
+Print status and progress information of a running device replace operation.
++
+`Options`
++
+-1
+print once instead of print continuously until the replace
+operation finishes (or is canceled)
+
+'cancel' mount_point::
+Cancel a running device replace operation.
+
+EXIT STATUS
+---
+'btrfs replace' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
-- 
1.9.1

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


[PATCH 07/27] btrfs-progs: Convert man page for btrfs-check.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-check.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile|  2 +-
 Documentation/btrfs-check.txt | 45 +++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-check.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 68b7e1f..a838ca1 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -21,7 +21,7 @@ MAN8_TXT += btrfs-filesystem.txt
 MAN8_TXT += btrfs-balance.txt
 MAN8_TXT += btrfs-device.txt
 MAN8_TXT += btrfs-scrub.txt
-#MAN8_TXT += btrfs-check.txt
+MAN8_TXT += btrfs-check.txt
 #MAN8_TXT += btrfs-rescue.txt
 #MAN8_TXT += btrfs-inspect-internal.txt
 #MAN8_TXT += btrfs-send.txt
diff --git a/Documentation/btrfs-check.txt b/Documentation/btrfs-check.txt
new file mode 100644
index 000..accbed4
--- /dev/null
+++ b/Documentation/btrfs-check.txt
@@ -0,0 +1,45 @@
+btrfs-check(8)
+==
+
+NAME
+
+btrfs-check - check or repair a btrfs filesystem offline
+
+SYNOPSIS
+
+'btrfs check' [options] device
+
+DESCRIPTION
+---
+'btrfs check' is used to check or repair a btrfs filesystem offline.
+
+OPTIONS
+---
+-s|--support superblock::
+use superblockth superblock copy.
+--repair::
+try to repair the filesystem.
+--init-csum-tree::
+create a new CRC tree.
+--init-extent-tree::
+create a new extent tree.
+
+EXIT STATUS
+---
+'btrfs check' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
+`btrfs-scrub`(8),
+`btrfs-rescue`(8)
+`btrfsck`(8)
-- 
1.9.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 17/27] btrfs-progs: Convert man page for btrfs-convert.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-convert.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile  |  2 +-
 Documentation/btrfs-convert.txt | 49 +
 2 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-convert.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index b4d8281..b2afc7a 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -4,7 +4,7 @@ MAN8_TXT =
 # Top level commands
 MAN8_TXT += btrfs.txt
 MAN8_TXT += btrfsck.txt
-#MAN8_TXT += btrfs-convert.txt
+MAN8_TXT += btrfs-convert.txt
 #MAN8_TXT += btrfs-debug-tree.txt
 #MAN8_TXT += btrfs-find-root.txt
 #MAN8_TXT += btrfs-image.txt
diff --git a/Documentation/btrfs-convert.txt b/Documentation/btrfs-convert.txt
new file mode 100644
index 000..780ca9e
--- /dev/null
+++ b/Documentation/btrfs-convert.txt
@@ -0,0 +1,49 @@
+btrfs-convert(8)
+
+
+NAME
+
+btrfs-convert - convert from ext2/3/4 filesystem to btrfs or rollback
+
+SYNOPSIS
+
+'btrfs-convert' [options] device
+
+DESCRIPTION
+---
+'btrfs-convert' is used to convert existed ext2/3/4 to btrfs filesystem,
+and the original filesystem image is accessible as from separate subvolume
+named 'ext2_subvol' as file image.
+
+OPTIONS
+---
+-d::
+Disable data checksum.
+-i::
+Ignore xattrs and ACLs.
+-n::
+Disable packing of small files.
+-r::
+Roll back to ext2fs.
+
+EXIT STATUS
+---
+'btrfs-convert' will return 0 if no error happened.
+If any problems happened, 1 will be returned.
+
+AUTHOR
+--
+Written by Shilong Wang and Wenruo Qu.
+
+COPYRIGHT
+-
+Copyright (C) 2013 FUJITSU LIMITED.
+
+License GPLv2: GNU GPL version 2 http://gnu.org/licenses/gpl.html.
+
+This is free software: you are free  to  change  and  redistribute  it. There 
is NO WARRANTY, to the extent permitted by law.
+
+SEE ALSO
+
+`mkfs.btrfs`(8)
+
-- 
1.9.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 19/27] btrfs-progs: Convert man page for btrfs-find-root.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-find-root.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile|  2 +-
 Documentation/btrfs-find-root.txt | 45 +++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-find-root.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 460c14f..7a38df9 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -6,7 +6,7 @@ MAN8_TXT += btrfs.txt
 MAN8_TXT += btrfsck.txt
 MAN8_TXT += btrfs-convert.txt
 MAN8_TXT += btrfs-debug-tree.txt
-#MAN8_TXT += btrfs-find-root.txt
+MAN8_TXT += btrfs-find-root.txt
 #MAN8_TXT += btrfs-image.txt
 #MAN8_TXT += btrfs-map-logical.txt
 #MAN8_TXT += btrfs-show-super.txt
diff --git a/Documentation/btrfs-find-root.txt 
b/Documentation/btrfs-find-root.txt
new file mode 100644
index 000..18b1e84
--- /dev/null
+++ b/Documentation/btrfs-find-root.txt
@@ -0,0 +1,45 @@
+btrfs-find-root(8)
+==
+
+NAME
+
+btrfs-find-root - filter to find btrfs root
+
+SYNOPSIS
+
+'btrfs-find-root' [options] dev
+
+DESCRIPTION
+---
+'btrfs-find-root' is used to find the satisfied root, you can filter by
+root tree's objectid, generation, level.
+
+OPTIONS
+---
+-g generation::
+Filter root tree by it's original transaction id, tree root's generation in 
default.
+-o objectid::
+Filter root tree by it's objectid,tree root's objectid in default.
+-l level::
+Filter root tree by B-+ tree's level, level 0 in default.
+
+EXIT STATUS
+---
+'btrfs-find-root' will return 0 if no error happened.
+If any problems happened, 1 will be returned.
+
+AUTHOR
+--
+Written by Shilong Wang and Wenruo Qu.
+
+COPYRIGHT
+-
+Copyright (C) 2013 FUJITSU LIMITED.
+
+License GPLv2: GNU GPL version 2 http://gnu.org/licenses/gpl.html.
+
+This is free software: you are free to change and redistribute it. There is NO 
WARRANTY, to the extent permitted by law.
+
+SEE ALSO
+
+`mkfs.btrfs`(8)
-- 
1.9.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 18/27] btrfs-progs: Convert man page for btrfs-debug-tree.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-debug-tree.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile |  2 +-
 Documentation/btrfs-debug-tree.txt | 50 ++
 2 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-debug-tree.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index b2afc7a..460c14f 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -5,7 +5,7 @@ MAN8_TXT =
 MAN8_TXT += btrfs.txt
 MAN8_TXT += btrfsck.txt
 MAN8_TXT += btrfs-convert.txt
-#MAN8_TXT += btrfs-debug-tree.txt
+MAN8_TXT += btrfs-debug-tree.txt
 #MAN8_TXT += btrfs-find-root.txt
 #MAN8_TXT += btrfs-image.txt
 #MAN8_TXT += btrfs-map-logical.txt
diff --git a/Documentation/btrfs-debug-tree.txt 
b/Documentation/btrfs-debug-tree.txt
new file mode 100644
index 000..80a85d4
--- /dev/null
+++ b/Documentation/btrfs-debug-tree.txt
@@ -0,0 +1,50 @@
+btrfs-debug-tree(8)
+===
+
+NAME
+
+btrfs-debug-tree - dump btrfs filesystem metadata into stdout
+
+SYNOPSIS
+
+'btrfs-debug-tree' [options] device
+
+DESCRIPTION
+---
+'btrfs-debug-tree' is used to dump the whole tree of the given device.
+
+This is maybe useful for analyzing filesystem state or inconsistence and has
+a positive educational effect on understanding the internal structure.
+device is the device file where the filesystem is stored.
+
+OPTIONS
+---
+-e::
+Print detailed extents info.
+-d::
+Print info of btrfs device and root tree dirs only.
+-r::
+Print info of roots only.
+-b block_num::
+Print info of the specified block only.
+
+EXIT STATUS
+---
+'btrfs-debug-tree' will return 0 if no error happened.
+If any problems happened, 1 will be returned.
+
+AUTHOR
+--
+Written by Shilong Wang and Wenruo Qu.
+
+COPYRIGHT
+-
+Copyright (C) 2013 FUJITSU LIMITED.
+
+License GPLv2: GNU GPL version 2 http://gnu.org/licenses/gpl.html.
+
+This is free software: you are free  to  change  and  redistribute  it. There 
is NO WARRANTY, to the extent permitted by law.
+
+SEE ALSO
+
+`mkfs.btrfs`(8)
-- 
1.9.1

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


[PATCH 09/27] btrfs-progs: Convert man page for btrfs-inspect-internal

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-inspect-internal.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile   |  2 +-
 Documentation/btrfs-inspect-internal.txt | 69 
 2 files changed, 70 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-inspect-internal.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index ebe0455..6655f06 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -23,7 +23,7 @@ MAN8_TXT += btrfs-device.txt
 MAN8_TXT += btrfs-scrub.txt
 MAN8_TXT += btrfs-check.txt
 MAN8_TXT += btrfs-rescue.txt
-#MAN8_TXT += btrfs-inspect-internal.txt
+MAN8_TXT += btrfs-inspect-internal.txt
 #MAN8_TXT += btrfs-send.txt
 #MAN8_TXT += btrfs-receive.txt
 #MAN8_TXT += btrfs-quota.txt
diff --git a/Documentation/btrfs-inspect-internal.txt 
b/Documentation/btrfs-inspect-internal.txt
new file mode 100644
index 000..4555c70
--- /dev/null
+++ b/Documentation/btrfs-inspect-internal.txt
@@ -0,0 +1,69 @@
+btrfs-inspect-internal(8)
+=
+
+NAME
+
+btrfs-inspect-internal - resolve different btrfs items for debug purpose
+
+SYNOPSIS
+
+'btrfs inspect-internal' subcommand args
+
+DESCRIPTION
+---
+'btrfs inspect-internal' is used to resolve different items for debug purpose.
+
+SUBCOMMAND
+--
+'inode-resolve' [-v] inode path::
+Resolves an inode in subvolume path to all filesystem paths.
++
+`Options`
++
+-v
+verbose mode. print count of returned paths and ioctl() return value
+
+'logical-resolve' [-Pv] [-s bufsize] logical path::
+Resolves a logical address in the filesystem mounted at path to all inodes.
++
+By default, each inode is then resolved to a file system path (similar to the
+inode-resolve subcommand).
++
+`Options`
++
+-P
+skip the path resolving and print the inodes instead
+-v
+verbose mode. print count of returned paths and all ioctl() return values
+-s bufsize
+set inode container's size.
++
+This is used to increase inode container's size in case it is
+not enough to read all the resolved results. The max value one can set is 64k.
+
+'subvolid-resolve' subvolid path::
+Get file system paths for the given subvolume ID.
+
+'rootid' path::
+For a given file or directory, return the containing tree root id. For a
+subvolume return it's own tree id.
++
+The result is undefined for the so-called empty subvolumes (identified by 
inode number 2).
+
+EXIT STATUS
+---
+'btrfs inspect-internal' returns a zero exist status if it succeeds. Non zero 
is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
+`btrfs-debug-tree`(8)
-- 
1.9.1

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


[PATCH 08/27] btrfs-progs: Convert man page for btrfs-rescue

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-rescue.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile |  2 +-
 Documentation/btrfs-rescue.txt | 60 ++
 2 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-rescue.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index a838ca1..ebe0455 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -22,7 +22,7 @@ MAN8_TXT += btrfs-balance.txt
 MAN8_TXT += btrfs-device.txt
 MAN8_TXT += btrfs-scrub.txt
 MAN8_TXT += btrfs-check.txt
-#MAN8_TXT += btrfs-rescue.txt
+MAN8_TXT += btrfs-rescue.txt
 #MAN8_TXT += btrfs-inspect-internal.txt
 #MAN8_TXT += btrfs-send.txt
 #MAN8_TXT += btrfs-receive.txt
diff --git a/Documentation/btrfs-rescue.txt b/Documentation/btrfs-rescue.txt
new file mode 100644
index 000..f66ca85
--- /dev/null
+++ b/Documentation/btrfs-rescue.txt
@@ -0,0 +1,60 @@
+btrfs-check(8)
+==
+
+NAME
+
+btrfs-rescue - Recover a damaged btrfs filesystem
+
+SYNOPSIS
+
+'btrfs rescue' subcommand args
+
+DESCRIPTION
+---
+'btrfs rescue' is used to try to recover a damaged btrfs filesystem.
+
+SUBCOMMAND
+--
+'chunk-recover' [options] device::
+Recover the chunk tree by scanning the devices
++
+`Options`
++
+-y
+assume an answer of 'yes' to all questions.
+-v
+verbose mode.
+-h
+help.
+
+NOTE: Since 'chunk-recover' will scan the whole device, it will be *VERY* slow
+especially executed on a large device.
+
+'super-recover' [options] device::
+Recover bad superblocks from good copies.
++
+`Options`
++
+-y
+assume an answer of 'yes' to all questions.
+-v
+verbose mode.
+
+EXIT STATUS
+---
+'btrfs rescue' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
+`btrfs-scrub`(8),
+`btrfs-check`(8)
-- 
1.9.1

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


[PATCH 11/27] btrfs-progs: Convert man page for btrfs-receive.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-receive.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile  |  2 +-
 Documentation/btrfs-receive.txt | 58 +
 2 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-receive.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 081ec42..2af4d40 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -25,7 +25,7 @@ MAN8_TXT += btrfs-check.txt
 MAN8_TXT += btrfs-rescue.txt
 MAN8_TXT += btrfs-inspect-internal.txt
 MAN8_TXT += btrfs-send.txt
-#MAN8_TXT += btrfs-receive.txt
+MAN8_TXT += btrfs-receive.txt
 #MAN8_TXT += btrfs-quota.txt
 #MAN8_TXT += btrfs-replace.txt
 #MAN8_TXT += btrfs-dedup.txt
diff --git a/Documentation/btrfs-receive.txt b/Documentation/btrfs-receive.txt
new file mode 100644
index 000..a67bc66
--- /dev/null
+++ b/Documentation/btrfs-receive.txt
@@ -0,0 +1,58 @@
+btrfs-receive(8)
+
+
+NAME
+
+btrfs-receive - receive subvolumes from stdin/file.
+
+SYNOPSIS
+
+'btrfs receive' [-ve] [-f infile] mount
+
+DESCRIPTION
+---
+Receives one or more subvolumes that were previously
+sent with 'btrfs send'. The received subvolumes are stored
+into mount.
+
+'btrfs receive' will fail with the following case:
+
+1. a receiving subvolume already exists.
+
+2. a previously received subvolume was changed after it was received.
+
+3. default subvolume is changed or you don't mount btrfs filesystem with
+fs tree.
+
+After receiving a subvolume, it is immediately set to read only.
+
+`Options`
+
+-v::
+Enable verbose debug output. Each occurrence of this option increases the
+verbose level more.
+-f infile::
+By default, btrfs receive uses stdin to receive the subvolumes.
+Use this option to specify a file to use instead.
+-e::
+Terminate after receiving an end cmd in the data stream.
+Without this option, the receiver terminates only if an error is recognized
+or on EOF.
+
+EXIT STATUS
+---
+'btrfs receive' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
+`btrfs-send`(8)
-- 
1.9.1

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


[PATCH 10/27] btrfs-progs: Convert man page for btrfs-send.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-send.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile   |  2 +-
 Documentation/btrfs-send.txt | 60 
 2 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-send.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 6655f06..081ec42 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -24,7 +24,7 @@ MAN8_TXT += btrfs-scrub.txt
 MAN8_TXT += btrfs-check.txt
 MAN8_TXT += btrfs-rescue.txt
 MAN8_TXT += btrfs-inspect-internal.txt
-#MAN8_TXT += btrfs-send.txt
+MAN8_TXT += btrfs-send.txt
 #MAN8_TXT += btrfs-receive.txt
 #MAN8_TXT += btrfs-quota.txt
 #MAN8_TXT += btrfs-replace.txt
diff --git a/Documentation/btrfs-send.txt b/Documentation/btrfs-send.txt
new file mode 100644
index 000..18a98fa
--- /dev/null
+++ b/Documentation/btrfs-send.txt
@@ -0,0 +1,60 @@
+btrfs-send(8)
+=
+
+NAME
+
+btrfs-send - send data of subvolume(s) to stdout/file.
+
+SYNOPSIS
+
+'btrfs send' [-ve] [-p parent] [-c clone-src] [-f outfile] subvol 
[subvol...]
+
+DESCRIPTION
+---
+Sends the subvolume(s) specified by subvol to stdout.
+
+By default, this will send the whole subvolume. To do an incremental
+send, use '-p parent'.
+
+If you want to allow btrfs to clone from any additional local snapshots,
+use '-c clone-src' (multiple times where applicable). 
+
+You must not specify clone sources unless you guarantee that these snapshots
+are exactly in the same state on both sides, the sender and the receiver.
+
+It is allowed to omit the '-p parent' option when '-c clone-src' options
+are given, in which case 'btrfs send' will determine a suitable parent among 
the
+clone sources itself.
+
+`Options`
+
+-v::
+Enable verbose debug output. Each occurrence of this option increases the
+verbose level more.
+-e::
+If sending multiple subvols at once, use the new format and omit the end cmd 
between the subvols.
+-p parent::
+Send an incremental stream from parent to subvol.
+-c clone-src::
+Use this snapshot as a clone source for an incremental send (multiple allowed).
+-f outfile::
+Output is normally written to stdout. To write to a file, use this option.
+An alternative would be to use pipes.
+
+EXIT STATUS
+---
+'btrfs send' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
+`btrfs-receive`(8)
-- 
1.9.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 15/27] btrfs-progs: Convert man page for btrfs-dedup.

2014-04-02 Thread Qu Wenruo
Although the btrfs-dedup function is not available in mainline kernel,
add the man page any way and add a warning into it.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile|  2 +-
 Documentation/btrfs-dedup.txt | 51 +++
 2 files changed, 52 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-dedup.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index a4f7ef0..4040951 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -29,7 +29,7 @@ MAN8_TXT += btrfs-receive.txt
 MAN8_TXT += btrfs-quota.txt
 MAN8_TXT += btrfs-qgroup.txt
 MAN8_TXT += btrfs-replace.txt
-#MAN8_TXT += btrfs-dedup.txt
+MAN8_TXT += btrfs-dedup.txt
 
 MAN_TXT = $(MAN8_TXT)
 MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
diff --git a/Documentation/btrfs-dedup.txt b/Documentation/btrfs-dedup.txt
new file mode 100644
index 000..d42cee6
--- /dev/null
+++ b/Documentation/btrfs-dedup.txt
@@ -0,0 +1,51 @@
+btrfs-dedup(8)
+==
+
+NAME
+
+btrfs-dedup - control the deduplication in a btrfs filesystem
+
+SYNOPSIS
+
+'btrfs dedup' subcommand args
+
+DESCRIPTION
+---
+WARNING: Deduplication function is not implemented in mainline kernel(v3.14
+yet). So most user may find this function not usable.
+
+'btrfs dedup' is used to control deduplication in a bttrfs filesystem.
+
+SUBCOMMAND
+--
+'enable' path::
+Enable data deduplication support for a filesystem.
+
+
+'disable' path::
+Disable data deduplication support for a filesystem.
+
+
+'on' [-b|--bs size] path::
+Switch on data deduplication or change the dedup blocksize.
+
+
+'off' path::
+Switch off data deduplication.
+
+EXIT STATUS
+---
+'btrfs dedup' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
-- 
1.9.1

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


[PATCH 04/27] btrfs-progs: Convert man page for btrfs-balance.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-balance.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile  |  2 +-
 Documentation/btrfs-balance.txt | 77 +
 2 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-balance.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 1fa2b35..4839b6d 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -18,7 +18,7 @@ MAN8_TXT += btrfs.txt
 # Sub commands for btrfs
 MAN8_TXT += btrfs-subvolume.txt
 MAN8_TXT += btrfs-filesystem.txt
-#MAN8_TXT += btrfs-balance.txt
+MAN8_TXT += btrfs-balance.txt
 #MAN8_TXT += btrfs-device.txt
 #MAN8_TXT += btrfs-scrub.txt
 #MAN8_TXT += btrfs-check.txt
diff --git a/Documentation/btrfs-balance.txt b/Documentation/btrfs-balance.txt
new file mode 100644
index 000..2289fdf
--- /dev/null
+++ b/Documentation/btrfs-balance.txt
@@ -0,0 +1,77 @@
+btrfs-balance(8)
+
+
+NAME
+
+btrfs-balance - balance btrfs filesystem
+
+SYNOPSIS
+
+'btrfs [filesystem] balance' subcommand|args
+
+DESCRIPTION
+---
+'btrfs balance' is used to balance chunks in a btrfs filesystem across
+multiple or even single device.
+
+SUBCOMMAND
+--
+path::
+Balance chunks across the devices *online*.
++
+'btrfs balance path' is deprecated,
+please use 'btrfs balance start' command instead.
+
+'start' [options] path::
+Balance chunks across the devices *online*.
++
+Balance and/or convert (change allocation profile of) chunks that
+passed all filters in a comma-separated list of filters for a
+particular chunk type.
+If filter list is not given balance all chunks of that type.
+In case none of the -d, -m or -s options is
+given balance all chunks in a filesystem.
++
+`Options`
++
+-d[filters]
+act on data chunks
+-m[filters]
+act on metadata chunks
+-s[filters]
+act on system chunks (only under -f)
+-v
+be verbose
+-f
+force reducing of metadata integrity
+
+'pause' path::
+Pause running balance.
+
+'cancel' path::
+Cancel running or paused balance.
+
+'resume' path::
+Resume interrupted balance.
+
+'status' [-v] path::
+Show status of running or paused balance.
++
+If '-v' option is given, output will be verbose.
+
+EXIT STATUS
+---
+'btrfs balance' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
-- 
1.9.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 03/27] btrfs-progs: Convert man page for filesystem subcommand.

2014-04-02 Thread Qu Wenruo
Convert man page for filesystem subcommand.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile |   2 +-
 Documentation/btrfs-filesystem.txt | 163 +
 2 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-filesystem.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 15c1679..1fa2b35 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -17,7 +17,7 @@ MAN8_TXT += btrfs.txt
 
 # Sub commands for btrfs
 MAN8_TXT += btrfs-subvolume.txt
-#MAN8_TXT += btrfs-filesystem.txt
+MAN8_TXT += btrfs-filesystem.txt
 #MAN8_TXT += btrfs-balance.txt
 #MAN8_TXT += btrfs-device.txt
 #MAN8_TXT += btrfs-scrub.txt
diff --git a/Documentation/btrfs-filesystem.txt 
b/Documentation/btrfs-filesystem.txt
new file mode 100644
index 000..de9b3f3
--- /dev/null
+++ b/Documentation/btrfs-filesystem.txt
@@ -0,0 +1,163 @@
+btrfs-filesystem(8)
+===
+
+NAME
+
+btrfs-filesystem - control btrfs filesystem
+
+SYNOPSIS
+
+'btrfs filesystem' subcommand args
+
+DESCRIPTION
+---
+'btrfs filesystem' is used to do the filesystem level control jobs, including
+all the regular filesystem operations like setting/getting label,
+resizing, defragment.
+
+SUBCOMMAND
+--
+'df' [-b] path [path...]::
+Show space usage information for a mount point.
++
+If '-b' is given, then byte is used as unit. Default unit will be
+human-readable unit such as KiB/MiB/GiB.
++
+The command 'btrfs filesystem df' is used to query how many space on the 
+disk(s) are used and an estimation of the free
+space of the filesystem.
+The output of the command 'btrfs filesystem df' shows:
+
+`Disk size`
+the total size of the disks which compose the filesystem.
+
+`Disk allocated`
+the size of the area of the disks used by the chunks.
+
+`Disk unallocated`
+the size of the area of the disks which is free (i.e.
+the differences of the values above).
+
+`Used`
+the portion of the logical space used by the file and metadata.
+
+`Free (estimated)`
+the estimated free space available: i.e. how many space can be used
+by the user. The evaluation cannot be rigorous because it depends by the
+allocation policy (DUP, Single, RAID1...) of the metadata and data chunks. +
+If every chunk is stored as Single the sum of the free (estimated) space
+and the used space  is equal to the disk size.
+Otherwise if all the chunk are mirrored (raid1 or raid10) or duplicated
+the sum of the free (estimated) space and the used space is
+half of the disk size. Normally the free (estimated) is between
+these two limits.
+
+`Data to disk ratio`
+the ratio betwen the logical size (i.e. the space available by
+the chunks) and the disk allocated (by the chunks). Normally it is 
+lower than 100% because the metadata is duplicated for security reasons.
+If all the data and metadata are duplicated (or have a profile like RAID1)
+the Data to disk ratio could be 50%.
+
+'show' [--mounted|--all-devices|path|uuid|device|lable]::
+Show the btrfs filesystem with some additional info.
++
+If no option nor path|uuid|device|lable is passed, btrfs shows
+information of all the btrfs filesystem both mounted and unmounted.
+If '--mounted' is passed, it would probe btrfs kernel to list mounted btrfs
+filesystem(s);
+If '--all-devices' is passed, all the devices under /dev are scanned;
+otherwise the devices list is extracted from the /proc/partitions file.
+
+'sync' path::
+Force a sync for the filesystem identified by path.
+
+'defragment' [options] file|dir [file|dir...]::
+Defragment file data and/or directory metadata *online*.
++
+If '-r' is passed, files in dir will be defragmented recursively.
+The start position and the number of bytes to defragment can be specified by
+start and len using '-s' and '-l' options below.
+Any extent bigger than threshold given by '-t' option, will be considered
+already defragged.
+Use 0 to take the kernel default, and use 1 to
+say every single extent must be rewritten.
+You can also turn on compression in defragment operations.
++
+`Options`
++
+-v
+be verbose
+-c
+compress file contents while defragmenting
+-r
+defragment files recursively
+-f
+flush filesystem after defragmenting
+-s start
+defragment only from byte start onward
+-l len
+defragment only up to len bytes
+-t size
+defragment only files at least size bytes big
++
+For start, len, size it is possible to append a suffix
+like 'k' for 1 KBytes, 'm' for 1 MBytes...
++
+WARNING: defragmenting with kernels up to 2.6.37 will unlink COW-ed copies of 
data,
+don't use it if you use snapshots, have de-duplicated your data or made
+copies with `cp --reflink`.
+
+// Some wording are extracted by the resize2fs man page
+'resize' [devid:][+/-]size[gkm]|[devid:]max path::
+Resize a filesystem identified by path for the underlying device
+devid *online*. +
+The devid can be found with 'btrfs filesystem 

[PATCH 13/27] btrfs-progs: Convert and enhance the man page of btrfs-qgroup.

2014-04-02 Thread Qu Wenruo
Convert and enhance the man page of btrfs-qgroup.

The original man page for btrfs-qgroup subcommand is almost useless for
new user(like me), so adds more information on it.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile |   1 +
 Documentation/btrfs-qgroup.txt | 110 +
 2 files changed, 111 insertions(+)
 create mode 100644 Documentation/btrfs-qgroup.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 645a8e4..84a4859 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -27,6 +27,7 @@ MAN8_TXT += btrfs-inspect-internal.txt
 MAN8_TXT += btrfs-send.txt
 MAN8_TXT += btrfs-receive.txt
 MAN8_TXT += btrfs-quota.txt
+MAN8_TXT += btrfs-qgroup.txt
 #MAN8_TXT += btrfs-replace.txt
 #MAN8_TXT += btrfs-dedup.txt
 
diff --git a/Documentation/btrfs-qgroup.txt b/Documentation/btrfs-qgroup.txt
new file mode 100644
index 000..d054423
--- /dev/null
+++ b/Documentation/btrfs-qgroup.txt
@@ -0,0 +1,110 @@
+btrfs-qgroup(8)
+===
+
+NAME
+
+btrfs-qgroup - control the quota group of a btrfs filesystem
+
+SYNOPSIS
+
+'btrfs qgroup' subcommand args
+
+DESCRIPTION
+---
+'btrfs qgroup' is used to control quota group(qgroup) of a btrfs filesystem.
+
+NOTE: To use qgroup, it needs to enable quota first using 'btrfs quota'
+command.
+
+WARNING: Qgroup is not stable yet and will impact performance in current 
mainline
+kernel(v3.14 so far).
+
+QGROUP
+--
+Quota group or qgroup in btrfs has its hierarchy like subvolume.
+One subvolume/snapshot can reach its quota limits if it consumes all the quota
+assigned to it or any of the parent qgroup(s).
+
+Also for snapshot, it consumes no quota initially since all its data
+shares with its parent, so only modification in snapshot consumes quota.
+
+Every subvolume/snapshot will have its own qgroup with id '0/subvolume id'
+upon creating, but can be later destroyed by 'btrfs qgroup destroy' command.
+
+NOTE: If the qgroup of a subvolume is destroyed, quota about the subvolume
+will not be functional until qgroup '0/subvolume id' is created again.
+
+SUBCOMMAND
+--
+'assign' src dst path::
+Assign qgroup src as the child qgroup of dst in the btrfs filesystem
+identified by path.
+
+'remove' src dst path::
+Remove the relationship between child qgroup src and parent qgroup dst in
+the btrfs filesystem identified by path.
+
+'create' qgroupid path::
+Create a subvolume quota group.
++
+For the '0/subvolume id' qgroup, a qgroup can be created even before the
+subvolume created.
+
+'destroy' qgroupid path::
+Destroy a qgroup.
++
+If a qgroup is no isolated,which means it is a parent or child qgroup, it
+can't be destroyed.
+
+'show' [options] path::
+Show all qgroups in the btrfs filesystem identified by path.
++
+`Options`
++
+-p
+print parent qgroup id.
+-c
+print child qgroup id.
+-r
+print max referenced size of qgroup.
+-e
+print max exclusive size of qgroup.
+-F
+list all qgroups which impact the given path(include ancestral qgroups)
+-f
+list all qgroups which impact the given path(exclude ancestral qgroups)
+--sort=[\+/-]ATTR[,[+/-]ATTR]...
+list qgroups in order of ATTR.
++
+ATTR can be one or more of qgroupid,rfer,excl,max_rfer,max_excl.
++
+Prefix \'+' means ascending order and \'-' means descending order of ATTR.
+If no prefix is given, use ascending order by default.
++
+If multiple ATTRs is given, use comma to separate.
+
+'limit' [options] size|none [qgroupid] path::
+Limit the size of a qgroup to size or no limit in the btrfs filesystem
+identified by path.
++
+If qgroupid is not given, qgroup of the subvolume identified by path
+is used if possible.
+
+EXIT STATUS
+---
+'btrfs qgroup' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
+`btrfs-subvolume`(8),
+`btrfs-quota`(8),
-- 
1.9.1

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


[PATCH 06/27] btrfs-progs: Convert man page for btrfs-scrub

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-scrub.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile|  2 +-
 Documentation/btrfs-scrub.txt | 98 +++
 2 files changed, 99 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-scrub.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 79ae9de..68b7e1f 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -20,7 +20,7 @@ MAN8_TXT += btrfs-subvolume.txt
 MAN8_TXT += btrfs-filesystem.txt
 MAN8_TXT += btrfs-balance.txt
 MAN8_TXT += btrfs-device.txt
-#MAN8_TXT += btrfs-scrub.txt
+MAN8_TXT += btrfs-scrub.txt
 #MAN8_TXT += btrfs-check.txt
 #MAN8_TXT += btrfs-rescue.txt
 #MAN8_TXT += btrfs-inspect-internal.txt
diff --git a/Documentation/btrfs-scrub.txt b/Documentation/btrfs-scrub.txt
new file mode 100644
index 000..3973f31
--- /dev/null
+++ b/Documentation/btrfs-scrub.txt
@@ -0,0 +1,98 @@
+btrfs-scrub(8)
+==
+
+NAME
+
+btrfs-scrub - scrub btrfs filesystem
+
+SYNOPSIS
+
+'btrfs scrub' subcommand args
+
+DESCRIPTION
+---
+'btrfs scrub' is used to scrub a btrfs filesystem, which will reading all data
+from all disks and verifying checksums.
+
+SUBCOMMAND
+--
+'start' [-BdqrRf] [-c ioprio_class -n ioprio_classdata] path|device::
+Start a scrub on all devices of the filesystem identified by path or on
+a single device.
++
+Without options, scrub is started as a background process.
+Progress can be obtained with the 'scrub status' command. Scrubbing
+involves reading all data from all disks and verifying checksums. Errors are
+corrected along the way if possible.
++
+The default IO priority of scrub is the idle class. The priority can be
+configured similar to the `ionice`(1) syntax using '-c' and '-n' options.
++
+`Options`
++
+-B
+Do not background and print scrub statistics when finished.
+-d
+Print separate statistics for each device of the filesystem (-B only).
+-q
+Quiet. Omit error messages and statistics.
+-r
+Read only mode. Do not attempt to correct anything.
+-R
+Raw print mode. Print full data instead of summary.
+-c ioprio_class
+Set IO priority class (see
+ ionice (1)
+manpage).
+-n ioprio_classdata
+Set IO priority classdata (see `ionice`(1) manpage).
+-f
+force to check whether scrub has started or resumed in userspace.
+this is useful when scrub stat record file is damaged.
+
+'cancel' path|device::
+If a scrub is running on the filesystem identified by path, cancel it.
++
+Progress is saved in the scrub progress file and scrubbing can be resumed later
+using the scrub resume command.
+If a device is given, the corresponding filesystem is found and
+scrub cancel behaves as if it was called on that filesystem.
+
+'resume' [-BdqrR] [-c ioprio_class -n ioprio_classdata] path|device::
+Resume a canceled or interrupted scrub cycle on the filesystem identified by
+path or on a given device.
++
+Does not start a new scrub if the last scrub finished successfully.
++
+`Options`
++
+see 'scrub start'.
+
+'status' [-d] path|device::
+Show status of a running scrub for the filesystem identified by path or
+for the specified device.
++
+If no scrub is running, show statistics of the last finished or canceled scrub
+for that filesystem or device.
++
+`Options`
++
+-d
+Print separate statistics for each device of the filesystem.
+
+EXIT STATUS
+---
+'btrfs scrub' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
-- 
1.9.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 12/27] btrfs-progs: Convert man page for btrfs-quota.

2014-04-02 Thread Qu Wenruo
Convert man page for btrfs-quota.

Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com
---
 Documentation/Makefile|  2 +-
 Documentation/btrfs-quota.txt | 59 +++
 2 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/btrfs-quota.txt

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 2af4d40..645a8e4 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -26,7 +26,7 @@ MAN8_TXT += btrfs-rescue.txt
 MAN8_TXT += btrfs-inspect-internal.txt
 MAN8_TXT += btrfs-send.txt
 MAN8_TXT += btrfs-receive.txt
-#MAN8_TXT += btrfs-quota.txt
+MAN8_TXT += btrfs-quota.txt
 #MAN8_TXT += btrfs-replace.txt
 #MAN8_TXT += btrfs-dedup.txt
 
diff --git a/Documentation/btrfs-quota.txt b/Documentation/btrfs-quota.txt
new file mode 100644
index 000..82f2f49
--- /dev/null
+++ b/Documentation/btrfs-quota.txt
@@ -0,0 +1,59 @@
+btrfs-quota(8)
+==
+
+NAME
+
+btrfs-quota - control the quota of a btrfs filesystem
+
+SYNOPSIS
+
+'btrfs quota' subcommand args
+
+DESCRIPTION
+---
+'btrfs quota' is used to enable/disable or rescan subvolume quota of a btrfs
+filesystem.
+
+For setting quota or other quota operations on a btrfs filesystem, please see
+`btrfs-qgroup`(8) for details.
+
+WARNING: Quota and qgroup in btrfs filesystem is not stable and impacts
+performance in mainline kernel yet(v3.14 so far).
+
+SUBCOMMAND
+--
+'enable' path::
+Enable subvolume quota support for a filesystem.
+
+
+'disable' path::
+Disable subvolume quota support for a filesystem.
+
+'rescan' [-s] path::
+Trash all qgroup numbers and scan the metadata again with the current config.
++
+`Options`
++
+-s
+show status of a running rescan operation.
+-w
+wait for rescan operation to finish(can be already in progress).
+
+EXIT STATUS
+---
+'btrfs quota' returns a zero exist status if it succeeds. Non zero is
+returned in case of failure.
+
+AVAILABILITY
+
+'btrfs' is part of btrfs-progs. Btrfs filesystem is currently under heavy
+development,
+and not suitable for any uses other than benchmarking and review.
+Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
+further details.
+
+SEE ALSO
+
+`mkfs.btrfs`(8),
+`btrfs-subvolume`(8),
+`btrfs-qgroup`(8)
-- 
1.9.1

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


[PATCH v3] lib: add size unit t/p/e to memparse

2014-04-02 Thread Gui Hecheng
For modern filesystems such as btrfs, t/p/e size level operations
are common.
add size unit t/p/e parsing to memparse

Signed-off-by: Gui Hecheng guihc.f...@cn.fujitsu.com
---
changelog
v1-v2: replace kilobyte with kibibyte, and others
v2-v3: add missing unit bytes in comment
---
 lib/cmdline.c | 25 -
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/lib/cmdline.c b/lib/cmdline.c
index eb67911..511b9be 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -119,11 +119,17 @@ char *get_options(const char *str, int nints, int *ints)
  * @retptr: (output) Optional pointer to next char after parse completes
  *
  * Parses a string into a number.  The number stored at @ptr is
- * potentially suffixed with %K (for kilobytes, or 1024 bytes),
- * %M (for megabytes, or 1048576 bytes), or %G (for gigabytes, or
- * 1073741824).  If the number is suffixed with K, M, or G, then
- * the return value is the number multiplied by one kilobyte, one
- * megabyte, or one gigabyte, respectively.
+ * potentially suffixed with
+ * %K (for kibibytes, or 1024 bytes),
+ * %M (for mebibytes, or 1048576 bytes),
+ * %G (for gibibytes, or 1073741824 bytes),
+ * %T (for tebibytes, or 1099511627776 bytes),
+ * %P (for pebibytes, or 1125899906842624 bytes),
+ * %E (for exbibytes, or 1152921504606846976 bytes).
+ * If the number is suffixed with K, M, G, T, P, E, then
+ * the return value is the number multiplied by one kibibyte, one
+ * mebibyte, one gibibyte, one tebibyte, one pebibyte, one exbibyte,
+ * respectively.
  */
 
 unsigned long long memparse(const char *ptr, char **retptr)
@@ -133,6 +139,15 @@ unsigned long long memparse(const char *ptr, char **retptr)
unsigned long long ret = simple_strtoull(ptr, endptr, 0);
 
switch (*endptr) {
+   case 'E':
+   case 'e':
+   ret = 10;
+   case 'P':
+   case 'p':
+   ret = 10;
+   case 'T':
+   case 't':
+   ret = 10;
case 'G':
case 'g':
ret = 10;
-- 
1.8.1.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: avoid warning bomb of btrfs_delayed_inode_reserve_metadata

2014-04-02 Thread Liu Bo
When we nearly run out of global_block_rsv's reserved space, this WARNING will
be hit for thousands of times, which is not good because the kernel log has
nothing else.

Signed-off-by: Liu Bo bo.li@oracle.com
---
 fs/btrfs/delayed-inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 451b00c..32862f0 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -649,7 +649,7 @@ static int btrfs_delayed_inode_reserve_metadata(
goto out;
 
ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
-   if (!WARN_ON(ret))
+   if (!WARN_ON_ONCE(ret))
goto out;
 
/*
-- 
1.8.2.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 RFC] Btrfs: device_list_add() should not update list when mounted

2014-04-02 Thread Anand Jain
Device list add shouldn't update the list when FS is mounted,
unless the whole loop w.r.t to bringing back the missing disk
is completed. (That is making it to be part of the group profile
and the code for this isn't there yet).

As as of now (without this patch) when device is scanned with
missing disk, it would update in the device list but the disk
is left unused, it won't be opened by the btrfs and won't be
part of the btrfs group profile operation.

reproducer 1:
 mkfs.btrfs -draid1 -mraid1 /dev/sdb /dev/sdc
 modprobe -r btrfs
 mount -o degraded /dev/sdb /btrfs
 btrfs dev scan /dev/sdc

 use btrfs-devlist (or any of your method) to know that
 /dev/sdc isn't actually part of the above FS, (though now
 the missing disk path is updated in the btrfs_fs_devices)
 whats more btrfs kernel didn't open it all.

 And so mkfs.ext4 can be successfully be created on /dev/sdc,
 whereas it fails on /dev/sdb

reproducer 2:
disappear a disk then replace (RAID1) the disappeared disk
and then make the disappeared disk to reappear.


 mkfs.btrfs -f -m raid1 -d raid1 /dev/sdc /dev/sdd
 mount /dev/sdc /btrfs
 dd if=/dev/zero of=/btrfs/tf1 count=1
 btrfs fi sync /btrfs
---

devmgt[1] will help to attach or detach a disk easily

--
 devmgt show
 devmgt detach /dev/sdc
--

btrfs sill unaware of device missing (but thats not the point)
--
 btrfs fi show -m
Label: none  uuid: 5dc0aaf4-4683-4050-b2d6-5ebe5f5cd120
Total devices 2 FS bytes used 32.00KiB
devid1 size 958.94MiB used 115.88MiB path /dev/sdc --
devid2 size 958.94MiB used 103.88MiB path /dev/sdd

 btrfs rep start -f 1 /dev/sde /btrfs
Label: none  uuid: 5dc0aaf4-4683-4050-b2d6-5ebe5f5cd120
Total devices 2 FS bytes used 32.00KiB
devid1 size 958.94MiB used 115.88MiB path /dev/sde
devid2 size 958.94MiB used 103.88MiB path /dev/sdd
--

so far good. now missing /dev/sdc comes-back.

---
 devmgt attach host2

btrfs fi show -m shows sdc
Label: none  uuid: 5dc0aaf4-4683-4050-b2d6-5ebe5f5cd120^M
Total devices 2 FS bytes used 32.00KiB^M
devid1 size 958.94MiB used 115.88MiB path /dev/sdc - Wrong.
devid2 size 958.94MiB used 103.88MiB path /dev/sdd
---

this is wrong it should be sde. this happened because when
disk comes back device_list_add() is called which would invariably
replace the existing disk with the given disk with the same fsid/devid.
But the actual IO is still going to sde not to sdc.

Further when we start fresh with (modprobe -r btrfs)
unless it is carefully managed using btrfs dev scan dev
it may pair with wrong disk (there will be a new patch
to fix this).

This patch is hand tested with the related device operations
viz device del, device add, replace, device scan, replace missing.

[1] github.com/anajain/devmgt.git

Signed-off-by: Anand Jain anand.j...@oracle.com
---
 fs/btrfs/volumes.c |   25 -
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index dbb91f0..59a49b2 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -472,9 +472,12 @@ static noinline int device_list_add(const char *path,
device = __find_device(fs_devices-devices, devid,
   disk_super-dev_item.uuid);
}
+
if (!device) {
-   if (fs_devices-opened)
+   if (fs_devices-opened) {
+   printk(KERN_INFO BTRFS: device list add failed, FS is 
open);
return -EBUSY;
+   }
 
device = btrfs_alloc_device(NULL, devid,
disk_super-dev_item.uuid);
@@ -497,6 +500,26 @@ static noinline int device_list_add(const char *path,
 
device-fs_devices = fs_devices;
} else if (!device-name || strcmp(device-name-str, path)) {
+   /*
+   * As of now this function doesn't support modifying the
+   * device list when the FS is in operation (mounted/opened)
+   * Also the below code to bring back the missing disk
+   * is incomplete (when fs is mounted) since it doesn't handle
+   * rest of the group profile fixups as part of 
missing-disk-reappearing,
+   * until we fix that we would return busy, this implies that user
+   * should use operations like '{btrfs} device add',
+   * 'device delete', 'device delete missing' to operate mounted 
disks,
+   * but they won't be able to use 'device scan' to update the 
device list
+   * of a mounted btrfs. Further when there are two disks with 
same devid
+   * and uuid (in some scenario) we want to avoid one of the other 
disk
+   * to replace the disk in operation using btrfs dev scan.
+   */
+
+   if (fs_devices-opened) {
+   printk(KERN_INFO BTRFS: device list update failed, FS 

[PATCH RFC v2] Btrfs: device_list_add() should not update list when mounted

2014-04-02 Thread Anand Jain
Device list add shouldn't update the list when FS is mounted,
unless the whole loop w.r.t to bringing back the missing disk
is completed. (That is making it to be part of the group profile
and the code for this isn't there yet).

As as of now (without this patch) when device is scanned with
missing disk, it would update in the device list but the disk
is left unused, it won't be opened by the btrfs and won't be
part of the btrfs group profile operation.

reproducer 1:
 mkfs.btrfs -draid1 -mraid1 /dev/sdb /dev/sdc
 modprobe -r btrfs
 mount -o degraded /dev/sdb /btrfs
 btrfs dev scan /dev/sdc

 use btrfs-devlist (or any of your method) to know that
 /dev/sdc isn't actually part of the above FS, (though now
 the missing disk path is updated in the btrfs_fs_devices)
 whats more btrfs kernel didn't open it all.

 And so mkfs.ext4 can be successfully be created on /dev/sdc,
 whereas it fails on /dev/sdb

reproducer 2:
disappear a disk then replace (RAID1) the disappeared disk
and then make the disappeared disk to reappear.

 mkfs.btrfs -f -m raid1 -d raid1 /dev/sdc /dev/sdd
 mount /dev/sdc /btrfs
 dd if=/dev/zero of=/btrfs/tf1 count=1
 btrfs fi sync /btrfs

devmgt[1] will help to attach or detach a disk easily

 devmgt show
 devmgt detach /dev/sdc

btrfs sill unaware of device missing (but thats not the point)

 btrfs fi show -m
Label: none  uuid: 5dc0aaf4-4683-4050-b2d6-5ebe5f5cd120
Total devices 2 FS bytes used 32.00KiB
devid1 size 958.94MiB used 115.88MiB path /dev/sdc --
devid2 size 958.94MiB used 103.88MiB path /dev/sdd

 btrfs rep start -f 1 /dev/sde /btrfs
Label: none  uuid: 5dc0aaf4-4683-4050-b2d6-5ebe5f5cd120
Total devices 2 FS bytes used 32.00KiB
devid1 size 958.94MiB used 115.88MiB path /dev/sde
devid2 size 958.94MiB used 103.88MiB path /dev/sdd

so far good. now missing /dev/sdc comes-back.

 devmgt attach host2

btrfs fi show -m shows sdc
Label: none  uuid: 5dc0aaf4-4683-4050-b2d6-5ebe5f5cd120^M
Total devices 2 FS bytes used 32.00KiB^M
devid1 size 958.94MiB used 115.88MiB path /dev/sdc - Wrong.
devid2 size 958.94MiB used 103.88MiB path /dev/sdd

this is wrong it should be sde. this happened because when
disk comes back device_list_add() is called which would invariably
replace the existing disk with the given disk with the same fsid/devid.
But the actual IO is still going to sde not to sdc.

Further when we start fresh with (modprobe -r btrfs)
unless it is carefully managed using btrfs dev scan dev
it may pair with wrong disk (there will be a new patch
to fix this).

This patch is hand tested with the related device operations
viz device del, device add, replace, device scan, replace missing.

[1] github.com/anajain/devmgt.git

Signed-off-by: Anand Jain anand.j...@oracle.com
---

v1-v2: remove '---' in commit messages which conflict with git am

 fs/btrfs/volumes.c |   25 -
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index dbb91f0..59a49b2 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -472,9 +472,12 @@ static noinline int device_list_add(const char *path,
device = __find_device(fs_devices-devices, devid,
   disk_super-dev_item.uuid);
}
+
if (!device) {
-   if (fs_devices-opened)
+   if (fs_devices-opened) {
+   printk(KERN_INFO BTRFS: device list add failed, FS is 
open);
return -EBUSY;
+   }
 
device = btrfs_alloc_device(NULL, devid,
disk_super-dev_item.uuid);
@@ -497,6 +500,26 @@ static noinline int device_list_add(const char *path,
 
device-fs_devices = fs_devices;
} else if (!device-name || strcmp(device-name-str, path)) {
+   /*
+   * As of now this function doesn't support modifying the
+   * device list when the FS is in operation (mounted/opened)
+   * Also the below code to bring back the missing disk
+   * is incomplete (when fs is mounted) since it doesn't handle
+   * rest of the group profile fixups as part of 
missing-disk-reappearing,
+   * until we fix that we would return busy, this implies that user
+   * should use operations like '{btrfs} device add',
+   * 'device delete', 'device delete missing' to operate mounted 
disks,
+   * but they won't be able to use 'device scan' to update the 
device list
+   * of a mounted btrfs. Further when there are two disks with 
same devid
+   * and uuid (in some scenario) we want to avoid one of the other 
disk
+   * to replace the disk in operation using btrfs dev scan.
+   */
+
+   if (fs_devices-opened) {
+   printk(KERN_INFO 

[PATCH] Btrfs: use helpers for last_trans_log_full_commit instead of opencode

2014-04-02 Thread Wang Shilong
From: Miao Xie mi...@cn.fujitsu.com

Signed-off-by: Miao Xie mi...@cn.fujitsu.com
Signed-off-by: Wang Shilong wangsl.f...@cn.fujitsu.com
---
 fs/btrfs/extent-tree.c |  5 ++---
 fs/btrfs/inode.c   |  2 +-
 fs/btrfs/tree-log.c| 40 +---
 fs/btrfs/tree-log.h| 16 
 4 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 7e3e4f1..1b3ea77 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -26,10 +26,9 @@
 #include linux/ratelimit.h
 #include linux/percpu_counter.h
 #include hash.h
-#include ctree.h
+#include tree-log.h
 #include disk-io.h
 #include print-tree.h
-#include transaction.h
 #include volumes.h
 #include raid56.h
 #include locking.h
@@ -8600,7 +8599,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle 
*trans,
 
extent_root = root-fs_info-extent_root;
 
-   root-fs_info-last_trans_log_full_commit = trans-transid;
+   btrfs_set_log_full_commit(root-fs_info, trans);
 
cache = btrfs_create_block_group_cache(root, chunk_offset, size);
if (!cache)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f713d95..70d826b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8296,7 +8296,7 @@ static int btrfs_rename(struct inode *old_dir, struct 
dentry *old_dentry,
BTRFS_I(old_inode)-dir_index = 0ULL;
if (unlikely(old_ino == BTRFS_FIRST_FREE_OBJECTID)) {
/* force full log commit if subvolume involved. */
-   root-fs_info-last_trans_log_full_commit = trans-transid;
+   btrfs_set_log_full_commit(root-fs_info, trans);
} else {
ret = btrfs_insert_inode_ref(trans, dest,
 new_dentry-d_name.name,
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index ffee158..9e1f2cd 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -20,13 +20,11 @@
 #include linux/slab.h
 #include linux/blkdev.h
 #include linux/list_sort.h
-#include ctree.h
-#include transaction.h
+#include tree-log.h
 #include disk-io.h
 #include locking.h
 #include print-tree.h
 #include backref.h
-#include tree-log.h
 #include hash.h
 
 /* magic values for the inode_only field in btrfs_log_inode:
@@ -144,12 +142,10 @@ static int start_log_trans(struct btrfs_trans_handle 
*trans,
 
mutex_lock(root-log_mutex);
if (root-log_root) {
-   if (ACCESS_ONCE(root-fs_info-last_trans_log_full_commit) ==
-   trans-transid) {
+   if (btrfs_need_log_full_commit(root-fs_info, trans)) {
ret = -EAGAIN;
goto out;
}
-
if (!root-log_start_pid) {
root-log_start_pid = current-pid;
clear_bit(BTRFS_ROOT_MULTI_LOG_TASKS, root-state);
@@ -2512,8 +2508,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
}
 
/* bail out if we need to do a full commit */
-   if (ACCESS_ONCE(root-fs_info-last_trans_log_full_commit) ==
-   trans-transid) {
+   if (btrfs_need_log_full_commit(root-fs_info, trans)) {
ret = -EAGAIN;
btrfs_free_logged_extents(log, log_transid);
mutex_unlock(root-log_mutex);
@@ -2534,8 +2529,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
blk_finish_plug(plug);
btrfs_abort_transaction(trans, root, ret);
btrfs_free_logged_extents(log, log_transid);
-   ACCESS_ONCE(root-fs_info-last_trans_log_full_commit) =
-   trans-transid;
+   btrfs_set_log_full_commit(root-fs_info, trans);
mutex_unlock(root-log_mutex);
goto out;
}
@@ -2578,8 +2572,8 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
list_del_init(root_log_ctx.list);
 
blk_finish_plug(plug);
-   ACCESS_ONCE(root-fs_info-last_trans_log_full_commit) =
-   trans-transid;
+   btrfs_set_log_full_commit(root-fs_info, trans);
+
if (ret != -ENOSPC) {
btrfs_abort_transaction(trans, root, ret);
mutex_unlock(log_root_tree-log_mutex);
@@ -2623,8 +2617,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
 * now that we've moved on to the tree of log tree roots,
 * check the full commit flag again
 */
-   if (ACCESS_ONCE(root-fs_info-last_trans_log_full_commit) ==
-   trans-transid) {
+   if (btrfs_need_log_full_commit(root-fs_info, trans)) {
blk_finish_plug(plug);
btrfs_wait_marked_extents(log, log-dirty_log_pages, mark);
btrfs_free_logged_extents(log, log_transid);
@@ -2638,8 +2631,7 @@ int 

[PATCH v2 4/9] Btrfs: use bitfield instead of integer data type for the some variants in btrfs_root

2014-04-02 Thread Wang Shilong
From: Miao Xie mi...@cn.fujitsu.com

Signed-off-by: Miao Xie mi...@cn.fujitsu.com
Signed-off-by: Wang Shilong wangsl.f...@cn.fujitsu.com
---
v1-v2: fix wrong test where we should test @force_cow
while we test @root_refs(Thanks to Josef)
---
 fs/btrfs/ctree.c   | 25 ++---
 fs/btrfs/ctree.h   | 39 +--
 fs/btrfs/disk-io.c | 33 +++--
 fs/btrfs/extent-tree.c |  6 +++---
 fs/btrfs/file.c|  4 +++-
 fs/btrfs/inode.c   | 29 ++---
 fs/btrfs/ioctl.c   |  4 ++--
 fs/btrfs/relocation.c  | 17 +
 fs/btrfs/root-tree.c   |  2 +-
 fs/btrfs/transaction.c | 33 +
 fs/btrfs/tree-defrag.c |  2 +-
 fs/btrfs/tree-log.c|  9 +
 12 files changed, 109 insertions(+), 94 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 88d1b1e..b4cb3c3 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -224,7 +224,8 @@ static struct extent_buffer 
*btrfs_read_lock_root_node(struct btrfs_root *root)
 static void add_root_to_dirty_list(struct btrfs_root *root)
 {
spin_lock(root-fs_info-trans_lock);
-   if (root-track_dirty  list_empty(root-dirty_list)) {
+   if (test_bit(BTRFS_ROOT_TRACK_DIRTY, root-state) 
+   list_empty(root-dirty_list)) {
list_add(root-dirty_list,
 root-fs_info-dirty_cowonly_roots);
}
@@ -246,9 +247,10 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
int level;
struct btrfs_disk_key disk_key;
 
-   WARN_ON(root-ref_cows  trans-transid !=
-   root-fs_info-running_transaction-transid);
-   WARN_ON(root-ref_cows  trans-transid != root-last_trans);
+   WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, root-state) 
+   trans-transid != root-fs_info-running_transaction-transid);
+   WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, root-state) 
+   trans-transid != root-last_trans);
 
level = btrfs_header_level(buf);
if (level == 0)
@@ -997,14 +999,14 @@ int btrfs_block_can_be_shared(struct btrfs_root *root,
 * snapshot and the block was not allocated by tree relocation,
 * we know the block is not shared.
 */
-   if (root-ref_cows 
+   if (test_bit(BTRFS_ROOT_REF_COWS, root-state) 
buf != root-node  buf != root-commit_root 
(btrfs_header_generation(buf) =
 btrfs_root_last_snapshot(root-root_item) ||
 btrfs_header_flag(buf, BTRFS_HEADER_FLAG_RELOC)))
return 1;
 #ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-   if (root-ref_cows 
+   if (test_bit(BTRFS_ROOT_REF_COWS, root-state) 
btrfs_header_backref_rev(buf)  BTRFS_MIXED_BACKREF_REV)
return 1;
 #endif
@@ -1146,9 +1148,10 @@ static noinline int __btrfs_cow_block(struct 
btrfs_trans_handle *trans,
 
btrfs_assert_tree_locked(buf);
 
-   WARN_ON(root-ref_cows  trans-transid !=
-   root-fs_info-running_transaction-transid);
-   WARN_ON(root-ref_cows  trans-transid != root-last_trans);
+   WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, root-state) 
+   trans-transid != root-fs_info-running_transaction-transid);
+   WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, root-state) 
+   trans-transid != root-last_trans);
 
level = btrfs_header_level(buf);
 
@@ -1193,7 +1196,7 @@ static noinline int __btrfs_cow_block(struct 
btrfs_trans_handle *trans,
return ret;
}
 
-   if (root-ref_cows) {
+   if (test_bit(BTRFS_ROOT_REF_COWS, root-state)) {
ret = btrfs_reloc_cow_block(trans, root, buf, cow);
if (ret)
return ret;
@@ -1556,7 +1559,7 @@ static inline int should_cow_block(struct 
btrfs_trans_handle *trans,
!btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN) 
!(root-root_key.objectid != BTRFS_TREE_RELOC_OBJECTID 
  btrfs_header_flag(buf, BTRFS_HEADER_FLAG_RELOC)) 
-   !root-force_cow)
+   !test_bit(BTRFS_ROOT_FORCE_COW, root-state))
return 0;
return 1;
 }
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 2a9d32e..8777b61 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1688,6 +1688,26 @@ struct btrfs_subvolume_writers {
 };
 
 /*
+ * The state of btrfs root
+ */
+/*
+ * btrfs_record_root_in_trans is a multi-step process,
+ * and it can race with the balancing code.   But the
+ * race is very small, and only the first time the root
+ * is added to each transaction.  So IN_TRANS_SETUP
+ * is used to tell us when more checks are required
+ */
+#define BTRFS_ROOT_IN_TRANS_SETUP  0
+#define BTRFS_ROOT_REF_COWS1
+#define BTRFS_ROOT_TRACK_DIRTY 2
+#define BTRFS_ROOT_IN_RADIX3
+#define BTRFS_ROOT_DUMMY_ROOT  4
+#define BTRFS_ROOT_ORPHAN_ITEM_INSERTED5
+#define 

[PATCH] Btrfs: fix unlock in __start_delalloc_inodes()

2014-04-02 Thread Wang Shilong
This patch fix a regression caused by the following patch:
Btrfs: don't flush all delalloc inodes when we doesn't get s_umount lock

break while loop will make us call @spin_unlock() without
calling @spin_lock() before, fix it.

Signed-off-by: Wang Shilong wangsl.f...@cn.fujitsu.com
---
 fs/btrfs/inode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5cb3075..f1e5297 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8481,19 +8481,20 @@ static int __start_delalloc_inodes(struct btrfs_root 
*root, int delay_iput,
else
iput(inode);
ret = -ENOMEM;
-   break;
+   goto out;
}
list_add_tail(work-list, works);
btrfs_queue_work(root-fs_info-flush_workers,
 work-work);
ret++;
if (nr != -1  ret = nr)
-   break;
+   goto out;
cond_resched();
spin_lock(root-delalloc_lock);
}
spin_unlock(root-delalloc_lock);
 
+out:
list_for_each_entry_safe(work, next, works, list) {
list_del_init(work-list);
btrfs_wait_and_free_delalloc_work(work);
-- 
1.9.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 00/27] Replace the old man page with asciidoc and man page for each btrfs subcommand.

2014-04-02 Thread Chris Mason

On 04/02/2014 04:29 AM, Qu Wenruo wrote:

Convert the old btrfs man pages to new asciidoc and split the huge
btrfs man page into subcommand man page.

The asciidoc style and Makefile things are mostly simplified from git
Documentation, which only supports man page output and remove html output,
since html output is somewhat overkilled for btrfs.


Thanks for doing this.  I've never liked roff, but I'll give people on 
the list a chance to complain before taking this one.


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


Re: [PATCH 00/27] Replace the old man page with asciidoc and man page for each btrfs subcommand.

2014-04-02 Thread Marc MERLIN
On Wed, Apr 02, 2014 at 09:24:10AM -0400, Chris Mason wrote:
 On 04/02/2014 04:29 AM, Qu Wenruo wrote:
 Convert the old btrfs man pages to new asciidoc and split the huge
 btrfs man page into subcommand man page.
 
 The asciidoc style and Makefile things are mostly simplified from git
 Documentation, which only supports man page output and remove html output,
 since html output is somewhat overkilled for btrfs.
 
 Thanks for doing this.  I've never liked roff, but I'll give people
 on the list a chance to complain before taking this one.

1970's called and it wants it troff back :)

More seriously, thanks much for this patch, it makes the source man
pages easier to read and to edit, which is a great thing for keeping them
more up to date.

+10 here.

Marc
-- 
A mouse is a device used to point at the xterm you want to type in - A.S.R.
Microsoft is to operating systems 
   what McDonalds is to gourmet cooking
Home page: http://marc.merlins.org/ | PGP 1024R/763BE901
--
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 lockdep with 3.15 merge window v3.14-751-g683b6c6f82a6

2014-04-02 Thread David Sterba
On Tue, Apr 01, 2014 at 06:23:11PM -0400, Josh Boyer wrote:
 Below is a lockdep spew I have on a local VM running Linus' tree as of
 this afternoon.  The specific git commit is v3.14-751-g683b6c6f82a6.

 [  295.349016]CPU0CPU1
 [  295.349016]
 [  295.349016]   lock(found-groups_sem);
 [  295.349016]local_irq_disable();
 [  295.349016]lock(delayed_node-mutex);
 [  295.349016]lock(found-groups_sem);
 [  295.349016]   Interrupt
 [  295.349016] lock(delayed_node-mutex);

Fixed by https://patchwork.kernel.org/patch/3894781/
--
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 lockdep with 3.15 merge window v3.14-751-g683b6c6f82a6

2014-04-02 Thread Josh Boyer
On Wed, Apr 2, 2014 at 12:47 PM, David Sterba dste...@suse.cz wrote:
 On Tue, Apr 01, 2014 at 06:23:11PM -0400, Josh Boyer wrote:
 Below is a lockdep spew I have on a local VM running Linus' tree as of
 this afternoon.  The specific git commit is v3.14-751-g683b6c6f82a6.

 [  295.349016]CPU0CPU1
 [  295.349016]
 [  295.349016]   lock(found-groups_sem);
 [  295.349016]local_irq_disable();
 [  295.349016]lock(delayed_node-mutex);
 [  295.349016]lock(found-groups_sem);
 [  295.349016]   Interrupt
 [  295.349016] lock(delayed_node-mutex);

 Fixed by https://patchwork.kernel.org/patch/3894781/

Thanks for the pointer!  I'll grab that and give it a shot on my VM.

josh
--
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: avoid warning bomb of btrfs_delayed_inode_reserve_metadata

2014-04-02 Thread David Sterba
On Wed, Apr 02, 2014 at 05:41:10PM +0800, Liu Bo wrote:
 When we nearly run out of global_block_rsv's reserved space, this WARNING will
 be hit for thousands of times, which is not good because the kernel log has
 nothing else.
 
   ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
 - if (!WARN_ON(ret))
 + if (!WARN_ON_ONCE(ret))
   goto out;

The warning has been mistakenly added in

fae7f21cece9a4c181
btrfs: Use WARN_ON()'s return value in place of WARN_ON(1)

@@ -649,14 +649,13 @@ static int btrfs_delayed_inode_reserve_metadata(
goto out;

ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
-   if (!ret)
+   if (!WARN_ON(ret))
goto out;

[previous WARN_ON removed a few lines below]
---

WARN_ON will trigger because it sees 'ret' though in the previous code
did not reach the WARN_ON below. The correct pattern is

-   if (condition)
+   if (WARN_ON(condition))

I haven't spotted any other bugs from the same class in the patch. I'll
send a fix and cc stable.
--
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 reversed warning condition in btrfs_delayed_inode_reserve_metadata

2014-04-02 Thread David Sterba
Commit fae7f21cece9a4c181 (btrfs: Use WARN_ON()'s return value in place of
WARN_ON(1)) cleaned up WARN_ON usage and in one place reversed the condition
that led to loads of warnings that were not supposed to occur.

WARN_ON will trigger because it sees 'ret' though in the previous code
did not reach the WARN_ON below. The correct pattern is

-   if (condition)
+   if (WARN_ON(condition))

CC: Dulshani Gunawardhana dulshani.gunawardhan...@gmail.com
CC: sta...@vger.kernel.org # 3.13
Reported-by: Liu Bo bo.li@oracle.com
Signed-off-by: David Sterba dste...@suse.cz
---
 fs/btrfs/delayed-inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 451b00c86f6c..098af20abd88 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -649,7 +649,7 @@ static int btrfs_delayed_inode_reserve_metadata(
goto out;
 
ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
-   if (!WARN_ON(ret))
+   if (WARN_ON(!ret))
goto out;
 
/*
-- 
1.9.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 00/27] Replace the old man page with asciidoc and man page for each btrfs subcommand.

2014-04-02 Thread David Sterba
On Wed, Apr 02, 2014 at 04:29:11PM +0800, Qu Wenruo wrote:
 Convert the old btrfs man pages to new asciidoc and split the huge
 btrfs man page into subcommand man page.

Excellent!

 The asciidoc style and Makefile things are mostly simplified from git
 Documentation, which only supports man page output and remove html output,
 since html output is somewhat overkilled for btrfs.

Well, I've been thinking about automatically pushing the man pages to
wiki, with asciidoc it would be much easier, the formatting capabilities
are better than what *roff provides.

 1) More human-readable raw documentations.
   The roff grammar is not so easy to read, especially mixed with a lot
   of special words.
 
 2) Easier to modify man page.
   The old huge btrfs man page makes it hard to maintain.
   It's common that some one adds some new options, but only modifies
   the detailed options but not the 'SYNOPSIS' section.

I hope both points will encourage more people to contribute to the
documentation.
--
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


Space cache degradation

2014-04-02 Thread Justin Maggard
I've found that, after using some btrfs filesystems for some time,
that the first large write after a reboot takes a very long time.  So
I went to work trying out different test cases to simplify
reproduction of the issue, and I've got it down to just these steps:

1) mkfs.btrfs on a large-ish device.  I used a 14TB MD RAID5 device.
2) Fill it up a bit over half-way with ~5MB files.  In my test I made
30 copies of a 266GB data set consisting of 52,356 files and 20,268
folders.
3) umount
4) mount
5) time fallocate -l 2G /mount/point/2G.dat
real 3m9.412s
user 0m0.002s
sys 0m2.939s

By comparison, if I don't use space cache things go much better:
# umount
# mount -o nospace_cache
# time fallocate -l 2G /mount/point/2G.dat
real 0m15.982s
user 0m0.002s
sys 0m0.103s

If I use the clear_cache mount option, that also resolves the slowness.

Is this a known issue?  For me it's 100% reproducible, on various
kernel versions including 3.14-rc8.  Is there anything I should
provide to help debug?

-Justin
--
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: Space cache degradation

2014-04-02 Thread Chris Mason



On 04/02/2014 01:54 PM, Justin Maggard wrote:

I've found that, after using some btrfs filesystems for some time,
that the first large write after a reboot takes a very long time.  So
I went to work trying out different test cases to simplify
reproduction of the issue, and I've got it down to just these steps:

1) mkfs.btrfs on a large-ish device.  I used a 14TB MD RAID5 device.
2) Fill it up a bit over half-way with ~5MB files.  In my test I made
30 copies of a 266GB data set consisting of 52,356 files and 20,268
folders.
3) umount
4) mount
5) time fallocate -l 2G /mount/point/2G.dat
real 3m9.412s
user 0m0.002s
sys 0m2.939s

By comparison, if I don't use space cache things go much better:
# umount
# mount -o nospace_cache
# time fallocate -l 2G /mount/point/2G.dat
real 0m15.982s
user 0m0.002s
sys 0m0.103s

If I use the clear_cache mount option, that also resolves the slowness.

Is this a known issue?  For me it's 100% reproducible, on various
kernel versions including 3.14-rc8.  Is there anything I should
provide to help debug?



Neat, not a known issue.  What's probably happening is that without 
space cache on, you're jumping out into unused space while it 
regenerates the space cache.  Once the caching thread is done caching 
all the free space, you should go slowly again.


I'll try to reproduce.

-chris



--
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 lockdep with 3.15 merge window v3.14-751-g683b6c6f82a6

2014-04-02 Thread Josh Boyer
On Wed, Apr 2, 2014 at 12:56 PM, Josh Boyer jwbo...@fedoraproject.org wrote:
 On Wed, Apr 2, 2014 at 12:47 PM, David Sterba dste...@suse.cz wrote:
 On Tue, Apr 01, 2014 at 06:23:11PM -0400, Josh Boyer wrote:
 Below is a lockdep spew I have on a local VM running Linus' tree as of
 this afternoon.  The specific git commit is v3.14-751-g683b6c6f82a6.

 [  295.349016]CPU0CPU1
 [  295.349016]
 [  295.349016]   lock(found-groups_sem);
 [  295.349016]local_irq_disable();
 [  295.349016]lock(delayed_node-mutex);
 [  295.349016]lock(found-groups_sem);
 [  295.349016]   Interrupt
 [  295.349016] lock(delayed_node-mutex);

 Fixed by https://patchwork.kernel.org/patch/3894781/

 Thanks for the pointer!  I'll grab that and give it a shot on my VM.

FWIW, this does seem to make the issue go away in my VM after testing
it for a while.  Thanks again for the pointer.

josh
--
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 lockdep with 3.15 merge window v3.14-751-g683b6c6f82a6

2014-04-02 Thread Chris Mason

On 04/02/2014 12:47 PM, David Sterba wrote:

On Tue, Apr 01, 2014 at 06:23:11PM -0400, Josh Boyer wrote:

Below is a lockdep spew I have on a local VM running Linus' tree as of
this afternoon.  The specific git commit is v3.14-751-g683b6c6f82a6.



[  295.349016]CPU0CPU1
[  295.349016]
[  295.349016]   lock(found-groups_sem);
[  295.349016]local_irq_disable();
[  295.349016]lock(delayed_node-mutex);
[  295.349016]lock(found-groups_sem);
[  295.349016]   Interrupt
[  295.349016] lock(delayed_node-mutex);


Fixed by 
https://urldefense.proofpoint.com/v1/url?u=https://patchwork.kernel.org/patch/3894781/k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0Ar=6%2FL0lzzDhu0Y1hL9xm%2BQyA%3D%3D%0Am=R1vuFCUzlD4QksU2UH3APFiFgMVkwmMci%2Bktv%2BzqQnE%3D%0As=adbe2bfbb243d9781307cfff001f30c01afd35a32e0fb976ecca933ef4cebd26



I've got this lined up for my next pull as well.  I sent early this 
time, but more is going in.


-chris
--
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 reversed warning condition in btrfs_delayed_inode_reserve_metadata

2014-04-02 Thread Liu Bo
On Wed, Apr 02, 2014 at 07:13:00PM +0200, David Sterba wrote:
 Commit fae7f21cece9a4c181 (btrfs: Use WARN_ON()'s return value in place of
 WARN_ON(1)) cleaned up WARN_ON usage and in one place reversed the condition
 that led to loads of warnings that were not supposed to occur.
 
 WARN_ON will trigger because it sees 'ret' though in the previous code
 did not reach the WARN_ON below. The correct pattern is
 
 -   if (condition)
 +   if (WARN_ON(condition))
 

Reviewed-by: Liu Bo bo.li@oracle.com

 CC: Dulshani Gunawardhana dulshani.gunawardhan...@gmail.com
 CC: sta...@vger.kernel.org # 3.13
 Reported-by: Liu Bo bo.li@oracle.com
 Signed-off-by: David Sterba dste...@suse.cz
 ---
  fs/btrfs/delayed-inode.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
 index 451b00c86f6c..098af20abd88 100644
 --- a/fs/btrfs/delayed-inode.c
 +++ b/fs/btrfs/delayed-inode.c
 @@ -649,7 +649,7 @@ static int btrfs_delayed_inode_reserve_metadata(
   goto out;
  
   ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
 - if (!WARN_ON(ret))
 + if (WARN_ON(!ret))
   goto out;
  
   /*
 -- 
 1.9.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
-liubo
--
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 reversed warning condition in btrfs_delayed_inode_reserve_metadata

2014-04-02 Thread Liu Bo
On Wed, Apr 02, 2014 at 07:13:00PM +0200, David Sterba wrote:
 Commit fae7f21cece9a4c181 (btrfs: Use WARN_ON()'s return value in place of
 WARN_ON(1)) cleaned up WARN_ON usage and in one place reversed the condition
 that led to loads of warnings that were not supposed to occur.
 
 WARN_ON will trigger because it sees 'ret' though in the previous code
 did not reach the WARN_ON below. The correct pattern is
 
 -   if (condition)
 +   if (WARN_ON(condition))
 
 CC: Dulshani Gunawardhana dulshani.gunawardhan...@gmail.com
 CC: sta...@vger.kernel.org # 3.13
 Reported-by: Liu Bo bo.li@oracle.com
 Signed-off-by: David Sterba dste...@suse.cz
 ---
  fs/btrfs/delayed-inode.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
 index 451b00c86f6c..098af20abd88 100644
 --- a/fs/btrfs/delayed-inode.c
 +++ b/fs/btrfs/delayed-inode.c
 @@ -649,7 +649,7 @@ static int btrfs_delayed_inode_reserve_metadata(
   goto out;
  
   ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
 - if (!WARN_ON(ret))
 + if (WARN_ON(!ret))
   goto out;

Oh sorry, I'd have to get my Reviewed-by back and give a NACK instead.

With this patch, (ret = 0) triggers the WARNING, which is not right.

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