Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1489499
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4.4 012/118] kernfs: dont depend on d_find_any_alias() when generating notifications |
| Date | 2016-09-22 21:40 +0200 |
| Message-ID | <ski0G-226-23@gated-at.bofh.it> (permalink) |
| References | <skg8x-Rq-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <tj@kernel.org>
commit df6a58c5c5aa8ecb1e088ecead3fa33ae70181f1 upstream.
kernfs_notify_workfn() sends out file modified events for the
scheduled kernfs_nodes. Because the modifications aren't from
userland, it doesn't have the matching file struct at hand and can't
use fsnotify_modify(). Instead, it looked up the inode and then used
d_find_any_alias() to find the dentry and used fsnotify_parent() and
fsnotify() directly to generate notifications.
The assumption was that the relevant dentries would have been pinned
if there are listeners, which isn't true as inotify doesn't pin
dentries at all and watching the parent doesn't pin the child dentries
even for dnotify. This led to, for example, inotify watchers not
getting notifications if the system is under memory pressure and the
matching dentries got reclaimed. It can also be triggered through
/proc/sys/vm/drop_caches or a remount attempt which involves shrinking
dcache.
fsnotify_parent() only uses the dentry to access the parent inode,
which kernfs can do easily. Update kernfs_notify_workfn() so that it
uses fsnotify() directly for both the parent and target inodes without
going through d_find_any_alias(). While at it, supply the target file
name to fsnotify() from kernfs_node->name.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Evgeny Vereshchagin <evvers@ya.ru>
Fixes: d911d9874801 ("kernfs: make kernfs_notify() trigger inotify events too")
Cc: John McCutchan <john@johnmccutchan.com>
Cc: Robert Love <rlove@rlove.org>
Cc: Eric Paris <eparis@parisplace.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/kernfs/file.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -833,21 +833,35 @@ repeat:
mutex_lock(&kernfs_mutex);
list_for_each_entry(info, &kernfs_root(kn)->supers, node) {
+ struct kernfs_node *parent;
struct inode *inode;
- struct dentry *dentry;
+ /*
+ * We want fsnotify_modify() on @kn but as the
+ * modifications aren't originating from userland don't
+ * have the matching @file available. Look up the inodes
+ * and generate the events manually.
+ */
inode = ilookup(info->sb, kn->ino);
if (!inode)
continue;
- dentry = d_find_any_alias(inode);
- if (dentry) {
- fsnotify_parent(NULL, dentry, FS_MODIFY);
- fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE,
- NULL, 0);
- dput(dentry);
+ parent = kernfs_get_parent(kn);
+ if (parent) {
+ struct inode *p_inode;
+
+ p_inode = ilookup(info->sb, parent->ino);
+ if (p_inode) {
+ fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD,
+ inode, FSNOTIFY_EVENT_INODE, kn->name, 0);
+ iput(p_inode);
+ }
+
+ kernfs_put(parent);
}
+ fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE,
+ kn->name, 0);
iput(inode);
}
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 055/118] ARM: dts: overo: fix gpmc nand cs0 range Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 025/118] x86/AMD: Apply erratum 665 on machines without a BIOS fix Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 060/118] bus: arm-ccn: Fix XP watchpoint settings bitmask Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 029/118] iio: adc: rockchip_saradc: reset saradc controller before programming it Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 034/118] iio: accel: bmc150: reset chip at init time Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 062/118] dm log writes: move IO accounting earlier to fix error path Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 022/118] IB/uverbs: Fix race between uverbs_close and remove_one Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 048/118] cpuset: make sure new tasks conform to the current config of the cpuset Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 021/118] dm flakey: fix reads to be issued if drop_writes configured Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 027/118] iio: accel: kxsd9: Fix raw read return Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 037/118] iio:core: fix IIO_VAL_FRACTIONAL sign handling Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 003/118] clocksource/drivers/sun4i: Clear interrupts after stopping timer in probe function Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 056/118] ARM: dts: overo: fix gpmc nand on boards with ethernet Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 066/118] arm64: spinlocks: implement smp_mb__before_spinlock() as smp_mb() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 059/118] bus: arm-ccn: Do not attempt to configure XPs for cycle counter Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 030/118] iio: adc: ti_am335x_adc: Protect FIFO1 from concurrent access Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 026/118] kvm-arm: Unmap shadow pagetables properly Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 053/118] ARM: OMAP3: hwmod data: Add sysc information for DSI Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 008/118] tipc: move linearization of buffers to generic code Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 031/118] iio: adc: ti_am335x_adc: Increase timeout value waiting for ADC sample Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 028/118] iio: proximity: as3935: set up buffer timestamps for non-zero values Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:40 +0200
[PATCH 4.4 012/118] kernfs: dont depend on d_find_any_alias() when generating notifications Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:40 +0200
[PATCH 4.4 015/118] nfsd: Close race between nfsd4_release_lockowner and nfsd4_lock Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:40 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Holger Hoffstätte <holger@applied-asynchrony.com> - 2016-09-22 22:00 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 10:20 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Holger Hoffstätte <holger@applied-asynchrony.com> - 2016-09-23 10:50 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 11:30 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Guenter Roeck <linux@roeck-us.net> - 2016-09-23 01:50 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Guenter Roeck <linux@roeck-us.net> - 2016-09-23 05:10 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 10:10 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 10:10 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 10:20 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 10:20 +0200
csiph-web