mirror of
https://github.com/upa/mscp.git
synced 2026-02-04 03:24:58 +08:00
default chunk size is filesize/(nr_conn*4) (Issue #20)
and clean-up chunk_sz related parts.
This commit is contained in:
@@ -198,7 +198,11 @@ parallel. The default value is 16M bytes.
|
|||||||
.TP
|
.TP
|
||||||
.B \-S \fIMAX_CHUNK_SIZE\fR
|
.B \-S \fIMAX_CHUNK_SIZE\fR
|
||||||
Specifies the maximum chunk size. The default is file size divided by
|
Specifies the maximum chunk size. The default is file size divided by
|
||||||
the number of connections.
|
the number of connections and devided by 4. If the calculated value
|
||||||
|
is smarller than the
|
||||||
|
.B MIN_CHUNK_SIZE
|
||||||
|
value,
|
||||||
|
MIN_CHUNK_SIZE is used.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-a \fINR_AHEAD\fR
|
.B \-a \fINR_AHEAD\fR
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
MSCP
|
MSCP
|
||||||
====
|
====
|
||||||
|
|
||||||
:Date: v0.2.0-8-gef2dd55
|
:Date: v0.2.0-9-g675126a
|
||||||
|
|
||||||
NAME
|
NAME
|
||||||
====
|
====
|
||||||
@@ -102,7 +102,9 @@ OPTIONS
|
|||||||
|
|
||||||
**-S MAX_CHUNK_SIZE**
|
**-S MAX_CHUNK_SIZE**
|
||||||
Specifies the maximum chunk size. The default is file size divided by
|
Specifies the maximum chunk size. The default is file size divided by
|
||||||
the number of connections.
|
the number of connections and devided by 4. If the calculated value
|
||||||
|
is smarller than the **MIN_CHUNK_SIZE** value, MIN_CHUNK_SIZE is
|
||||||
|
used.
|
||||||
|
|
||||||
**-a NR_AHEAD**
|
**-a NR_AHEAD**
|
||||||
Specifies the number of inflight SFTP commands. The default value is
|
Specifies the number of inflight SFTP commands. The default value is
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void usage(bool print_help)
|
|||||||
" -R CHECKPOINT resume transferring from the checkpoint\n"
|
" -R CHECKPOINT resume transferring from the checkpoint\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -s MIN_CHUNK_SIZE min chunk size (default: 16M bytes)\n"
|
" -s MIN_CHUNK_SIZE min chunk size (default: 16M bytes)\n"
|
||||||
" -S MAX_CHUNK_SIZE max chunk size (default: filesize/nr_conn)\n"
|
" -S MAX_CHUNK_SIZE max chunk size (default: filesize/nr_conn/4)\n"
|
||||||
" -a NR_AHEAD number of inflight SFTP commands (default: 32)\n"
|
" -a NR_AHEAD number of inflight SFTP commands (default: 32)\n"
|
||||||
" -b BUF_SZ buffer size for i/o and transfer\n"
|
" -b BUF_SZ buffer size for i/o and transfer\n"
|
||||||
" -L LIMIT_BITRATE Limit the bitrate, n[KMG] (default: 0, no limit)\n"
|
" -L LIMIT_BITRATE Limit the bitrate, n[KMG] (default: 0, no limit)\n"
|
||||||
|
|||||||
14
src/mscp.c
14
src/mscp.c
@@ -330,18 +330,10 @@ int mscp_set_dst_path(struct mscp *m, const char *dst_path)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_page_mask(void)
|
static size_t get_page_mask(void)
|
||||||
{
|
{
|
||||||
long page_sz = sysconf(_SC_PAGESIZE);
|
size_t page_sz = sysconf(_SC_PAGESIZE);
|
||||||
size_t page_mask = 0;
|
return ~(page_sz - 1);
|
||||||
int n;
|
|
||||||
|
|
||||||
for (n = 0; page_sz > 0; page_sz >>= 1, n++) {
|
|
||||||
page_mask <<= 1;
|
|
||||||
page_mask |= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return page_mask >> 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mscp_stop_copy_thread(struct mscp *m)
|
static void mscp_stop_copy_thread(struct mscp *m)
|
||||||
|
|||||||
@@ -102,13 +102,10 @@ static int resolve_chunk(struct path *p, size_t size, struct path_resolve_args *
|
|||||||
size_t chunk_sz, off, len;
|
size_t chunk_sz, off, len;
|
||||||
size_t remaind;
|
size_t remaind;
|
||||||
|
|
||||||
if (size <= a->min_chunk_sz)
|
if (a->max_chunk_sz)
|
||||||
chunk_sz = size;
|
|
||||||
else if (a->max_chunk_sz)
|
|
||||||
chunk_sz = a->max_chunk_sz;
|
chunk_sz = a->max_chunk_sz;
|
||||||
else {
|
else {
|
||||||
chunk_sz = (size - (size % a->nr_conn)) / a->nr_conn;
|
chunk_sz = (size / (a->nr_conn * 4)) & a->chunk_align;
|
||||||
chunk_sz &= ~a->chunk_align; /* align with page_sz */
|
|
||||||
if (chunk_sz <= a->min_chunk_sz)
|
if (chunk_sz <= a->min_chunk_sz)
|
||||||
chunk_sz = a->min_chunk_sz;
|
chunk_sz = a->min_chunk_sz;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user