From: Jonathan Corbet <corbet@lwn.net>
To: linux-kernel@vger.kernel.org
Cc: Andi Kleen <andi@firstfloor.org>, Oleg Nesterov <oleg@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Al Viro <viro@ZenIV.linux.org.uk>,
Davide Libenzi <davidel@xmailserver.org>,
David Miller <davem@davemloft.net>,
Christoph Hellwig <hch@lst.de>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Matt Mackall <mpm@selenic.com>, Jonathan Corbet <corbet@lwn.net>
Subject: [PATCH 1/4] Rename struct file->f_ep_lock
Date: Sat, 7 Feb 2009 13:06:54 -0700 [thread overview]
Message-ID: <1234037217-16124-2-git-send-email-corbet@lwn.net> (raw)
In-Reply-To: <1234037217-16124-1-git-send-email-corbet@lwn.net>
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.
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
---
fs/eventpoll.c | 12 +++++++-----
fs/file_table.c | 1 +
include/linux/eventpoll.h | 1 -
include/linux/fs.h | 2 +-
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index ba2f9ec..1a59e09 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -427,10 +427,10 @@ static int ep_remove(struct eventpoll *ep, struct epitem *epi)
ep_unregister_pollwait(ep, epi);
/* Remove the current item from the list of epoll hooks */
- spin_lock(&file->f_ep_lock);
+ spin_lock(&file->f_lock);
if (ep_is_linked(&epi->fllink))
list_del_init(&epi->fllink);
- spin_unlock(&file->f_ep_lock);
+ spin_unlock(&file->f_lock);
rb_erase(&epi->rbn, &ep->rbr);
@@ -549,7 +549,7 @@ void eventpoll_release_file(struct file *file)
struct epitem *epi;
/*
- * We don't want to get "file->f_ep_lock" because it is not
+ * We don't want to get "file->f_lock" because it is not
* necessary. It is not necessary because we're in the "struct file"
* cleanup path, and this means that noone is using this file anymore.
* So, for example, epoll_ctl() cannot hit here sicne if we reach this
@@ -558,6 +558,8 @@ void eventpoll_release_file(struct file *file)
* will correctly serialize the operation. We do need to acquire
* "ep->mtx" after "epmutex" because ep_remove() requires it when called
* from anywhere but ep_free().
+ *
+ * Besides, ep_remove() acquires the lock, so we can't hold it here.
*/
mutex_lock(&epmutex);
@@ -800,9 +802,9 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
goto error_unregister;
/* Add the current item to the list of active epoll hook for this file */
- spin_lock(&tfile->f_ep_lock);
+ spin_lock(&tfile->f_lock);
list_add_tail(&epi->fllink, &tfile->f_ep_links);
- spin_unlock(&tfile->f_ep_lock);
+ spin_unlock(&tfile->f_lock);
/*
* 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 bbeeac6..aa1e180 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -127,6 +127,7 @@ struct file *get_empty_filp(void)
atomic_long_set(&f->f_count, 1);
rwlock_init(&f->f_owner.lock);
f->f_cred = get_cred(cred);
+ spin_lock_init(&f->f_lock);
eventpoll_init_file(f);
/* f->f_version: 0 */
return f;
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
index f1e1d3c..f6856a5 100644
--- a/include/linux/eventpoll.h
+++ b/include/linux/eventpoll.h
@@ -61,7 +61,6 @@ struct file;
static inline void eventpoll_init_file(struct file *file)
{
INIT_LIST_HEAD(&file->f_ep_links);
- spin_lock_init(&file->f_ep_lock);
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6022f44..0d71633 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -842,6 +842,7 @@ struct file {
#define f_dentry f_path.dentry
#define f_vfsmnt f_path.mnt
const struct file_operations *f_op;
+ spinlock_t f_lock; /* f_ep_links */
atomic_long_t f_count;
unsigned int f_flags;
fmode_t f_mode;
@@ -860,7 +861,6 @@ struct file {
#ifdef CONFIG_EPOLL
/* Used by fs/eventpoll.c to link all the hooks to this file */
struct list_head f_ep_links;
- spinlock_t f_ep_lock;
#endif /* #ifdef CONFIG_EPOLL */
struct address_space *f_mapping;
#ifdef CONFIG_DEBUG_WRITECOUNT
--
1.6.1.2
next prev parent reply other threads:[~2009-02-07 20:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-07 20:06 [PATCH/RFC] Fasync BKL removal Jonathan Corbet
2009-02-07 20:06 ` Jonathan Corbet [this message]
2009-02-08 8:56 ` [PATCH 1/4] Rename struct file->f_ep_lock Christoph Hellwig
2009-02-08 19:51 ` Davide Libenzi
2009-02-07 20:06 ` [PATCH 2/4] Use f_lock to protect f_flags Jonathan Corbet
2009-02-08 9:02 ` Christoph Hellwig
2009-02-07 20:06 ` [PATCH 3/4] Move FASYNC bit handling to f_op->fasync() Jonathan Corbet
2009-02-08 9:05 ` Christoph Hellwig
2009-02-10 2:41 ` Jonathan Corbet
2009-02-07 20:06 ` [PATCH 4/4] Rationalize fasync return values Jonathan Corbet
2009-02-07 20:28 ` [PATCH/RFC] Fasync BKL removal Matt Mackall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1234037217-16124-2-git-send-email-corbet@lwn.net \
--to=corbet@lwn.net \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=andi@firstfloor.org \
--cc=davem@davemloft.net \
--cc=davidel@xmailserver.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.com \
--cc=oleg@redhat.com \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®