Bug 85381

Summary: ext4 & tmpfs: Splicing to regular files doesn't trigger inotify
Product: File System Reporter: Richard Li (richardpku)
Component: ext4Assignee: fs_ext4 (fs_ext4)
Status: RESOLVED CODE_FIX    
Severity: normal CC: darioandre, jack
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.14 Subsystem:
Regression: No Bisected commit-id:

Description Richard Li 2014-10-01 16:56:36 UTC
* How to reproduce:

/tmp % cat a.c
#define _GNU_SOURCE 1
#include <limits.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int main(void)
{
        int pipefd[2];
        pipe(pipefd);

        for (;;) {
                sleep(1);
                write(pipefd[1], "Hello world\n", 12);
                splice(pipefd[0], NULL, 1, NULL, INT_MAX, 0);
        }
}
/tmp % gcc a.c
/tmp % touch a.txt
/tmp % ./a.out > a.txt & tail -f a.txt


* Expected result:

tail prints "Hello world" every second.



* Actual result:

btrfs: Works as expected;
ext4/tmpfs: tail blocks on inotify forever and prints nothing.
Comment 1 Jan Kara 2014-10-02 12:05:01 UTC
So this isn't a problem with current kernel (I tested 3.17-rc5) anymore. I believe it got fixed by Al Viro's splice rewrite so 3.16 and newer kernels should have the problem fixed.
Comment 2 Dario Andreani 2018-10-11 07:27:11 UTC
I still see this issue on kernel versions 4.4 and 4.9. But not on 4.15.