Mark Fasheh
2013-Jan-30 22:50 UTC
[PATCH 0/5] btrfs-progs: better support for external users of send, V3
Hi, The following 5 patches make changes to btrfs-progs in order to provide support for external software that wants to make use of the excellent btrfs send ioctl. The first patch introduces support for the BTRFS_SEND_FLAG_NO_FILE_DATA flag which is introduced in my kernel patch titled: btrfs: add "no file data" flag to btrfs send ioctl which can be found on the btrfs list, and for convenience is also attached at the end of this e-mail. The 2nd patch creates a libbtrfs and links the rest of the build to it. The functionality I chose to export as of right now centers on send support. With this library, an external program has a much easier time processing the stream which a send ioctl provides. It''s worth nothing btw that this patch can stand alone if need be. The 3rd patch introduces send-test, a small piece of software (not built by default) to allow for testing of the send ioctl (including our new flag). As send-test is a client of libbtrfs it might also serve as example code for developers looking to make use of send. The 4th patch makes minor changes so that libbtrfs is usable from C++. The 5th patch was contributed by Jeff Mahoney and it changes the build to use autotools. This wound up making packaging of the resulting library far less painful so I felt it would be advantageous for us to have it upstream so all packagers can benefit from it. The patches can also be viewed on github: https://github.com/markfasheh/btrfs-progs-patches/tree/no-data-and-libify Testing has been pretty straight-forward - I build the software, verify that things work by making a file system or using send-test. Please review. Thanks, --Mark Changelog: - included patch by Jeff Mahoney to use autotools - Fixed whitespace error in patch 3 (thanks to Anand Jain for reporting) - "make version; make install" should work now (again, thanks to Anand Jain) - included patch by Arvin Schnell to make it possible to use libbtrfs from C++ - From this patch I removed some code from cmds-send.c that was added by mistake. - libbtrfs properly links to libuuid and libm (Reported by Arvin) - library symlinks are now properly installed (Reported by Arvin) From: Mark Fasheh <mfasheh@suse.de> btrfs: add "no file data" flag to btrfs send ioctl This patch adds the flag, BTRFS_SEND_FLAG_NO_FILE_DATA to the btrfs send ioctl code. When this flag is set, the btrfs send code will never write file data into the stream (thus also avoiding expensive reads of that data in the first place). BTRFS_SEND_C_UPDATE_EXTENT commands will be sent (instead of BTRFS_SEND_C_WRITE) with an offset, length pair indicating the extent in question. This patch does not affect the operation of BTRFS_SEND_C_CLONE commands - they will continue to be sent when a search finds an appropriate extent to clone from. Signed-off-by: Mark Fasheh <mfasheh@suse.de> diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h index 731e287..1f6cfdd 100644 --- a/fs/btrfs/ioctl.h +++ b/fs/btrfs/ioctl.h @@ -363,6 +363,13 @@ struct btrfs_ioctl_received_subvol_args { __u64 reserved[16]; /* in */ }; +/* + * Caller doesn''t want file data in the send stream, even if the + * search of clone sources doesn''t find an extent. UPDATE_EXTENT + * commands will be sent instead of WRITE commands. + */ +#define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1 + struct btrfs_ioctl_send_args { __s64 send_fd; /* in */ __u64 clone_sources_count; /* in */ diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index e78b297..8d0c6b4 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -85,6 +85,7 @@ struct send_ctx { u32 send_max_size; u64 total_send_size; u64 cmd_send_size[BTRFS_SEND_C_MAX + 1]; + u64 flags; /* ''flags'' member of btrfs_ioctl_send_args is u64 */ struct vfsmount *mnt; @@ -3707,6 +3708,39 @@ out: return ret; } +/* + * Send an update extent command to user space. + */ +static int send_update_extent(struct send_ctx *sctx, + u64 offset, u32 len) +{ + int ret = 0; + struct fs_path *p; + + p = fs_path_alloc(sctx); + if (!p) + return -ENOMEM; + + ret = begin_cmd(sctx, BTRFS_SEND_C_UPDATE_EXTENT); + if (ret < 0) + goto out; + + ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); + if (ret < 0) + goto out; + + TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p); + TLV_PUT_U64(sctx, BTRFS_SEND_A_FILE_OFFSET, offset); + TLV_PUT_U64(sctx, BTRFS_SEND_A_SIZE, len); + + ret = send_cmd(sctx); + +tlv_put_failure: +out: + fs_path_free(sctx, p); + return ret; +} + static int send_write_or_clone(struct send_ctx *sctx, struct btrfs_path *path, struct btrfs_key *key, @@ -3742,7 +3776,11 @@ static int send_write_or_clone(struct send_ctx *sctx, goto out; } - if (!clone_root) { + if (clone_root) { + ret = send_clone(sctx, offset, len, clone_root); + } else if (sctx->flags & BTRFS_SEND_FLAG_NO_FILE_DATA) { + ret = send_update_extent(sctx, offset, len); + } else { while (pos < len) { l = len - pos; if (l > BTRFS_SEND_READ_SIZE) @@ -3755,10 +3793,7 @@ static int send_write_or_clone(struct send_ctx *sctx, pos += ret; } ret = 0; - } else { - ret = send_clone(sctx, offset, len, clone_root); } - out: return ret; } @@ -4570,6 +4605,11 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_) INIT_RADIX_TREE(&sctx->name_cache, GFP_NOFS); INIT_LIST_HEAD(&sctx->name_cache_list); + if (arg->flags & ~BTRFS_SEND_FLAG_NO_FILE_DATA) + return -EINVAL; + + sctx->flags = arg->flags; + sctx->send_filp = fget(arg->send_fd); if (IS_ERR(sctx->send_filp)) { ret = PTR_ERR(sctx->send_filp); diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h index 1bf4f32..8bb18f7 100644 --- a/fs/btrfs/send.h +++ b/fs/btrfs/send.h @@ -86,6 +86,7 @@ enum btrfs_send_cmd { BTRFS_SEND_C_UTIMES, BTRFS_SEND_C_END, + BTRFS_SEND_C_UPDATE_EXTENT, __BTRFS_SEND_C_MAX, }; #define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Fasheh
2013-Jan-30 22:50 UTC
[PATCH 1/5] btrfs-progs: Add support for BTRFS_SEND_FLAG_NO_FILE_DATA
The flag and command are synced from kernel to user. Also, this patch adds a callback for the BTRFS_SEND_C_UPDATE_EXTENT in struct btrfs_send_ops. read_and_process_cmd() is updated to decode BTRFS_SEND_C_UPDATE_EXTENT and send the values through the right callback. I did not add a callback definition to cmds-receive.c as that code never uses BTRFS_SEND_FLAG_NO_FILE_DATA. Signed-off-by: Mark Fasheh <mfasheh@suse.de> --- ioctl.h | 7 +++++++ send-stream.c | 6 ++++++ send-stream.h | 1 + send.h | 1 + 4 files changed, 15 insertions(+) diff --git a/ioctl.h b/ioctl.h index 6fda3a1..b7f1ce3 100644 --- a/ioctl.h +++ b/ioctl.h @@ -321,6 +321,13 @@ struct btrfs_ioctl_received_subvol_args { __u64 reserved[16]; /* in */ }; +/* + * Caller doesn''t want file data in the send stream, even if the + * search of clone sources doesn''t find an extent. UPDATE_EXTENT + * commands will be sent instead of WRITE commands. + */ +#define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1 + struct btrfs_ioctl_send_args { __s64 send_fd; /* in */ __u64 clone_sources_count; /* in */ diff --git a/send-stream.c b/send-stream.c index 55fa728..a3628e4 100644 --- a/send-stream.c +++ b/send-stream.c @@ -418,6 +418,12 @@ static int read_and_process_cmd(struct btrfs_send_stream *s) TLV_GET_TIMESPEC(s, BTRFS_SEND_A_CTIME, &ct); ret = s->ops->utimes(path, &at, &mt, &ct, s->user); break; + case BTRFS_SEND_C_UPDATE_EXTENT: + TLV_GET_STRING(s, BTRFS_SEND_A_PATH, &path); + TLV_GET_U64(s, BTRFS_SEND_A_FILE_OFFSET, &offset); + TLV_GET_U64(s, BTRFS_SEND_A_SIZE, &tmp); + ret = s->ops->update_extent(path, offset, tmp, s->user); + break; case BTRFS_SEND_C_END: ret = 1; break; diff --git a/send-stream.h b/send-stream.h index b69b7f1..9a17e32 100644 --- a/send-stream.h +++ b/send-stream.h @@ -49,6 +49,7 @@ struct btrfs_send_ops { int (*utimes)(const char *path, struct timespec *at, struct timespec *mt, struct timespec *ct, void *user); + int (*update_extent)(const char *path, u64 offset, u64 len, void *user); }; int btrfs_read_and_process_send_stream(int fd, diff --git a/send.h b/send.h index 9934e94..48d425a 100644 --- a/send.h +++ b/send.h @@ -86,6 +86,7 @@ enum btrfs_send_cmd { BTRFS_SEND_C_UTIMES, BTRFS_SEND_C_END, + BTRFS_SEND_C_UPDATE_EXTENT, __BTRFS_SEND_C_MAX, }; #define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Fasheh
2013-Jan-30 22:50 UTC
[PATCH 2/5] btrfs-progs: libify some parts of btrfs-progs
External software wanting to use the functionality provided by the btrfs send ioctl has a hard time doing so without replicating tons of work. Of particular interest are functions like btrfs_read_and_process_send_stream() and subvol_uuid_search(). As that functionality requires a bit more than just send-stream.c and send-utils.c we have to pull in some other parts of the progs package. This patch adds code to the Makefile and headers to create a library, libbtrfs which the btrfs command now links to. Signed-off-by: Mark Fasheh <mfasheh@suse.de> --- Makefile | 83 ++++++++++++++++++++++++++++++++++++-------------------- btrfs-list.h | 4 +++ crc32c.h | 4 +++ ctree.h | 9 ++++++ extent-cache.h | 6 ++++ extent_io.h | 7 +++++ radix-tree.h | 4 +++ rbtree.h | 4 +++ send-utils.h | 5 ++++ 9 files changed, 96 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 4894903..4962985 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,17 @@ CC = gcc -AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 +AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -DBTRFS_FLAT_INCLUDES -fPIC CFLAGS = -g -O1 objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ - root-tree.o dir-item.o file-item.o inode-item.o \ - inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \ - volumes.o utils.o btrfs-list.o btrfslabel.o repair.o \ - send-stream.o send-utils.o qgroup.o + root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \ + extent-cache.o extent_io.o volumes.o utils.o btrfslabel.o repair.o \ + qgroup.o cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \ cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \ cmds-quota.o cmds-qgroup.o +libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o +libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \ + crc32c.h list.h kerncompat.h radix-tree.h extent-cache.h \ + extent_io.h ioctl.h ctree.h CHECKFLAGS= -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \ -Wuninitialized -Wshadow -Wundef @@ -17,13 +20,20 @@ DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@ INSTALL = install prefix ?= /usr/local bindir = $(prefix)/bin -LIBS=-luuid -lm +libdir = $(prefix)/lib +incdir = $(prefix)/include/btrfs +lib_LIBS=-luuid -lm -L. +LIBS=$(lib_LIBS) -lbtrfs RESTORE_LIBS=-lz progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck \ btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \ btrfs-find-root btrfs-restore btrfstune +libs = libbtrfs.so.1.0 +lib_links = libbtrfs.so.1 libbtrfs.so +headers = $(libbtrfs_headers) + # make C=1 to enable sparse ifdef C check = sparse $(CHECKFLAGS) @@ -36,70 +46,77 @@ endif $(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $< -all: version $(progs) manpages +all: version $(libs) $(progs) manpages version: bash version.sh -btrfs: $(objects) btrfs.o help.o common.o $(cmds_objects) +$(libs): $(libbtrfs_objects) $(lib_links) send.h + $(CC) $(CFLAGS) $(libbtrfs_objects) $(lib_LIBS) -shared -Wl,-soname,libbtrfs.so.1 -o libbtrfs.so.1.0 + +$(lib_links): + ln -sf libbtrfs.so.1.0 libbtrfs.so.1 + ln -sf libbtrfs.so.1.0 libbtrfs.so + +btrfs: $(objects) btrfs.o help.o common.o $(cmds_objects) $(libs) $(CC) $(CFLAGS) -o btrfs btrfs.o help.o common.o $(cmds_objects) \ $(objects) $(LDFLAGS) $(LIBS) -lpthread -calc-size: $(objects) calc-size.o +calc-size: $(objects) $(libs) calc-size.o $(CC) $(CFLAGS) -o calc-size calc-size.o $(objects) $(LDFLAGS) $(LIBS) -btrfs-find-root: $(objects) find-root.o +btrfs-find-root: $(objects) $(libs) find-root.o $(CC) $(CFLAGS) -o btrfs-find-root find-root.o $(objects) $(LDFLAGS) $(LIBS) -btrfs-restore: $(objects) restore.o +btrfs-restore: $(objects) $(libs) restore.o $(CC) $(CFLAGS) -o btrfs-restore restore.o $(objects) $(LDFLAGS) $(LIBS) $(RESTORE_LIBS) -btrfsctl: $(objects) btrfsctl.o +btrfsctl: $(objects) $(libs) btrfsctl.o $(CC) $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS) -btrfs-vol: $(objects) btrfs-vol.o +btrfs-vol: $(objects) $(libs) btrfs-vol.o $(CC) $(CFLAGS) -o btrfs-vol btrfs-vol.o $(objects) $(LDFLAGS) $(LIBS) -btrfs-show: $(objects) btrfs-show.o +btrfs-show: $(objects) $(libs) btrfs-show.o $(CC) $(CFLAGS) -o btrfs-show btrfs-show.o $(objects) $(LDFLAGS) $(LIBS) -btrfsck: $(objects) btrfsck.o +btrfsck: $(objects) $(libs) btrfsck.o $(CC) $(CFLAGS) -o btrfsck btrfsck.o $(objects) $(LDFLAGS) $(LIBS) -mkfs.btrfs: $(objects) mkfs.o +mkfs.btrfs: $(objects) $(libs) mkfs.o $(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS) -btrfs-debug-tree: $(objects) debug-tree.o +btrfs-debug-tree: $(objects) $(libs) debug-tree.o $(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) $(LIBS) -btrfs-zero-log: $(objects) btrfs-zero-log.o +btrfs-zero-log: $(objects) $(libs) btrfs-zero-log.o $(CC) $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o $(LDFLAGS) $(LIBS) -btrfs-select-super: $(objects) btrfs-select-super.o +btrfs-select-super: $(objects) $(libs) btrfs-select-super.o $(CC) $(CFLAGS) -o btrfs-select-super $(objects) btrfs-select-super.o $(LDFLAGS) $(LIBS) -btrfstune: $(objects) btrfstune.o +btrfstune: $(objects) $(libs) btrfstune.o $(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS) -btrfs-map-logical: $(objects) btrfs-map-logical.o +btrfs-map-logical: $(objects) $(libs) btrfs-map-logical.o $(CC) $(CFLAGS) -o btrfs-map-logical $(objects) btrfs-map-logical.o $(LDFLAGS) $(LIBS) -btrfs-corrupt-block: $(objects) btrfs-corrupt-block.o +btrfs-corrupt-block: $(objects) $(libs) btrfs-corrupt-block.o $(CC) $(CFLAGS) -o btrfs-corrupt-block $(objects) btrfs-corrupt-block.o $(LDFLAGS) $(LIBS) -btrfs-image: $(objects) btrfs-image.o +btrfs-image: $(objects) $(libs) btrfs-image.o $(CC) $(CFLAGS) -o btrfs-image $(objects) btrfs-image.o -lpthread -lz $(LDFLAGS) $(LIBS) -dir-test: $(objects) dir-test.o +dir-test: $(objects) $(libs) dir-test.o $(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS) -quick-test: $(objects) quick-test.o +quick-test: $(objects) $(libs) quick-test.o $(CC) $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS) -btrfs-convert: $(objects) convert.o +btrfs-convert: $(objects) $(libs) convert.o $(CC) $(CFLAGS) -o btrfs-convert $(objects) convert.o -lext2fs -lcom_err $(LDFLAGS) $(LIBS) -ioctl-test: $(objects) ioctl-test.o +ioctl-test: $(objects) $(libs) ioctl-test.o $(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS) manpages: @@ -109,12 +126,18 @@ install-man: cd man; $(MAKE) install clean : - rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image btrfs-select-super \ - btrfs-zero-log btrfstune dir-test ioctl-test quick-test version.h + rm -f $(progs) $(libs) cscope.out *.o .*.d btrfs-convert btrfs-image \ + btrfs-select-super btrfs-zero-log btrfstune dir-test ioctl-test \ + quick-test version.h cd man; $(MAKE) clean -install: $(progs) install-man +install: $(libs) $(progs) install-man $(INSTALL) -m755 -d $(DESTDIR)$(bindir) $(INSTALL) $(progs) $(DESTDIR)$(bindir) + $(INSTALL) -m755 -d $(DESTDIR)$(libdir) + $(INSTALL) $(libs) $(DESTDIR)$(libdir) + cp -a $(lib_links) $(DESTDIR)$(libdir) + $(INSTALL) -m755 -d $(DESTDIR)$(incdir) + $(INSTALL) $(headers) $(DESTDIR)$(incdir) -include .*.d diff --git a/btrfs-list.h b/btrfs-list.h index cde4b3c..da6bf1c 100644 --- a/btrfs-list.h +++ b/btrfs-list.h @@ -16,7 +16,11 @@ * Boston, MA 021110-1307, USA. */ +#if BTRFS_FLAT_INCLUDES #include "kerncompat.h" +#else +#include <btrfs/kerncompat.h> +#endif /* BTRFS_FLAT_INCLUDES */ struct root_info; diff --git a/crc32c.h b/crc32c.h index 7f12e77..c552ef6 100644 --- a/crc32c.h +++ b/crc32c.h @@ -19,7 +19,11 @@ #ifndef __CRC32C__ #define __CRC32C__ +#if BTRFS_FLAT_INCLUDES #include "kerncompat.h" +#else +#include <btrfs/kerncompat.h> +#endif /* BTRFS_FLAT_INCLUDES */ u32 crc32c_le(u32 seed, unsigned char const *data, size_t length); void crc32c_optimization_init(void); diff --git a/ctree.h b/ctree.h index 293b24f..7a1ffce 100644 --- a/ctree.h +++ b/ctree.h @@ -19,12 +19,21 @@ #ifndef __BTRFS__ #define __BTRFS__ +#if BTRFS_FLAT_INCLUDES #include "list.h" #include "kerncompat.h" #include "radix-tree.h" #include "extent-cache.h" #include "extent_io.h" #include "ioctl.h" +#else +#include <btrfs/list.h> +#include <btrfs/kerncompat.h> +#include <btrfs/radix-tree.h> +#include <btrfs/extent-cache.h> +#include <btrfs/extent_io.h> +#include <btrfs/ioctl.h> +#endif /* BTRFS_FLAT_INCLUDES */ struct btrfs_root; struct btrfs_trans_handle; diff --git a/extent-cache.h b/extent-cache.h index 7f2f2a6..4cd0f79 100644 --- a/extent-cache.h +++ b/extent-cache.h @@ -18,8 +18,14 @@ #ifndef __PENDING_EXTENT__ #define __PENDING_EXTENT__ + +#if BTRFS_FLAT_INCLUDES #include "kerncompat.h" #include "rbtree.h" +#else +#include <btrfs/kerncompat.h> +#include <btrfs/rbtree.h> +#endif /* BTRFS_FLAT_INCLUDES */ struct cache_tree { struct rb_root root; diff --git a/extent_io.h b/extent_io.h index a5d6bf0..4553859 100644 --- a/extent_io.h +++ b/extent_io.h @@ -18,9 +18,16 @@ #ifndef __EXTENTMAP__ #define __EXTENTMAP__ + +#if BTRFS_FLAT_INCLUDES #include "kerncompat.h" #include "extent-cache.h" #include "list.h" +#else +#include <btrfs/kerncompat.h> +#include <btrfs/extent-cache.h> +#include <btrfs/list.h> +#endif /* BTRFS_FLAT_INCLUDES */ #define EXTENT_DIRTY 1 #define EXTENT_WRITEBACK (1 << 1) diff --git a/radix-tree.h b/radix-tree.h index d99ea7e..bf96d83 100644 --- a/radix-tree.h +++ b/radix-tree.h @@ -37,7 +37,11 @@ #ifndef _LINUX_RADIX_TREE_H #define _LINUX_RADIX_TREE_H +#if BTRFS_FLAT_INCLUDES #include "kerncompat.h" +#else +#include <btrfs/kerncompat.h> +#endif /* BTRFS_FLAT_INCLUDES */ #define RADIX_TREE_MAX_TAGS 2 diff --git a/rbtree.h b/rbtree.h index bed054d..b636ddd 100644 --- a/rbtree.h +++ b/rbtree.h @@ -93,7 +93,11 @@ static inline struct page * rb_insert_page_cache(struct inode * inode, #ifndef _LINUX_RBTREE_H #define _LINUX_RBTREE_H +#if BTRFS_FLAT_INCLUDES #include "kerncompat.h" +#else +#include <btrfs/kerncompat.h> +#endif /* BTRFS_FLAT_INCLUDES */ struct rb_node { unsigned long rb_parent_color; diff --git a/send-utils.h b/send-utils.h index da407eb..8040c50 100644 --- a/send-utils.h +++ b/send-utils.h @@ -18,8 +18,13 @@ #ifndef SEND_UTILS_H_ #define SEND_UTILS_H_ +#if BTRFS_FLAT_INCLUDES #include "ctree.h" #include "rbtree.h" +#else +#include <btrfs/ctree.h> +#include <btrfs/rbtree.h> +#endif /* BTRFS_FLAT_INCLUDES */ enum subvol_search_type { subvol_search_by_root_id, -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
send-test.c links against libbtrfs and uses the send functionality provided to decode and print a send stream to the console. Signed-off-by: Mark Fasheh <mfasheh@suse.de> --- Makefile | 5 +- send-test.c | 458 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 send-test.c diff --git a/Makefile b/Makefile index 4962985..27d62c0 100644 --- a/Makefile +++ b/Makefile @@ -119,6 +119,9 @@ btrfs-convert: $(objects) $(libs) convert.o ioctl-test: $(objects) $(libs) ioctl-test.o $(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS) +send-test: $(objects) send-test.o + $(CC) $(CFLAGS) -o send-test send-test.o $(LDFLAGS) $(LIBS) -lpthread + manpages: cd man; $(MAKE) @@ -128,7 +131,7 @@ install-man: clean : rm -f $(progs) $(libs) cscope.out *.o .*.d btrfs-convert btrfs-image \ btrfs-select-super btrfs-zero-log btrfstune dir-test ioctl-test \ - quick-test version.h + quick-test send-test version.h cd man; $(MAKE) clean install: $(libs) $(progs) install-man diff --git a/send-test.c b/send-test.c new file mode 100644 index 0000000..8c14718 --- /dev/null +++ b/send-test.c @@ -0,0 +1,458 @@ +/* + * Copyright (C) 2013 SUSE. All rights reserved. + * + * This code is adapted from cmds-send.c and cmds-receive.c, + * Both of which are: + * + * Copyright (C) 2012 Alexander Block. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License v2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#define _GNU_SOURCE + +#include <unistd.h> +#include <stdint.h> +#include <dirent.h> +#include <pthread.h> +#include <math.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <libgen.h> +#include <mntent.h> +#include <limits.h> +#include <stdlib.h> +#include <asm/types.h> +#include <uuid/uuid.h> + +/* + * This should be compilable without the rest of the btrfs-progs + * source distribution. + */ +#if BTRFS_FLAT_INCLUDES +#include "send-utils.h" +#include "send-stream.h" +#else +#include <btrfs/send-utils.h> +#include <btrfs/send-stream.h> +#endif /* BTRFS_FLAT_INCLUDES */ + +static int pipefd[2]; +struct btrfs_ioctl_send_args io_send = {0, }; +static char *subvol_path; +static char *root_path; + +struct recv_args { + char *full_subvol_path; + char *root_path; +}; + +void usage(int error) +{ + printf("send-test <btrfs root> <subvol>\n"); + if (error) + exit(error); +} + +static int print_subvol(const char *path, const u8 *uuid, u64 ctransid, + void *user) +{ + struct recv_args *r = user; + char uuid_str[128]; + + r->full_subvol_path = path_cat(r->root_path, path); + uuid_unparse(uuid, uuid_str); + + printf("subvol\t%s\t%llu\t%s\n", uuid_str, + (unsigned long long)ctransid, r->full_subvol_path); + + return 0; +} + +static int print_snapshot(const char *path, const u8 *uuid, u64 ctransid, + const u8 *parent_uuid, u64 parent_ctransid, + void *user) +{ + struct recv_args *r = user; + char uuid_str[128]; + char parent_uuid_str[128]; + + r->full_subvol_path = path_cat(r->root_path, path); + uuid_unparse(uuid, uuid_str); + uuid_unparse(parent_uuid, parent_uuid_str); + + printf("snapshot\t%s\t%llu\t%s\t%llu\t%s\n", uuid_str, + (unsigned long long)ctransid, parent_uuid_str, + (unsigned long long)parent_ctransid, r->full_subvol_path); + + return 0; +} + +static int print_mkfile(const char *path, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("mkfile\t%s\n", full_path); + + free(full_path); + return 0; +} + +static int print_mkdir(const char *path, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("mkdir\t%s\n", full_path); + + free(full_path); + return 0; +} + +static int print_mknod(const char *path, u64 mode, u64 dev, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("mknod\t%llo\t0x%llx\t%s\n", (unsigned long long)mode, + (unsigned long long)dev, full_path); + + free(full_path); + return 0; +} + +static int print_mkfifo(const char *path, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("mkfifo\t%s\n", full_path); + + free(full_path); + return 0; +} + +static int print_mksock(const char *path, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("mksock\t%s\n", full_path); + + free(full_path); + return 0; +} + +static int print_symlink(const char *path, const char *lnk, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("symlink\t%s\t%s\n", lnk, full_path); + + free(full_path); + return 0; +} + +static int print_rename(const char *from, const char *to, void *user) +{ + struct recv_args *r = user; + char *full_from = path_cat(r->full_subvol_path, from); + char *full_to = path_cat(r->full_subvol_path, to); + + printf("rename\t%s\t%s\n", from, to); + + free(full_from); + free(full_to); + return 0; +} + +static int print_link(const char *path, const char *lnk, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("link\t%s\t%s\n", lnk, full_path); + + free(full_path); + return 0; +} + +static int print_unlink(const char *path, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("unlink\t%s\n", full_path); + + free(full_path); + return 0; +} + +static int print_rmdir(const char *path, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("rmdir\t%s\n", full_path); + + free(full_path); + return 0; +} + +static int print_write(const char *path, const void *data, u64 offset, + u64 len, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("write\t%llu\t%llu\t%s\n", (unsigned long long)offset, + (unsigned long long)len, full_path); + + free(full_path); + return 0; +} + +static int print_clone(const char *path, u64 offset, u64 len, + const u8 *clone_uuid, u64 clone_ctransid, + const char *clone_path, u64 clone_offset, + void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("clone\t%s\t%s\n", full_path, clone_path); + + free(full_path); + return 0; +} + +static int print_set_xattr(const char *path, const char *name, + const void *data, int len, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("set_xattr\t%s\t%s\t%d\n", full_path, + name, len); + + free(full_path); + return 0; +} + +static int print_remove_xattr(const char *path, const char *name, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("remove_xattr\t%s\t%s\n", full_path, name); + + free(full_path); + return 0; +} + +static int print_truncate(const char *path, u64 size, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("truncate\t%llu\t%s\n", (unsigned long long)size, full_path); + + free(full_path); + return 0; +} + +static int print_chmod(const char *path, u64 mode, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("chmod\t%llo\t%s\n", (unsigned long long)mode, full_path); + + free(full_path); + return 0; +} + +static int print_chown(const char *path, u64 uid, u64 gid, void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("chown\t%llu\t%llu\t%s\n", (unsigned long long)uid, + (unsigned long long)gid, full_path); + + free(full_path); + return 0; +} + +static int print_utimes(const char *path, struct timespec *at, + struct timespec *mt, struct timespec *ct, + void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("utimes\t%s\n", full_path); + + free(full_path); + return 0; +} + +static int print_update_extent(const char *path, u64 offset, u64 len, + void *user) +{ + struct recv_args *r = user; + char *full_path = path_cat(r->full_subvol_path, path); + + printf("update_extent\t%s\t%llu\t%llu\n", full_path, offset, len); + + free(full_path); + return 0; +} + +struct btrfs_send_ops send_ops_print = { + .subvol = print_subvol, + .snapshot = print_snapshot, + .mkfile = print_mkfile, + .mkdir = print_mkdir, + .mknod = print_mknod, + .mkfifo = print_mkfifo, + .mksock = print_mksock, + .symlink = print_symlink, + .rename = print_rename, + .link = print_link, + .unlink = print_unlink, + .rmdir = print_rmdir, + .write = print_write, + .clone = print_clone, + .set_xattr = print_set_xattr, + .remove_xattr = print_remove_xattr, + .truncate = print_truncate, + .chmod = print_chmod, + .chown = print_chown, + .utimes = print_utimes, + .update_extent = print_update_extent, +}; + +static void *process_thread(void *arg_) +{ + int ret; + + while (1) { + ret = btrfs_read_and_process_send_stream(pipefd[0], + &send_ops_print, arg_); + if (ret) + break; + } + + if (ret > 0) + ret = 0; + + return ERR_PTR(ret); +} + +int main(int argc, char **argv) +{ + int ret = 0; + int subvol_fd; + pthread_t t_read; + pthread_attr_t t_attr; + void *t_err = NULL; + struct recv_args r; + + if (argc != 3) + usage(EINVAL); + + root_path = realpath(argv[1], NULL); + if (!root_path) { + ret = errno; + usage(ret); + } + + subvol_path = realpath(argv[2], NULL); + if (!subvol_path) { + ret = errno; + usage(ret); + } + + r.full_subvol_path = subvol_path; + r.root_path = root_path; + + subvol_fd = open(subvol_path, O_RDONLY|O_NOATIME); + if (subvol_fd < 0) { + ret = errno; + fprintf(stderr, "ERROR: Subvolume open failed. %s\n", + strerror(ret)); + goto out; + } + + ret = pthread_attr_init(&t_attr); + if (ret < 0) { + fprintf(stderr, "ERROR: pthread init failed. %s\n", + strerror(ret)); + goto out; + } + + ret = pipe(pipefd); + if (ret < 0) { + ret = errno; + fprintf(stderr, "ERROR: pipe failed. %s\n", strerror(ret)); + goto out; + } + + ret = pthread_create(&t_read, &t_attr, process_thread, &r); + if (ret < 0) { + ret = errno; + fprintf(stderr, "ERROR: pthread create failed. %s\n", + strerror(ret)); + goto out; + } + + io_send.send_fd = pipefd[1]; + io_send.clone_sources_count = 0; + io_send.clone_sources = NULL; + io_send.parent_root = 0; + io_send.flags = BTRFS_SEND_FLAG_NO_FILE_DATA; + + ret = ioctl(subvol_fd, BTRFS_IOC_SEND, &io_send); + if (ret) { + ret = errno; + fprintf(stderr, "ERROR: send ioctl failed with %d: %s\n", ret, + strerror(ret)); + goto out; + } + + close(pipefd[1]); + + ret = pthread_join(t_read, &t_err); + if (ret) { + fprintf(stderr, "ERROR: pthread_join failed: %s\n", + strerror(ret)); + goto out; + } + if (t_err) { + ret = (long int)t_err; + fprintf(stderr, "ERROR: failed to process send stream, ret=%ld " + "(%s)\n", (long int)t_err, strerror(ret)); + goto out; + } + + pthread_attr_destroy(&t_attr); +out: + return ret; +} -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Arvin Schnell <aschnell@suse.de> Please find attached a patch to make the new libbtrfs usable from C++ (at least for the parts snapper will likely need). Signed-off-by: Arvin Schnell <aschnell@suse.de> Signed-off-by: Mark Fasheh <mfasheh@suse.de> --- extent_io.c | 6 +++--- extent_io.h | 6 +++--- ioctl.h | 9 +++++++++ list.h | 40 ++++++++++++++++++++-------------------- rbtree.h | 2 +- send-stream.h | 7 +++++++ send-utils.h | 7 +++++++ send.h | 8 ++++++++ 8 files changed, 58 insertions(+), 27 deletions(-) diff --git a/extent_io.c b/extent_io.c index ebb35b2..70ecc48 100644 --- a/extent_io.c +++ b/extent_io.c @@ -48,7 +48,7 @@ static struct extent_state *alloc_extent_state(void) return NULL; state->refs = 1; state->state = 0; - state->private = 0; + state->xprivate = 0; return state; } @@ -509,7 +509,7 @@ int set_state_private(struct extent_io_tree *tree, u64 start, u64 private) ret = -ENOENT; goto out; } - state->private = private; + state->xprivate = private; out: return ret; } @@ -530,7 +530,7 @@ int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private) ret = -ENOENT; goto out; } - *private = state->private; + *private = state->xprivate; out: return ret; } diff --git a/extent_io.h b/extent_io.h index 4553859..6d8404d 100644 --- a/extent_io.h +++ b/extent_io.h @@ -54,7 +54,7 @@ struct extent_state { u64 end; int refs; unsigned long state; - u64 private; + u64 xprivate; }; struct extent_buffer { @@ -93,8 +93,8 @@ int extent_buffer_uptodate(struct extent_buffer *eb); int set_extent_buffer_uptodate(struct extent_buffer *eb); int clear_extent_buffer_uptodate(struct extent_io_tree *tree, struct extent_buffer *eb); -int set_state_private(struct extent_io_tree *tree, u64 start, u64 private); -int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private); +int set_state_private(struct extent_io_tree *tree, u64 start, u64 xprivate); +int get_state_private(struct extent_io_tree *tree, u64 start, u64 *xprivate); struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree, u64 bytenr, u32 blocksize); struct extent_buffer *find_first_extent_buffer(struct extent_io_tree *tree, diff --git a/ioctl.h b/ioctl.h index b7f1ce3..56de39f 100644 --- a/ioctl.h +++ b/ioctl.h @@ -22,6 +22,10 @@ #include <linux/ioctl.h> #include <time.h> +#ifdef __cplusplus +extern "C" { +#endif + #define BTRFS_IOCTL_MAGIC 0x94 #define BTRFS_VOL_NAME_MAX 255 @@ -439,4 +443,9 @@ struct btrfs_ioctl_clone_range_args { struct btrfs_ioctl_qgroup_create_args) #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \ struct btrfs_ioctl_qgroup_limit_args) + +#ifdef __cplusplus +} +#endif + #endif diff --git a/list.h b/list.h index d31090c..50f4619 100644 --- a/list.h +++ b/list.h @@ -19,8 +19,8 @@ #ifndef _LINUX_LIST_H #define _LINUX_LIST_H -#define LIST_POISON1 ((void *) 0x00100100) -#define LIST_POISON2 ((void *) 0x00200200) +#define LIST_POISON1 ((struct list_head *) 0x00100100) +#define LIST_POISON2 ((struct list_head *) 0x00200200) /* * Simple doubly linked list implementation. @@ -54,17 +54,17 @@ static inline void INIT_LIST_HEAD(struct list_head *list) * the prev/next entries already! */ #ifndef CONFIG_DEBUG_LIST -static inline void __list_add(struct list_head *new, +static inline void __list_add(struct list_head *xnew, struct list_head *prev, struct list_head *next) { - next->prev = new; - new->next = next; - new->prev = prev; - prev->next = new; + next->prev = xnew; + xnew->next = next; + xnew->prev = prev; + prev->next = xnew; } #else -extern void __list_add(struct list_head *new, +extern void __list_add(struct list_head *xnew, struct list_head *prev, struct list_head *next); #endif @@ -78,12 +78,12 @@ extern void __list_add(struct list_head *new, * This is good for implementing stacks. */ #ifndef CONFIG_DEBUG_LIST -static inline void list_add(struct list_head *new, struct list_head *head) +static inline void list_add(struct list_head *xnew, struct list_head *head) { - __list_add(new, head, head->next); + __list_add(xnew, head, head->next); } #else -extern void list_add(struct list_head *new, struct list_head *head); +extern void list_add(struct list_head *xnew, struct list_head *head); #endif @@ -95,9 +95,9 @@ extern void list_add(struct list_head *new, struct list_head *head); * Insert a new entry before the specified head. * This is useful for implementing queues. */ -static inline void list_add_tail(struct list_head *new, struct list_head *head) +static inline void list_add_tail(struct list_head *xnew, struct list_head *head) { - __list_add(new, head->prev, head); + __list_add(xnew, head->prev, head); } /* @@ -137,18 +137,18 @@ extern void list_del(struct list_head *entry); * Note: if ''old'' was empty, it will be overwritten. */ static inline void list_replace(struct list_head *old, - struct list_head *new) + struct list_head *xnew) { - new->next = old->next; - new->next->prev = new; - new->prev = old->prev; - new->prev->next = new; + xnew->next = old->next; + xnew->next->prev = xnew; + xnew->prev = old->prev; + xnew->prev->next = xnew; } static inline void list_replace_init(struct list_head *old, - struct list_head *new) + struct list_head *xnew) { - list_replace(old, new); + list_replace(old, xnew); INIT_LIST_HEAD(old); } /** diff --git a/rbtree.h b/rbtree.h index b636ddd..8f717a9 100644 --- a/rbtree.h +++ b/rbtree.h @@ -149,7 +149,7 @@ extern struct rb_node *rb_first(struct rb_root *); extern struct rb_node *rb_last(struct rb_root *); /* Fast replacement of a single node without remove/rebalance/add/rebalance */ -extern void rb_replace_node(struct rb_node *victim, struct rb_node *new, +extern void rb_replace_node(struct rb_node *victim, struct rb_node *xnew, struct rb_root *root); static inline void rb_link_node(struct rb_node * node, struct rb_node * parent, diff --git a/send-stream.h b/send-stream.h index 9a17e32..9223018 100644 --- a/send-stream.h +++ b/send-stream.h @@ -18,6 +18,10 @@ #ifndef SEND_STREAM_H_ #define SEND_STREAM_H_ +#ifdef __cplusplus +extern "C" { +#endif + struct btrfs_send_ops { int (*subvol)(const char *path, const u8 *uuid, u64 ctransid, void *user); @@ -55,5 +59,8 @@ struct btrfs_send_ops { int btrfs_read_and_process_send_stream(int fd, struct btrfs_send_ops *ops, void *user); +#ifdef __cplusplus +} +#endif #endif /* SEND_STREAM_H_ */ diff --git a/send-utils.h b/send-utils.h index 8040c50..199dd03 100644 --- a/send-utils.h +++ b/send-utils.h @@ -26,6 +26,10 @@ #include <btrfs/rbtree.h> #endif /* BTRFS_FLAT_INCLUDES */ +#ifdef __cplusplus +extern "C" { +#endif + enum subvol_search_type { subvol_search_by_root_id, subvol_search_by_uuid, @@ -70,5 +74,8 @@ void subvol_uuid_search_add(struct subvol_uuid_search *s, char *path_cat(const char *p1, const char *p2); char *path_cat3(const char *p1, const char *p2, const char *p3); +#ifdef __cplusplus +} +#endif #endif /* SEND_UTILS_H_ */ diff --git a/send.h b/send.h index 48d425a..e8da785 100644 --- a/send.h +++ b/send.h @@ -19,6 +19,10 @@ #include "ctree.h" +#ifdef __cplusplus +extern "C" { +#endif + #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream" #define BTRFS_SEND_STREAM_VERSION 1 @@ -132,3 +136,7 @@ enum { #ifdef __KERNEL__ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg); #endif + +#ifdef __cplusplus +} +#endif -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Jeff Mahoney <jeffm@suse.com> Since we''re building shared libraries now, let''s not reinvent the wheel. This also makes packaging libbtrfs much easier. The following (empty) files are added to satisfy autoconf: AUTHORS ChangeLog NEWS INSTALL. Changes by Mark Fasheh: - Fixes to make this patch work with upstream - I moved the previous contents of INSTALL to README since that seems to make more sense now) Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Mark Fasheh <mfasheh@suse.de> --- INSTALL | 59 -------- Makefile | 146 -------------------- Makefile.am | 53 ++++++++ README | 59 ++++++++ autogen.sh | 5 + configure.ac | 6 + man/Makefile | 37 ----- man/Makefile.am | 2 + man/btrfs-image.8 | 34 +++++ man/btrfs-image.8.in | 34 ----- man/btrfs-show.8 | 22 +++ man/btrfs-show.8.in | 22 --- man/btrfs.8 | 365 ++++++++++++++++++++++++++++++++++++++++++++++++++ man/btrfs.8.in | 365 -------------------------------------------------- man/btrfsck.8 | 17 +++ man/btrfsck.8.in | 17 --- man/btrfsctl.8 | 48 +++++++ man/btrfsctl.8.in | 48 ------- man/mkfs.btrfs.8 | 79 +++++++++++ man/mkfs.btrfs.8.in | 79 ----------- 20 files changed, 690 insertions(+), 807 deletions(-) create mode 100644 AUTHORS create mode 100644 ChangeLog delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 NEWS create mode 100644 README create mode 100755 autogen.sh create mode 100644 configure.ac delete mode 100644 man/Makefile create mode 100644 man/Makefile.am create mode 100644 man/btrfs-image.8 delete mode 100644 man/btrfs-image.8.in create mode 100644 man/btrfs-show.8 delete mode 100644 man/btrfs-show.8.in create mode 100644 man/btrfs.8 delete mode 100644 man/btrfs.8.in create mode 100644 man/btrfsck.8 delete mode 100644 man/btrfsck.8.in create mode 100644 man/btrfsctl.8 delete mode 100644 man/btrfsctl.8.in create mode 100644 man/mkfs.btrfs.8 delete mode 100644 man/mkfs.btrfs.8.in diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e69de29 diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/INSTALL b/INSTALL index 6afbd90..e69de29 100644 --- a/INSTALL +++ b/INSTALL @@ -1,59 +0,0 @@ -Install Instructions - -Btrfs puts snapshots and subvolumes into the root directory of the FS. This -directory can only be changed by btrfsctl right now, and normal filesystem -operations do not work on it. The default subvolume is called ''default'', -and you can create files and directories in mount_point/default - -Btrfs uses libcrc32c in the kernel for file and metadata checksums. You need -to compile the kernel with: - -CONFIG_LIBCRC32C=m - -libcrc32c can be static as well. Once your kernel is setup, typing make in the -btrfs module sources will build against the running kernel. When the build is -complete: - -modprobe libcrc32c -insmod btrfs.ko - -The Btrfs utility programs require libuuid to build. This can be found -in the e2fsprogs sources, and is usually available as libuuid or -e2fsprogs-devel from various distros. - -Building the utilities is just make ; make install. The programs go -into /usr/local/bin. The mains commands available are: - -mkfs.btrfs: create a filesystem - -btrfs: control program to create snapshots and subvolumes: - # mount a btrfs filesystem - mount /dev/sda2 /mnt - - # create a subvolume - btrfs subvolume create /mnt/new_subvol_name - - # snapshot of a subvolume - btrfs subvolume snapshot /mnt/default /mnt/snapshot_of_default - btrfs subvolume snapshot /mnt/snapshot_of_default \ - /mnt/snapshot_of_a_snapshot - - # list of the subvolumes - ls /mnt - default snapshot_of_a_snapshot snapshot_of_new_subvol - new_subvol_name snapshot_of_default - - # removal of a subvolume or a snapshot - btrfs subvolume delete /mn/snapshot_of_a_snapshot - - # look a the btrfs man page for further information - man btrfs - -btrfsck: do a limited check of the FS extent trees.</li> - -btrfs-debug-tree: print all of the FS metadata in text form. Example: - - btrfs-debug-tree /dev/sda2 >& big_output_file - - - diff --git a/Makefile b/Makefile deleted file mode 100644 index 27d62c0..0000000 --- a/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -CC = gcc -AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -DBTRFS_FLAT_INCLUDES -fPIC -CFLAGS = -g -O1 -objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ - root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \ - extent-cache.o extent_io.o volumes.o utils.o btrfslabel.o repair.o \ - qgroup.o -cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \ - cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \ - cmds-quota.o cmds-qgroup.o -libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o -libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \ - crc32c.h list.h kerncompat.h radix-tree.h extent-cache.h \ - extent_io.h ioctl.h ctree.h - -CHECKFLAGS= -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \ - -Wuninitialized -Wshadow -Wundef -DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@ - -INSTALL = install -prefix ?= /usr/local -bindir = $(prefix)/bin -libdir = $(prefix)/lib -incdir = $(prefix)/include/btrfs -lib_LIBS=-luuid -lm -L. -LIBS=$(lib_LIBS) -lbtrfs -RESTORE_LIBS=-lz - -progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck \ - btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \ - btrfs-find-root btrfs-restore btrfstune - -libs = libbtrfs.so.1.0 -lib_links = libbtrfs.so.1 libbtrfs.so -headers = $(libbtrfs_headers) - -# make C=1 to enable sparse -ifdef C - check = sparse $(CHECKFLAGS) -else - check = ls -endif - -.c.o: - $(check) $< - $(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $< - - -all: version $(libs) $(progs) manpages - -version: - bash version.sh - -$(libs): $(libbtrfs_objects) $(lib_links) send.h - $(CC) $(CFLAGS) $(libbtrfs_objects) $(lib_LIBS) -shared -Wl,-soname,libbtrfs.so.1 -o libbtrfs.so.1.0 - -$(lib_links): - ln -sf libbtrfs.so.1.0 libbtrfs.so.1 - ln -sf libbtrfs.so.1.0 libbtrfs.so - -btrfs: $(objects) btrfs.o help.o common.o $(cmds_objects) $(libs) - $(CC) $(CFLAGS) -o btrfs btrfs.o help.o common.o $(cmds_objects) \ - $(objects) $(LDFLAGS) $(LIBS) -lpthread - -calc-size: $(objects) $(libs) calc-size.o - $(CC) $(CFLAGS) -o calc-size calc-size.o $(objects) $(LDFLAGS) $(LIBS) - -btrfs-find-root: $(objects) $(libs) find-root.o - $(CC) $(CFLAGS) -o btrfs-find-root find-root.o $(objects) $(LDFLAGS) $(LIBS) - -btrfs-restore: $(objects) $(libs) restore.o - $(CC) $(CFLAGS) -o btrfs-restore restore.o $(objects) $(LDFLAGS) $(LIBS) $(RESTORE_LIBS) - -btrfsctl: $(objects) $(libs) btrfsctl.o - $(CC) $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS) - -btrfs-vol: $(objects) $(libs) btrfs-vol.o - $(CC) $(CFLAGS) -o btrfs-vol btrfs-vol.o $(objects) $(LDFLAGS) $(LIBS) - -btrfs-show: $(objects) $(libs) btrfs-show.o - $(CC) $(CFLAGS) -o btrfs-show btrfs-show.o $(objects) $(LDFLAGS) $(LIBS) - -btrfsck: $(objects) $(libs) btrfsck.o - $(CC) $(CFLAGS) -o btrfsck btrfsck.o $(objects) $(LDFLAGS) $(LIBS) - -mkfs.btrfs: $(objects) $(libs) mkfs.o - $(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS) - -btrfs-debug-tree: $(objects) $(libs) debug-tree.o - $(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) $(LIBS) - -btrfs-zero-log: $(objects) $(libs) btrfs-zero-log.o - $(CC) $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o $(LDFLAGS) $(LIBS) - -btrfs-select-super: $(objects) $(libs) btrfs-select-super.o - $(CC) $(CFLAGS) -o btrfs-select-super $(objects) btrfs-select-super.o $(LDFLAGS) $(LIBS) - -btrfstune: $(objects) $(libs) btrfstune.o - $(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS) - -btrfs-map-logical: $(objects) $(libs) btrfs-map-logical.o - $(CC) $(CFLAGS) -o btrfs-map-logical $(objects) btrfs-map-logical.o $(LDFLAGS) $(LIBS) - -btrfs-corrupt-block: $(objects) $(libs) btrfs-corrupt-block.o - $(CC) $(CFLAGS) -o btrfs-corrupt-block $(objects) btrfs-corrupt-block.o $(LDFLAGS) $(LIBS) - -btrfs-image: $(objects) $(libs) btrfs-image.o - $(CC) $(CFLAGS) -o btrfs-image $(objects) btrfs-image.o -lpthread -lz $(LDFLAGS) $(LIBS) - -dir-test: $(objects) $(libs) dir-test.o - $(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS) - -quick-test: $(objects) $(libs) quick-test.o - $(CC) $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS) - -btrfs-convert: $(objects) $(libs) convert.o - $(CC) $(CFLAGS) -o btrfs-convert $(objects) convert.o -lext2fs -lcom_err $(LDFLAGS) $(LIBS) - -ioctl-test: $(objects) $(libs) ioctl-test.o - $(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS) - -send-test: $(objects) send-test.o - $(CC) $(CFLAGS) -o send-test send-test.o $(LDFLAGS) $(LIBS) -lpthread - -manpages: - cd man; $(MAKE) - -install-man: - cd man; $(MAKE) install - -clean : - rm -f $(progs) $(libs) cscope.out *.o .*.d btrfs-convert btrfs-image \ - btrfs-select-super btrfs-zero-log btrfstune dir-test ioctl-test \ - quick-test send-test version.h - cd man; $(MAKE) clean - -install: $(libs) $(progs) install-man - $(INSTALL) -m755 -d $(DESTDIR)$(bindir) - $(INSTALL) $(progs) $(DESTDIR)$(bindir) - $(INSTALL) -m755 -d $(DESTDIR)$(libdir) - $(INSTALL) $(libs) $(DESTDIR)$(libdir) - cp -a $(lib_links) $(DESTDIR)$(libdir) - $(INSTALL) -m755 -d $(DESTDIR)$(incdir) - $(INSTALL) $(headers) $(DESTDIR)$(incdir) - --include .*.d diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..0a25838 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,53 @@ +SUBDIRS = man + +AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 \ + -DBTRFS_FLAT_INCLUDES + +version.h : version.sh + sh $(top_srcdir)/version.sh + +noinst_LTLIBRARIES = libbtrfs_static.la +lib_LTLIBRARIES = libbtrfs.la +libbtrfs_la_SOURCES = send-stream.c send-utils.c rbtree.c btrfs-list.c crc32c.c +libbtrfs_la_LDFLAGS = -version-info 0:1:0 +libbtrfs_static_la_SOURCES = $(libbtrfs_la_SOURCES) + +noinst_LTLIBRARIES += libbtrfscore.la +libbtrfscore_la_SOURCES = ctree.c disk-io.c radix-tree.c extent-tree.c \ + print-tree.c root-tree.c dir-item.c file-item.c \ + inode-item.c inode-map.c extent-cache.c extent_io.c \ + volumes.c utils.c btrfslabel.c repair.c qgroup.c + +CMDS = cmds-subvolume.c cmds-filesystem.c cmds-device.c cmds-scrub.c \ + cmds-inspect.c cmds-balance.c cmds-send.c cmds-receive.c \ + cmds-quota.c cmds-qgroup.c + +sbin_PROGRAMS = mkfs.btrfs btrfs-debug-tree btrfsck btrfs btrfs-image \ + btrfs-zero-log btrfs-find-root btrfs-restore btrfstune \ + btrfs-select-super btrfs-convert +bin_PROGRAMS = btrfsctl btrfs-show btrfs-vol btrfs-map-logical +noinst_PROGRAMS = send-test + +LDADD = libbtrfscore.la libbtrfs_static.la -luuid -lm + +libbtrfsdir = $(includedir)/btrfs +libbtrfs_HEADERS = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \ + crc32c.h list.h kerncompat.h radix-tree.h extent-cache.h \ + extent_io.h ioctl.h ctree.h + +btrfs_SOURCES = btrfs.c help.c common.c $(CMDS) +btrfs_LDADD = -lpthread $(LDADD) +btrfs_debug_tree_SOURCES = debug-tree.c + +btrfs_convert_SOURCES = convert.c +btrfs_convert_LDADD = -lext2fs -lcom_err $(LDADD) + +btrfs_restore_SOURCES = restore.c +btrfs_restore_LDADD = -lz $(LDADD) + +btrfs_find_root_SOURCES = find-root.c + +btrfs_image_LDADD = -lpthread -lz $(LDADD) + +send_test_LDADD = -lpthread $(LDADD) + diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..292350b --- /dev/null +++ b/README @@ -0,0 +1,59 @@ +Usage Instructions + +Btrfs puts snapshots and subvolumes into the root directory of the FS. This +directory can only be changed by btrfsctl right now, and normal filesystem +operations do not work on it. The default subvolume is called ''default'', +and you can create files and directories in mount_point/default + +Btrfs uses libcrc32c in the kernel for file and metadata checksums. You need +to compile the kernel with: + +CONFIG_LIBCRC32C=m + +libcrc32c can be static as well. Once your kernel is setup, typing make in the +btrfs module sources will build against the running kernel. When the build is +complete: + +modprobe libcrc32c +insmod btrfs.ko + +The Btrfs utility programs require libuuid to build. This can be found +in the e2fsprogs sources, and is usually available as libuuid or +e2fsprogs-devel from various distros. + +Building the utilities is just ./autogen.sh ; make ; make install. +The main commands available are: + +mkfs.btrfs: create a filesystem + +btrfs: control program to create snapshots and subvolumes: + # mount a btrfs filesystem + mount /dev/sda2 /mnt + + # create a subvolume + btrfs subvolume create /mnt/new_subvol_name + + # snapshot of a subvolume + btrfs subvolume snapshot /mnt/default /mnt/snapshot_of_default + btrfs subvolume snapshot /mnt/snapshot_of_default \ + /mnt/snapshot_of_a_snapshot + + # list of the subvolumes + ls /mnt + default snapshot_of_a_snapshot snapshot_of_new_subvol + new_subvol_name snapshot_of_default + + # removal of a subvolume or a snapshot + btrfs subvolume delete /mn/snapshot_of_a_snapshot + + # look a the btrfs man page for further information + man btrfs + +btrfsck: do a limited check of the FS extent trees.</li> + +btrfs-debug-tree: print all of the FS metadata in text form. Example: + + btrfs-debug-tree /dev/sda2 >& big_output_file + + + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..154cd1c --- /dev/null +++ b/autogen.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +rm -fr aclocal.m4 autom4te.cache/ +autoreconf -iv +./configure diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..080b7f4 --- /dev/null +++ b/configure.ac @@ -0,0 +1,6 @@ +AC_INIT([btrfsprogs], [0.20]) +AM_INIT_AUTOMAKE([1.9]) + +AC_PROG_LIBTOOL +AC_PROG_CC +AC_OUTPUT([Makefile man/Makefile]) diff --git a/man/Makefile b/man/Makefile deleted file mode 100644 index 4a90b75..0000000 --- a/man/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -GZIP=gzip -INSTALL= install - -prefix ?= /usr/local -bindir = $(prefix)/bin -mandir = $(prefix)/man -man8dir = $(mandir)/man8 - -MANPAGES = mkfs.btrfs.8.gz btrfsctl.8.gz btrfsck.8.gz btrfs-image.8.gz \ - btrfs-show.8.gz btrfs.8.gz - -all: $(MANPAGES) - -mkfs.btrfs.8.gz: mkfs.btrfs.8.in - $(GZIP) -n -c mkfs.btrfs.8.in > mkfs.btrfs.8.gz - -btrfs.8.gz: btrfs.8.in - $(GZIP) -n -c btrfs.8.in > btrfs.8.gz - -btrfsctl.8.gz: btrfsctl.8.in - $(GZIP) -n -c btrfsctl.8.in > btrfsctl.8.gz - -btrfsck.8.gz: btrfsck.8.in - $(GZIP) -n -c btrfsck.8.in > btrfsck.8.gz - -btrfs-image.8.gz: btrfs-image.8.in - $(GZIP) -n -c btrfs-image.8.in > btrfs-image.8.gz - -btrfs-show.8.gz: btrfs-show.8.in - $(GZIP) -n -c btrfs-show.8.in > btrfs-show.8.gz - -clean : - rm -f $(MANPAGES) - -install: $(MANPAGES) - $(INSTALL) -m755 -d $(DESTDIR)$(man8dir) - $(INSTALL) -m 644 $(MANPAGES) $(DESTDIR)$(man8dir) diff --git a/man/Makefile.am b/man/Makefile.am new file mode 100644 index 0000000..a6e6c9d --- /dev/null +++ b/man/Makefile.am @@ -0,0 +1,2 @@ +man8_MANS = btrfs.8 btrfsck.8 btrfsctl.8 btrfs-image.8 \ + btrfs-show.8 mkfs.btrfs.8 diff --git a/man/btrfs-image.8 b/man/btrfs-image.8 new file mode 100644 index 0000000..7a348f8 --- /dev/null +++ b/man/btrfs-image.8 @@ -0,0 +1,34 @@ +.TH BTRFS-IMAGE 8 +.SH NAME +btrfs-image \- create/restore an image of the filesystem +.SH SYNOPSIS +.B btrfs-image +[options] \fIsource\fP \fItarget\fP +.SH DESCRIPTION +.B btrfs-image +is used to create an image of a btrfs filesystem. All data will be zeroed, +but metadata and the like is preserved. +.I source +is the special file corresponding to the device containing a btrfs filesystem. +(e.g \fI/dev/sdXX\fP). +.I target +is the image file that btrfs-image creates. When used with \fB-r\fP option, +\fBbtrfs-image\fP restores the image file from source into target. +.SH OPTIONS +.TP +\fB\-r\fP +restore metadump image. +.TP +\fB\-c\fR \fIvalue\fP +compression level (0 ~ 9). +.TP +\fB\-t\fR \fIvalue\fP +number of threads (1 ~ 32) to be used to process the image dump or restore. +.SH AVAILABILITY +.B btrfs-image +is part of btrfs-progs. Btrfs 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. +.SH SEE ALSO +.BR btrfsck (8), btrfsctl (8), mkfs.btrfs (8) diff --git a/man/btrfs-image.8.in b/man/btrfs-image.8.in deleted file mode 100644 index 7a348f8..0000000 --- a/man/btrfs-image.8.in +++ /dev/null @@ -1,34 +0,0 @@ -.TH BTRFS-IMAGE 8 -.SH NAME -btrfs-image \- create/restore an image of the filesystem -.SH SYNOPSIS -.B btrfs-image -[options] \fIsource\fP \fItarget\fP -.SH DESCRIPTION -.B btrfs-image -is used to create an image of a btrfs filesystem. All data will be zeroed, -but metadata and the like is preserved. -.I source -is the special file corresponding to the device containing a btrfs filesystem. -(e.g \fI/dev/sdXX\fP). -.I target -is the image file that btrfs-image creates. When used with \fB-r\fP option, -\fBbtrfs-image\fP restores the image file from source into target. -.SH OPTIONS -.TP -\fB\-r\fP -restore metadump image. -.TP -\fB\-c\fR \fIvalue\fP -compression level (0 ~ 9). -.TP -\fB\-t\fR \fIvalue\fP -number of threads (1 ~ 32) to be used to process the image dump or restore. -.SH AVAILABILITY -.B btrfs-image -is part of btrfs-progs. Btrfs 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. -.SH SEE ALSO -.BR btrfsck (8), btrfsctl (8), mkfs.btrfs (8) diff --git a/man/btrfs-show.8 b/man/btrfs-show.8 new file mode 100644 index 0000000..cb98b68 --- /dev/null +++ b/man/btrfs-show.8 @@ -0,0 +1,22 @@ +.TH BTRFS-SHOW 8 +.SH NAME +btrfs-show \- scan the /dev directory for btrfs partitions and print results. +.SH SYNOPSIS +.B btrfs-show +.SH NOTE +.B btrfs-show +is deprecated. Please consider to switch to the btrfs utility. +.SH DESCRIPTION +.B btrfs-show +is used to scan the /dev directory for btrfs partitions and display brief +information such as lable, uuid, etc of each btrfs partition. +.SH OPTIONS +none +.SH AVAILABILITY +.B btrfs-show +is part of btrfs-progs. Btrfs 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. +.SH SEE ALSO +.BR btrfsck (8), btrfsctl (8), mkfs.btrfs (8), btrfs-image (8) diff --git a/man/btrfs-show.8.in b/man/btrfs-show.8.in deleted file mode 100644 index cb98b68..0000000 --- a/man/btrfs-show.8.in +++ /dev/null @@ -1,22 +0,0 @@ -.TH BTRFS-SHOW 8 -.SH NAME -btrfs-show \- scan the /dev directory for btrfs partitions and print results. -.SH SYNOPSIS -.B btrfs-show -.SH NOTE -.B btrfs-show -is deprecated. Please consider to switch to the btrfs utility. -.SH DESCRIPTION -.B btrfs-show -is used to scan the /dev directory for btrfs partitions and display brief -information such as lable, uuid, etc of each btrfs partition. -.SH OPTIONS -none -.SH AVAILABILITY -.B btrfs-show -is part of btrfs-progs. Btrfs 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. -.SH SEE ALSO -.BR btrfsck (8), btrfsctl (8), mkfs.btrfs (8), btrfs-image (8) diff --git a/man/btrfs.8 b/man/btrfs.8 new file mode 100644 index 0000000..9222580 --- /dev/null +++ b/man/btrfs.8 @@ -0,0 +1,365 @@ +.TH BTRFS 8 "" "btrfs" "btrfs" +.\" +.\" Man page written by Goffredo Baroncelli <kreijack@inwind.it> (Feb 2010) +.\" +.SH NAME +btrfs \- control a btrfs filesystem +.SH SYNOPSIS +\fBbtrfs\fP \fBsubvolume snapshot\fP\fI [-r] <source> [<dest>/]<name>\fP +.PP +\fBbtrfs\fP \fBsubvolume delete\fP\fI <subvolume> [<subvolume>...]\fP +.PP +\fBbtrfs\fP \fBsubvolume create\fP\fI [<dest>/]<name>\fP +.PP +\fBbtrfs\fP \fBsubvolume list\fP\fI [-aprts] [-g [+|-]value] [-c [+|-]value] [--rootid=rootid,gen,ogen,path] <path>\fP +.PP +\fBbtrfs\fP \fBsubvolume set-default\fP\fI <id> <path>\fP +.PP +\fBbtrfs\fP \fBsubvolume get-default\fP\fI <path>\fP +.PP +\fBbtrfs\fP \fBfilesystem defragment\fP -c[zlib|lzo] [-l \fIlen\fR] \ +[-s \fIstart\fR] [-t \fIsize\fR] -[vf] <\fIfile\fR>|<\fIdir\fR> \ +[<\fIfile\fR>|<\fIdir\fR>...] +.PP +\fBbtrfs\fP \fBfilesystem sync\fP\fI <path> \fP +.PP +\fBbtrfs\fP \fBfilesystem resize\fP\fI [devid:][+/\-]<size>[gkm]|[devid:]max <filesystem>\fP +.PP +\fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP +.PP +\fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP +.PP +\fBbtrfs\fP \fBfilesystem balance\fP\fI <path> \fP +.PP +\fBbtrfs\fP \fBdevice scan\fP\fI [--all-devices|<device> [<device>...]]\fP +.PP +\fBbtrfs\fP \fBdevice show\fP\fI [--all-devices|<uuid>|<label>]\fP +.PP +\fBbtrfs\fP \fBdevice add\fP\fI <device> [<device>...] <path> \fP +.PP +\fBbtrfs\fP \fBdevice delete\fP\fI <device> [<device>...] <path> \fP +.PP +\fBbtrfs\fP \fBscrub start\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP} +.PP +\fBbtrfs\fP \fBscrub cancel\fP {\fI<path>\fP|\fI<device>\fP} +.PP +\fBbtrfs\fP \fBscrub resume\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP} +.PP +\fBbtrfs\fP \fBscrub status\fP [-d] {\fI<path>\fP|\fI<device>\fP} +.PP +\fBbtrfs\fP \fBinspect-internal inode-resolve\fP [-v] \fI<inode>\fP \fI<path>\fP +.PP +\fBbtrfs\fP \fBinspect-internal logical-resolve\fP +[-Pv] [-s size] \fI<logical>\fP \fI<path>\fP +.PP +\fBbtrfs\fP \fBhelp|\-\-help|\-h \fP\fI\fP +.PP +\fBbtrfs\fP \fB<command> \-\-help \fP\fI\fP +.PP +.SH DESCRIPTION +.B btrfs +is used to control the filesystem and the files and directories 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 +.I btrfs sub snaps +instead of +.I btrfs subvolume snapshot. +But +.I btrfs file s +is not allowed, because +.I file s +may be interpreted both as +.I filesystem show +and as +.I filesystem sync. +In this case +.I btrfs +returns filesystem sync +If a command is terminated by +.I --help +, the detailed help is showed. If the passed command matches more commands, +detailed help of all the matched commands is showed. For example +.I btrfs dev --help +shows the help of all +.I device* +commands. + +.SH COMMANDS +.TP + +\fBsubvolume snapshot\fR\fI [-r] <source> [<dest>/]<name>\fR +Create a writable/readonly snapshot of the subvolume \fI<source>\fR with the +name \fI<name>\fR in the \fI<dest>\fR directory. If \fI<source>\fR is not a +subvolume, \fBbtrfs\fR returns an error. If \fI-r\fR is given, the snapshot +will be readonly. +.TP + +\fBsubvolume delete\fR\fI <subvolume> [<subvolume>...]\fR +Delete the subvolume \fI<subvolume>\fR. If \fI<subvolume>\fR is not a +subvolume, \fBbtrfs\fR returns an error. +.TP + +\fBsubvolume create\fR\fI [<dest>/]<name>\fR +Create a subvolume in \fI<dest>\fR (or in the current directory if +\fI<dest>\fR is omitted). +.TP + +\fBsubvolume list\fR\fI [-aprts][-g [+|-]value] [-c [+|-]value] [--sort=gen,ogen,rootid,path] <path>\fR +.RS +List the subvolumes present in the filesystem \fI<path>\fR. 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 \fItop level\fR +subvolume. + +The subvolume''s ID may be used by the \fBsubvolume set-default\fR command, or +at mount time via the \fIsubvol=\fR option. +If \fI-p\fR is given, then \fIparent <ID>\fR is added to the output between ID +and top level. The parent''s ID may be used at mount time via the +\fIsubvolrootid=\fR option. + +\fB-t\fP print the result as a table. + +\fB-a\fP print all the subvolumes in the filesystem. + +\fB-r\fP only readonly subvolumes in the filesystem wille be listed. + +\fB-s\fP only snapshot subvolumes in the filesystem will be listed. + +\fB-g [+|-]value\fP +list subvolumes in the filesystem that its generation is +>=, <= or = value. ''+'' means >= value, ''-'' means <= value, If there is +neither ''+'' nor ''-'', it means = value. + +\fB-c [+|-]value\fP +list subvolumes in the filesystem that its ogeneration is +>=, <= or = value. The usage is the same to ''-g'' option. + +\fB--sort=gen,ogen,path,rootid\fP +list subvolumes in order by specified items. +you can add ''+'' or ''-'' in front of each items, ''+'' means ascending,''-'' +means descending. The default is ascending. + +for \fB--sort\fP you can combine some items together by '','', just like +\f--sort=+ogen,-gen,path,rootid\fR. +.RE +.TP + +\fBsubvolume set-default\fR\fI <id> <path>\fR +Set the subvolume of the filesystem \fI<path>\fR which is mounted as +\fIdefault\fR. The subvolume is identified by \fI<id>\fR, which +is returned by the \fBsubvolume list\fR command. +.TP + +\fBsubvolume get-default\fR\fI <path>\fR +Get the default subvolume of the filesystem \fI<path>\fR. The output format +is similar to \fBsubvolume list\fR command. +.TP + +\fBfilesystem defragment\fP -c[zlib|lzo] [-l \fIlen\fR] [-s \fIstart\fR] \ +[-t \fIsize\fR] -[vf] <\fIfile\fR>|<\fIdir\fR> [<\fIfile\fR>|<\fIdir\fR>...] + +Defragment file data and/or directory metadata. To defragment all files in a +directory you have to specify each one on its own or use your shell wildcards. + +The start position and the number of bytes to defragment can be specified by +\fIstart\fR and \fIlen\fR. Any extent bigger than threshold 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. + +\fB-v\fP be verbose + +\fB-c\fP compress file contents while defragmenting + +\fB-f\fP flush filesystem after defragmenting + +\fB-s start\fP defragment only from byte \fIstart\fR onward + +\fB-l len\fP defragment only up to \fIlen\fR bytes + +\fB-t size\fP defragment only files at least \fIsize\fR bytes big + +NOTE: 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 \fBcp --reflink\fP. +.TP + +\fBsubvolume find-new\fR\fI <subvolume> <last_gen>\fR +List the recently modified files in a subvolume, after \fI<last_gen>\fR ID. +.TP + +\fBfilesystem sync\fR\fI <path> \fR +Force a sync for the filesystem identified by \fI<path>\fR. +.TP + +.\" +.\" Some wording are extracted by the resize2fs man page +.\" + +\fBfilesystem resize\fR\fI [devid:][+/\-]<size>[gkm]|[devid:]max <path>\fR +Resize a filesystem identified by \fI<path>\fR for the underlying device +\fIdevid\fR. The \fIdevid\fR can be found with \fBbtrfs filesystem show\fR and +defaults to 1 if not specified. +The \fI<size>\fR parameter specifies the new size of the filesystem. +If the prefix \fI+\fR or \fI\-\fR is present the size is increased or decreased +by the quantity \fI<size>\fR. +If no units are specified, the unit of the \fI<size>\fR parameter defaults to +bytes. Optionally, the size parameter may be suffixed by one of the following +units designators: ''K'', ''M'', or ''G'', kilobytes, megabytes, or gigabytes, +respectively. + +If ''max'' is passed, the filesystem will occupy all available space on the +device \fIdevid\fR. + +The \fBresize\fR command \fBdoes not\fR manipulate the size of underlying +partition. If you wish to enlarge/reduce a filesystem, you must make sure you +can expand the partition before enlarging the filesystem and shrink the +partition after reducing the size of the filesystem. This can done using +\fBfdisk(8)\fR or \fBparted(8)\fR to delete the existing partition and recreate +it with the new desired size. When recreating the partition make sure to use +the same starting disk cylinder as before. +.TP + +\fBfilesystem label\fP\fI <dev> [newlabel]\fP +Show or update the label of a filesystem. \fI<dev>\fR is used to identify the +filesystem. +If a \fInewlabel\fR optional argument is passed, the label is changed. The +following constraints exist for a label: +.IP +- the maximum allowable length shall be less or equal than 256 chars +.IP +- the label shall not contain the ''/'' or ''\\'' characters. + +NOTE: Currently there are the following limitations: +.IP +- the filesystem has to be unmounted +.IP +- the filesystem should not have more than one device. +.TP + +\fBfilesystem show\fR [--all-devices|<uuid>|<label>]\fR +Show the btrfs filesystem with some additional info. If no \fIUUID\fP or +\fIlabel\fP is passed, \fBbtrfs\fR show info of all the btrfs filesystem. +If \fB--all-devices\fP is passed, all the devices under /dev are scanned; +otherwise the devices list is extracted from the /proc/partitions file. +.TP + +\fBfilesystem balance\fR \fI<path>\fR +Balance the chunks of the filesystem identified by \fI<path>\fR +across the devices. +.TP + +\fBdevice add\fR\fI <dev> [<dev>..] <path>\fR +Add device(s) to the filesystem identified by \fI<path>\fR. +.TP + +\fBdevice delete\fR\fI <dev> [<dev>..] <path>\fR +Remove device(s) from a filesystem identified by \fI<path>\fR. +.TP + +\fBdevice scan\fR \fI[--all-devices|<device> [<device>...]\fR +If one or more devices are passed, these are scanned for a btrfs filesystem. +If no devices are passed, \fBbtrfs\fR scans all the block devices listed +in the /proc/partitions file. +Finally, if \fB--all-devices\fP is passed, all the devices under /dev are +scanned. +.TP + +\fBscrub start\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP} +Start a scrub on all devices of the filesystem identified by \fI<path>\fR or on +a single \fI<device>\fR. Without options, scrub is started as a background +process. Progress can be obtained with the \fBscrub status\fR command. Scrubbing +involves reading all data from all disks and verifying checksums. Errors are +corrected along the way if possible. +.RS + +\fIOptions\fR +.IP -B 5 +Do not background and print scrub statistics when finished. +.IP -d 5 +Print separate statistics for each device of the filesystem (-B only). +.IP -q 5 +Quiet. Omit error messages and statistics. +.IP -r 5 +Read only mode. Do not attempt to correct anything. +.IP -u 5 +Scrub unused space as well. (NOT IMPLEMENTED) +.RE +.TP + +\fBscrub cancel\fP {\fI<path>\fP|\fI<device>\fP} +If a scrub is running on the filesystem identified by \fI<path>\fR, cancel it. +Progress is saved in the scrub progress file and scrubbing can be resumed later +using the \fBscrub resume\fR command. +If a \fI<device>\fR is given, the corresponding filesystem is found and +\fBscrub cancel\fP behaves as if it was called on that filesystem. +.TP + +\fBscrub resume\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP} +Resume a canceled or interrupted scrub cycle on the filesystem identified by +\fI<path>\fR or on a given \fI<device>\fR. Does not start a new scrub if the +last scrub finished successfully. +.RS + +\fIOptions\fR +.TP +see \fBscrub start\fP. +.RE +.TP + +\fBscrub status\fP [-d] {\fI<path>\fP|\fI<device>\fP} +Show status of a running scrub for the filesystem identified by \fI<path>\fR or +for the specified \fI<device>\fR. +If no scrub is running, show statistics of the last finished or canceled scrub +for that filesystem or device. +.RS + +\fIOptions\fR +.IP -d 5 +Print separate statistics for each device of the filesystem. +.RE +.TP + +\fBinspect-internal inode-resolve\fP [-v] \fI<inode>\fP \fI<path>\fP +Resolves an <inode> in subvolume <path> to all filesystem paths. +.RS + +\fIOptions\fR +.IP -v 5 +verbose mode. print count of returned paths and ioctl() return value +.RE +.TP + +\fBinspect-internal logical-resolve\fP [-Pv] [-s bufsize] \fI<logical>\fP \fI<path>\fP +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 +\fBinode-resolve\fP subcommand). +.RS + +\fIOptions\fR +.IP -P 5 +skip the path resolving and print the inodes instead +.IP -v 5 +verbose mode. print count of returned paths and all ioctl() return values +.IP -s bufsize 5 +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. +.RE + +.SH EXIT STATUS +\fBbtrfs\fR returns a zero exist status if it succeeds. Non zero is returned in +case of failure. + +.SH AVAILABILITY +.B 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. +.SH SEE ALSO +.BR mkfs.btrfs (8) diff --git a/man/btrfs.8.in b/man/btrfs.8.in deleted file mode 100644 index 9222580..0000000 --- a/man/btrfs.8.in +++ /dev/null @@ -1,365 +0,0 @@ -.TH BTRFS 8 "" "btrfs" "btrfs" -.\" -.\" Man page written by Goffredo Baroncelli <kreijack@inwind.it> (Feb 2010) -.\" -.SH NAME -btrfs \- control a btrfs filesystem -.SH SYNOPSIS -\fBbtrfs\fP \fBsubvolume snapshot\fP\fI [-r] <source> [<dest>/]<name>\fP -.PP -\fBbtrfs\fP \fBsubvolume delete\fP\fI <subvolume> [<subvolume>...]\fP -.PP -\fBbtrfs\fP \fBsubvolume create\fP\fI [<dest>/]<name>\fP -.PP -\fBbtrfs\fP \fBsubvolume list\fP\fI [-aprts] [-g [+|-]value] [-c [+|-]value] [--rootid=rootid,gen,ogen,path] <path>\fP -.PP -\fBbtrfs\fP \fBsubvolume set-default\fP\fI <id> <path>\fP -.PP -\fBbtrfs\fP \fBsubvolume get-default\fP\fI <path>\fP -.PP -\fBbtrfs\fP \fBfilesystem defragment\fP -c[zlib|lzo] [-l \fIlen\fR] \ -[-s \fIstart\fR] [-t \fIsize\fR] -[vf] <\fIfile\fR>|<\fIdir\fR> \ -[<\fIfile\fR>|<\fIdir\fR>...] -.PP -\fBbtrfs\fP \fBfilesystem sync\fP\fI <path> \fP -.PP -\fBbtrfs\fP \fBfilesystem resize\fP\fI [devid:][+/\-]<size>[gkm]|[devid:]max <filesystem>\fP -.PP -\fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP -.PP -\fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP -.PP -\fBbtrfs\fP \fBfilesystem balance\fP\fI <path> \fP -.PP -\fBbtrfs\fP \fBdevice scan\fP\fI [--all-devices|<device> [<device>...]]\fP -.PP -\fBbtrfs\fP \fBdevice show\fP\fI [--all-devices|<uuid>|<label>]\fP -.PP -\fBbtrfs\fP \fBdevice add\fP\fI <device> [<device>...] <path> \fP -.PP -\fBbtrfs\fP \fBdevice delete\fP\fI <device> [<device>...] <path> \fP -.PP -\fBbtrfs\fP \fBscrub start\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP} -.PP -\fBbtrfs\fP \fBscrub cancel\fP {\fI<path>\fP|\fI<device>\fP} -.PP -\fBbtrfs\fP \fBscrub resume\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP} -.PP -\fBbtrfs\fP \fBscrub status\fP [-d] {\fI<path>\fP|\fI<device>\fP} -.PP -\fBbtrfs\fP \fBinspect-internal inode-resolve\fP [-v] \fI<inode>\fP \fI<path>\fP -.PP -\fBbtrfs\fP \fBinspect-internal logical-resolve\fP -[-Pv] [-s size] \fI<logical>\fP \fI<path>\fP -.PP -\fBbtrfs\fP \fBhelp|\-\-help|\-h \fP\fI\fP -.PP -\fBbtrfs\fP \fB<command> \-\-help \fP\fI\fP -.PP -.SH DESCRIPTION -.B btrfs -is used to control the filesystem and the files and directories 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 -.I btrfs sub snaps -instead of -.I btrfs subvolume snapshot. -But -.I btrfs file s -is not allowed, because -.I file s -may be interpreted both as -.I filesystem show -and as -.I filesystem sync. -In this case -.I btrfs -returns filesystem sync -If a command is terminated by -.I --help -, the detailed help is showed. If the passed command matches more commands, -detailed help of all the matched commands is showed. For example -.I btrfs dev --help -shows the help of all -.I device* -commands. - -.SH COMMANDS -.TP - -\fBsubvolume snapshot\fR\fI [-r] <source> [<dest>/]<name>\fR -Create a writable/readonly snapshot of the subvolume \fI<source>\fR with the -name \fI<name>\fR in the \fI<dest>\fR directory. If \fI<source>\fR is not a -subvolume, \fBbtrfs\fR returns an error. If \fI-r\fR is given, the snapshot -will be readonly. -.TP - -\fBsubvolume delete\fR\fI <subvolume> [<subvolume>...]\fR -Delete the subvolume \fI<subvolume>\fR. If \fI<subvolume>\fR is not a -subvolume, \fBbtrfs\fR returns an error. -.TP - -\fBsubvolume create\fR\fI [<dest>/]<name>\fR -Create a subvolume in \fI<dest>\fR (or in the current directory if -\fI<dest>\fR is omitted). -.TP - -\fBsubvolume list\fR\fI [-aprts][-g [+|-]value] [-c [+|-]value] [--sort=gen,ogen,rootid,path] <path>\fR -.RS -List the subvolumes present in the filesystem \fI<path>\fR. 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 \fItop level\fR -subvolume. - -The subvolume''s ID may be used by the \fBsubvolume set-default\fR command, or -at mount time via the \fIsubvol=\fR option. -If \fI-p\fR is given, then \fIparent <ID>\fR is added to the output between ID -and top level. The parent''s ID may be used at mount time via the -\fIsubvolrootid=\fR option. - -\fB-t\fP print the result as a table. - -\fB-a\fP print all the subvolumes in the filesystem. - -\fB-r\fP only readonly subvolumes in the filesystem wille be listed. - -\fB-s\fP only snapshot subvolumes in the filesystem will be listed. - -\fB-g [+|-]value\fP -list subvolumes in the filesystem that its generation is ->=, <= or = value. ''+'' means >= value, ''-'' means <= value, If there is -neither ''+'' nor ''-'', it means = value. - -\fB-c [+|-]value\fP -list subvolumes in the filesystem that its ogeneration is ->=, <= or = value. The usage is the same to ''-g'' option. - -\fB--sort=gen,ogen,path,rootid\fP -list subvolumes in order by specified items. -you can add ''+'' or ''-'' in front of each items, ''+'' means ascending,''-'' -means descending. The default is ascending. - -for \fB--sort\fP you can combine some items together by '','', just like -\f--sort=+ogen,-gen,path,rootid\fR. -.RE -.TP - -\fBsubvolume set-default\fR\fI <id> <path>\fR -Set the subvolume of the filesystem \fI<path>\fR which is mounted as -\fIdefault\fR. The subvolume is identified by \fI<id>\fR, which -is returned by the \fBsubvolume list\fR command. -.TP - -\fBsubvolume get-default\fR\fI <path>\fR -Get the default subvolume of the filesystem \fI<path>\fR. The output format -is similar to \fBsubvolume list\fR command. -.TP - -\fBfilesystem defragment\fP -c[zlib|lzo] [-l \fIlen\fR] [-s \fIstart\fR] \ -[-t \fIsize\fR] -[vf] <\fIfile\fR>|<\fIdir\fR> [<\fIfile\fR>|<\fIdir\fR>...] - -Defragment file data and/or directory metadata. To defragment all files in a -directory you have to specify each one on its own or use your shell wildcards. - -The start position and the number of bytes to defragment can be specified by -\fIstart\fR and \fIlen\fR. Any extent bigger than threshold 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. - -\fB-v\fP be verbose - -\fB-c\fP compress file contents while defragmenting - -\fB-f\fP flush filesystem after defragmenting - -\fB-s start\fP defragment only from byte \fIstart\fR onward - -\fB-l len\fP defragment only up to \fIlen\fR bytes - -\fB-t size\fP defragment only files at least \fIsize\fR bytes big - -NOTE: 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 \fBcp --reflink\fP. -.TP - -\fBsubvolume find-new\fR\fI <subvolume> <last_gen>\fR -List the recently modified files in a subvolume, after \fI<last_gen>\fR ID. -.TP - -\fBfilesystem sync\fR\fI <path> \fR -Force a sync for the filesystem identified by \fI<path>\fR. -.TP - -.\" -.\" Some wording are extracted by the resize2fs man page -.\" - -\fBfilesystem resize\fR\fI [devid:][+/\-]<size>[gkm]|[devid:]max <path>\fR -Resize a filesystem identified by \fI<path>\fR for the underlying device -\fIdevid\fR. The \fIdevid\fR can be found with \fBbtrfs filesystem show\fR and -defaults to 1 if not specified. -The \fI<size>\fR parameter specifies the new size of the filesystem. -If the prefix \fI+\fR or \fI\-\fR is present the size is increased or decreased -by the quantity \fI<size>\fR. -If no units are specified, the unit of the \fI<size>\fR parameter defaults to -bytes. Optionally, the size parameter may be suffixed by one of the following -units designators: ''K'', ''M'', or ''G'', kilobytes, megabytes, or gigabytes, -respectively. - -If ''max'' is passed, the filesystem will occupy all available space on the -device \fIdevid\fR. - -The \fBresize\fR command \fBdoes not\fR manipulate the size of underlying -partition. If you wish to enlarge/reduce a filesystem, you must make sure you -can expand the partition before enlarging the filesystem and shrink the -partition after reducing the size of the filesystem. This can done using -\fBfdisk(8)\fR or \fBparted(8)\fR to delete the existing partition and recreate -it with the new desired size. When recreating the partition make sure to use -the same starting disk cylinder as before. -.TP - -\fBfilesystem label\fP\fI <dev> [newlabel]\fP -Show or update the label of a filesystem. \fI<dev>\fR is used to identify the -filesystem. -If a \fInewlabel\fR optional argument is passed, the label is changed. The -following constraints exist for a label: -.IP -- the maximum allowable length shall be less or equal than 256 chars -.IP -- the label shall not contain the ''/'' or ''\\'' characters. - -NOTE: Currently there are the following limitations: -.IP -- the filesystem has to be unmounted -.IP -- the filesystem should not have more than one device. -.TP - -\fBfilesystem show\fR [--all-devices|<uuid>|<label>]\fR -Show the btrfs filesystem with some additional info. If no \fIUUID\fP or -\fIlabel\fP is passed, \fBbtrfs\fR show info of all the btrfs filesystem. -If \fB--all-devices\fP is passed, all the devices under /dev are scanned; -otherwise the devices list is extracted from the /proc/partitions file. -.TP - -\fBfilesystem balance\fR \fI<path>\fR -Balance the chunks of the filesystem identified by \fI<path>\fR -across the devices. -.TP - -\fBdevice add\fR\fI <dev> [<dev>..] <path>\fR -Add device(s) to the filesystem identified by \fI<path>\fR. -.TP - -\fBdevice delete\fR\fI <dev> [<dev>..] <path>\fR -Remove device(s) from a filesystem identified by \fI<path>\fR. -.TP - -\fBdevice scan\fR \fI[--all-devices|<device> [<device>...]\fR -If one or more devices are passed, these are scanned for a btrfs filesystem. -If no devices are passed, \fBbtrfs\fR scans all the block devices listed -in the /proc/partitions file. -Finally, if \fB--all-devices\fP is passed, all the devices under /dev are -scanned. -.TP - -\fBscrub start\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP} -Start a scrub on all devices of the filesystem identified by \fI<path>\fR or on -a single \fI<device>\fR. Without options, scrub is started as a background -process. Progress can be obtained with the \fBscrub status\fR command. Scrubbing -involves reading all data from all disks and verifying checksums. Errors are -corrected along the way if possible. -.RS - -\fIOptions\fR -.IP -B 5 -Do not background and print scrub statistics when finished. -.IP -d 5 -Print separate statistics for each device of the filesystem (-B only). -.IP -q 5 -Quiet. Omit error messages and statistics. -.IP -r 5 -Read only mode. Do not attempt to correct anything. -.IP -u 5 -Scrub unused space as well. (NOT IMPLEMENTED) -.RE -.TP - -\fBscrub cancel\fP {\fI<path>\fP|\fI<device>\fP} -If a scrub is running on the filesystem identified by \fI<path>\fR, cancel it. -Progress is saved in the scrub progress file and scrubbing can be resumed later -using the \fBscrub resume\fR command. -If a \fI<device>\fR is given, the corresponding filesystem is found and -\fBscrub cancel\fP behaves as if it was called on that filesystem. -.TP - -\fBscrub resume\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP} -Resume a canceled or interrupted scrub cycle on the filesystem identified by -\fI<path>\fR or on a given \fI<device>\fR. Does not start a new scrub if the -last scrub finished successfully. -.RS - -\fIOptions\fR -.TP -see \fBscrub start\fP. -.RE -.TP - -\fBscrub status\fP [-d] {\fI<path>\fP|\fI<device>\fP} -Show status of a running scrub for the filesystem identified by \fI<path>\fR or -for the specified \fI<device>\fR. -If no scrub is running, show statistics of the last finished or canceled scrub -for that filesystem or device. -.RS - -\fIOptions\fR -.IP -d 5 -Print separate statistics for each device of the filesystem. -.RE -.TP - -\fBinspect-internal inode-resolve\fP [-v] \fI<inode>\fP \fI<path>\fP -Resolves an <inode> in subvolume <path> to all filesystem paths. -.RS - -\fIOptions\fR -.IP -v 5 -verbose mode. print count of returned paths and ioctl() return value -.RE -.TP - -\fBinspect-internal logical-resolve\fP [-Pv] [-s bufsize] \fI<logical>\fP \fI<path>\fP -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 -\fBinode-resolve\fP subcommand). -.RS - -\fIOptions\fR -.IP -P 5 -skip the path resolving and print the inodes instead -.IP -v 5 -verbose mode. print count of returned paths and all ioctl() return values -.IP -s bufsize 5 -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. -.RE - -.SH EXIT STATUS -\fBbtrfs\fR returns a zero exist status if it succeeds. Non zero is returned in -case of failure. - -.SH AVAILABILITY -.B 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. -.SH SEE ALSO -.BR mkfs.btrfs (8) diff --git a/man/btrfsck.8 b/man/btrfsck.8 new file mode 100644 index 0000000..4bf1cff --- /dev/null +++ b/man/btrfsck.8 @@ -0,0 +1,17 @@ +.TH BTRFSCK 8 +.SH NAME +btrfsck \- check a btrfs filesystem +.SH SYNOPSIS +.B btrfsck \fI device\fP +.SH DESCRIPTION +\fBbtrfsck\fP is used to check a btrfs filesystem. +\fIdevice\fP is the device file where the filesystem is stored. +.SH AVAILABILITY +.B btrfsck +is part of btrfs-progs. Btrfs 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. +.SH SEE ALSO +.BR mkfs.btrfs (8) +.BR btrfsctl (8) diff --git a/man/btrfsck.8.in b/man/btrfsck.8.in deleted file mode 100644 index 4bf1cff..0000000 --- a/man/btrfsck.8.in +++ /dev/null @@ -1,17 +0,0 @@ -.TH BTRFSCK 8 -.SH NAME -btrfsck \- check a btrfs filesystem -.SH SYNOPSIS -.B btrfsck \fI device\fP -.SH DESCRIPTION -\fBbtrfsck\fP is used to check a btrfs filesystem. -\fIdevice\fP is the device file where the filesystem is stored. -.SH AVAILABILITY -.B btrfsck -is part of btrfs-progs. Btrfs 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. -.SH SEE ALSO -.BR mkfs.btrfs (8) -.BR btrfsctl (8) diff --git a/man/btrfsctl.8 b/man/btrfsctl.8 new file mode 100644 index 0000000..8705fa6 --- /dev/null +++ b/man/btrfsctl.8 @@ -0,0 +1,48 @@ +.TH BTRFSCTL 8 +.SH NAME +btrfsctl \- control a btrfs filesystem +.SH SYNOPSIS +.B btrfsctl +[ \fB\-d\fP\fI file|directory \fP ] +[ \fB\-s\fP\fI snapshot-name directory\fP ] +[ \fB \-S\fP\fI subvolume-name directory\fP ] +[ \fB \-r\fP\fI [+-]size\fP ] +[ \fB \-A\fP\fI device\fP ] +[ \fB \-a\fP ] +[ \fB \-c\fP ] +.SH NOTE +B btrfsctl +is deprecated. Please consider to switch to the btrfs utility. +.SH DESCRIPTION +.B btrfsctl +is used to control the filesystem and the files and directories stored. It is the tool to create a new snapshot for the filesystem. +.SH OPTIONS +.TP +\fB\-d\fR \fIfile|directory\fR +Defragment a file or a directory. If the argument is a directory, the entire b-tree under the directory is defragged. +.TP +\fB\-s\fR \fIsnapshot-name directory\fR +Creates a new \fIsnapshot\fP of the \fIdirectory\fP specified. +.TP +\fB\-S\fR \fIsubvolume-name directory\fR +Creates a new subvolume. +.TP +\fB\-r\fR \fI[+|-]size\fR +Resizes the filesystem with the \fIsize\fP specified. If the value is preceded with a signed symbol, the filesystem is resized with respect to the current filesystem size. \fIsize\fP can be suffixed by k,m or g to represent kilobytes, megabytes, or gigabytes respectively. +.TP +\fB\-A\fR \fIdevice\fR +Scans the \fIdevice\fR for btrfs filesystem. +.TP +\fB\-a\fR +Scans all devices present in the system for btrfs filesystem. +.TP +\fB\-c\fR +Forces a filesystem sync. +.SH AVAILABILITY +.B btrfsctl +is part of btrfs-progs. Btrfs 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. +.SH SEE ALSO +.BR mkfs.btrfs (8) diff --git a/man/btrfsctl.8.in b/man/btrfsctl.8.in deleted file mode 100644 index 8705fa6..0000000 --- a/man/btrfsctl.8.in +++ /dev/null @@ -1,48 +0,0 @@ -.TH BTRFSCTL 8 -.SH NAME -btrfsctl \- control a btrfs filesystem -.SH SYNOPSIS -.B btrfsctl -[ \fB\-d\fP\fI file|directory \fP ] -[ \fB\-s\fP\fI snapshot-name directory\fP ] -[ \fB \-S\fP\fI subvolume-name directory\fP ] -[ \fB \-r\fP\fI [+-]size\fP ] -[ \fB \-A\fP\fI device\fP ] -[ \fB \-a\fP ] -[ \fB \-c\fP ] -.SH NOTE -B btrfsctl -is deprecated. Please consider to switch to the btrfs utility. -.SH DESCRIPTION -.B btrfsctl -is used to control the filesystem and the files and directories stored. It is the tool to create a new snapshot for the filesystem. -.SH OPTIONS -.TP -\fB\-d\fR \fIfile|directory\fR -Defragment a file or a directory. If the argument is a directory, the entire b-tree under the directory is defragged. -.TP -\fB\-s\fR \fIsnapshot-name directory\fR -Creates a new \fIsnapshot\fP of the \fIdirectory\fP specified. -.TP -\fB\-S\fR \fIsubvolume-name directory\fR -Creates a new subvolume. -.TP -\fB\-r\fR \fI[+|-]size\fR -Resizes the filesystem with the \fIsize\fP specified. If the value is preceded with a signed symbol, the filesystem is resized with respect to the current filesystem size. \fIsize\fP can be suffixed by k,m or g to represent kilobytes, megabytes, or gigabytes respectively. -.TP -\fB\-A\fR \fIdevice\fR -Scans the \fIdevice\fR for btrfs filesystem. -.TP -\fB\-a\fR -Scans all devices present in the system for btrfs filesystem. -.TP -\fB\-c\fR -Forces a filesystem sync. -.SH AVAILABILITY -.B btrfsctl -is part of btrfs-progs. Btrfs 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. -.SH SEE ALSO -.BR mkfs.btrfs (8) diff --git a/man/mkfs.btrfs.8 b/man/mkfs.btrfs.8 new file mode 100644 index 0000000..72025ed --- /dev/null +++ b/man/mkfs.btrfs.8 @@ -0,0 +1,79 @@ +.TH MKFS.BTRFS 8 +.SH NAME +mkfs.btrfs \- create a btrfs filesystem +.SH SYNOPSIS +.B mkfs.btrfs +[ \fB\-A\fP\fI alloc-start\fP ] +[ \fB\-b\fP\fI byte-count\fP ] +[ \fB\-d\fP\fI data-profile\fP ] +[ \fB\-l\fP\fI leafsize\fP ] +[ \fB\-L\fP\fI label\fP ] +[ \fB\-m\fP\fI metadata profile\fP ] +[ \fB\-M\fP\fI mixed data+metadata\fP ] +[ \fB\-n\fP\fI nodesize\fP ] +[ \fB\-s\fP\fI sectorsize\fP ] +[ \fB\-r\fP\fI rootdir\fP ] +[ \fB\-K\fP ] +[ \fB\-h\fP ] +[ \fB\-V\fP ] +\fI device\fP [ \fIdevice ...\fP ] +.SH DESCRIPTION +.B mkfs.btrfs +is used to create a btrfs filesystem (usually in a disk partition, or an array +of disk partitions). +.I device +is the special file corresponding to the device (e.g \fI/dev/sdXX\fP ). +If multiple \fI devices \fP are specified, btrfs is created +spanning across the specified \fI devices\fP. +.SH OPTIONS +.TP +\fB\-A\fR, \fB\-\-alloc\-start \fIoffset\fR +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. +.TP +\fB\-b\fR, \fB\-\-byte\-count \fIsize\fR +Specify the size of the resultant filesystem. If this option is not used, +mkfs.btrfs uses all the available storage for the filesystem. +.TP +\fB\-d\fR, \fB\-\-data \fItype\fR +Specify how the data must be spanned across the devices specified. Valid +values are raid0, raid1, raid10 or single. +.TP +\fB\-l\fR, \fB\-\-leafsize \fIsize\fR +Specify the leaf size, the least data item in which btrfs stores data. The +default value is the page size. +.TP +\fB\-L\fR, \fB\-\-label \fIname\fR +Specify a label for the filesystem. +.TP +\fB\-m\fR, \fB\-\-metadata \fIprofile\fR +Specify how metadata must be spanned across the devices specified. Valid +values are raid0, raid1, raid10 or single. +.TP +\fB\-M\fR, \fB\-\-mixed\fR +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. +.TP +\fB\-n\fR, \fB\-\-nodesize \fIsize\fR +Specify the nodesize. By default the value is set to the pagesize. +.TP +\fB\-s\fR, \fB\-\-sectorsize \fIsize\fR +Specify the sectorsize, the minimum block allocation. +.TP +\fB\-r\fR, \fB\-\-rootdir \fIrootdir\fR +Specify a directory to copy into the newly created fs. +.TP +\fB\-K\fR, \fB\-\-nodiscard \fR +Do not perform whole device TRIM operation by default. +.TP +\fB\-V\fR, \fB\-\-version\fR +Print the \fBmkfs.btrfs\fP version and exit. +.SH AVAILABILITY +.B mkfs.btrfs +is part of btrfs-progs. Btrfs 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. +.SH SEE ALSO +.BR btrfsck (8) diff --git a/man/mkfs.btrfs.8.in b/man/mkfs.btrfs.8.in deleted file mode 100644 index 72025ed..0000000 --- a/man/mkfs.btrfs.8.in +++ /dev/null @@ -1,79 +0,0 @@ -.TH MKFS.BTRFS 8 -.SH NAME -mkfs.btrfs \- create a btrfs filesystem -.SH SYNOPSIS -.B mkfs.btrfs -[ \fB\-A\fP\fI alloc-start\fP ] -[ \fB\-b\fP\fI byte-count\fP ] -[ \fB\-d\fP\fI data-profile\fP ] -[ \fB\-l\fP\fI leafsize\fP ] -[ \fB\-L\fP\fI label\fP ] -[ \fB\-m\fP\fI metadata profile\fP ] -[ \fB\-M\fP\fI mixed data+metadata\fP ] -[ \fB\-n\fP\fI nodesize\fP ] -[ \fB\-s\fP\fI sectorsize\fP ] -[ \fB\-r\fP\fI rootdir\fP ] -[ \fB\-K\fP ] -[ \fB\-h\fP ] -[ \fB\-V\fP ] -\fI device\fP [ \fIdevice ...\fP ] -.SH DESCRIPTION -.B mkfs.btrfs -is used to create a btrfs filesystem (usually in a disk partition, or an array -of disk partitions). -.I device -is the special file corresponding to the device (e.g \fI/dev/sdXX\fP ). -If multiple \fI devices \fP are specified, btrfs is created -spanning across the specified \fI devices\fP. -.SH OPTIONS -.TP -\fB\-A\fR, \fB\-\-alloc\-start \fIoffset\fR -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. -.TP -\fB\-b\fR, \fB\-\-byte\-count \fIsize\fR -Specify the size of the resultant filesystem. If this option is not used, -mkfs.btrfs uses all the available storage for the filesystem. -.TP -\fB\-d\fR, \fB\-\-data \fItype\fR -Specify how the data must be spanned across the devices specified. Valid -values are raid0, raid1, raid10 or single. -.TP -\fB\-l\fR, \fB\-\-leafsize \fIsize\fR -Specify the leaf size, the least data item in which btrfs stores data. The -default value is the page size. -.TP -\fB\-L\fR, \fB\-\-label \fIname\fR -Specify a label for the filesystem. -.TP -\fB\-m\fR, \fB\-\-metadata \fIprofile\fR -Specify how metadata must be spanned across the devices specified. Valid -values are raid0, raid1, raid10 or single. -.TP -\fB\-M\fR, \fB\-\-mixed\fR -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. -.TP -\fB\-n\fR, \fB\-\-nodesize \fIsize\fR -Specify the nodesize. By default the value is set to the pagesize. -.TP -\fB\-s\fR, \fB\-\-sectorsize \fIsize\fR -Specify the sectorsize, the minimum block allocation. -.TP -\fB\-r\fR, \fB\-\-rootdir \fIrootdir\fR -Specify a directory to copy into the newly created fs. -.TP -\fB\-K\fR, \fB\-\-nodiscard \fR -Do not perform whole device TRIM operation by default. -.TP -\fB\-V\fR, \fB\-\-version\fR -Print the \fBmkfs.btrfs\fP version and exit. -.SH AVAILABILITY -.B mkfs.btrfs -is part of btrfs-progs. Btrfs 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. -.SH SEE ALSO -.BR btrfsck (8) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe Brandenburger
2013-Feb-05 06:18 UTC
Re: [PATCH 2/5] btrfs-progs: libify some parts of btrfs-progs
Hi Mark, A week ago I posted a patch to move fs/btrfs/ioctl.h to include/uapi/linux/btrfs.h in the kernel tree: http://thread.gmane.org/gmane.comp.file-systems.btrfs/22763/focus=22764 My main motivation was to export the kernel headers with the ioctl constants/structs so that other programs may use the ioctls, in my case I was interested in implementing strace support for parsing btrfs ioctls (I''m still working on that project.) I see you took a different approach, using the header files present in btrfs-progs and installing those in /usr/include/btrfs (not a linux/ subdirectory.) As your main objective is to export part of btrfs-progs functionality as a library, that makes sense too... I''m not saying that either way is better, just that it probably needs some coordination. I think in the end we''ll need a little bit of both approaches, the kernel exporting one of the header files (for ioctls) and the userland exporting some others (for a libbtrfs external interface.) Here are some relevant project ideas mentioned in the Wiki: 1) Provide a library covering ''btrfs'' functionality (https://btrfs.wiki.kernel.org/index.php/Project_ideas#Provide_a_library_covering_.27btrfs.27_functionality) -- your patchset implements part of this. 2) Remove ioctl.h in btrfs and btrfs-progs world, create include/linux/btrfs.h with those definitions (https://btrfs.wiki.kernel.org/index.php/Cleanup_ideas#Remove_ioctl.h_in_btrfs_and_btrfs-progs_world.2C_create_include.2Flinux.2Fbtrfs.h_with_those_definitions) -- my patchset implements part of this, the part of the kernel but not the part of btrfs-progs 3) Use the kernel code in user mode (https://btrfs.wiki.kernel.org/index.php/Cleanup_ideas#Use_the_kernel_code_in_user_mode) -- none of them implements this, I''ve been thinking about this one and I don''t have a good solution yet... I''ll send a separate e-mail about this one to the list later. Cheers, Filipe On Wed, Jan 30, 2013 at 2:50 PM, Mark Fasheh <mfasheh@suse.de> wrote:> External software wanting to use the functionality provided by the btrfs > send ioctl has a hard time doing so without replicating tons of work. Of > particular interest are functions like btrfs_read_and_process_send_stream() > and subvol_uuid_search(). As that functionality requires a bit more than > just send-stream.c and send-utils.c we have to pull in some other parts of > the progs package. > > This patch adds code to the Makefile and headers to create a library, > libbtrfs which the btrfs command now links to. > > Signed-off-by: Mark Fasheh <mfasheh@suse.de> > --- > Makefile | 83 ++++++++++++++++++++++++++++++++++++-------------------- > btrfs-list.h | 4 +++ > crc32c.h | 4 +++ > ctree.h | 9 ++++++ > extent-cache.h | 6 ++++ > extent_io.h | 7 +++++ > radix-tree.h | 4 +++ > rbtree.h | 4 +++ > send-utils.h | 5 ++++ > 9 files changed, 96 insertions(+), 30 deletions(-)-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html