小编qxi*_*xia的帖子

为什么fsync()在Linux内核3.1.*上比在内核3.0上花费更多的时间

我有一个测试程序.在Linux内核3.1.*上大约需要37秒,但在内核3.0.18上只需要大约1秒钟(我只需要在同一台机器上替换内核).请给我一个如何在内核3.1上改进它的线索.谢谢!

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>


int my_fsync(int fd)
{
    // return fdatasync(fd);
    return fsync(fd);
}


int main(int argc, char **argv)
{
    int rc = 0;
    int count;
    int i;
    char oldpath[1024];
    char newpath[1024];
    char *writebuffer = calloc(1024, 1);

    snprintf(oldpath, sizeof(oldpath), "./%s", "foo");
    snprintf(newpath, sizeof(newpath), "./%s", "foo.new");

    for (count = 0; count < 1000; ++count) {
    int fd = open(newpath, O_CREAT | O_TRUNC | O_WRONLY, S_IRWXU);
    if (fd == -1) {
        fprintf(stderr, "open …
Run Code Online (Sandbox Code Playgroud)

fsync linux-kernel

7
推荐指数
1
解决办法
1997
查看次数

标签 统计

fsync ×1

linux-kernel ×1