diff options
| author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-03-11 10:11:25 -0500 |
|---|---|---|
| committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-03-16 08:05:25 -0400 |
| commit | f5cf319cf32d2284b3fbc24f3c526e2a9363b4ac (patch) | |
| tree | 0d9a970edf83931e3fe7dbda8e2501aed87eb6c2 | |
| parent | cab95d446cb766062fa7e2e7e326035d7c65b803 (diff) | |
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>
| -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) | |||
| 892 | static int dbg_scan_orphans(struct ubifs_info *c, struct check_info *ci) | 892 | static int dbg_scan_orphans(struct ubifs_info *c, struct check_info *ci) |
| 893 | { | 893 | { |
| 894 | int lnum, err = 0; | 894 | int lnum, err = 0; |
| 895 | void *buf; | ||
| 895 | 896 | ||
| 896 | /* Check no-orphans flag and skip this if no orphans */ | 897 | /* Check no-orphans flag and skip this if no orphans */ |
| 897 | if (c->no_orphs) | 898 | if (c->no_orphs) |
| 898 | return 0; | 899 | return 0; |
| 899 | 900 | ||
| 901 | buf = __vmalloc(c->leb_size, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL); | ||
| 902 | if (!buf) { | ||
| 903 | ubifs_err("cannot allocate memory to check orphans"); | ||
| 904 | return 0; | ||
| 905 | } | ||
| 906 | |||
| 900 | for (lnum = c->orph_first; lnum <= c->orph_last; lnum++) { | 907 | for (lnum = c->orph_first; lnum <= c->orph_last; lnum++) { |
| 901 | struct ubifs_scan_leb *sleb; | 908 | struct ubifs_scan_leb *sleb; |
| 902 | 909 | ||
| 903 | sleb = ubifs_scan(c, lnum, 0, c->dbg->buf, 0); | 910 | sleb = ubifs_scan(c, lnum, 0, buf, 0); |
| 904 | if (IS_ERR(sleb)) { | 911 | if (IS_ERR(sleb)) { |
| 905 | err = PTR_ERR(sleb); | 912 | err = PTR_ERR(sleb); |
| 906 | break; | 913 | break; |
| @@ -912,6 +919,7 @@ static int dbg_scan_orphans(struct ubifs_info *c, struct check_info *ci) | |||
| 912 | break; | 919 | break; |
| 913 | } | 920 | } |
| 914 | 921 | ||
| 922 | vfree(buf); | ||
| 915 | return err; | 923 | return err; |
| 916 | } | 924 | } |
| 917 | 925 | ||
