summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0008-Update-for-lzo-support.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0008-Update-for-lzo-support.patch')
-rw-r--r--meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0008-Update-for-lzo-support.patch203
1 files changed, 203 insertions, 0 deletions
diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0008-Update-for-lzo-support.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0008-Update-for-lzo-support.patch
new file mode 100644
index 0000000000..a1bd4152fb
--- /dev/null
+++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0008-Update-for-lzo-support.patch
@@ -0,0 +1,203 @@
1Upstream-Status: Inappropriate [Backport]
2From 97e64f8cb21685b7359169f3047c0d082b0ff7e8 Mon Sep 17 00:00:00 2001
3From: Li Zefan <lizf@cn.fujitsu.com>
4Date: Thu, 18 Nov 2010 03:49:56 +0000
5Subject: [PATCH 08/15] Update for lzo support
6
7[Btrfs-Progs][V2] Update for lzo support
8
9- Add incompat flag, otherwise btrfs-progs will report error
10 when operating on btrfs filesystems mounted with lzo option.
11
12- Update man page.
13
14- Allow to turn on lzo compression for defrag operation:
15
16 # btrfs filesystem defragment -c[zlib, lzo] <file>
17
18 Note: "-c zlib" will fail, because that's how getopt() works
19 for optional arguments.
20
21Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
22Signed-off-by: Chris Mason <chris.mason@oracle.com>
23---
24 btrfs.c | 2 +-
25 btrfs_cmds.c | 24 ++++++++++++++++++++----
26 ctree.h | 10 +++++++---
27 ioctl.h | 9 ++++++++-
28 man/btrfs.8.in | 10 ++++++----
29 5 files changed, 42 insertions(+), 13 deletions(-)
30
31diff --git a/btrfs.c b/btrfs.c
32index 46314cf..1b4f403 100644
33--- a/btrfs.c
34+++ b/btrfs.c
35@@ -65,7 +65,7 @@ static struct Command commands[] = {
36 "List the recently modified files in a filesystem."
37 },
38 { do_defrag, -1,
39- "filesystem defragment", "[-vcf] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\n"
40+ "filesystem defragment", "[-vf] [-c[zlib,lzo]] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\n"
41 "Defragment a file or a directory."
42 },
43 { do_set_default_subvol, 2,
44diff --git a/btrfs_cmds.c b/btrfs_cmds.c
45index c21a007..26d4fcc 100644
46--- a/btrfs_cmds.c
47+++ b/btrfs_cmds.c
48@@ -142,10 +142,21 @@ static u64 parse_size(char *s)
49 return atoll(s) * mult;
50 }
51
52+static int parse_compress_type(char *s)
53+{
54+ if (strcmp(optarg, "zlib") == 0)
55+ return BTRFS_COMPRESS_ZLIB;
56+ else if (strcmp(optarg, "lzo") == 0)
57+ return BTRFS_COMPRESS_LZO;
58+ else {
59+ fprintf(stderr, "Unknown compress type %s\n", s);
60+ exit(1);
61+ };
62+}
63+
64 int do_defrag(int ac, char **av)
65 {
66 int fd;
67- int compress = 0;
68 int flush = 0;
69 u64 start = 0;
70 u64 len = (u64)-1;
71@@ -157,15 +168,18 @@ int do_defrag(int ac, char **av)
72 int fancy_ioctl = 0;
73 struct btrfs_ioctl_defrag_range_args range;
74 int e=0;
75+ int compress_type = BTRFS_COMPRESS_NONE;
76
77 optind = 1;
78 while(1) {
79- int c = getopt(ac, av, "vcfs:l:t:");
80+ int c = getopt(ac, av, "vc::fs:l:t:");
81 if (c < 0)
82 break;
83 switch(c) {
84 case 'c':
85- compress = 1;
86+ compress_type = BTRFS_COMPRESS_ZLIB;
87+ if (optarg)
88+ compress_type = parse_compress_type(optarg);
89 fancy_ioctl = 1;
90 break;
91 case 'f':
92@@ -203,8 +217,10 @@ int do_defrag(int ac, char **av)
93 range.start = start;
94 range.len = len;
95 range.extent_thresh = thresh;
96- if (compress)
97+ if (compress_type) {
98 range.flags |= BTRFS_DEFRAG_RANGE_COMPRESS;
99+ range.compress_type = compress_type;
100+ }
101 if (flush)
102 range.flags |= BTRFS_DEFRAG_RANGE_START_IO;
103
104diff --git a/ctree.h b/ctree.h
105index ed83d02..61eb639 100644
106--- a/ctree.h
107+++ b/ctree.h
108@@ -354,12 +354,14 @@ struct btrfs_super_block {
109 #define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
110 #define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
111 #define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
112+#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3)
113
114 #define BTRFS_FEATURE_COMPAT_SUPP 0ULL
115 #define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
116 #define BTRFS_FEATURE_INCOMPAT_SUPP \
117 (BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \
118 BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL | \
119+ BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \
120 BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS)
121
122 /*
123@@ -505,9 +507,11 @@ struct btrfs_timespec {
124 } __attribute__ ((__packed__));
125
126 typedef enum {
127- BTRFS_COMPRESS_NONE = 0,
128- BTRFS_COMPRESS_ZLIB = 1,
129- BTRFS_COMPRESS_LAST = 2,
130+ BTRFS_COMPRESS_NONE = 0,
131+ BTRFS_COMPRESS_ZLIB = 1,
132+ BTRFS_COMPRESS_LZO = 2,
133+ BTRFS_COMPRESS_TYPES = 2,
134+ BTRFS_COMPRESS_LAST = 3,
135 } btrfs_compression_type;
136
137 /* we don't understand any encryption methods right now */
138diff --git a/ioctl.h b/ioctl.h
139index 776d7a9..bb7b9e0 100644
140--- a/ioctl.h
141+++ b/ioctl.h
142@@ -116,8 +116,15 @@ struct btrfs_ioctl_defrag_range_args {
143 */
144 __u32 extent_thresh;
145
146+ /*
147+ * which compression method to use if turning on compression
148+ * for this defrag operation. If unspecified, zlib will
149+ * be used
150+ */
151+ __u32 compress_type;
152+
153 /* spare for later */
154- __u32 unused[5];
155+ __u32 unused[4];
156 };
157
158 struct btrfs_ioctl_space_info {
159diff --git a/man/btrfs.8.in b/man/btrfs.8.in
160index cba2de1..1ffed13 100644
161--- a/man/btrfs.8.in
162+++ b/man/btrfs.8.in
163@@ -15,12 +15,12 @@ btrfs \- control a btrfs filesystem
164 .PP
165 \fBbtrfs\fP \fBsubvolume set-default\fP\fI <id> <path>\fP
166 .PP
167-\fBbtrfs\fP \fBfilesystem defragment\fP\fI [-vcf] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\fP
168-.PP
169 \fBbtrfs\fP \fBfilesystem sync\fP\fI <path> \fP
170 .PP
171 \fBbtrfs\fP \fBfilesystem resize\fP\fI [+/\-]<size>[gkm]|max <filesystem>\fP
172 .PP
173+\fBbtrfs\fP \fBfilesystem defrag\fP\fI [options] <file>|<dir> [<file>|<dir>...]\fP
174+.PP
175 \fBbtrfs\fP \fBdevice scan\fP\fI [<device> [<device>..]]\fP
176 .PP
177 \fBbtrfs\fP \fBdevice show\fP\fI <dev>|<label> [<dev>|<label>...]\fP
178@@ -30,7 +30,6 @@ btrfs \- control a btrfs filesystem
179 \fBbtrfs\fP \fBdevice add\fP\fI <dev> [<dev>..] <path> \fP
180 .PP
181 \fBbtrfs\fP \fBdevice delete\fP\fI <dev> [<dev>..] <path> \fP]
182-
183 .PP
184 \fBbtrfs\fP \fBhelp|\-\-help|\-h \fP\fI\fP
185 .PP
186@@ -104,10 +103,13 @@ Set the subvolume of the filesystem \fI<path>\fR which is mounted as
187 is returned by the \fBsubvolume list\fR command.
188 .TP
189
190-\fBfilesystem defragment\fP\fI [-vcf] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\fR
191+\fBfilesystem defragment\fP -c[zlib|lzo] [-l \fIlen\fR] [-s \fIstart\fR] [-t \fIsize\fR] -[vf] <\fIfile\fR>|<\fIdir\fR> [<\fIfile\fR>|<\fIdir\fR>...]
192+
193 Defragment file data and/or directory metadata. To defragment all files in a
194 directory you have to specify each one on its own or use your shell wildcards.
195
196+The start position and the number of bytes to deframention can be specified by \fIstart\fR and \fIlen\fR. Any extent bigger than \fIthresh\fR will be considered already defragged. Use 0 to take the kernel default, and use 1 to say eveery single extent must be rewritten. You can also turn on compression in defragment operations.
197+
198 \fB-v\fP be verbose
199
200 \fB-c\fP compress file contents while defragmenting
201--
2021.7.2.3
203