mm: fix exec activate_mm vs TLB shootdown and lazy tlb switching race
[linux/fpc-iii.git] / fs / pstore / platform.c
blob8af9efa0ca0aeb1758d61f2147ffcbd0469e384c
1 /*
2 * Persistent Storage - platform driver interface parts.
4 * Copyright (C) 2007-2008 Google, Inc.
5 * Copyright (C) 2010 Intel Corporation <tony.luck@intel.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define pr_fmt(fmt) "pstore: " fmt
23 #include <linux/atomic.h>
24 #include <linux/types.h>
25 #include <linux/errno.h>
26 #include <linux/init.h>
27 #include <linux/kmsg_dump.h>
28 #include <linux/console.h>
29 #include <linux/module.h>
30 #include <linux/pstore.h>
31 #ifdef CONFIG_PSTORE_ZLIB_COMPRESS
32 #include <linux/zlib.h>
33 #endif
34 #ifdef CONFIG_PSTORE_LZO_COMPRESS
35 #include <linux/lzo.h>
36 #endif
37 #ifdef CONFIG_PSTORE_LZ4_COMPRESS
38 #include <linux/lz4.h>
39 #endif
40 #include <linux/string.h>
41 #include <linux/timer.h>
42 #include <linux/slab.h>
43 #include <linux/uaccess.h>
44 #include <linux/hardirq.h>
45 #include <linux/jiffies.h>
46 #include <linux/workqueue.h>
48 #include "internal.h"
51 * We defer making "oops" entries appear in pstore - see
52 * whether the system is actually still running well enough
53 * to let someone see the entry
55 static int pstore_update_ms = -1;
56 module_param_named(update_ms, pstore_update_ms, int, 0600);
57 MODULE_PARM_DESC(update_ms, "milliseconds before pstore updates its content "
58 "(default is -1, which means runtime updates are disabled; "
59 "enabling this option is not safe, it may lead to further "
60 "corruption on Oopses)");
62 static int pstore_new_entry;
64 static void pstore_timefunc(unsigned long);
65 static DEFINE_TIMER(pstore_timer, pstore_timefunc, 0, 0);
67 static void pstore_dowork(struct work_struct *);
68 static DECLARE_WORK(pstore_work, pstore_dowork);
71 * pstore_lock just protects "psinfo" during
72 * calls to pstore_register()
74 static DEFINE_SPINLOCK(pstore_lock);
75 struct pstore_info *psinfo;
77 static char *backend;
79 /* Compression parameters */
80 #ifdef CONFIG_PSTORE_ZLIB_COMPRESS
81 #define COMPR_LEVEL 6
82 #define WINDOW_BITS 12
83 #define MEM_LEVEL 4
84 static struct z_stream_s stream;
85 #else
86 static unsigned char *workspace;
87 #endif
89 struct pstore_zbackend {
90 int (*compress)(const void *in, void *out, size_t inlen, size_t outlen);
91 int (*decompress)(void *in, void *out, size_t inlen, size_t outlen);
92 void (*allocate)(void);
93 void (*free)(void);
95 const char *name;
98 static char *big_oops_buf;
99 static size_t big_oops_buf_sz;
101 /* How much of the console log to snapshot */
102 unsigned long kmsg_bytes = PSTORE_DEFAULT_KMSG_BYTES;
104 void pstore_set_kmsg_bytes(int bytes)
106 kmsg_bytes = bytes;
109 /* Tag each group of saved records with a sequence number */
110 static int oopscount;
112 static const char *get_reason_str(enum kmsg_dump_reason reason)
114 switch (reason) {
115 case KMSG_DUMP_PANIC:
116 return "Panic";
117 case KMSG_DUMP_OOPS:
118 return "Oops";
119 case KMSG_DUMP_EMERG:
120 return "Emergency";
121 case KMSG_DUMP_RESTART:
122 return "Restart";
123 case KMSG_DUMP_HALT:
124 return "Halt";
125 case KMSG_DUMP_POWEROFF:
126 return "Poweroff";
127 default:
128 return "Unknown";
133 * Should pstore_dump() wait for a concurrent pstore_dump()? If
134 * not, the current pstore_dump() will report a failure to dump
135 * and return.
137 static bool pstore_cannot_wait(enum kmsg_dump_reason reason)
139 /* In NMI path, pstore shouldn't block regardless of reason. */
140 if (in_nmi())
141 return true;
143 switch (reason) {
144 /* In panic case, other cpus are stopped by smp_send_stop(). */
145 case KMSG_DUMP_PANIC:
146 /* Emergency restart shouldn't be blocked. */
147 case KMSG_DUMP_EMERG:
148 return true;
149 default:
150 return false;
154 #ifdef CONFIG_PSTORE_ZLIB_COMPRESS
155 /* Derived from logfs_compress() */
156 static int compress_zlib(const void *in, void *out, size_t inlen, size_t outlen)
158 int err, ret;
160 ret = -EIO;
161 err = zlib_deflateInit2(&stream, COMPR_LEVEL, Z_DEFLATED, WINDOW_BITS,
162 MEM_LEVEL, Z_DEFAULT_STRATEGY);
163 if (err != Z_OK)
164 goto error;
166 stream.next_in = in;
167 stream.avail_in = inlen;
168 stream.total_in = 0;
169 stream.next_out = out;
170 stream.avail_out = outlen;
171 stream.total_out = 0;
173 err = zlib_deflate(&stream, Z_FINISH);
174 if (err != Z_STREAM_END)
175 goto error;
177 err = zlib_deflateEnd(&stream);
178 if (err != Z_OK)
179 goto error;
181 if (stream.total_out >= stream.total_in)
182 goto error;
184 ret = stream.total_out;
185 error:
186 return ret;
189 /* Derived from logfs_uncompress */
190 static int decompress_zlib(void *in, void *out, size_t inlen, size_t outlen)
192 int err, ret;
194 ret = -EIO;
195 err = zlib_inflateInit2(&stream, WINDOW_BITS);
196 if (err != Z_OK)
197 goto error;
199 stream.next_in = in;
200 stream.avail_in = inlen;
201 stream.total_in = 0;
202 stream.next_out = out;
203 stream.avail_out = outlen;
204 stream.total_out = 0;
206 err = zlib_inflate(&stream, Z_FINISH);
207 if (err != Z_STREAM_END)
208 goto error;
210 err = zlib_inflateEnd(&stream);
211 if (err != Z_OK)
212 goto error;
214 ret = stream.total_out;
215 error:
216 return ret;
219 static void allocate_zlib(void)
221 size_t size;
222 size_t cmpr;
224 switch (psinfo->bufsize) {
225 /* buffer range for efivars */
226 case 1000 ... 2000:
227 cmpr = 56;
228 break;
229 case 2001 ... 3000:
230 cmpr = 54;
231 break;
232 case 3001 ... 3999:
233 cmpr = 52;
234 break;
235 /* buffer range for nvram, erst */
236 case 4000 ... 10000:
237 cmpr = 45;
238 break;
239 default:
240 cmpr = 60;
241 break;
244 big_oops_buf_sz = (psinfo->bufsize * 100) / cmpr;
245 big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL);
246 if (big_oops_buf) {
247 size = max(zlib_deflate_workspacesize(WINDOW_BITS, MEM_LEVEL),
248 zlib_inflate_workspacesize());
249 stream.workspace = kmalloc(size, GFP_KERNEL);
250 if (!stream.workspace) {
251 pr_err("No memory for compression workspace; skipping compression\n");
252 kfree(big_oops_buf);
253 big_oops_buf = NULL;
255 } else {
256 pr_err("No memory for uncompressed data; skipping compression\n");
257 stream.workspace = NULL;
262 static void free_zlib(void)
264 kfree(stream.workspace);
265 stream.workspace = NULL;
266 kfree(big_oops_buf);
267 big_oops_buf = NULL;
268 big_oops_buf_sz = 0;
271 static const struct pstore_zbackend backend_zlib = {
272 .compress = compress_zlib,
273 .decompress = decompress_zlib,
274 .allocate = allocate_zlib,
275 .free = free_zlib,
276 .name = "zlib",
278 #endif
280 #ifdef CONFIG_PSTORE_LZO_COMPRESS
281 static int compress_lzo(const void *in, void *out, size_t inlen, size_t outlen)
283 int ret;
285 ret = lzo1x_1_compress(in, inlen, out, &outlen, workspace);
286 if (ret != LZO_E_OK) {
287 pr_err("lzo_compress error, ret = %d!\n", ret);
288 return -EIO;
291 return outlen;
294 static int decompress_lzo(void *in, void *out, size_t inlen, size_t outlen)
296 int ret;
298 ret = lzo1x_decompress_safe(in, inlen, out, &outlen);
299 if (ret != LZO_E_OK) {
300 pr_err("lzo_decompress error, ret = %d!\n", ret);
301 return -EIO;
304 return outlen;
307 static void allocate_lzo(void)
309 big_oops_buf_sz = lzo1x_worst_compress(psinfo->bufsize);
310 big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL);
311 if (big_oops_buf) {
312 workspace = kmalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL);
313 if (!workspace) {
314 pr_err("No memory for compression workspace; skipping compression\n");
315 kfree(big_oops_buf);
316 big_oops_buf = NULL;
318 } else {
319 pr_err("No memory for uncompressed data; skipping compression\n");
320 workspace = NULL;
324 static void free_lzo(void)
326 kfree(workspace);
327 kfree(big_oops_buf);
328 big_oops_buf = NULL;
329 big_oops_buf_sz = 0;
332 static const struct pstore_zbackend backend_lzo = {
333 .compress = compress_lzo,
334 .decompress = decompress_lzo,
335 .allocate = allocate_lzo,
336 .free = free_lzo,
337 .name = "lzo",
339 #endif
341 #ifdef CONFIG_PSTORE_LZ4_COMPRESS
342 static int compress_lz4(const void *in, void *out, size_t inlen, size_t outlen)
344 int ret;
346 ret = LZ4_compress_default(in, out, inlen, outlen, workspace);
347 if (!ret) {
348 pr_err("LZ4_compress_default error; compression failed!\n");
349 return -EIO;
352 return ret;
355 static int decompress_lz4(void *in, void *out, size_t inlen, size_t outlen)
357 int ret;
359 ret = LZ4_decompress_safe(in, out, inlen, outlen);
360 if (ret < 0) {
362 * LZ4_decompress_safe will return an error code
363 * (< 0) if decompression failed
365 pr_err("LZ4_decompress_safe error, ret = %d!\n", ret);
366 return -EIO;
369 return ret;
372 static void allocate_lz4(void)
374 big_oops_buf_sz = LZ4_compressBound(psinfo->bufsize);
375 big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL);
376 if (big_oops_buf) {
377 workspace = kmalloc(LZ4_MEM_COMPRESS, GFP_KERNEL);
378 if (!workspace) {
379 pr_err("No memory for compression workspace; skipping compression\n");
380 kfree(big_oops_buf);
381 big_oops_buf = NULL;
383 } else {
384 pr_err("No memory for uncompressed data; skipping compression\n");
385 workspace = NULL;
389 static void free_lz4(void)
391 kfree(workspace);
392 kfree(big_oops_buf);
393 big_oops_buf = NULL;
394 big_oops_buf_sz = 0;
397 static const struct pstore_zbackend backend_lz4 = {
398 .compress = compress_lz4,
399 .decompress = decompress_lz4,
400 .allocate = allocate_lz4,
401 .free = free_lz4,
402 .name = "lz4",
404 #endif
406 static const struct pstore_zbackend *zbackend =
407 #if defined(CONFIG_PSTORE_ZLIB_COMPRESS)
408 &backend_zlib;
409 #elif defined(CONFIG_PSTORE_LZO_COMPRESS)
410 &backend_lzo;
411 #elif defined(CONFIG_PSTORE_LZ4_COMPRESS)
412 &backend_lz4;
413 #else
414 NULL;
415 #endif
417 static int pstore_compress(const void *in, void *out,
418 size_t inlen, size_t outlen)
420 if (zbackend)
421 return zbackend->compress(in, out, inlen, outlen);
422 else
423 return -EIO;
426 static int pstore_decompress(void *in, void *out, size_t inlen, size_t outlen)
428 if (zbackend)
429 return zbackend->decompress(in, out, inlen, outlen);
430 else
431 return -EIO;
434 static void allocate_buf_for_compression(void)
436 if (zbackend) {
437 pr_info("using %s compression\n", zbackend->name);
438 zbackend->allocate();
439 } else {
440 pr_err("allocate compression buffer error!\n");
444 static void free_buf_for_compression(void)
446 if (zbackend)
447 zbackend->free();
448 else
449 pr_err("free compression buffer error!\n");
453 * Called when compression fails, since the printk buffer
454 * would be fetched for compression calling it again when
455 * compression fails would have moved the iterator of
456 * printk buffer which results in fetching old contents.
457 * Copy the recent messages from big_oops_buf to psinfo->buf
459 static size_t copy_kmsg_to_buffer(int hsize, size_t len)
461 size_t total_len;
462 size_t diff;
464 total_len = hsize + len;
466 if (total_len > psinfo->bufsize) {
467 diff = total_len - psinfo->bufsize + hsize;
468 memcpy(psinfo->buf, big_oops_buf, hsize);
469 memcpy(psinfo->buf + hsize, big_oops_buf + diff,
470 psinfo->bufsize - hsize);
471 total_len = psinfo->bufsize;
472 } else
473 memcpy(psinfo->buf, big_oops_buf, total_len);
475 return total_len;
478 void pstore_record_init(struct pstore_record *record,
479 struct pstore_info *psinfo)
481 memset(record, 0, sizeof(*record));
483 record->psi = psinfo;
485 /* Report zeroed timestamp if called before timekeeping has resumed. */
486 if (__getnstimeofday(&record->time)) {
487 record->time.tv_sec = 0;
488 record->time.tv_nsec = 0;
493 * callback from kmsg_dump. (s2,l2) has the most recently
494 * written bytes, older bytes are in (s1,l1). Save as much
495 * as we can from the end of the buffer.
497 static void pstore_dump(struct kmsg_dumper *dumper,
498 enum kmsg_dump_reason reason)
500 unsigned long total = 0;
501 const char *why;
502 unsigned int part = 1;
503 int ret;
505 why = get_reason_str(reason);
507 if (down_trylock(&psinfo->buf_lock)) {
508 /* Failed to acquire lock: give up if we cannot wait. */
509 if (pstore_cannot_wait(reason)) {
510 pr_err("dump skipped in %s path: may corrupt error record\n",
511 in_nmi() ? "NMI" : why);
512 return;
514 if (down_interruptible(&psinfo->buf_lock)) {
515 pr_err("could not grab semaphore?!\n");
516 return;
520 oopscount++;
521 while (total < kmsg_bytes) {
522 char *dst;
523 size_t dst_size;
524 int header_size;
525 int zipped_len = -1;
526 size_t dump_size;
527 struct pstore_record record;
529 pstore_record_init(&record, psinfo);
530 record.type = PSTORE_TYPE_DMESG;
531 record.count = oopscount;
532 record.reason = reason;
533 record.part = part;
534 record.buf = psinfo->buf;
536 if (big_oops_buf) {
537 dst = big_oops_buf;
538 dst_size = big_oops_buf_sz;
539 } else {
540 dst = psinfo->buf;
541 dst_size = psinfo->bufsize;
544 /* Write dump header. */
545 header_size = snprintf(dst, dst_size, "%s#%d Part%u\n", why,
546 oopscount, part);
547 dst_size -= header_size;
549 /* Write dump contents. */
550 if (!kmsg_dump_get_buffer(dumper, true, dst + header_size,
551 dst_size, &dump_size))
552 break;
554 if (big_oops_buf) {
555 zipped_len = pstore_compress(dst, psinfo->buf,
556 header_size + dump_size,
557 psinfo->bufsize);
559 if (zipped_len > 0) {
560 record.compressed = true;
561 record.size = zipped_len;
562 } else {
563 record.size = copy_kmsg_to_buffer(header_size,
564 dump_size);
566 } else {
567 record.size = header_size + dump_size;
570 ret = psinfo->write(&record);
571 if (ret == 0 && reason == KMSG_DUMP_OOPS && pstore_is_mounted())
572 pstore_new_entry = 1;
574 total += record.size;
575 part++;
578 up(&psinfo->buf_lock);
581 static struct kmsg_dumper pstore_dumper = {
582 .dump = pstore_dump,
586 * Register with kmsg_dump to save last part of console log on panic.
588 static void pstore_register_kmsg(void)
590 kmsg_dump_register(&pstore_dumper);
593 static void pstore_unregister_kmsg(void)
595 kmsg_dump_unregister(&pstore_dumper);
598 #ifdef CONFIG_PSTORE_CONSOLE
599 static void pstore_console_write(struct console *con, const char *s, unsigned c)
601 struct pstore_record record;
603 pstore_record_init(&record, psinfo);
604 record.type = PSTORE_TYPE_CONSOLE;
606 record.buf = (char *)s;
607 record.size = c;
608 psinfo->write(&record);
611 static struct console pstore_console = {
612 .name = "pstore",
613 .write = pstore_console_write,
614 .flags = CON_PRINTBUFFER | CON_ENABLED | CON_ANYTIME,
615 .index = -1,
618 static void pstore_register_console(void)
620 register_console(&pstore_console);
623 static void pstore_unregister_console(void)
625 unregister_console(&pstore_console);
627 #else
628 static void pstore_register_console(void) {}
629 static void pstore_unregister_console(void) {}
630 #endif
632 static int pstore_write_user_compat(struct pstore_record *record,
633 const char __user *buf)
635 int ret = 0;
637 if (record->buf)
638 return -EINVAL;
640 record->buf = memdup_user(buf, record->size);
641 if (unlikely(IS_ERR(record->buf))) {
642 ret = PTR_ERR(record->buf);
643 goto out;
646 ret = record->psi->write(record);
648 kfree(record->buf);
649 out:
650 record->buf = NULL;
652 return unlikely(ret < 0) ? ret : record->size;
656 * platform specific persistent storage driver registers with
657 * us here. If pstore is already mounted, call the platform
658 * read function right away to populate the file system. If not
659 * then the pstore mount code will call us later to fill out
660 * the file system.
662 int pstore_register(struct pstore_info *psi)
664 struct module *owner = psi->owner;
666 if (backend && strcmp(backend, psi->name)) {
667 pr_warn("ignoring unexpected backend '%s'\n", psi->name);
668 return -EPERM;
671 /* Sanity check flags. */
672 if (!psi->flags) {
673 pr_warn("backend '%s' must support at least one frontend\n",
674 psi->name);
675 return -EINVAL;
678 /* Check for required functions. */
679 if (!psi->read || !psi->write) {
680 pr_warn("backend '%s' must implement read() and write()\n",
681 psi->name);
682 return -EINVAL;
685 spin_lock(&pstore_lock);
686 if (psinfo) {
687 pr_warn("backend '%s' already loaded: ignoring '%s'\n",
688 psinfo->name, psi->name);
689 spin_unlock(&pstore_lock);
690 return -EBUSY;
693 if (!psi->write_user)
694 psi->write_user = pstore_write_user_compat;
695 psinfo = psi;
696 mutex_init(&psinfo->read_mutex);
697 sema_init(&psinfo->buf_lock, 1);
698 spin_unlock(&pstore_lock);
700 if (owner && !try_module_get(owner)) {
701 psinfo = NULL;
702 return -EINVAL;
705 if (psi->flags & PSTORE_FLAGS_DMESG)
706 allocate_buf_for_compression();
708 if (pstore_is_mounted())
709 pstore_get_records(0);
711 if (psi->flags & PSTORE_FLAGS_DMESG)
712 pstore_register_kmsg();
713 if (psi->flags & PSTORE_FLAGS_CONSOLE)
714 pstore_register_console();
715 if (psi->flags & PSTORE_FLAGS_FTRACE)
716 pstore_register_ftrace();
717 if (psi->flags & PSTORE_FLAGS_PMSG)
718 pstore_register_pmsg();
720 /* Start watching for new records, if desired. */
721 if (pstore_update_ms >= 0) {
722 pstore_timer.expires = jiffies +
723 msecs_to_jiffies(pstore_update_ms);
724 add_timer(&pstore_timer);
728 * Update the module parameter backend, so it is visible
729 * through /sys/module/pstore/parameters/backend
731 backend = psi->name;
733 pr_info("Registered %s as persistent store backend\n", psi->name);
735 module_put(owner);
737 return 0;
739 EXPORT_SYMBOL_GPL(pstore_register);
741 void pstore_unregister(struct pstore_info *psi)
743 /* Stop timer and make sure all work has finished. */
744 pstore_update_ms = -1;
745 del_timer_sync(&pstore_timer);
746 flush_work(&pstore_work);
748 if (psi->flags & PSTORE_FLAGS_PMSG)
749 pstore_unregister_pmsg();
750 if (psi->flags & PSTORE_FLAGS_FTRACE)
751 pstore_unregister_ftrace();
752 if (psi->flags & PSTORE_FLAGS_CONSOLE)
753 pstore_unregister_console();
754 if (psi->flags & PSTORE_FLAGS_DMESG)
755 pstore_unregister_kmsg();
757 free_buf_for_compression();
759 psinfo = NULL;
760 backend = NULL;
762 EXPORT_SYMBOL_GPL(pstore_unregister);
764 static void decompress_record(struct pstore_record *record)
766 int unzipped_len;
767 char *decompressed;
769 if (!record->compressed)
770 return;
772 /* Only PSTORE_TYPE_DMESG support compression. */
773 if (record->type != PSTORE_TYPE_DMESG) {
774 pr_warn("ignored compressed record type %d\n", record->type);
775 return;
778 /* No compression method has created the common buffer. */
779 if (!big_oops_buf) {
780 pr_warn("no decompression buffer allocated\n");
781 return;
784 unzipped_len = pstore_decompress(record->buf, big_oops_buf,
785 record->size, big_oops_buf_sz);
786 if (unzipped_len <= 0) {
787 pr_err("decompression failed: %d\n", unzipped_len);
788 return;
791 /* Build new buffer for decompressed contents. */
792 decompressed = kmalloc(unzipped_len + record->ecc_notice_size,
793 GFP_KERNEL);
794 if (!decompressed) {
795 pr_err("decompression ran out of memory\n");
796 return;
798 memcpy(decompressed, big_oops_buf, unzipped_len);
800 /* Append ECC notice to decompressed buffer. */
801 memcpy(decompressed + unzipped_len, record->buf + record->size,
802 record->ecc_notice_size);
804 /* Swap out compresed contents with decompressed contents. */
805 kfree(record->buf);
806 record->buf = decompressed;
807 record->size = unzipped_len;
808 record->compressed = false;
812 * Read all the records from one persistent store backend. Create
813 * files in our filesystem. Don't warn about -EEXIST errors
814 * when we are re-scanning the backing store looking to add new
815 * error records.
817 void pstore_get_backend_records(struct pstore_info *psi,
818 struct dentry *root, int quiet)
820 int failed = 0;
821 unsigned int stop_loop = 65536;
823 if (!psi || !root)
824 return;
826 mutex_lock(&psi->read_mutex);
827 if (psi->open && psi->open(psi))
828 goto out;
831 * Backend callback read() allocates record.buf. decompress_record()
832 * may reallocate record.buf. On success, pstore_mkfile() will keep
833 * the record.buf, so free it only on failure.
835 for (; stop_loop; stop_loop--) {
836 struct pstore_record *record;
837 int rc;
839 record = kzalloc(sizeof(*record), GFP_KERNEL);
840 if (!record) {
841 pr_err("out of memory creating record\n");
842 break;
844 pstore_record_init(record, psi);
846 record->size = psi->read(record);
848 /* No more records left in backend? */
849 if (record->size <= 0) {
850 kfree(record);
851 break;
854 decompress_record(record);
855 rc = pstore_mkfile(root, record);
856 if (rc) {
857 /* pstore_mkfile() did not take record, so free it. */
858 kfree(record->buf);
859 kfree(record);
860 if (rc != -EEXIST || !quiet)
861 failed++;
864 if (psi->close)
865 psi->close(psi);
866 out:
867 mutex_unlock(&psi->read_mutex);
869 if (failed)
870 pr_warn("failed to create %d record(s) from '%s'\n",
871 failed, psi->name);
872 if (!stop_loop)
873 pr_err("looping? Too many records seen from '%s'\n",
874 psi->name);
877 static void pstore_dowork(struct work_struct *work)
879 pstore_get_records(1);
882 static void pstore_timefunc(unsigned long dummy)
884 if (pstore_new_entry) {
885 pstore_new_entry = 0;
886 schedule_work(&pstore_work);
889 if (pstore_update_ms >= 0)
890 mod_timer(&pstore_timer,
891 jiffies + msecs_to_jiffies(pstore_update_ms));
894 module_param(backend, charp, 0444);
895 MODULE_PARM_DESC(backend, "Pstore backend to use");