rsync 中的默认块大小是多少

dcd*_*cds 6 rsync

rsync 中的默认块大小是多少?

如果我在不提供--block-size选项的情况下执行 rsync 那么块大小有什么用?

我在 Linux 平台上使用 rsync。

小智 5

  • 如果您--block-size=BLOCKSIZE在命令行上指定,则使用该块大小。
  • 如果文件大小小于或等于 490,000 字节,则块大小设置为 700 字节。
  • 如果文件大于 490,000 字节,则块大小将设置为文件大小的平方根(四舍五入为 8 的倍数),最大块大小取决于协议版本。
    • 对于协议版本 <30,最大块大小为 536,870,912 (~536MB),而
    • 对于协议版本 >=30,最大块大小为 131,072 (~131KB),这是更合理的。
    • 对于 17GB 的文件(131KB 的平方),您将达到 131KB 的最大块大小。

因此,根据新版本rsync,根据源代码常量中的定义,块大小范围在 700 字节到 131KB 之间。


Kus*_*nda 4

rsync手册中:

\n\n
\n

-B,--block-size=BLOCKSIZE

\n\n

这会强制 rsync\xe2\x80\x99s 增量传输\n 算法中使用的块大小为固定值。通常根据要更新的每个文件的大小来选择。详细信息请参阅技术报告\n。

\n
\n\n

该技术报告可在https://rsync.samba.org/tech_report/上找到,尽管它很旧,并且没有详细介绍如何选择块大小,只是“S 的值在 500 到 1000 之间是相当大的”。适用于大多数用途”(这些值不是代码中实际使用的值,请参见下文)。

\n\n

实际源代码中的几条注释表明文件大小的平方根用作块大小(四舍五入到 8 的倍数):

\n\n
/*\n * set (initialize) the size entries in the per-file sum_struct\n * calculating dynamic block and checksum sizes.\n *\n * This is only called from generate_and_send_sums() but is a separate\n * function to encapsulate the logic.\n *\n * The block size is a rounded square root of file length.\n *\n * The checksum size is determined according to:\n *     blocksum_bits = BLOCKSUM_BIAS + 2*log2(file_len) - log2(block_len)\n * provided by Donovan Baarda which gives a probability of rsync\n * algorithm corrupting data and falling back using the whole md4\n * checksums.\n *\n * This might be made one of several selectable heuristics.\n */\nstatic void sum_sizes_sqroot(struct sum_struct *sum, int64 len)\n{\n
Run Code Online (Sandbox Code Playgroud)\n\n

[...]

\n\n
        else {\n            blength = 0;\n            do {\n                blength |= c;\n                if (len < (int64)blength * blength)\n                    blength &= ~c;\n                c >>= 1;\n            } while (c >= 8);   /* round to multiple of 8 */\n            blength = MAX(blength, BLOCK_SIZE);\n        }\n
Run Code Online (Sandbox Code Playgroud)\n\n

所选择的块大小与所使用的 Unix 类型无关。

\n