diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-07-26 03:53:30 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-10-29 04:16:46 -0400 |
commit | 7d945a3aa7608f68dba04083d3421e0b43052660 (patch) | |
tree | 6d236bc977372f3c93cfde81e68ef46e55159eff | |
parent | 0d85c799623cb6022adb1317ed2987ab9c097c2e (diff) |
logfs get_sb, part 3
take logfs_get_sb_device() calls to logfs_get_sb() itself
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/logfs/dev_bdev.c | 15 | ||||
-rw-r--r-- | fs/logfs/dev_mtd.c | 10 | ||||
-rw-r--r-- | fs/logfs/logfs.h | 18 | ||||
-rw-r--r-- | fs/logfs/super.c | 25 |
4 files changed, 29 insertions, 39 deletions
diff --git a/fs/logfs/dev_bdev.c b/fs/logfs/dev_bdev.c index a322fec10173..223b673dcc7b 100644 --- a/fs/logfs/dev_bdev.c +++ b/fs/logfs/dev_bdev.c | |||
@@ -9,7 +9,6 @@ | |||
9 | #include <linux/bio.h> | 9 | #include <linux/bio.h> |
10 | #include <linux/blkdev.h> | 10 | #include <linux/blkdev.h> |
11 | #include <linux/buffer_head.h> | 11 | #include <linux/buffer_head.h> |
12 | #include <linux/slab.h> | ||
13 | #include <linux/gfp.h> | 12 | #include <linux/gfp.h> |
14 | 13 | ||
15 | #define PAGE_OFS(ofs) ((ofs) & (PAGE_SIZE-1)) | 14 | #define PAGE_OFS(ofs) ((ofs) & (PAGE_SIZE-1)) |
@@ -321,27 +320,23 @@ static const struct logfs_device_ops bd_devops = { | |||
321 | .put_device = bdev_put_device, | 320 | .put_device = bdev_put_device, |
322 | }; | 321 | }; |
323 | 322 | ||
324 | int logfs_get_sb_bdev(struct logfs_super *p, | 323 | int logfs_get_sb_bdev(struct logfs_super *p, struct file_system_type *type, |
325 | struct file_system_type *type, int flags, | 324 | const char *devname) |
326 | const char *devname, struct vfsmount *mnt) | ||
327 | { | 325 | { |
328 | struct block_device *bdev; | 326 | struct block_device *bdev; |
329 | 327 | ||
330 | bdev = open_bdev_exclusive(devname, FMODE_READ|FMODE_WRITE, type); | 328 | bdev = open_bdev_exclusive(devname, FMODE_READ|FMODE_WRITE, type); |
331 | if (IS_ERR(bdev)) { | 329 | if (IS_ERR(bdev)) |
332 | kfree(p); | ||
333 | return PTR_ERR(bdev); | 330 | return PTR_ERR(bdev); |
334 | } | ||
335 | 331 | ||
336 | if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) { | 332 | if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) { |
337 | int mtdnr = MINOR(bdev->bd_dev); | 333 | int mtdnr = MINOR(bdev->bd_dev); |
338 | close_bdev_exclusive(bdev, FMODE_READ|FMODE_WRITE); | 334 | close_bdev_exclusive(bdev, FMODE_READ|FMODE_WRITE); |
339 | return logfs_get_sb_mtd(p, type, flags, mtdnr, mnt); | 335 | return logfs_get_sb_mtd(p, mtdnr); |
340 | } | 336 | } |
341 | 337 | ||
342 | p->s_bdev = bdev; | 338 | p->s_bdev = bdev; |
343 | p->s_mtd = NULL; | 339 | p->s_mtd = NULL; |
344 | p->s_devops = &bd_devops; | 340 | p->s_devops = &bd_devops; |
345 | 341 | return 0; | |
346 | return logfs_get_sb_device(p, type, flags, mnt); | ||
347 | } | 342 | } |
diff --git a/fs/logfs/dev_mtd.c b/fs/logfs/dev_mtd.c index 7b22d57d1469..9e3dbe3712ae 100644 --- a/fs/logfs/dev_mtd.c +++ b/fs/logfs/dev_mtd.c | |||
@@ -265,18 +265,14 @@ static const struct logfs_device_ops mtd_devops = { | |||
265 | .put_device = mtd_put_device, | 265 | .put_device = mtd_put_device, |
266 | }; | 266 | }; |
267 | 267 | ||
268 | int logfs_get_sb_mtd(struct logfs_super *s, | 268 | int logfs_get_sb_mtd(struct logfs_super *s, int mtdnr) |
269 | struct file_system_type *type, int flags, | ||
270 | int mtdnr, struct vfsmount *mnt) | ||
271 | { | 269 | { |
272 | struct mtd_info *mtd = get_mtd_device(NULL, mtdnr); | 270 | struct mtd_info *mtd = get_mtd_device(NULL, mtdnr); |
273 | if (IS_ERR(mtd)) { | 271 | if (IS_ERR(mtd)) |
274 | kfree(s); | ||
275 | return PTR_ERR(mtd); | 272 | return PTR_ERR(mtd); |
276 | } | ||
277 | 273 | ||
278 | s->s_bdev = NULL; | 274 | s->s_bdev = NULL; |
279 | s->s_mtd = mtd; | 275 | s->s_mtd = mtd; |
280 | s->s_devops = &mtd_devops; | 276 | s->s_devops = &mtd_devops; |
281 | return logfs_get_sb_device(s, type, flags, mnt); | 277 | return 0; |
282 | } | 278 | } |
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h index bdd56fa4b084..5d2e66b48290 100644 --- a/fs/logfs/logfs.h +++ b/fs/logfs/logfs.h | |||
@@ -472,29 +472,23 @@ void logfs_compr_exit(void); | |||
472 | /* dev_bdev.c */ | 472 | /* dev_bdev.c */ |
473 | #ifdef CONFIG_BLOCK | 473 | #ifdef CONFIG_BLOCK |
474 | int logfs_get_sb_bdev(struct logfs_super *s, | 474 | int logfs_get_sb_bdev(struct logfs_super *s, |
475 | struct file_system_type *type, int flags, | 475 | struct file_system_type *type, |
476 | const char *devname, struct vfsmount *mnt); | 476 | const char *devname); |
477 | #else | 477 | #else |
478 | static inline int logfs_get_sb_bdev(struct logfs_super *s, | 478 | static inline int logfs_get_sb_bdev(struct logfs_super *s, |
479 | struct file_system_type *type, int flags, | 479 | struct file_system_type *type, |
480 | const char *devname, struct vfsmount *mnt) | 480 | const char *devname) |
481 | { | 481 | { |
482 | kfree(s); | ||
483 | return -ENODEV; | 482 | return -ENODEV; |
484 | } | 483 | } |
485 | #endif | 484 | #endif |
486 | 485 | ||
487 | /* dev_mtd.c */ | 486 | /* dev_mtd.c */ |
488 | #ifdef CONFIG_MTD | 487 | #ifdef CONFIG_MTD |
489 | int logfs_get_sb_mtd(struct logfs_super *s, | 488 | int logfs_get_sb_mtd(struct logfs_super *s, int mtdnr) |
490 | struct file_system_type *type, int flags, | ||
491 | int mtdnr, struct vfsmount *mnt); | ||
492 | #else | 489 | #else |
493 | static inline int logfs_get_sb_mtd(struct logfs_super *s, | 490 | static inline int logfs_get_sb_mtd(struct logfs_super *s, int mtdnr) |
494 | struct file_system_type *type, int flags, | ||
495 | int mtdnr, struct vfsmount *mnt) | ||
496 | { | 491 | { |
497 | kfree(s); | ||
498 | return -ENODEV; | 492 | return -ENODEV; |
499 | } | 493 | } |
500 | #endif | 494 | #endif |
diff --git a/fs/logfs/super.c b/fs/logfs/super.c index c80837e54bb3..f57a150b4779 100644 --- a/fs/logfs/super.c +++ b/fs/logfs/super.c | |||
@@ -596,26 +596,31 @@ static int logfs_get_sb(struct file_system_type *type, int flags, | |||
596 | { | 596 | { |
597 | ulong mtdnr; | 597 | ulong mtdnr; |
598 | struct logfs_super *super; | 598 | struct logfs_super *super; |
599 | int err; | ||
599 | 600 | ||
600 | super = kzalloc(sizeof(*super), GFP_KERNEL); | 601 | super = kzalloc(sizeof(*super), GFP_KERNEL); |
601 | if (!super) | 602 | if (!super) |
602 | return -ENOMEM; | 603 | return -ENOMEM; |
603 | 604 | ||
604 | if (!devname) | 605 | if (!devname) |
605 | return logfs_get_sb_bdev(super, type, flags, devname, mnt); | 606 | err = logfs_get_sb_bdev(super, type, devname); |
606 | if (strncmp(devname, "mtd", 3)) | 607 | else if (strncmp(devname, "mtd", 3)) |
607 | return logfs_get_sb_bdev(super, type, flags, devname, mnt); | 608 | err = logfs_get_sb_bdev(super, type, devname); |
608 | 609 | else { | |
609 | { | ||
610 | char *garbage; | 610 | char *garbage; |
611 | mtdnr = simple_strtoul(devname+3, &garbage, 0); | 611 | mtdnr = simple_strtoul(devname+3, &garbage, 0); |
612 | if (*garbage) { | 612 | if (*garbage) |
613 | kfree(super); | 613 | err = -EINVAL; |
614 | return -EINVAL; | 614 | else |
615 | } | 615 | err = logfs_get_sb_mtd(super, mtdnr); |
616 | } | ||
617 | |||
618 | if (err) { | ||
619 | kfree(super); | ||
620 | return err; | ||
616 | } | 621 | } |
617 | 622 | ||
618 | return logfs_get_sb_mtd(super, type, flags, mtdnr, mnt); | 623 | return logfs_get_sb_device(super, type, flags, mnt); |
619 | } | 624 | } |
620 | 625 | ||
621 | static struct file_system_type logfs_fs_type = { | 626 | static struct file_system_type logfs_fs_type = { |