Merge tag 'fsnotify_for_v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / fs / fcntl.c
index d737ff082472ef03cc2365270ac79b97aed68db6..12273b6ea56dbdeb2a2bff0c6846030e4fc9bcd5 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/rcupdate.h>
 #include <linux/pid_namespace.h>
 #include <linux/user_namespace.h>
-#include <linux/shmem_fs.h>
+#include <linux/memfd.h>
 #include <linux/compat.h>
 
 #include <linux/poll.h>
@@ -871,9 +871,9 @@ int fasync_remove_entry(struct file *filp, struct fasync_struct **fapp)
                if (fa->fa_file != filp)
                        continue;
 
-               spin_lock_irq(&fa->fa_lock);
+               write_lock_irq(&fa->fa_lock);
                fa->fa_file = NULL;
-               spin_unlock_irq(&fa->fa_lock);
+               write_unlock_irq(&fa->fa_lock);
 
                *fp = fa->fa_next;
                call_rcu(&fa->fa_rcu, fasync_free_rcu);
@@ -918,13 +918,13 @@ struct fasync_struct *fasync_insert_entry(int fd, struct file *filp, struct fasy
                if (fa->fa_file != filp)
                        continue;
 
-               spin_lock_irq(&fa->fa_lock);
+               write_lock_irq(&fa->fa_lock);
                fa->fa_fd = fd;
-               spin_unlock_irq(&fa->fa_lock);
+               write_unlock_irq(&fa->fa_lock);
                goto out;
        }
 
-       spin_lock_init(&new->fa_lock);
+       rwlock_init(&new->fa_lock);
        new->magic = FASYNC_MAGIC;
        new->fa_file = filp;
        new->fa_fd = fd;
@@ -987,14 +987,13 @@ static void kill_fasync_rcu(struct fasync_struct *fa, int sig, int band)
 {
        while (fa) {
                struct fown_struct *fown;
-               unsigned long flags;
 
                if (fa->magic != FASYNC_MAGIC) {
                        printk(KERN_ERR "kill_fasync: bad magic number in "
                               "fasync_struct!\n");
                        return;
                }
-               spin_lock_irqsave(&fa->fa_lock, flags);
+               read_lock(&fa->fa_lock);
                if (fa->fa_file) {
                        fown = &fa->fa_file->f_owner;
                        /* Don't send SIGURG to processes which have not set a
@@ -1003,7 +1002,7 @@ static void kill_fasync_rcu(struct fasync_struct *fa, int sig, int band)
                        if (!(sig == SIGURG && fown->signum == 0))
                                send_sigio(fown, fa->fa_fd, band);
                }
-               spin_unlock_irqrestore(&fa->fa_lock, flags);
+               read_unlock(&fa->fa_lock);
                fa = rcu_dereference(fa->fa_next);
        }
 }