chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
f9ac154
)
copy: teach copy_bytes() btrfs reflink magic
author
Lennart Poettering
<lennart@poettering.net>
Fri, 12 Dec 2014 02:20:53 +0000
(
03:20
+0100)
committer
Lennart Poettering
<lennart@poettering.net>
Fri, 12 Dec 2014 12:35:32 +0000
(13:35 +0100)
src/shared/copy.c
patch
|
blob
|
history
diff --git
a/src/shared/copy.c
b/src/shared/copy.c
index f22a9409918a84c0eb3fb28f94db26077b844615..4c41f2fdd4c24bb7dcf57ac300d7bfc88f23a84f 100644
(file)
--- a/
src/shared/copy.c
+++ b/
src/shared/copy.c
@@
-27,10
+27,18
@@
int copy_bytes(int fdf, int fdt, off_t max_bytes) {
bool try_sendfile = true;
int copy_bytes(int fdf, int fdt, off_t max_bytes) {
bool try_sendfile = true;
+ int r;
assert(fdf >= 0);
assert(fdt >= 0);
assert(fdf >= 0);
assert(fdt >= 0);
+ /* Try btrfs reflinks first. */
+ if (max_bytes == (off_t) -1) {
+ r = btrfs_reflink(fdf, fdt);
+ if (r >= 0)
+ return 0;
+ }
+
for (;;) {
size_t m = PIPE_BUF;
ssize_t n;
for (;;) {
size_t m = PIPE_BUF;
ssize_t n;
@@
-64,7
+72,6
@@
int copy_bytes(int fdf, int fdt, off_t max_bytes) {
/* As a fallback just copy bits by hand */
{
char buf[m];
/* As a fallback just copy bits by hand */
{
char buf[m];
- int r;
n = read(fdf, buf, m);
if (n < 0)
n = read(fdf, buf, m);
if (n < 0)
@@
-72,7
+79,7
@@
int copy_bytes(int fdf, int fdt, off_t max_bytes) {
if (n == 0) /* EOF */
break;
if (n == 0) /* EOF */
break;
- r = loop_write(fdt, buf, n, false);
+ r = loop_write(fdt, buf,
(size_t)
n, false);
if (r < 0)
return r;
if (r < 0)
return r;