splice() from /dev/zero to a pipe does not work (5.9+)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

While doing some micro benchmarking with stress-ng I discovered that
since linux 5.9 the splicing from /dev/zero to a pipe now fails with
-EINVAL.

I bisected this down to the following commit:

36e2c7421f02a22f71c9283e55fdb672a9eb58e7 is the first bad commit
commit 36e2c7421f02a22f71c9283e55fdb672a9eb58e7
Author: Christoph Hellwig <hch@xxxxxx>
Date:   Thu Sep 3 16:22:34 2020 +0200

    fs: don't allow splice read/write without explicit ops

I'm not sure if this has been reported before, or if it's intentional
behavior or not. As it stands, it's a regression in the stress-ng splice
test case.

Prior to that commit, splicing worked from /dev/zero to a pipe. Below is
an example of the reproducer:

--- reproducer below ---

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

#define FAIL(x) { perror(x); exit(1); }

int main(void)
{
        int fd_in, fd_out, fds[2];
        ssize_t ret;
        loff_t off_in, off_out;
        const size_t len = 4096;

        if ((fd_in = open("/dev/zero", O_RDONLY)) < 0)
                FAIL("open /dev/zero failed");

        /*
         *   /dev/zero -> pipe splice -> pipe splice -> /dev/null
         */
        if (pipe(fds) < 0)
                FAIL("pipe FAILed\n");

        if ((fd_out = open("/dev/null", O_WRONLY)) < 0)
                FAIL("open /dev/null failed");

        ret = splice(fd_in, NULL, fds[1], NULL, len, SPLICE_F_MOVE);
        if (ret < 0)
                FAIL("splice failed");

        ret = splice(fds[0], NULL, fd_out, NULL, len, SPLICE_F_MOVE);
        if (ret < 0)
                FAIL("splice failed");

        return 0;
}



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux