From: dragos.tatulea@intel.com
To: cbouatmailru@gmail.com, linux-kernel@vger.kernel.org
Cc: adrian.hunter@intel.com, octavian.purdila@intel.com
Subject: [PATCH 6/8] pstore: do not run timer while pstore is not mounted
Date: Mon, 15 Oct 2012 14:40:08 +0300 [thread overview]
Message-ID: <1350301210-16953-7-git-send-email-dragos.tatulea@intel.com> (raw)
In-Reply-To: <1350301210-16953-1-git-send-email-dragos.tatulea@intel.com>
From: Adrian Hunter <adrian.hunter@intel.com>
A timer is used to periodically check for new dumps.
The timer is not needed unless pstore is mounted,
so disable it otherwise.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
fs/pstore/inode.c | 3 +++
fs/pstore/internal.h | 2 ++
fs/pstore/platform.c | 36 +++++++++++++++++++++++++++++-------
3 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 4800c09..5e20a8d 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -397,6 +397,8 @@ static int pstore_fill_super(struct super_block *sb, void *data, int silent)
pstore_get_records(0);
+ pstore_add_timer();
+
return 0;
}
@@ -408,6 +410,7 @@ static struct dentry *pstore_mount(struct file_system_type *fs_type,
static void pstore_kill_sb(struct super_block *sb)
{
+ pstore_del_timer();
kill_litter_super(sb);
pstore_sb = NULL;
}
diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
index 4847f58..c7b8197 100644
--- a/fs/pstore/internal.h
+++ b/fs/pstore/internal.h
@@ -54,4 +54,6 @@ extern int pstore_mkfile(enum pstore_type_id, char *psname, u64 id,
struct timespec time, struct pstore_info *psi);
extern int pstore_is_mounted(void);
+extern void pstore_add_timer(void);
+extern void pstore_del_timer(void);
#endif
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 63ff377..3a4c38f 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -54,6 +54,8 @@ static int pstore_new_entry;
static void pstore_timefunc(unsigned long);
static DEFINE_TIMER(pstore_timer, pstore_timefunc, 0, 0);
+static DEFINE_SPINLOCK(pstore_timer_lock);
+static int pstore_timer_on;
static void pstore_dowork(struct work_struct *);
static DECLARE_WORK(pstore_work, pstore_dowork);
@@ -351,12 +353,6 @@ int pstore_register(struct pstore_info *psi)
pstore_register_console();
pstore_register_ftrace();
- if (pstore_update_ms >= 0) {
- pstore_timer.expires = jiffies +
- msecs_to_jiffies(pstore_update_ms);
- add_timer(&pstore_timer);
- }
-
pstore_debugfs_init();
return 0;
@@ -411,12 +407,38 @@ static void pstore_dowork(struct work_struct *work)
static void pstore_timefunc(unsigned long dummy)
{
+ unsigned long flags;
+
if (pstore_new_entry) {
pstore_new_entry = 0;
schedule_work(&pstore_work);
}
- mod_timer(&pstore_timer, jiffies + msecs_to_jiffies(pstore_update_ms));
+ spin_lock_irqsave(&pstore_timer_lock, flags);
+ if (pstore_timer_on)
+ mod_timer(&pstore_timer,
+ jiffies + msecs_to_jiffies(pstore_update_ms));
+ spin_unlock_irqrestore(&pstore_timer_lock, flags);
+}
+
+void pstore_add_timer(void)
+{
+ pstore_timer_on = 1;
+ if (pstore_update_ms >= 0) {
+ pstore_timer.expires = jiffies +
+ msecs_to_jiffies(pstore_update_ms);
+ add_timer(&pstore_timer);
+ }
+}
+
+void pstore_del_timer(void)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&pstore_timer_lock, flags);
+ pstore_timer_on = 0;
+ spin_unlock_irqrestore(&pstore_timer_lock, flags);
+ del_timer_sync(&pstore_timer);
}
/* pstore_write must only be called from PSTORE_DUMP notifier callbacks */
--
1.7.9.5
next prev parent reply other threads:[~2012-10-15 11:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-15 11:40 [PATCH 0/8] pstore: add interface for dumpers and add task list dumper dragos.tatulea
2012-10-15 11:40 ` [PATCH 1/8] pstore: add flags dragos.tatulea
2012-10-15 11:40 ` [PATCH 2/8] pstore: add debugfs support for causing dumps and panics dragos.tatulea
2012-10-15 11:40 ` [PATCH 3/8] pstore: add support for external writers dragos.tatulea
2012-10-15 11:40 ` [PATCH 4/8] pstore: allow storing different type id's in ram backend dragos.tatulea
2012-10-15 11:40 ` [PATCH 5/8] pstore: add task list dumper dragos.tatulea
2012-10-15 11:40 ` dragos.tatulea [this message]
2012-10-15 11:40 ` [PATCH 7/8] pstore: make sure pstore_write exists on flush error dragos.tatulea
2012-10-15 11:40 ` [PATCH 8/8] pstore: max out console log level during sysfs dump switch dragos.tatulea
-- strict thread matches above, loose matches on Subject: below --
2012-10-15 11:38 [PATCH 0/8] pstore: add interface for dumpers and add task list dumper dragos.tatulea
2012-10-15 11:38 ` [PATCH 6/8] pstore: do not run timer while pstore is not mounted dragos.tatulea
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=1350301210-16953-7-git-send-email-dragos.tatulea@intel.com \
--to=dragos.tatulea@intel.com \
--cc=adrian.hunter@intel.com \
--cc=cbouatmailru@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=octavian.purdila@intel.com \
/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®