Bug 12812

Summary: [PATCH]do_sendfile does not invoke any fsnotify_* (inotify) functions
Product: File System Reporter: Scott Wolchok (swolchok)
Component: OtherAssignee: fs_other
Status: RESOLVED CODE_FIX    
Severity: enhancement CC: alan, florian
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.28 Subsystem:
Regression: No Bisected commit-id:

Description Scott Wolchok 2009-03-02 21:48:06 UTC
Problem Description: do_sendfile in fs/read_write.c does not call fsnotify functions, unlike its neighbors. Manifests as a lack of inotify ACCESS event when a file is sent using sendfile(2).

I am a kernel hacking newbie, but I came up with the following patch, which seems good enough for my purposes. j_eng in #kernel on irc.freenode.net suggests that unnamed sockets shouldn't have the MODIFY event fired, since they can't be watched with inotify anyway.

--- /usr/src/linux-source-2.6.26-1-amd64/fs/read_write.c        2008-07-13 17:51:29.000000000 -0400
+++ linux-source-2.6.26/fs/read_write.c 2009-03-02 22:52:09.000000000 -0500
@@ -778,6 +778,8 @@ static ssize_t do_sendfile(int out_fd, i
        if (retval > 0) {
                add_rchar(current, retval);
                add_wchar(current, retval);
+                fsnotify_access(in_file->f_path.dentry);
+                fsnotify_modify(out_file->f_path.dentry);
        }

        inc_syscr(current);
Comment 1 Andrew Morton 2009-03-02 21:58:16 UTC
Thanks.

Please submit patches via email, not via bugzilla, as per
Documentation/SubmittingPatches.

Suitable recipients for this one are

Jens Axboe <jens.axboe@oracle.com>
Andrew Morton <akpm@linux-foundation.org>,
linux-fsdevel@vger.kernel.org
linux-kernel@vger.kernel.org
Comment 2 Florian Mickler 2012-12-22 09:22:02 UTC
A patch referencing this bug report has been merged in Linux v3.8-rc1:

commit a68c2f12b4b28994aaf622bbe5724b7258cc2fcf
Author: Scott Wolchok <swolchok@umich.edu>
Date:   Thu Dec 20 15:05:52 2012 -0800

    sendfile: allows bypassing of notifier events