[PATCH 0/3 V3] btrfs: a new tool to manage a btrfs filesystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

enclosed in the next emails you can find the patches which introduce a new 
program called "btrfs". This program has the aim to replace the 
utilities of the btrfs-prog package, like:
- btrfsctl
- btrfs-show
- btrfs-volume
- btrfs

The goals are:
- improve the usability of the tools 
- add a man page which documents all the commands
- correct the btrfsctl return codes

I put a lot of attentions in order to avoid regression respect the old tools.
A clone of my git repository is available at

        http://cassiopea.homelinux.net/git/btrfs-command.git

(commit 874cca3025639d6343a57c3ff64a01d613b5e34a, remember to switch to the 
"remotes/origin/multi-level-command" branch (I hate git!!!)

on the basis of the suggestion received, I update my patches. From the 
previous patches (V2) the main changes are :
- removed the short form of the command (like '-C')
- deployed the "multi level" command (i.e.: btrfs snapshot create)
- split the source in two files. This because the new parses are quite big 
(about  295 lines; for example btrfsctl.c are only 239 lines).

The "multi level" command parser is quite flexible. They accepts the full-
length command (btrfs subvolume create) and a contract form (btrfs subvol cr). 
The commands may be arbitrary shortly (even 1 chars) but they have to be un-
ambiguous. For example
- btrfs s s 		-> OK (matches 'btrfs subvolume snapshot' only)
- btrfs filesystem s	-> FAIL (matches both 'btrfs filesystem show' and 
				'btrfs filesystem sync')

The parser highlights which part of the command are ambiguous.

I used the following structure for the commands:
  
   btrfs <object> <action>

where <object> are: 
- subvolume (valid action: create, delete, snapshot, list [not implemented])
- filesystem (valid action: defragment, sync, resize, balance, show)
- device (valid action: add, delete, scan )

Comments are welcome

BR
G.Baroncelli
----

$ git diff remotes/origin/orig | diffstat
 Makefile       |    6
 btrfs.c        |  333 +++++++++++++++++++++++++++++
 btrfs_cmds.c   |  647 +++++++++++++++++++++++++++++++++++++++++++++[...]
 btrfs_cmds.h   |   28 ++
 man/Makefile   |    5
 man/btrfs.8.in |  149 +++++++++++++
 6 files changed, 1166 insertions(+), 2 deletions(-)

----

$ ./btrfs
Usage:
        btrfs subvolume snapshot <source> [<dest>/]<name>
                Create a writable snapshot of the subvolume <source> with
                the name <name> in the <dest> directory.
        btrfs subvolume delete <subvolume>
                Delete the subvolume <subvolume>.
        btrfs subvolume create [<dest>/]<name>
                Create a subvolume in <dest> (or the current directory if
                not passed).
        btrfs filesystem defragment <file>|<dir> [<file>|<dir>...]
                Defragment a file or a directory.
        btrfs filesystem sync <path>
                Force a sync on the filesystem <path>.
        btrfs filesystem resize [+/-]<newsize>[gkm]|max <filesystem>
                Resize the file system. If 'max' is passed, the filesystem
                will occupe all available space on the device.
        btrfs filesystem show [<uuid>|<label>]
                Show the info of a btrfs filesystem. If no <uuid> or <label>
                is passed, info of all the btrfs filesystem are shown.
        btrfs filesystem balance <path>
                Balance the chunks across the device.
        btrfs device scan [<device> [<device>..]
                Scan all device for or the passed device for a btrfs
                filesystem.
        btrfs device add <dev> [<dev>..] <path>
                Add a device to a filesystem.
        btrfs device delete <dev> [<dev>..] <path>
                Remove a device from a filesystem.

        btrfs help|--help|-h
                Show the help.

Btrfs v0.19-26-g874cca3-dirty

----

BTRFS(8)                           btrfs                           BTRFS(8)



NAME
       btrfs - control a btrfs filesystem

SYNOPSIS
       btrfs subvolume snapshot <source> [<dest>/]<name>

       btrfs subvolume delete <subvolume>

       btrfs subvolume create [<dest>/]<name>

       btrfs filesystem defrag <file>|<dir> [<file>|<dir>...]

       btrfs filesystem sync <path>

       btrfs filesystem resize [+/-]<size>[gkm]|max <filesystem>

       btrfs device scan [<device> [<device>..]]

       btrfs device show <dev>|<label> [<dev>|<label>...]

       btrfs device balance <path>

       btrfs device add <dev> [<dev>..] <path>

       btrfs device delete <dev> [<dev>..] <path> ]


       btrfs help|--help|-h

DESCRIPTION
       btrfs  is  used to control the filesystem and the files and directo‐
       ries stored. It is the tool to create or destroy  a  snapshot  or  a
       subvolume for the filesystem, to defrag a file or a directory, flush
       the data to the disk, to resize the filesystem, to scan the device. 

       It is possible to abbreviate the commands unless the  commands   are
       ambiguous.   For  example:  it  is  possible  to run btrfs sub snaps
       instead of btrfs  subvolume  snapshot.   But  btrfs  dev  s  is  not
       allowed, because dev s may be interpreted both as device show and as
       device scan.  In this case btrfs returns an error.                  

       If a command is terminated by --help , the relevant help is  showed.
       If  the  passed  command  matches more commands, the help of all the
       matched commands are showed. For example btrfs dev --help shows  the
       help of all device* command.                                        


COMMANDS
       subvolume snapshot <source> [<dest>/]<name>
              Create  a  writaeble  snapshot of the subvolume <source> with
              the name <name> in the <dest> directory. If <source> is not a
              subvolume, btrfs returns an error.                           


       subvolume delete <subvolume>
              Delete  the  subvolume  <subvolume>.  If <subvolume> is not a
              subvolume, btrfs returns an error.                           


       subvolume create [<dest>/]<name>
              Create a subvolume in <dest> (or in the current directory  if
              <dest> is not passed).                                       


       filesystem defragment <file>|<dir> [<file>|<dir>...]
              Defragment files and/or directories.         


       device scan [<device> [<device>..]]
              Scan  devices  for  a  btrfs  filesystem.  If  no devices are
              passed, btrfs scans all the block devices.                   


       filesystem sync <path>
              Force a sync for the filesystem identified by <path>.



       filesystem resize [+/-]<size>[gkm]|max <filesystem>
              Resize a filesystem identified by <path>.  The <size> parame‐
              ter  specifies the new size of the filesystem.  If the prefix
              + or - is present the size is increased or decreased  by  the
              quantity  <size>.  If no units are specified, the unit of the
              <size> parameter defaults  to  bytes.  Optionally,  the  size
              parameter  may  be suffixed by one of the following the units
              designators: 'K', 'M', or 'G', kilobytes, megabytes, or giga‐
              bytes, respectively.                                         

              If  'max' is passed, the filesystem will occupy all available
              space on the volume(s).                                      

              The resize command does not manipulate the size of underlying
              partitions.   If you wish to enlarge/reduce a filesystem, you
              must make sure you can expand/reduce the size of  the  parti‐
              tion also.                                                   


       filesystem show [<uuid>|<label>]
              Show  the  btrfs  filesystem with some additional info. If no
              UUID or label is passed, btrfs show info  of  all  the  btrfs
              filesystem.


       device balance|-b <path>
              Balance  the  chunks  of  the filesystem identified by <path>
              across the devices.


       device add <dev> [<dev>..] <path>
              Add device(s) to the filesystem identified by <path>.


       device delete <dev> [<dev>..] <path>
              Remove device(s) from a filesystem identified by <path>.

EXIT STATUS
       btrfs 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  bench‐
       marking    and   review.    Please   refer   to   the   btrfs   wiki
       http://btrfs.wiki.kernel.org for further details.

SEE ALSO
       mkfs.btrfs(8)



btrfs                                                              BTRFS(8)

-- 
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijackATinwind.it>
Key fingerprint = 4769 7E51 5293 D36C 814E  C054 BF04 F161 3DC5 0512

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux