Skip to content

Commit 7df678e

Browse files
committed
feat(padcpio): new helper binary for cpio data alignment
1. Purpose Improve cpio archive creation performance and space efficiency by ensuring that file data is aligned within the archive to the filesystem block size. For filesystems supporting reflinks (e.g. XFS and Btrfs) this ensures that cpio archive data can share the same copy-on-write extents as the archive source files. A GNU cpio binary capable of copy-on-write cloning data via copy_file_range is required to make proper use of this. Padding can't be added to cpio archives arbitrarily, so we need to inject extra files into the archive to provide filesystem alignment. 2. Behaviour Read a zero terminated file list from stdin. If an input file, when cpio serialized, is aligned to <padding alignment order> then print it to stdout. If the cpio archived file data would be unaligned then create a padding file in <pad dir> which, when cpio archived before the input file, will provide cpio alignment and print the pad file path before the input file path. GNU cpio reorders hardlinks, so avoid extra complexity by deferring them (unpadded) to the end of the archive. Signed-off-by: David Disseldorp <ddiss@suse.de>
1 parent 6d0c867 commit 7df678e

File tree

3 files changed

+389
-2
lines changed

3 files changed

+389
-2
lines changed

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
5151

5252
.PHONY: install clean archive rpm srpm testimage test all check AUTHORS CONTRIBUTORS doc dracut-version.sh
5353

54-
all: dracut-version.sh dracut.pc dracut-install skipcpio/skipcpio dracut-util
54+
all: dracut-version.sh dracut.pc dracut-install skipcpio/skipcpio skipcpio/padcpio dracut-util
5555

5656
%.o : %.c
5757
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(KMOD_CFLAGS) $< -o $@
@@ -85,6 +85,9 @@ SKIPCPIO_OBJECTS = skipcpio/skipcpio.o
8585
skipcpio/skipcpio.o: skipcpio/skipcpio.c
8686
skipcpio/skipcpio: $(SKIPCPIO_OBJECTS)
8787

88+
skipcpio/padcpio.o: skipcpio/padcpio.c
89+
skipcpio/padcpio: skipcpio/padcpio.o
90+
8891
UTIL_OBJECTS = util/util.o
8992
util/util.o: util/util.c
9093
util/util: $(UTIL_OBJECTS)
@@ -193,6 +196,9 @@ endif
193196
if [ -f skipcpio/skipcpio ]; then \
194197
install -m 0755 skipcpio/skipcpio $(DESTDIR)$(pkglibdir)/skipcpio; \
195198
fi
199+
if [ -f skipcpio/padcpio ]; then \
200+
install -m 0755 skipcpio/padcpio $(DESTDIR)$(pkglibdir)/padcpio; \
201+
fi
196202
if [ -f dracut-util ]; then \
197203
install -m 0755 dracut-util $(DESTDIR)$(pkglibdir)/dracut-util; \
198204
fi
@@ -218,7 +224,7 @@ clean:
218224
$(RM) dracut-*.rpm dracut-*.tar.bz2 dracut-*.tar.xz
219225
$(RM) dracut-version.sh
220226
$(RM) dracut-install install/dracut-install $(DRACUT_INSTALL_OBJECTS)
221-
$(RM) skipcpio/skipcpio $(SKIPCPIO_OBJECTS)
227+
$(RM) skipcpio/skipcpio $(SKIPCPIO_OBJECTS) skipcpio/padcpio skipcpio/padcpio.o
222228
$(RM) dracut-util util/util $(UTIL_OBJECTS)
223229
$(RM) $(manpages) dracut.html
224230
$(RM) dracut.pc

dracut.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
298298
%{dracutlibdir}/dracut-install
299299
%{dracutlibdir}/dracut-util
300300
%{dracutlibdir}/skipcpio
301+
%{dracutlibdir}/padcpio
301302
%config(noreplace) %{_sysconfdir}/dracut.conf
302303
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel}
303304
%{dracutlibdir}/dracut.conf.d/01-dist.conf

0 commit comments

Comments
 (0)