<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/fs/notify, branch v3.8</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/fs/notify?h=v3.8</id>
<link rel='self' href='https://git.amat.us/linux/atom/fs/notify?h=v3.8'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2012-12-21T04:11:52Z</updated>
<entry>
<title>Merge branch 'for-next' of git://git.infradead.org/users/eparis/notify</title>
<updated>2012-12-21T04:11:52Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-12-21T04:11:52Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=96680d2b9174668100824d763382240c71baa811'/>
<id>urn:sha1:96680d2b9174668100824d763382240c71baa811</id>
<content type='text'>
Pull filesystem notification updates from Eric Paris:
 "This pull mostly is about locking changes in the fsnotify system.  By
  switching the group lock from a spin_lock() to a mutex() we can now
  hold the lock across things like iput().  This fixes a problem
  involving unmounting a fs and having inodes be busy, first pointed out
  by FAT, but reproducible with tmpfs.

  This also restores signal driven I/O for inotify, which has been
  broken since about 2.6.32."

Ugh.  I *hate* the timing of this.  It was rebased after the merge
window opened, and then left to sit with the pull request coming the day
before the merge window closes.  That's just crap.  But apparently the
patches themselves have been around for over a year, just gathering
dust, so now it's suddenly critical.

Fixed up semantic conflict in fs/notify/fdinfo.c as per Stephen
Rothwell's fixes from -next.

* 'for-next' of git://git.infradead.org/users/eparis/notify:
  inotify: automatically restart syscalls
  inotify: dont skip removal of watch descriptor if creation of ignored event failed
  fanotify: dont merge permission events
  fsnotify: make fasync generic for both inotify and fanotify
  fsnotify: change locking order
  fsnotify: dont put marks on temporary list when clearing marks by group
  fsnotify: introduce locked versions of fsnotify_add_mark() and fsnotify_remove_mark()
  fsnotify: pass group to fsnotify_destroy_mark()
  fsnotify: use a mutex instead of a spinlock to protect a groups mark list
  fanotify: add an extra flag to mark_remove_from_mask that indicates wheather a mark should be destroyed
  fsnotify: take groups mark_lock before mark lock
  fsnotify: use reference counting for groups
  fsnotify: introduce fsnotify_get_group()
  inotify, fanotify: replace fsnotify_put_group() with fsnotify_destroy_group()
</content>
</entry>
<entry>
<title>fs, fanotify: add @mflags field to fanotify output</title>
<updated>2012-12-18T01:15:28Z</updated>
<author>
<name>Cyrill Gorcunov</name>
<email>gorcunov@openvz.org</email>
</author>
<published>2012-12-18T00:05:16Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=e6dbcafb744ab94a94142a6e721e16330397fad8'/>
<id>urn:sha1:e6dbcafb744ab94a94142a6e721e16330397fad8</id>
<content type='text'>
The kernel keeps FAN_MARK_IGNORED_SURV_MODIFY bit separately from
fsnotify_mark::mask|ignored_mask thus put it in @mflags (mark flags)
field so the user-space reader will be able to detect if such bit were
used on mark creation procedure.

 | pos:	0
 | flags:	04002
 | fanotify flags:10 event-flags:0
 | fanotify mnt_id:12 mflags:40 mask:38 ignored_mask:40000003
 | fanotify ino:4f969 sdev:800013 mflags:0 mask:3b ignored_mask:40000000 fhandle-bytes:8 fhandle-type:1 f_handle:69f90400c275b5b4

Signed-off-by: Cyrill Gorcunov &lt;gorcunov@openvz.org&gt;
Cc: Pavel Emelyanov &lt;xemul@parallels.com&gt;
Cc: Oleg Nesterov &lt;oleg@redhat.com&gt;
Cc: Andrey Vagin &lt;avagin@openvz.org&gt;
Cc: Al Viro &lt;viro@ZenIV.linux.org.uk&gt;
Cc: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Cc: James Bottomley &lt;jbottomley@parallels.com&gt;
Cc: "Aneesh Kumar K.V" &lt;aneesh.kumar@linux.vnet.ibm.com&gt;
Cc: Matthew Helsley &lt;matt.helsley@gmail.com&gt;
Cc: "J. Bruce Fields" &lt;bfields@fieldses.org&gt;
Cc: Tvrtko Ursulin &lt;tvrtko.ursulin@onelan.co.uk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>fs, notify: add procfs fdinfo helper</title>
<updated>2012-12-18T01:15:28Z</updated>
<author>
<name>Cyrill Gorcunov</name>
<email>gorcunov@openvz.org</email>
</author>
<published>2012-12-18T00:05:12Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=be77196b809cdce8603a5aadd5e3cfabd3cbef96'/>
<id>urn:sha1:be77196b809cdce8603a5aadd5e3cfabd3cbef96</id>
<content type='text'>
This allow us to print out fsnotify details such as watchee inode, device,
mask and optionally a file handle.

For inotify objects if kernel compiled with exportfs support the output
will be

 | pos:	0
 | flags:	02000000
 | inotify wd:3 ino:9e7e sdev:800013 mask:800afce ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:7e9e0000640d1b6d
 | inotify wd:2 ino:a111 sdev:800013 mask:800afce ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:11a1000020542153
 | inotify wd:1 ino:6b149 sdev:800013 mask:800afce ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:49b1060023552153

If kernel compiled without exportfs support, the file handle
won't be provided but inode and device only.

 | pos:	0
 | flags:	02000000
 | inotify wd:3 ino:9e7e sdev:800013 mask:800afce ignored_mask:0
 | inotify wd:2 ino:a111 sdev:800013 mask:800afce ignored_mask:0
 | inotify wd:1 ino:6b149 sdev:800013 mask:800afce ignored_mask:0

For fanotify the output is like

 | pos:	0
 | flags:	04002
 | fanotify flags:10 event-flags:0
 | fanotify mnt_id:12 mask:3b ignored_mask:0
 | fanotify ino:50205 sdev:800013 mask:3b ignored_mask:40000000 fhandle-bytes:8 fhandle-type:1 f_handle:05020500fb1d47e7

To minimize impact on general fsnotify code the new functionality
is gathered in fs/notify/fdinfo.c file.

Signed-off-by: Cyrill Gorcunov &lt;gorcunov@openvz.org&gt;
Acked-by: Pavel Emelyanov &lt;xemul@parallels.com&gt;
Cc: Oleg Nesterov &lt;oleg@redhat.com&gt;
Cc: Andrey Vagin &lt;avagin@openvz.org&gt;
Cc: Al Viro &lt;viro@ZenIV.linux.org.uk&gt;
Cc: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Cc: James Bottomley &lt;jbottomley@parallels.com&gt;
Cc: "Aneesh Kumar K.V" &lt;aneesh.kumar@linux.vnet.ibm.com&gt;
Cc: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Cc: Matthew Helsley &lt;matt.helsley@gmail.com&gt;
Cc: "J. Bruce Fields" &lt;bfields@fieldses.org&gt;
Cc: "Aneesh Kumar K.V" &lt;aneesh.kumar@linux.vnet.ibm.com&gt;
Cc: Tvrtko Ursulin &lt;tvrtko.ursulin@onelan.co.uk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>fs/notify/inode_mark.c: make fsnotify_find_inode_mark_locked() static</title>
<updated>2012-12-18T01:15:13Z</updated>
<author>
<name>Tushar Behera</name>
<email>tushar.behera@linaro.org</email>
</author>
<published>2012-12-17T23:59:40Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=ac5f121b8f2cad52b7671f9af872f8761b0ea1d4'/>
<id>urn:sha1:ac5f121b8f2cad52b7671f9af872f8761b0ea1d4</id>
<content type='text'>
Fixes following sparse warning:

  fs/notify/inode_mark.c:127:22: warning: symbol 'fsnotify_find_inode_mark_locked' was not declared. Should it be static?

Signed-off-by: Tushar Behera &lt;tushar.behera@linaro.org&gt;
Cc: Eric Paris &lt;eparis@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial</title>
<updated>2012-12-13T20:00:02Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-12-13T20:00:02Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=a2013a13e68354e0c8f3696b69701803e13fb737'/>
<id>urn:sha1:a2013a13e68354e0c8f3696b69701803e13fb737</id>
<content type='text'>
Pull trivial branch from Jiri Kosina:
 "Usual stuff -- comment/printk typo fixes, documentation updates, dead
  code elimination."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (39 commits)
  HOWTO: fix double words typo
  x86 mtrr: fix comment typo in mtrr_bp_init
  propagate name change to comments in kernel source
  doc: Update the name of profiling based on sysfs
  treewide: Fix typos in various drivers
  treewide: Fix typos in various Kconfig
  wireless: mwifiex: Fix typo in wireless/mwifiex driver
  messages: i2o: Fix typo in messages/i2o
  scripts/kernel-doc: check that non-void fcts describe their return value
  Kernel-doc: Convention: Use a "Return" section to describe return values
  radeon: Fix typo and copy/paste error in comments
  doc: Remove unnecessary declarations from Documentation/accounting/getdelays.c
  various: Fix spelling of "asynchronous" in comments.
  Fix misspellings of "whether" in comments.
  eisa: Fix spelling of "asynchronous".
  various: Fix spelling of "registered" in comments.
  doc: fix quite a few typos within Documentation
  target: iscsi: fix comment typos in target/iscsi drivers
  treewide: fix typo of "suport" in various comments and Kconfig
  treewide: fix typo of "suppport" in various comments
  ...
</content>
</entry>
<entry>
<title>inotify: automatically restart syscalls</title>
<updated>2012-12-11T18:44:37Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2012-03-26T17:07:59Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=1ca39ab9d21ac93f94b9e3eb364ea9a5cf2aba06'/>
<id>urn:sha1:1ca39ab9d21ac93f94b9e3eb364ea9a5cf2aba06</id>
<content type='text'>
We were mistakenly returning EINTR when we found an outstanding signal.
Instead we should returen ERESTARTSYS and allow the kernel to handle
things the right way.

Patch-from: Oleg Nesterov &lt;oleg@redhat.com&gt;
Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
</content>
</entry>
<entry>
<title>inotify: dont skip removal of watch descriptor if creation of ignored event failed</title>
<updated>2012-12-11T18:44:37Z</updated>
<author>
<name>Lino Sanfilippo</name>
<email>LinoSanfilippo@gmx.de</email>
</author>
<published>2012-03-24T22:44:19Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=8b99c3ccf735a2294c7842d236caa42e543e2c95'/>
<id>urn:sha1:8b99c3ccf735a2294c7842d236caa42e543e2c95</id>
<content type='text'>
In inotify_ignored_and_remove_idr() the removal of a watch descriptor is skipped
if the allocation of an ignored event failed and we are leaking memory (the
watch descriptor and the mark linked to it).
This patch ensures that the watch descriptor is removed regardless of whether
event creation failed or not.

Signed-off-by: Lino Sanfilippo &lt;LinoSanfilippo@gmx.de&gt;
Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
</content>
</entry>
<entry>
<title>fanotify: dont merge permission events</title>
<updated>2012-12-11T18:44:37Z</updated>
<author>
<name>Lino Sanfilippo</name>
<email>LinoSanfilippo@gmx.de</email>
</author>
<published>2012-03-23T01:42:23Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=03a1cec1f17ac1a6041996b3e40f96b5a2f90e1b'/>
<id>urn:sha1:03a1cec1f17ac1a6041996b3e40f96b5a2f90e1b</id>
<content type='text'>
Boyd Yang reported a problem for the case that multiple threads of the same
thread group are waiting for a reponse for a permission event.
In this case it is possible that some of the threads are never woken up, even
if the response for the event has been received
(see http://marc.info/?l=linux-kernel&amp;m=131822913806350&amp;w=2).

The reason is that we are currently merging permission events if they belong to
the same thread group. But we are not prepared to wake up more than one waiter
for each event. We do

wait_event(group-&gt;fanotify_data.access_waitq, event-&gt;response ||
			atomic_read(&amp;group-&gt;fanotify_data.bypass_perm));
and after that
  event-&gt;response = 0;

which is the reason that even if we woke up all waiters for the same event
some of them may see event-&gt;response being already set 0 again, then go back to
sleep and block forever.

With this patch we avoid that more than one thread is waiting for a response
by not merging permission events for the same thread group any more.

Reported-by: Boyd Yang &lt;boyd.yang@gmail.com&gt;
Signed-off-by: Lino Sanfilippo &lt;LinoSanfilipp@gmx.de&gt;
Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
</content>
</entry>
<entry>
<title>fsnotify: make fasync generic for both inotify and fanotify</title>
<updated>2012-12-11T18:44:36Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2011-10-14T21:43:39Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=0a6b6bd5919a65030b557ec8fe81f6fb3e93744a'/>
<id>urn:sha1:0a6b6bd5919a65030b557ec8fe81f6fb3e93744a</id>
<content type='text'>
inotify is supposed to support async signal notification when information
is available on the inotify fd.  This patch moves that support to generic
fsnotify functions so it can be used by all notification mechanisms.

Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
</content>
</entry>
<entry>
<title>fsnotify: change locking order</title>
<updated>2012-12-11T18:44:36Z</updated>
<author>
<name>Lino Sanfilippo</name>
<email>LinoSanfilippo@gmx.de</email>
</author>
<published>2011-08-11T23:13:31Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=6960b0d909cde5bdff49e4e5c1250edd10be7ebd'/>
<id>urn:sha1:6960b0d909cde5bdff49e4e5c1250edd10be7ebd</id>
<content type='text'>
On Mon, Aug 01, 2011 at 04:38:22PM -0400, Eric Paris wrote:
&gt;
&gt; I finally built and tested a v3.0 kernel with these patches (I know I'm
&gt; SOOOOOO far behind).  Not what I hoped for:
&gt;
&gt; &gt; [  150.937798] VFS: Busy inodes after unmount of tmpfs. Self-destruct in 5 seconds.  Have a nice day...
&gt; &gt; [  150.945290] BUG: unable to handle kernel NULL pointer dereference at 0000000000000070
&gt; &gt; [  150.946012] IP: [&lt;ffffffff810ffd58&gt;] shmem_free_inode+0x18/0x50
&gt; &gt; [  150.946012] PGD 2bf9e067 PUD 2bf9f067 PMD 0
&gt; &gt; [  150.946012] Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
&gt; &gt; [  150.946012] CPU 0
&gt; &gt; [  150.946012] Modules linked in: nfs lockd fscache auth_rpcgss nfs_acl sunrpc ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 ip6table_filter ip6_tables ext4 jbd2 crc16 joydev ata_piix i2c_piix4 pcspkr uinput ipv6 autofs4 usbhid [last unloaded: scsi_wait_scan]
&gt; &gt; [  150.946012]
&gt; &gt; [  150.946012] Pid: 2764, comm: syscall_thrash Not tainted 3.0.0+ #1 Red Hat KVM
&gt; &gt; [  150.946012] RIP: 0010:[&lt;ffffffff810ffd58&gt;]  [&lt;ffffffff810ffd58&gt;] shmem_free_inode+0x18/0x50
&gt; &gt; [  150.946012] RSP: 0018:ffff88002c2e5df8  EFLAGS: 00010282
&gt; &gt; [  150.946012] RAX: 000000004e370d9f RBX: 0000000000000000 RCX: ffff88003a029438
&gt; &gt; [  150.946012] RDX: 0000000033630a5f RSI: 0000000000000000 RDI: ffff88003491c240
&gt; &gt; [  150.946012] RBP: ffff88002c2e5e08 R08: 0000000000000000 R09: 0000000000000000
&gt; &gt; [  150.946012] R10: 0000000000000000 R11: 0000000000000000 R12: ffff88003a029428
&gt; &gt; [  150.946012] R13: ffff88003a029428 R14: ffff88003a029428 R15: ffff88003499a610
&gt; &gt; [  150.946012] FS:  00007f5a05420700(0000) GS:ffff88003f600000(0000) knlGS:0000000000000000
&gt; &gt; [  150.946012] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
&gt; &gt; [  150.946012] CR2: 0000000000000070 CR3: 000000002a662000 CR4: 00000000000006f0
&gt; &gt; [  150.946012] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
&gt; &gt; [  150.946012] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
&gt; &gt; [  150.946012] Process syscall_thrash (pid: 2764, threadinfo ffff88002c2e4000, task ffff88002bfbc760)
&gt; &gt; [  150.946012] Stack:
&gt; &gt; [  150.946012]  ffff88003a029438 ffff88003a029428 ffff88002c2e5e38 ffffffff81102f76
&gt; &gt; [  150.946012]  ffff88003a029438 ffff88003a029598 ffffffff8160f9c0 ffff88002c221250
&gt; &gt; [  150.946012]  ffff88002c2e5e68 ffffffff8115e9be ffff88002c2e5e68 ffff88003a029438
&gt; &gt; [  150.946012] Call Trace:
&gt; &gt; [  150.946012]  [&lt;ffffffff81102f76&gt;] shmem_evict_inode+0x76/0x130
&gt; &gt; [  150.946012]  [&lt;ffffffff8115e9be&gt;] evict+0x7e/0x170
&gt; &gt; [  150.946012]  [&lt;ffffffff8115ee40&gt;] iput_final+0xd0/0x190
&gt; &gt; [  150.946012]  [&lt;ffffffff8115ef33&gt;] iput+0x33/0x40
&gt; &gt; [  150.946012]  [&lt;ffffffff81180205&gt;] fsnotify_destroy_mark_locked+0x145/0x160
&gt; &gt; [  150.946012]  [&lt;ffffffff81180316&gt;] fsnotify_destroy_mark+0x36/0x50
&gt; &gt; [  150.946012]  [&lt;ffffffff81181937&gt;] sys_inotify_rm_watch+0x77/0xd0
&gt; &gt; [  150.946012]  [&lt;ffffffff815aca52&gt;] system_call_fastpath+0x16/0x1b
&gt; &gt; [  150.946012] Code: 67 4a 00 b8 e4 ff ff ff eb aa 66 0f 1f 84 00 00 00 00 00 55 48 89 e5 48 83 ec 10 48 89 1c 24 4c 89 64 24 08 48 8b 9f 40 05 00 00
&gt; &gt; [  150.946012]  83 7b 70 00 74 1c 4c 8d a3 80 00 00 00 4c 89 e7 e8 d2 5d 4a
&gt; &gt; [  150.946012] RIP  [&lt;ffffffff810ffd58&gt;] shmem_free_inode+0x18/0x50
&gt; &gt; [  150.946012]  RSP &lt;ffff88002c2e5df8&gt;
&gt; &gt; [  150.946012] CR2: 0000000000000070
&gt;
&gt; Looks at aweful lot like the problem from:
&gt; http://www.spinics.net/lists/linux-fsdevel/msg46101.html
&gt;

I tried to reproduce this bug with your test program, but without success.
However, if I understand correctly, this occurs since we dont hold any locks when
we call iput() in mark_destroy(), right?
With the patches you tested, iput() is also not called within any lock, since the
groups mark_mutex is released temporarily before iput() is called.  This is, since
the original codes behaviour is similar.
However since we now have a mutex as the biggest lock, we can do what you
suggested (http://www.spinics.net/lists/linux-fsdevel/msg46107.html) and
call iput() with the mutex held to avoid the race.
The patch below implements this. It uses nested locking to avoid deadlock in case
we do the final iput() on an inode which still holds marks and thus would take
the mutex again when calling fsnotify_inode_delete() in destroy_inode().

Signed-off-by: Lino Sanfilippo &lt;LinoSanfilippo@gmx.de&gt;
Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
</content>
</entry>
</feed>
