02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

10 Apr, 2017

12 commits

  • These are very thin wrappers, just remove them. Drop
    fs/notify/vfsmount_mark.c as it is empty now.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • The function is already mostly contained in what
    fsnotify_clear_marks_by_group() does. Just update that function to not
    select marks when all of them should be destroyed and remove
    fsnotify_detach_group_marks().

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • fanotify wants to drop fsnotify_mark_srcu lock when waiting for response
    from userspace so that the whole notification subsystem is not blocked
    during that time. This patch provides a framework for safely getting
    mark reference for a mark found in the object list which pins the mark
    in that list. We can then drop fsnotify_mark_srcu, wait for userspace
    response and then safely continue iteration of the object list once we
    reaquire fsnotify_mark_srcu.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Currently we queue all marks for destruction on group shutdown and then
    destroy them from fsnotify_destroy_group() instead from a worker thread
    which is the usual path. However worker can already be processing some
    list of marks to destroy so this does not make 100% all marks are really
    destroyed by the time group is shut down. This isn't a big problem as
    each mark holds group reference and thus group stays partially alive
    until all marks are really freed but there's no point in complicating
    our lives - just wait for the delayed work to be finished instead.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Currently we free fsnotify_mark_connector structure only when inode /
    vfsmount is getting freed. This can however impose noticeable memory
    overhead when marks get attached to inodes only temporarily. So free the
    connector structure once the last mark is detached from the object.
    Since notification infrastructure can be working with the connector
    under the protection of fsnotify_mark_srcu, we have to be careful and
    free the fsnotify_mark_connector only after SRCU period passes.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • fsnotify_detach_mark() calls fsnotify_destroy_inode_mark() or
    fsnotify_destroy_vfsmount_mark() to remove mark from object list. These
    two functions are however very similar and differ only in the lock they
    use to protect the object list of marks. Simplify the code by removing
    the indirection and removing mark from the object list in a common
    function.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Instead of passing spinlock into fsnotify_destroy_marks() determine it
    directly in that function from the connector type. This will reduce code
    churn when changing lock protecting list of marks.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Move locking of locks protecting a list of marks into
    fsnotify_recalc_mask(). This reduces code churn in the following patch
    which changes the lock protecting the list of marks.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Adding notification mark to object list has been currently done through
    fsnotify_add_{inode|vfsmount}_mark() helpers from
    fsnotify_add_mark_locked() which call fsnotify_add_mark_list(). Remove
    this unnecessary indirection to simplify the code.

    Pushing all the locking to fsnotify_add_mark_list() also allows us to
    allocate the connector structure with GFP_KERNEL mode.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Currently inode reference is held by fsnotify marks. Change the rules so
    that inode reference is held by fsnotify_mark_connector structure
    whenever the list is non-empty. This simplifies the code and is more
    logical.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Move pointer to inode / vfsmount from mark itself to the
    fsnotify_mark_connector structure. This is another step on the path
    towards decoupling inode / vfsmount lifetime from notification mark
    lifetime.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Currently notification marks are attached to object (inode or vfsmnt) by
    a hlist_head in the object. The list is also protected by a spinlock in
    the object. So while there is any mark attached to the list of marks,
    the object must be pinned in memory (and thus e.g. last iput() deleting
    inode cannot happen). Also for list iteration in fsnotify() to work, we
    must hold fsnotify_mark_srcu lock so that mark itself and
    mark->obj_list.next cannot get freed. Thus we are required to wait for
    response to fanotify events from userspace process with
    fsnotify_mark_srcu lock held. That causes issues when userspace process
    is buggy and does not reply to some event - basically the whole
    notification subsystem gets eventually stuck.

    So to be able to drop fsnotify_mark_srcu lock while waiting for
    response, we have to pin the mark in memory and make sure it stays in
    the object list (as removing the mark waiting for response could lead to
    lost notification events for groups later in the list). However we don't
    want inode reclaim to block on such mark as that would lead to system
    just locking up elsewhere.

    This commit is the first in the series that paves way towards solving
    these conflicting lifetime needs. Instead of anchoring the list of marks
    directly in the object, we anchor it in a dedicated structure
    (fsnotify_mark_connector) and just point to that structure from the
    object. The following commits will also add spinlock protecting the list
    and object pointer to the structure.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     

20 May, 2016

1 commit

  • Inotify instance is destroyed when all references to it are dropped.
    That not only means that the corresponding file descriptor needs to be
    closed but also that all corresponding instance marks are freed (as each
    mark holds a reference to the inotify instance). However marks are
    freed only after SRCU period ends which can take some time and thus if
    user rapidly creates and frees inotify instances, number of existing
    inotify instances can exceed max_user_instances limit although from user
    point of view there is always at most one existing instance. Thus
    inotify_init() returns EMFILE error which is hard to justify from user
    point of view. This problem is exposed by LTP inotify06 testcase on
    some machines.

    We fix the problem by making sure all group marks are properly freed
    while destroying inotify instance. We wait for SRCU period to end in
    that path anyway since we have to make sure there is no event being
    added to the instance while we are tearing down the instance. So it
    takes only some plumbing to allow for marks to be destroyed in that path
    as well and not from a dedicated work item.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Jan Kara
    Reported-by: Xiaoguang Wang
    Tested-by: Xiaoguang Wang
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Kara
     

05 Sep, 2015

1 commit

  • Free list is used when all marks on given inode / mount should be
    destroyed when inode / mount is going away. However we can free all of
    the marks without using a special list with some care.

    Signed-off-by: Jan Kara
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Kara
     

14 Dec, 2014

1 commit


14 Nov, 2014

1 commit

  • fsnotify() needs to merge inode and mount marks lists when notifying
    groups about events so that ignore masks from inode marks are reflected
    in mount mark notifications and groups are notified in proper order
    (according to priorities).

    Currently the sorting of the lists done by fsnotify_add_inode_mark() /
    fsnotify_add_vfsmount_mark() and fsnotify() differed which resulted
    ignore masks not being used in some cases.

    Fix the problem by always using the same comparison function when
    sorting / merging the mark lists.

    Thanks to Heinrich Schuchardt for improvements of my patch.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=87721
    Signed-off-by: Jan Kara
    Reported-by: Heinrich Schuchardt
    Tested-by: Heinrich Schuchardt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Kara
     

10 Oct, 2014

1 commit


28 Jul, 2010

10 commits

  • The global fsnotify groups lists were invented as a way to increase the
    performance of fsnotify by shortcutting events which were not interesting.
    With the changes to walk the object lists rather than global groups lists
    these shortcuts are not useful.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • Because we walk the object->fsnotify_marks list instead of the global
    fsnotify groups list we don't need the fsnotify_inode_mask and
    fsnotify_vfsmount_mask as these were simply shortcuts in fsnotify() for
    performance. They are now extra checks, rip them out.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • Currently reading the inode->i_fsnotify_marks or
    vfsmount->mnt_fsnotify_marks lists are protected by a spinlock on both the
    read and the write side. This patch protects the read side of those lists
    with a new single srcu.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • inotify marks must pin inodes in core. dnotify doesn't technically need to
    since they are closed when the directory is closed. fanotify also need to
    pin inodes in core as it works today. But the next step is to introduce
    the concept of 'ignored masks' which is actually a mask of events for an
    inode of no interest. I claim that these should be liberally sent to the
    kernel and should not pin the inode in core. If the inode is brought back
    in the listener will get an event it may have thought excluded, but this is
    not a serious situation and one any listener should deal with.

    This patch lays the ground work for non-pinning inode marks by using lazy
    inode pinning. We do not pin a mark until it has a non-zero mask entry. If a
    listener new sets a mask we never pin the inode.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • Per-mount watches allow groups to listen to fsnotify events on an entire
    mount. This patch simply adds and initializes the fields needed in the
    vfsmount struct to make this happen.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Eric Paris

    Andreas Gruenbacher
     
  • Much like inode-mark.c has all of the code dealing with marks on inodes
    this patch adds a vfsmount-mark.c which has similar code but is intended
    for marks on vfsmounts.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • currently all marking is done by functions in inode-mark.c. Some of this
    is pretty generic and should be instead done in a generic function and we
    should only put the inode specific code in inode-mark.c

    Signed-off-by: Eric Paris

    Eric Paris
     
  • currently all of the notification systems implemented select which inodes
    they care about and receive messages only about those inodes (or the
    children of those inodes.) This patch begins to flesh out fsnotify support
    for the concept of listeners that want to hear notification for an inode
    accessed below a given monut point. This patch implements a second list
    of fsnotify groups to hold these types of groups and a second global mask
    to hold the events of interest for this type of group.

    The reason we want a second group list and mask is because the inode based
    notification should_send_event support which makes each group look for a mark
    on the given inode. With one nfsmount listener that means that every group would
    have to take the inode->i_lock, look for their mark, not find one, and return
    for every operation. By seperating vfsmount from inode listeners only when
    there is a inode listener will the inode groups have to look for their
    mark and take the inode lock. vfsmount listeners will have to grab the lock and
    look for a mark but there should be fewer of them, and one vfsmount listener
    won't cause the i_lock to be grabbed and released for every fsnotify group
    on every io operation.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • Currently all fsnotify groups are added immediately to the
    fsnotify_inode_groups list upon creation. This means, even groups with no
    watches (common for audit) will be on the global tracking list and will
    get checked for every event. This patch adds groups to the global list on
    when the first inode mark is added to the group.

    Signed-of-by: Eric Paris

    Eric Paris
     
  • Simple renaming patch. fsnotify is about to support mount point listeners
    so I am renaming fsnotify_groups and fsnotify_mask to indicate these are lists
    used only for groups which have watches on inodes.

    Signed-off-by: Eric Paris

    Eric Paris
     

12 Jun, 2009

4 commits

  • inotify needs to do asyc notification in which event information is stored
    on a queue until the listener is ready to receive it. This patch
    implements a generic notification queue for inotify (and later fanotify) to
    store events to be sent at a later time.

    Signed-off-by: Eric Paris
    Acked-by: Al Viro
    Cc: Christoph Hellwig

    Eric Paris
     
  • inotify and dnotify both use a similar parent notification mechanism. We
    add a generic parent notification mechanism to fsnotify for both of these
    to use. This new machanism also adds the dentry flag optimization which
    exists for inotify to dnotify.

    Signed-off-by: Eric Paris
    Acked-by: Al Viro
    Cc: Christoph Hellwig

    Eric Paris
     
  • This patch creates a way for fsnotify groups to attach marks to inodes.
    These marks have little meaning to the generic fsnotify infrastructure
    and thus their meaning should be interpreted by the group that attached
    them to the inode's list.

    dnotify and inotify will make use of these markings to indicate which
    inodes are of interest to their respective groups. But this implementation
    has the useful property that in the future other listeners could actually
    use the marks for the exact opposite reason, aka to indicate which inodes
    it had NO interest in.

    Signed-off-by: Eric Paris
    Acked-by: Al Viro
    Cc: Christoph Hellwig

    Eric Paris
     
  • fsnotify is a backend for filesystem notification. fsnotify does
    not provide any userspace interface but does provide the basis
    needed for other notification schemes such as dnotify. fsnotify
    can be extended to be the backend for inotify or the upcoming
    fanotify. fsnotify provides a mechanism for "groups" to register for
    some set of filesystem events and to then deliver those events to
    those groups for processing.

    fsnotify has a number of benefits, the first being actually shrinking the size
    of an inode. Before fsnotify to support both dnotify and inotify an inode had

    unsigned long i_dnotify_mask; /* Directory notify events */
    struct dnotify_struct *i_dnotify; /* for directory notifications */
    struct list_head inotify_watches; /* watches on this inode */
    struct mutex inotify_mutex; /* protects the watches list

    But with fsnotify this same functionallity (and more) is done with just

    __u32 i_fsnotify_mask; /* all events for this inode */
    struct hlist_head i_fsnotify_mark_entries; /* marks on this inode */

    That's right, inotify, dnotify, and fanotify all in 64 bits. We used that
    much space just in inotify_watches alone, before this patch set.

    fsnotify object lifetime and locking is MUCH better than what we have today.
    inotify locking is incredibly complex. See 8f7b0ba1c8539 as an example of
    what's been busted since inception. inotify needs to know internal semantics
    of superblock destruction and unmounting to function. The inode pinning and
    vfs contortions are horrible.

    no fsnotify implementers do allocation under locks. This means things like
    f04b30de3 which (due to an overabundance of caution) changes GFP_KERNEL to
    GFP_NOFS can be reverted. There are no longer any allocation rules when using
    or implementing your own fsnotify listener.

    fsnotify paves the way for fanotify. In brief fanotify is a notification
    mechanism that delivers the lisener both an 'event' and an open file descriptor
    to the object in question. This means that fanotify is pathname agnostic.
    Some on lkml may not care for the original companies or users that pushed for
    TALPA, but fanotify was designed with flexibility and input for other users in
    mind. The readahead group expressed interest in fanotify as it could be used
    to profile disk access on boot without breaking the audit system. The desktop
    search groups have also expressed interest in fanotify as it solves a number
    of the race conditions and problems present with managing inotify when more
    than a limited number of specific files are of interest. fanotify can provide
    for a userspace access control system which makes it a clean interface for AV
    vendors to hook without trying to do binary patching on the syscall table,
    LSM, and everywhere else they do their things today. With this patch series
    fanotify can be implemented in less than 1200 lines of easy to review code.
    Almost all of which is the socket based user interface.

    This patch series builds fsnotify to the point that it can implement
    dnotify and inotify_user. Patches exist and will be sent soon after
    acceptance to finish the in kernel inotify conversion (audit) and implement
    fanotify.

    Signed-off-by: Eric Paris
    Acked-by: Al Viro
    Cc: Christoph Hellwig

    Eric Paris