Commit c7a6c4ed authored by OGAWA Hirofumi's avatar OGAWA Hirofumi Committed by Linus Torvalds

fat: use __getname()

__getname() is faster than __get_free_page(). Use it.
Signed-off-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f22032ba
...@@ -247,7 +247,7 @@ static int fat_parse_long(struct inode *dir, loff_t *pos, ...@@ -247,7 +247,7 @@ static int fat_parse_long(struct inode *dir, loff_t *pos,
unsigned char id, slot, slots, alias_checksum; unsigned char id, slot, slots, alias_checksum;
if (!*unicode) { if (!*unicode) {
*unicode = (wchar_t *)__get_free_page(GFP_KERNEL); *unicode = __getname();
if (!*unicode) { if (!*unicode) {
brelse(*bh); brelse(*bh);
return -ENOMEM; return -ENOMEM;
...@@ -327,7 +327,7 @@ int fat_search_long(struct inode *inode, const unsigned char *name, ...@@ -327,7 +327,7 @@ int fat_search_long(struct inode *inode, const unsigned char *name,
loff_t cpos = 0; loff_t cpos = 0;
int chl, i, j, last_u, err; int chl, i, j, last_u, err;
bufname = (unsigned char*)__get_free_page(GFP_KERNEL); bufname = __getname();
if (!bufname) if (!bufname)
return -ENOMEM; return -ENOMEM;
...@@ -396,8 +396,8 @@ parse_record: ...@@ -396,8 +396,8 @@ parse_record:
bufuname[last_u] = 0x0000; bufuname[last_u] = 0x0000;
xlate_len = utf8 xlate_len = utf8
?utf8_wcstombs(bufname, bufuname, PAGE_SIZE) ?utf8_wcstombs(bufname, bufuname, PATH_MAX)
:uni16_to_x8(bufname, bufuname, PAGE_SIZE, uni_xlate, nls_io); :uni16_to_x8(bufname, bufuname, PATH_MAX, uni_xlate, nls_io);
if (xlate_len == name_len) if (xlate_len == name_len)
if ((!anycase && !memcmp(name, bufname, xlate_len)) || if ((!anycase && !memcmp(name, bufname, xlate_len)) ||
(anycase && !nls_strnicmp(nls_io, name, bufname, (anycase && !nls_strnicmp(nls_io, name, bufname,
...@@ -406,8 +406,8 @@ parse_record: ...@@ -406,8 +406,8 @@ parse_record:
if (nr_slots) { if (nr_slots) {
xlate_len = utf8 xlate_len = utf8
?utf8_wcstombs(bufname, unicode, PAGE_SIZE) ?utf8_wcstombs(bufname, unicode, PATH_MAX)
:uni16_to_x8(bufname, unicode, PAGE_SIZE, uni_xlate, nls_io); :uni16_to_x8(bufname, unicode, PATH_MAX, uni_xlate, nls_io);
if (xlate_len != name_len) if (xlate_len != name_len)
continue; continue;
if ((!anycase && !memcmp(name, bufname, xlate_len)) || if ((!anycase && !memcmp(name, bufname, xlate_len)) ||
...@@ -427,9 +427,9 @@ Found: ...@@ -427,9 +427,9 @@ Found:
err = 0; err = 0;
EODir: EODir:
if (bufname) if (bufname)
free_page((unsigned long)bufname); __putname(bufname);
if (unicode) if (unicode)
free_page((unsigned long)unicode); __putname(unicode);
return err; return err;
} }
...@@ -619,7 +619,7 @@ parse_record: ...@@ -619,7 +619,7 @@ parse_record:
/* convert the unicode long name. 261 is maximum size /* convert the unicode long name. 261 is maximum size
* of unicode buffer. (13 * slots + nul) */ * of unicode buffer. (13 * slots + nul) */
void *longname = unicode + 261; void *longname = unicode + 261;
int buf_size = PAGE_SIZE - (261 * sizeof(unicode[0])); int buf_size = PATH_MAX - (261 * sizeof(unicode[0]));
int long_len = utf8 int long_len = utf8
? utf8_wcstombs(longname, unicode, buf_size) ? utf8_wcstombs(longname, unicode, buf_size)
: uni16_to_x8(longname, unicode, buf_size, uni_xlate, nls_io); : uni16_to_x8(longname, unicode, buf_size, uni_xlate, nls_io);
...@@ -652,7 +652,7 @@ EODir: ...@@ -652,7 +652,7 @@ EODir:
FillFailed: FillFailed:
brelse(bh); brelse(bh);
if (unicode) if (unicode)
free_page((unsigned long)unicode); __putname(unicode);
out: out:
unlock_kernel(); unlock_kernel();
return ret; return ret;
......
...@@ -472,7 +472,7 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, ...@@ -472,7 +472,7 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
if (utf8) { if (utf8) {
int name_len = strlen(name); int name_len = strlen(name);
*outlen = utf8_mbstowcs((wchar_t *)outname, name, PAGE_SIZE); *outlen = utf8_mbstowcs((wchar_t *)outname, name, PATH_MAX);
/* /*
* We stripped '.'s before and set len appropriately, * We stripped '.'s before and set len appropriately,
...@@ -565,7 +565,6 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name, ...@@ -565,7 +565,6 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name,
struct fat_mount_options *opts = &sbi->options; struct fat_mount_options *opts = &sbi->options;
struct msdos_dir_slot *ps; struct msdos_dir_slot *ps;
struct msdos_dir_entry *de; struct msdos_dir_entry *de;
unsigned long page;
unsigned char cksum, lcase; unsigned char cksum, lcase;
unsigned char msdos_name[MSDOS_NAME]; unsigned char msdos_name[MSDOS_NAME];
wchar_t *uname; wchar_t *uname;
...@@ -575,11 +574,10 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name, ...@@ -575,11 +574,10 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name,
*nr_slots = 0; *nr_slots = 0;
page = __get_free_page(GFP_KERNEL); uname = __getname();
if (!page) if (!uname)
return -ENOMEM; return -ENOMEM;
uname = (wchar_t *)page;
err = xlate_to_uni(name, len, (unsigned char *)uname, &ulen, &usize, err = xlate_to_uni(name, len, (unsigned char *)uname, &ulen, &usize,
opts->unicode_xlate, opts->utf8, sbi->nls_io); opts->unicode_xlate, opts->utf8, sbi->nls_io);
if (err) if (err)
...@@ -631,7 +629,7 @@ shortname: ...@@ -631,7 +629,7 @@ shortname:
de->starthi = cpu_to_le16(cluster >> 16); de->starthi = cpu_to_le16(cluster >> 16);
de->size = 0; de->size = 0;
out_free: out_free:
free_page(page); __putname(uname);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment