aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2009-02-06 15:52:43 -0500
committerJonathan Corbet <corbet@lwn.net>2009-03-16 10:32:27 -0400
commit684999149002dd046269666a390458e0acb38280 (patch)
treeb12ea4a953ba2bd90428092e7f35a222a4109510
parent041b62374c7fedc11a8a1eeda2868612d3d1436c (diff)
Rename struct file->f_ep_lock
This lock moves out of the CONFIG_EPOLL ifdef and becomes f_lock. For now, epoll remains the only user, but a future patch will use it to protect f_flags as well. Cc: Davide Libenzi <davidel@xmailserver.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
-rw-r--r--fs/eventpoll.c12
-rw-r--r--fs/file_table.c1
-rw-r--r--include/linux/eventpoll.h1
-rw-r--r--include/linux/fs.h2
4 files changed, 9 insertions, 7 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 011b9b8c90c6..c5c424f23fd5 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -417,10 +417,10 @@ static int ep_remove(struct eventpoll *ep, struct epitem *epi)
417 ep_unregister_pollwait(ep, epi); 417 ep_unregister_pollwait(ep, epi);
418 418
419 /* Remove the current item from the list of epoll hooks */ 419 /* Remove the current item from the list of epoll hooks */
420 spin_lock(&file->f_ep_lock); 420 spin_lock(&file->f_lock);
421 if (ep_is_linked(&epi->fllink)) 421 if (ep_is_linked(&epi->fllink))
422 list_del_init(&epi->fllink); 422 list_del_init(&epi->fllink);
423 spin_unlock(&file->f_ep_lock); 423 spin_unlock(&file->f_lock);
424 424
425 rb_erase(&epi->rbn, &ep->rbr); 425 rb_erase(&epi->rbn, &ep->rbr);
426 426
@@ -538,7 +538,7 @@ void eventpoll_release_file(struct file *file)
538 struct epitem *epi; 538 struct epitem *epi;
539 539
540 /* 540 /*
541 * We don't want to get "file->f_ep_lock" because it is not 541 * We don't want to get "file->f_lock" because it is not
542 * necessary. It is not necessary because we're in the "struct file" 542 * necessary. It is not necessary because we're in the "struct file"
543 * cleanup path, and this means that noone is using this file anymore. 543 * cleanup path, and this means that noone is using this file anymore.
544 * So, for example, epoll_ctl() cannot hit here sicne if we reach this 544 * So, for example, epoll_ctl() cannot hit here sicne if we reach this
@@ -547,6 +547,8 @@ void eventpoll_release_file(struct file *file)
547 * will correctly serialize the operation. We do need to acquire 547 * will correctly serialize the operation. We do need to acquire
548 * "ep->mtx" after "epmutex" because ep_remove() requires it when called 548 * "ep->mtx" after "epmutex" because ep_remove() requires it when called
549 * from anywhere but ep_free(). 549 * from anywhere but ep_free().
550 *
551 * Besides, ep_remove() acquires the lock, so we can't hold it here.
550 */ 552 */
551 mutex_lock(&epmutex); 553 mutex_lock(&epmutex);
552 554
@@ -785,9 +787,9 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
785 goto error_unregister; 787 goto error_unregister;
786 788
787 /* Add the current item to the list of active epoll hook for this file */ 789 /* Add the current item to the list of active epoll hook for this file */
788 spin_lock(&tfile->f_ep_lock); 790 spin_lock(&tfile->f_lock);
789 list_add_tail(&epi->fllink, &tfile->f_ep_links); 791 list_add_tail(&epi->fllink, &tfile->f_ep_links);
790 spin_unlock(&tfile->f_ep_lock); 792 spin_unlock(&tfile->f_lock);
791 793
792 /* 794 /*
793 * Add the current item to the RB tree. All RB tree operations are 795 * Add the current item to the RB tree. All RB tree operations are
diff --git a/fs/file_table.c b/fs/file_table.c
index bbeeac6efa1a..aa1e18050282 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -127,6 +127,7 @@ struct file *get_empty_filp(void)
127 atomic_long_set(&f->f_count, 1); 127 atomic_long_set(&f->f_count, 1);
128 rwlock_init(&f->f_owner.lock); 128 rwlock_init(&f->f_owner.lock);
129 f->f_cred = get_cred(cred); 129 f->f_cred = get_cred(cred);
130 spin_lock_init(&f->f_lock);
130 eventpoll_init_file(f); 131 eventpoll_init_file(f);
131 /* f->f_version: 0 */ 132 /* f->f_version: 0 */
132 return f; 133 return f;
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
index f1e1d3c47125..f6856a5a1d4b 100644
--- a/include/linux/eventpoll.h
+++ b/include/linux/eventpoll.h
@@ -61,7 +61,6 @@ struct file;
61static inline void eventpoll_init_file(struct file *file) 61static inline void eventpoll_init_file(struct file *file)
62{ 62{
63 INIT_LIST_HEAD(&file->f_ep_links); 63 INIT_LIST_HEAD(&file->f_ep_links);
64 spin_lock_init(&file->f_ep_lock);
65} 64}
66 65
67 66
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 92734c0012e6..2011600d12c7 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -848,6 +848,7 @@ struct file {
848#define f_dentry f_path.dentry 848#define f_dentry f_path.dentry
849#define f_vfsmnt f_path.mnt 849#define f_vfsmnt f_path.mnt
850 const struct file_operations *f_op; 850 const struct file_operations *f_op;
851 spinlock_t f_lock; /* f_ep_links */
851 atomic_long_t f_count; 852 atomic_long_t f_count;
852 unsigned int f_flags; 853 unsigned int f_flags;
853 fmode_t f_mode; 854 fmode_t f_mode;
@@ -866,7 +867,6 @@ struct file {
866#ifdef CONFIG_EPOLL 867#ifdef CONFIG_EPOLL
867 /* Used by fs/eventpoll.c to link all the hooks to this file */ 868 /* Used by fs/eventpoll.c to link all the hooks to this file */
868 struct list_head f_ep_links; 869 struct list_head f_ep_links;
869 spinlock_t f_ep_lock;
870#endif /* #ifdef CONFIG_EPOLL */ 870#endif /* #ifdef CONFIG_EPOLL */
871 struct address_space *f_mapping; 871 struct address_space *f_mapping;
872#ifdef CONFIG_DEBUG_WRITECOUNT 872#ifdef CONFIG_DEBUG_WRITECOUNT