]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - fs/notify/inode_mark.c
fsnotify: Remove fsnotify_recalc_{inode|vfsmount}_mask()
[mirror_ubuntu-artful-kernel.git] / fs / notify / inode_mark.c
CommitLineData
3be25f49
EP
1/*
2 * Copyright (C) 2008 Red Hat, Inc., Eric Paris <eparis@redhat.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
3be25f49
EP
19#include <linux/fs.h>
20#include <linux/init.h>
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/mutex.h>
3be25f49
EP
24#include <linux/spinlock.h>
25
60063497 26#include <linux/atomic.h>
3be25f49
EP
27
28#include <linux/fsnotify_backend.h>
29#include "fsnotify.h"
30
55fa6091
DC
31#include "../internal.h"
32
4d92604c
EP
33/*
34 * Given a group clear all of the inode marks associated with that group.
35 */
36void fsnotify_clear_inode_marks_by_group(struct fsnotify_group *group)
37{
86ffe245 38 fsnotify_clear_marks_by_group_flags(group, FSNOTIFY_OBJ_TYPE_INODE);
4d92604c
EP
39}
40
3be25f49 41/*
35566087
AG
42 * given a group and inode, find the mark associated with that combination.
43 * if found take a reference to that mark and return it, else return NULL
3be25f49 44 */
5444e298
EP
45struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *group,
46 struct inode *inode)
35566087 47{
08991e83 48 return fsnotify_find_mark(&inode->i_fsnotify_marks, group);
35566087 49}
3be25f49 50
164bc619
EP
51/**
52 * fsnotify_unmount_inodes - an sb is unmounting. handle any watched inodes.
74278da9 53 * @sb: superblock being unmounted.
164bc619 54 *
55fa6091 55 * Called during unmount with no locks held, so needs to be safe against
74278da9 56 * concurrent modifiers. We temporarily drop sb->s_inode_list_lock and CAN block.
164bc619 57 */
74278da9 58void fsnotify_unmount_inodes(struct super_block *sb)
164bc619 59{
5716863e 60 struct inode *inode, *iput_inode = NULL;
164bc619 61
74278da9 62 spin_lock(&sb->s_inode_list_lock);
5716863e 63 list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
164bc619 64 /*
a4ffdde6 65 * We cannot __iget() an inode in state I_FREEING,
164bc619
EP
66 * I_WILL_FREE, or I_NEW which is fine because by that point
67 * the inode cannot have any associated watches.
68 */
250df6ed
DC
69 spin_lock(&inode->i_lock);
70 if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) {
71 spin_unlock(&inode->i_lock);
164bc619 72 continue;
250df6ed 73 }
164bc619
EP
74
75 /*
76 * If i_count is zero, the inode cannot have any watches and
77 * doing an __iget/iput with MS_ACTIVE clear would actually
78 * evict all inodes with zero i_count from icache which is
79 * unnecessarily violent and may in fact be illegal to do.
80 */
250df6ed
DC
81 if (!atomic_read(&inode->i_count)) {
82 spin_unlock(&inode->i_lock);
164bc619 83 continue;
250df6ed 84 }
164bc619 85
5716863e 86 __iget(inode);
250df6ed 87 spin_unlock(&inode->i_lock);
74278da9 88 spin_unlock(&sb->s_inode_list_lock);
164bc619 89
5716863e
JK
90 if (iput_inode)
91 iput(iput_inode);
164bc619
EP
92
93 /* for each watch, send FS_UNMOUNT and then remove it */
94 fsnotify(inode, FS_UNMOUNT, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
95
96 fsnotify_inode_delete(inode);
97
5716863e 98 iput_inode = inode;
164bc619 99
74278da9 100 spin_lock(&sb->s_inode_list_lock);
164bc619 101 }
74278da9 102 spin_unlock(&sb->s_inode_list_lock);
5716863e
JK
103
104 if (iput_inode)
105 iput(iput_inode);
164bc619 106}