diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-03-11 18:11:25 +0300 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-03-16 15:05:25 +0300 |
commit | f5cf319cf32d2284b3fbc24f3c526e2a9363b4ac (patch) | |
tree | 0d9a970edf83931e3fe7dbda8e2501aed87eb6c2 /fs/ubifs | |
parent | cab95d446cb766062fa7e2e7e326035d7c65b803 (diff) | |
download | linux-f5cf319cf32d2284b3fbc24f3c526e2a9363b4ac.tar.xz |
UBIFS: allocate orphans scan buffer on demand
Instead of using pre-allocated 'c->dbg->buf' buffer in
'dbg_scan_orphans()', 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/ubifs')
-rw-r--r-- | fs/ubifs/orphan.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c index 82009c74b6a3..2cdbd31641d7 100644 --- a/fs/ubifs/orphan.c +++ b/fs/ubifs/orphan.c @@ -892,15 +892,22 @@ static int dbg_read_orphans(struct check_info *ci, struct ubifs_scan_leb *sleb) static int dbg_scan_orphans(struct ubifs_info *c, struct check_info *ci) { int lnum, err = 0; + void *buf; /* Check no-orphans flag and skip this if no orphans */ if (c->no_orphs) return 0; + buf = __vmalloc(c->leb_size, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL); + if (!buf) { + ubifs_err("cannot allocate memory to check orphans"); + return 0; + } + for (lnum = c->orph_first; lnum <= c->orph_last; lnum++) { struct ubifs_scan_leb *sleb; - sleb = ubifs_scan(c, lnum, 0, c->dbg->buf, 0); + sleb = ubifs_scan(c, lnum, 0, buf, 0); if (IS_ERR(sleb)) { err = PTR_ERR(sleb); break; @@ -912,6 +919,7 @@ static int dbg_scan_orphans(struct ubifs_info *c, struct check_info *ci) break; } + vfree(buf); return err; } |