platform.c (76cc9580e3fbd323651d06e8184a5a54e0e1066e) | platform.c (7e8cc8dce17574e432945fa75882cd401c3ef673) |
---|---|
1/* 2 * Persistent Storage - platform driver interface parts. 3 * 4 * Copyright (C) 2007-2008 Google, Inc. 5 * Copyright (C) 2010 Intel Corporation <tony.luck@intel.com> 6 * 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 --- 754 unchanged lines hidden (view full) --- 763 psinfo = NULL; 764 backend = NULL; 765} 766EXPORT_SYMBOL_GPL(pstore_unregister); 767 768static void decompress_record(struct pstore_record *record) 769{ 770 int unzipped_len; | 1/* 2 * Persistent Storage - platform driver interface parts. 3 * 4 * Copyright (C) 2007-2008 Google, Inc. 5 * Copyright (C) 2010 Intel Corporation <tony.luck@intel.com> 6 * 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 --- 754 unchanged lines hidden (view full) --- 763 psinfo = NULL; 764 backend = NULL; 765} 766EXPORT_SYMBOL_GPL(pstore_unregister); 767 768static void decompress_record(struct pstore_record *record) 769{ 770 int unzipped_len; |
771 char *decompressed; |
|
771 772 /* Only PSTORE_TYPE_DMESG support compression. */ 773 if (!record->compressed || record->type != PSTORE_TYPE_DMESG) { 774 pr_warn("ignored compressed record type %d\n", record->type); 775 return; 776 } 777 778 /* No compression method has created the common buffer. */ 779 if (!big_oops_buf) { 780 pr_warn("no decompression buffer allocated\n"); 781 return; 782 } 783 784 unzipped_len = pstore_decompress(record->buf, big_oops_buf, 785 record->size, big_oops_buf_sz); | 772 773 /* Only PSTORE_TYPE_DMESG support compression. */ 774 if (!record->compressed || record->type != PSTORE_TYPE_DMESG) { 775 pr_warn("ignored compressed record type %d\n", record->type); 776 return; 777 } 778 779 /* No compression method has created the common buffer. */ 780 if (!big_oops_buf) { 781 pr_warn("no decompression buffer allocated\n"); 782 return; 783 } 784 785 unzipped_len = pstore_decompress(record->buf, big_oops_buf, 786 record->size, big_oops_buf_sz); |
786 if (unzipped_len > 0) { 787 if (record->ecc_notice_size) 788 memcpy(big_oops_buf + unzipped_len, 789 record->buf + record->size, 790 record->ecc_notice_size); 791 kfree(record->buf); 792 record->buf = big_oops_buf; 793 record->size = unzipped_len; 794 record->compressed = false; 795 } else | 787 if (unzipped_len <= 0) { |
796 pr_err("decompression failed: %d\n", unzipped_len); | 788 pr_err("decompression failed: %d\n", unzipped_len); |
789 return; 790 } 791 792 /* Build new buffer for decompressed contents. */ 793 decompressed = kmalloc(unzipped_len + record->ecc_notice_size, 794 GFP_KERNEL); 795 if (!decompressed) { 796 pr_err("decompression ran out of memory\n"); 797 return; 798 } 799 memcpy(decompressed, big_oops_buf, unzipped_len); 800 801 /* Append ECC notice to decompressed buffer. */ 802 memcpy(decompressed + unzipped_len, record->buf + record->size, 803 record->ecc_notice_size); 804 805 /* Swap out compresed contents with decompressed contents. */ 806 kfree(record->buf); 807 record->buf = decompressed; 808 record->size = unzipped_len; 809 record->compressed = false; |
|
797} 798 799/* 800 * Read all the records from the persistent store. Create 801 * files in our filesystem. Don't warn about -EEXIST errors 802 * when we are re-scanning the backing store looking to add new 803 * error records. 804 */ --- 9 unchanged lines hidden (view full) --- 814 mutex_lock(&psi->read_mutex); 815 if (psi->open && psi->open(psi)) 816 goto out; 817 818 while ((record.size = psi->read(&record)) > 0) { 819 decompress_record(&record); 820 rc = pstore_mkfile(&record); 821 | 810} 811 812/* 813 * Read all the records from the persistent store. Create 814 * files in our filesystem. Don't warn about -EEXIST errors 815 * when we are re-scanning the backing store looking to add new 816 * error records. 817 */ --- 9 unchanged lines hidden (view full) --- 827 mutex_lock(&psi->read_mutex); 828 if (psi->open && psi->open(psi)) 829 goto out; 830 831 while ((record.size = psi->read(&record)) > 0) { 832 decompress_record(&record); 833 rc = pstore_mkfile(&record); 834 |
822 /* Free buffer other than big oops */ 823 if (record.buf != big_oops_buf) 824 kfree(record.buf); 825 | |
826 if (rc && (rc != -EEXIST || !quiet)) 827 failed++; 828 | 835 if (rc && (rc != -EEXIST || !quiet)) 836 failed++; 837 |
838 kfree(record.buf); |
|
829 memset(&record, 0, sizeof(record)); 830 record.psi = psi; 831 } 832 if (psi->close) 833 psi->close(psi); 834out: 835 mutex_unlock(&psi->read_mutex); 836 --- 24 unchanged lines hidden --- | 839 memset(&record, 0, sizeof(record)); 840 record.psi = psi; 841 } 842 if (psi->close) 843 psi->close(psi); 844out: 845 mutex_unlock(&psi->read_mutex); 846 --- 24 unchanged lines hidden --- |