1. 29 1月, 2014 1 次提交
  2. 22 1月, 2014 2 次提交
    • J
      fsnotify: remove .should_send_event callback · 83c4c4b0
      Jan Kara 提交于
      After removing event structure creation from the generic layer there is
      no reason for separate .should_send_event and .handle_event callbacks.
      So just remove the first one.
      Signed-off-by: NJan Kara <jack@suse.cz>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Cc: Eric Paris <eparis@parisplace.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      83c4c4b0
    • J
      fsnotify: do not share events between notification groups · 7053aee2
      Jan Kara 提交于
      Currently fsnotify framework creates one event structure for each
      notification event and links this event into all interested notification
      groups.  This is done so that we save memory when several notification
      groups are interested in the event.  However the need for event
      structure shared between inotify & fanotify bloats the event structure
      so the result is often higher memory consumption.
      
      Another problem is that fsnotify framework keeps path references with
      outstanding events so that fanotify can return open file descriptors
      with its events.  This has the undesirable effect that filesystem cannot
      be unmounted while there are outstanding events - a regression for
      inotify compared to a situation before it was converted to fsnotify
      framework.  For fanotify this problem is hard to avoid and users of
      fanotify should kind of expect this behavior when they ask for file
      descriptors from notified files.
      
      This patch changes fsnotify and its users to create separate event
      structure for each group.  This allows for much simpler code (~400 lines
      removed by this patch) and also smaller event structures.  For example
      on 64-bit system original struct fsnotify_event consumes 120 bytes, plus
      additional space for file name, additional 24 bytes for second and each
      subsequent group linking the event, and additional 32 bytes for each
      inotify group for private data.  After the conversion inotify event
      consumes 48 bytes plus space for file name which is considerably less
      memory unless file names are long and there are several groups
      interested in the events (both of which are uncommon).  Fanotify event
      fits in 56 bytes after the conversion (fanotify doesn't care about file
      names so its events don't have to have it allocated).  A win unless
      there are four or more fanotify groups interested in the event.
      
      The conversion also solves the problem with unmount when only inotify is
      used as we don't have to grab path references for inotify events.
      
      [hughd@google.com: fanotify: fix corruption preventing startup]
      Signed-off-by: NJan Kara <jack@suse.cz>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Cc: Eric Paris <eparis@parisplace.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NHugh Dickins <hughd@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7053aee2
  3. 28 2月, 2013 1 次提交
  4. 12 12月, 2012 2 次提交
    • L
      fsnotify: pass group to fsnotify_destroy_mark() · e2a29943
      Lino Sanfilippo 提交于
      In fsnotify_destroy_mark() dont get the group from the passed mark anymore,
      but pass the group itself as an additional parameter to the function.
      Signed-off-by: NLino Sanfilippo <LinoSanfilippo@gmx.de>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      e2a29943
    • L
      fsnotify: use reference counting for groups · 23e964c2
      Lino Sanfilippo 提交于
      Get a group ref for each mark that is added to the groups list and release that
      ref when the mark is freed in fsnotify_put_mark().
      We also use get a group reference for duplicated marks and for private event
      data.
      Now we dont free a group any more when the number of marks becomes 0 but when
      the groups ref count does. Since this will only happen when all marks are removed
      from a groups mark list, we dont have to set the groups number of marks to 1 at
      group creation.
      
      Beside clearing all marks in fsnotify_destroy_group() we do also flush the
      groups event queue. This is since events may hold references to groups (due to
      private event data) and we have to put those references first before we get a
      chance to put the final ref, which will result in a call to
      fsnotify_final_destroy_group().
      Signed-off-by: NLino Sanfilippo <LinoSanfilippo@gmx.de>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      23e964c2
  5. 06 4月, 2011 1 次提交
    • E
      inotify: fix double free/corruption of stuct user · d0de4dc5
      Eric Paris 提交于
      On an error path in inotify_init1 a normal user can trigger a double
      free of struct user.  This is a regression introduced by a2ae4cc9
      ("inotify: stop kernel memory leak on file creation failure").
      
      We fix this by making sure that if a group exists the user reference is
      dropped when the group is cleaned up.  We should not explictly drop the
      reference on error and also drop the reference when the group is cleaned
      up.
      
      The new lifetime rules are that an inotify group lives from
      inotify_new_group to the last fsnotify_put_group.  Since the struct user
      and inotify_devs are directly tied to this lifetime they are only
      changed/updated in those two locations.  We get rid of all special
      casing of struct user or user->inotify_devs.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Cc: stable@kernel.org (2.6.37 and up)
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d0de4dc5
  6. 31 3月, 2011 1 次提交
  7. 13 8月, 2010 1 次提交
  8. 28 7月, 2010 21 次提交
  9. 14 5月, 2010 1 次提交
  10. 16 1月, 2010 1 次提交
  11. 27 8月, 2009 1 次提交
  12. 18 8月, 2009 1 次提交
  13. 20 6月, 2009 1 次提交
    • E
      inotify: inotify_destroy_mark_entry could get called twice · 528da3e9
      Eric Paris 提交于
      inotify_destroy_mark_entry could get called twice for the same mark since it
      is called directly in inotify_rm_watch and when the mark is being destroyed for
      another reason.  As an example assume that the file being watched was just
      deleted so inotify_destroy_mark_entry would get called from the path
      fsnotify_inoderemove() -> fsnotify_destroy_marks_by_inode() ->
      fsnotify_destroy_mark_entry() -> inotify_destroy_mark_entry().  If this
      happened at the same time as userspace tried to remove a watch via
      inotify_rm_watch we could attempt to remove the mark from the idr twice and
      could thus double dec the ref cnt and potentially could be in a use after
      free/double free situation.  The fix is to have inotify_rm_watch use the
      generic recursive safe fsnotify_destroy_mark_by_entry() so we are sure the
      inotify_destroy_mark_entry() function can only be called one.
      
      This patch also renames the function to inotify_ingored_remove_idr() so it is
      clear what is actually going on in the function.
      
      Hopefully this fixes:
      [   20.342058] idr_remove called for id=20 which is not allocated.
      [   20.348000] Pid: 1860, comm: udevd Not tainted 2.6.30-tip #1077
      [   20.353933] Call Trace:
      [   20.356410]  [<ffffffff811a82b7>] idr_remove+0x115/0x18f
      [   20.361737]  [<ffffffff8134259d>] ? _spin_lock+0x6d/0x75
      [   20.367061]  [<ffffffff8111640a>] ? inotify_destroy_mark_entry+0xa3/0xcf
      [   20.373771]  [<ffffffff8111641e>] inotify_destroy_mark_entry+0xb7/0xcf
      [   20.380306]  [<ffffffff81115913>] inotify_freeing_mark+0xe/0x10
      [   20.386238]  [<ffffffff8111410d>] fsnotify_destroy_mark_by_entry+0x143/0x170
      [   20.393293]  [<ffffffff811163a3>] inotify_destroy_mark_entry+0x3c/0xcf
      [   20.399829]  [<ffffffff811164d1>] sys_inotify_rm_watch+0x9b/0xc6
      [   20.405850]  [<ffffffff8100bcdb>] system_call_fastpath+0x16/0x1b
      Reported-by: NPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Tested-by: NPeter Ziljlstra <peterz@infradead.org>
      528da3e9
  14. 12 6月, 2009 2 次提交