From: Greg Kroah-Hartman Date: Mon, 28 Apr 2014 04:36:39 +0000 (-0700) Subject: Merge 3.15-rc3 into staging-next X-Git-Tag: v3.16-rc1~30^2~37^2~13 X-Git-Url: https://repo.jachan.dev/linux.git/commitdiff_plain/d35cc56ddfc948d8df1aa6d41ac345fcec01854d?hp=-c Merge 3.15-rc3 into staging-next --- d35cc56ddfc948d8df1aa6d41ac345fcec01854d diff --combined fs/kernfs/dir.c index 43aa97988c31,ac127cd008bf..a693f5b01ae6 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@@ -232,9 -232,6 +232,6 @@@ static int kernfs_link_sibling(struct k struct rb_node **node = &kn->parent->dir.children.rb_node; struct rb_node *parent = NULL; - if (kernfs_type(kn) == KERNFS_DIR) - kn->parent->dir.subdirs++; - while (*node) { struct kernfs_node *pos; int result; @@@ -249,9 -246,15 +246,15 @@@ else return -EEXIST; } + /* add new node and rebalance the tree */ rb_link_node(&kn->rb, parent, node); rb_insert_color(&kn->rb, &kn->parent->dir.children); + + /* successfully added, account subdir number */ + if (kernfs_type(kn) == KERNFS_DIR) + kn->parent->dir.subdirs++; + return 0; } @@@ -711,7 -714,6 +714,7 @@@ struct kernfs_root *kernfs_create_root( return ERR_PTR(-ENOMEM); ida_init(&root->ino_ida); + INIT_LIST_HEAD(&root->supers); kn = __kernfs_new_node(root, "", S_IFDIR | S_IRUGO | S_IXUGO, KERNFS_DIR); diff --combined fs/kernfs/file.c index 98bacd9ea7fd,e01ea4a14a01..40251cd741a0 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@@ -14,7 -14,6 +14,7 @@@ #include #include #include +#include #include "kernfs-internal.h" @@@ -485,6 -484,8 +485,8 @@@ static int kernfs_fop_mmap(struct file ops = kernfs_ops(of->kn); rc = ops->mmap(of, vma); + if (rc) + goto out_put; /* * PowerPC's pci_mmap of legacy_mem uses shmem_zero_setup() @@@ -786,48 -787,20 +788,48 @@@ static unsigned int kernfs_fop_poll(str */ void kernfs_notify(struct kernfs_node *kn) { + struct kernfs_root *root = kernfs_root(kn); struct kernfs_open_node *on; + struct kernfs_super_info *info; unsigned long flags; + if (WARN_ON(kernfs_type(kn) != KERNFS_FILE)) + return; + + /* kick poll */ spin_lock_irqsave(&kernfs_open_node_lock, flags); - if (!WARN_ON(kernfs_type(kn) != KERNFS_FILE)) { - on = kn->attr.open; - if (on) { - atomic_inc(&on->event); - wake_up_interruptible(&on->poll); - } + on = kn->attr.open; + if (on) { + atomic_inc(&on->event); + wake_up_interruptible(&on->poll); } spin_unlock_irqrestore(&kernfs_open_node_lock, flags); + + /* kick fsnotify */ + mutex_lock(&kernfs_mutex); + + list_for_each_entry(info, &root->supers, node) { + struct inode *inode; + struct dentry *dentry; + + 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); + } + + iput(inode); + } + + mutex_unlock(&kernfs_mutex); } EXPORT_SYMBOL_GPL(kernfs_notify);