diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-03-11 08:39:09 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-03-16 08:05:24 -0400 |
commit | 73d9aec3fd212d7bf8af5aa1eca9c79f8a90ad5a (patch) | |
tree | f91a454bb4958af70a7e701a1e32c0231e2be548 /fs | |
parent | 2bcf002159c2aedd5c0ab5a21c3ea73fec87ff8d (diff) |
UBIFS: allocate dump buffer on demand
Instead of using pre-allocated 'c->dbg->buf' buffer in
'dbg_dump_leb()', dynamically allocate it when needed. The intend
is to get rid of the pre-allocated 'c->dbg->buf' buffer and save
128KiB of RAM (or more if PEB size is larger). Indeed, currently we
allocate this memory even if the user never enables any self-check,
which is wasteful.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ubifs/debug.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 02c10dccdd60..c2e5c08a9d30 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -810,16 +810,24 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum) | |||
810 | { | 810 | { |
811 | struct ubifs_scan_leb *sleb; | 811 | struct ubifs_scan_leb *sleb; |
812 | struct ubifs_scan_node *snod; | 812 | struct ubifs_scan_node *snod; |
813 | void *buf; | ||
813 | 814 | ||
814 | if (dbg_failure_mode) | 815 | if (dbg_failure_mode) |
815 | return; | 816 | return; |
816 | 817 | ||
817 | printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n", | 818 | printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n", |
818 | current->pid, lnum); | 819 | current->pid, lnum); |
819 | sleb = ubifs_scan(c, lnum, 0, c->dbg->buf, 0); | 820 | |
821 | buf = __vmalloc(c->leb_size, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL); | ||
822 | if (!buf) { | ||
823 | ubifs_err("cannot allocate memory for dumping LEB %d", lnum); | ||
824 | return; | ||
825 | } | ||
826 | |||
827 | sleb = ubifs_scan(c, lnum, 0, buf, 0); | ||
820 | if (IS_ERR(sleb)) { | 828 | if (IS_ERR(sleb)) { |
821 | ubifs_err("scan error %d", (int)PTR_ERR(sleb)); | 829 | ubifs_err("scan error %d", (int)PTR_ERR(sleb)); |
822 | return; | 830 | goto out; |
823 | } | 831 | } |
824 | 832 | ||
825 | printk(KERN_DEBUG "LEB %d has %d nodes ending at %d\n", lnum, | 833 | printk(KERN_DEBUG "LEB %d has %d nodes ending at %d\n", lnum, |
@@ -835,6 +843,9 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum) | |||
835 | printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n", | 843 | printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n", |
836 | current->pid, lnum); | 844 | current->pid, lnum); |
837 | ubifs_scan_destroy(sleb); | 845 | ubifs_scan_destroy(sleb); |
846 | |||
847 | out: | ||
848 | vfree(buf); | ||
838 | return; | 849 | return; |
839 | } | 850 | } |
840 | 851 | ||