btrfs-progs: better support for external users of send, V3
Subsystems (2)
cover 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 <[email protected]>
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.
fs/btrfs/ioctl.h +7 -0
@@ -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 */
fs/btrfs/send.c +44 -4
79 lines not on this page · raw message
fs/btrfs/send.h +1 -0
@@ -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)
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.
--- ioctl.h | 7 +++++++ send-stream.c | 6 ++++++ send-stream.h | 1 + send.h | 1 + 4 files changed, 15 insertions(+)
ioctl.h +7 -0
@@ -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 */
send-stream.c +6 -0
@@ -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 ;
send-stream.h +1 -0
@@ -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,
send.h +1 -0
@@ -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)
Signature · 1 line
1.7.10.4
PATCH 2/5 btrfs-progs: libify some parts of btrfs-progs
In reply to Mark FashehExternal 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.
--- 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(-)
Makefile +53 -30
@@ -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
btrfs-list.h +4 -0
@@ -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 ;
crc32c.h +4 -0
@@ -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 );
ctree.h +9 -0
@@ -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 ;
extent-cache.h +6 -0
@@ -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;
extent_io.h +7 -0
@@ -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)
radix-tree.h +4 -0
@@ -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
rbtree.h +4 -0
@@ -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;
send-utils.h +5 -0
@@ -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,
Signature · 1 line
1.7.10.4
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
Quoted 22 lines · Mark Fasheh
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()andsubvol_uuid_search(). As that functionality requires a bit more than justsend-stream.candsend-utils.cwe have to pull in some other parts of the progs package.This patch adds code to the
Makefileand headers to create a library, libbtrfs which the btrfs command now links to.Signed-off-by Mark Fasheh <[email protected]>--- 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(-)
PATCH 3/5 btrfs-progs: add send-test
In reply to Mark Fashehsend-test.c links against libbtrfs and uses the send functionality provided to decode and print a send stream to the console.
--- Makefile | 5 +- send-test.c | 458 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 send-test.c
Makefile +4 -1
@@ -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
send-test.c new file +458 -0
458 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 4/5 btrfs-progs: make libbtrfs usable from C++
In reply to Mark FashehFrom: Arvin Schnell <[email protected]>
Please find attached a patch to make the new libbtrfs usable from C++ (at least for the parts snapper will likely need).
--- 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(-)
extent_io.c +3 -3
@@ -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; }
extent_io.h +3 -3
@@ -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,
ioctl.h +9 -0
@@ -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
list.h +20 -20
@@ -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); }/**
rbtree.h +1 -1
@@ -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,
send-stream.h +7 -0
@@ -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_ */
send-utils.h +7 -0
@@ -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_ */
send.h +8 -0
@@ -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
Signature · 1 line
1.7.10.4
PATCH 5/5 btrfs-progs: use autotools for building
In reply to Mark FashehFrom: Jeff Mahoney <[email protected]>
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)
--- 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
AUTHORS new file +0 -0
ChangeLog new file +0 -0
INSTALL +0 -59
59 lines not on this page · raw message
Makefile deleted +0 -146
146 lines not on this page · raw message
Makefile.am new file +53 -0
53 lines not on this page · raw message
NEWS new file +0 -0
README new file +59 -0
59 lines not on this page · raw message
autogen.sh new file +5 -0
@@ -0,0 +1,5 @@ +#!/bin/sh + +rm -fr aclocal.m4 autom4te.cache/ +autoreconf -iv +./configure
configure.ac new file +6 -0
@@ -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])
man/Makefile deleted +0 -37
@@ -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)
man/Makefile.am new file +2 -0
@@ -0,0 +1,2 @@ +man8_MANS = btrfs.8 btrfsck.8 btrfsctl.8 btrfs-image.8 \ + btrfs-show.8 mkfs.btrfs.8
man/btrfs-image.8 new file +34 -0
@@ -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)
man/btrfs-image.8.in deleted +0 -34
@@ -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)
man/btrfs-show.8 new file +22 -0
@@ -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)
man/btrfs-show.8.in deleted +0 -22
@@ -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)
man/btrfs.8 new file +365 -0
365 lines not on this page · raw message
man/btrfs.8.in deleted +0 -365
365 lines not on this page · raw message
man/btrfsck.8 new file +17 -0
@@ -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)
man/btrfsck.8.in deleted +0 -17
@@ -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)
man/btrfsctl.8 new file +48 -0
48 lines not on this page · raw message
man/btrfsctl.8.in deleted +0 -48
48 lines not on this page · raw message
man/mkfs.btrfs.8 new file +79 -0
79 lines not on this page · raw message
man/mkfs.btrfs.8.in deleted +0 -79
79 lines not on this page · raw message
Signature · 1 line
1.7.10.4