Bug 12812 - [PATCH]do_sendfile does not invoke any fsnotify_* (inotify) functions
[PATCH]do_sendfile does not invoke any fsnotify_* (inotify) functions
Status: RESOLVED CODE_FIX
Product: File System
Classification: Unclassified
Component: Other
All Linux
: P1 enhancement
Assigned To: fs_other
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-03-02 21:48 UTC by Scott Wolchok
Modified: 2013-01-02 16:53 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.28
Tree: Mainline
Regression: No


Attachments

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

Note You need to log in before you can comment on or make changes to this bug.