Commit d8e9650dff48055057253ca30933605bd7d0733b

Authored by Li Zefan
Committed by Al Viro
1 parent 4c728ef583

vfs: remove duplicate code in get_fs_type()

save 14 bytes:

   text    data     bss     dec     hex filename
   1354      32       4    1390     56e fs/filesystems.o.before
   text    data     bss     dec     hex filename
   1340      32       4    1376     560 fs/filesystems.o

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 1 changed file with 13 additions and 10 deletions Side-by-side Diff

... ... @@ -253,24 +253,27 @@
253 253 module_init(proc_filesystems_init);
254 254 #endif
255 255  
256   -struct file_system_type *get_fs_type(const char *name)
  256 +static struct file_system_type *__get_fs_type(const char *name, int len)
257 257 {
258 258 struct file_system_type *fs;
259   - const char *dot = strchr(name, '.');
260   - unsigned len = dot ? dot - name : strlen(name);
261 259  
262 260 read_lock(&file_systems_lock);
263 261 fs = *(find_filesystem(name, len));
264 262 if (fs && !try_module_get(fs->owner))
265 263 fs = NULL;
266 264 read_unlock(&file_systems_lock);
267   - if (!fs && (request_module("%.*s", len, name) == 0)) {
268   - read_lock(&file_systems_lock);
269   - fs = *(find_filesystem(name, len));
270   - if (fs && !try_module_get(fs->owner))
271   - fs = NULL;
272   - read_unlock(&file_systems_lock);
273   - }
  265 + return fs;
  266 +}
  267 +
  268 +struct file_system_type *get_fs_type(const char *name)
  269 +{
  270 + struct file_system_type *fs;
  271 + const char *dot = strchr(name, '.');
  272 + int len = dot ? dot - name : strlen(name);
  273 +
  274 + fs = __get_fs_type(name, len);
  275 + if (!fs && (request_module("%.*s", len, name) == 0))
  276 + fs = __get_fs_type(name, len);
274 277  
275 278 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
276 279 put_filesystem(fs);