diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-07-26 03:25:05 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-10-29 04:16:41 -0400 |
commit | 71a1c0125f132b2a4656689ca585c5d8931e539c (patch) | |
tree | 5c33185d3b7b00d1e23e1725b70b5ef14795f5fc | |
parent | d2d1ea93069bd7706206b9c124e438ab2795612c (diff) |
logfs get_sb massage, part 1
move allocation of logfs_super to logfs_get_sb, pass it to
logfs_get_sb_...().
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/logfs/dev_bdev.c | 12 | ||||
-rw-r--r-- | fs/logfs/dev_mtd.c | 9 | ||||
-rw-r--r-- | fs/logfs/logfs.h | 17 | ||||
-rw-r--r-- | fs/logfs/super.c | 22 |
4 files changed, 39 insertions, 21 deletions
diff --git a/fs/logfs/dev_bdev.c b/fs/logfs/dev_bdev.c index 9bd2ce2a3040..bca8e2a8e55b 100644 --- a/fs/logfs/dev_bdev.c +++ b/fs/logfs/dev_bdev.c | |||
@@ -9,6 +9,7 @@ | |||
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> | ||
12 | #include <linux/gfp.h> | 13 | #include <linux/gfp.h> |
13 | 14 | ||
14 | #define PAGE_OFS(ofs) ((ofs) & (PAGE_SIZE-1)) | 15 | #define PAGE_OFS(ofs) ((ofs) & (PAGE_SIZE-1)) |
@@ -320,20 +321,23 @@ static const struct logfs_device_ops bd_devops = { | |||
320 | .put_device = bdev_put_device, | 321 | .put_device = bdev_put_device, |
321 | }; | 322 | }; |
322 | 323 | ||
323 | int logfs_get_sb_bdev(struct file_system_type *type, int flags, | 324 | int logfs_get_sb_bdev(struct logfs_super *p, |
325 | struct file_system_type *type, int flags, | ||
324 | const char *devname, struct vfsmount *mnt) | 326 | const char *devname, struct vfsmount *mnt) |
325 | { | 327 | { |
326 | struct block_device *bdev; | 328 | struct block_device *bdev; |
327 | 329 | ||
328 | bdev = open_bdev_exclusive(devname, FMODE_READ|FMODE_WRITE, type); | 330 | bdev = open_bdev_exclusive(devname, FMODE_READ|FMODE_WRITE, type); |
329 | if (IS_ERR(bdev)) | 331 | if (IS_ERR(bdev)) { |
332 | kfree(p); | ||
330 | return PTR_ERR(bdev); | 333 | return PTR_ERR(bdev); |
334 | } | ||
331 | 335 | ||
332 | if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) { | 336 | if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) { |
333 | int mtdnr = MINOR(bdev->bd_dev); | 337 | int mtdnr = MINOR(bdev->bd_dev); |
334 | close_bdev_exclusive(bdev, FMODE_READ|FMODE_WRITE); | 338 | close_bdev_exclusive(bdev, FMODE_READ|FMODE_WRITE); |
335 | return logfs_get_sb_mtd(type, flags, mtdnr, mnt); | 339 | return logfs_get_sb_mtd(p, type, flags, mtdnr, mnt); |
336 | } | 340 | } |
337 | 341 | ||
338 | return logfs_get_sb_device(type, flags, NULL, bdev, &bd_devops, mnt); | 342 | return logfs_get_sb_device(p, type, flags, NULL, bdev, &bd_devops, mnt); |
339 | } | 343 | } |
diff --git a/fs/logfs/dev_mtd.c b/fs/logfs/dev_mtd.c index a85d47d13e4b..e886cdcf9d7e 100644 --- a/fs/logfs/dev_mtd.c +++ b/fs/logfs/dev_mtd.c | |||
@@ -265,14 +265,17 @@ 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 file_system_type *type, int flags, | 268 | int logfs_get_sb_mtd(struct logfs_super *s, |
269 | struct file_system_type *type, int flags, | ||
269 | int mtdnr, struct vfsmount *mnt) | 270 | int mtdnr, struct vfsmount *mnt) |
270 | { | 271 | { |
271 | struct mtd_info *mtd; | 272 | struct mtd_info *mtd; |
272 | const struct logfs_device_ops *devops = &mtd_devops; | 273 | const struct logfs_device_ops *devops = &mtd_devops; |
273 | 274 | ||
274 | mtd = get_mtd_device(NULL, mtdnr); | 275 | mtd = get_mtd_device(NULL, mtdnr); |
275 | if (IS_ERR(mtd)) | 276 | if (IS_ERR(mtd)) { |
277 | kfree(s); | ||
276 | return PTR_ERR(mtd); | 278 | return PTR_ERR(mtd); |
277 | return logfs_get_sb_device(type, flags, mtd, NULL, devops, mnt); | 279 | } |
280 | return logfs_get_sb_device(s, type, flags, mtd, NULL, devops, mnt); | ||
278 | } | 281 | } |
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h index b8786264d243..a3f0aba9e526 100644 --- a/fs/logfs/logfs.h +++ b/fs/logfs/logfs.h | |||
@@ -471,24 +471,30 @@ void logfs_compr_exit(void); | |||
471 | 471 | ||
472 | /* dev_bdev.c */ | 472 | /* dev_bdev.c */ |
473 | #ifdef CONFIG_BLOCK | 473 | #ifdef CONFIG_BLOCK |
474 | int logfs_get_sb_bdev(struct file_system_type *type, int flags, | 474 | int logfs_get_sb_bdev(struct logfs_super *s, |
475 | struct file_system_type *type, int flags, | ||
475 | const char *devname, struct vfsmount *mnt); | 476 | const char *devname, struct vfsmount *mnt); |
476 | #else | 477 | #else |
477 | static inline int logfs_get_sb_bdev(struct file_system_type *type, int flags, | 478 | static inline int logfs_get_sb_bdev(struct logfs_super *s, |
479 | struct file_system_type *type, int flags, | ||
478 | const char *devname, struct vfsmount *mnt) | 480 | const char *devname, struct vfsmount *mnt) |
479 | { | 481 | { |
482 | kfree(s); | ||
480 | return -ENODEV; | 483 | return -ENODEV; |
481 | } | 484 | } |
482 | #endif | 485 | #endif |
483 | 486 | ||
484 | /* dev_mtd.c */ | 487 | /* dev_mtd.c */ |
485 | #ifdef CONFIG_MTD | 488 | #ifdef CONFIG_MTD |
486 | int logfs_get_sb_mtd(struct file_system_type *type, int flags, | 489 | int logfs_get_sb_mtd(struct logfs_super *s, |
490 | struct file_system_type *type, int flags, | ||
487 | int mtdnr, struct vfsmount *mnt); | 491 | int mtdnr, struct vfsmount *mnt); |
488 | #else | 492 | #else |
489 | static inline int logfs_get_sb_mtd(struct file_system_type *type, int flags, | 493 | static inline int logfs_get_sb_mtd(struct logfs_super *s, |
494 | struct file_system_type *type, int flags, | ||
490 | int mtdnr, struct vfsmount *mnt) | 495 | int mtdnr, struct vfsmount *mnt) |
491 | { | 496 | { |
497 | kfree(s); | ||
492 | return -ENODEV; | 498 | return -ENODEV; |
493 | } | 499 | } |
494 | #endif | 500 | #endif |
@@ -619,7 +625,8 @@ void emergency_read_end(struct page *page); | |||
619 | void logfs_crash_dump(struct super_block *sb); | 625 | void logfs_crash_dump(struct super_block *sb); |
620 | void *memchr_inv(const void *s, int c, size_t n); | 626 | void *memchr_inv(const void *s, int c, size_t n); |
621 | int logfs_statfs(struct dentry *dentry, struct kstatfs *stats); | 627 | int logfs_statfs(struct dentry *dentry, struct kstatfs *stats); |
622 | int logfs_get_sb_device(struct file_system_type *type, int flags, | 628 | int logfs_get_sb_device(struct logfs_super *s, |
629 | struct file_system_type *type, int flags, | ||
623 | struct mtd_info *mtd, struct block_device *bdev, | 630 | struct mtd_info *mtd, struct block_device *bdev, |
624 | const struct logfs_device_ops *devops, struct vfsmount *mnt); | 631 | const struct logfs_device_ops *devops, struct vfsmount *mnt); |
625 | int logfs_check_ds(struct logfs_disk_super *ds); | 632 | int logfs_check_ds(struct logfs_disk_super *ds); |
diff --git a/fs/logfs/super.c b/fs/logfs/super.c index 5336155c5d81..5e43178add98 100644 --- a/fs/logfs/super.c +++ b/fs/logfs/super.c | |||
@@ -536,19 +536,16 @@ static void logfs_kill_sb(struct super_block *sb) | |||
536 | log_super("LogFS: Finished unmounting\n"); | 536 | log_super("LogFS: Finished unmounting\n"); |
537 | } | 537 | } |
538 | 538 | ||
539 | int logfs_get_sb_device(struct file_system_type *type, int flags, | 539 | int logfs_get_sb_device(struct logfs_super *super, |
540 | struct file_system_type *type, int flags, | ||
540 | struct mtd_info *mtd, struct block_device *bdev, | 541 | struct mtd_info *mtd, struct block_device *bdev, |
541 | const struct logfs_device_ops *devops, struct vfsmount *mnt) | 542 | const struct logfs_device_ops *devops, struct vfsmount *mnt) |
542 | { | 543 | { |
543 | struct logfs_super *super; | ||
544 | struct super_block *sb; | 544 | struct super_block *sb; |
545 | int err = -ENOMEM; | 545 | int err = -ENOMEM; |
546 | static int mount_count; | 546 | static int mount_count; |
547 | 547 | ||
548 | log_super("LogFS: Start mount %x\n", mount_count++); | 548 | log_super("LogFS: Start mount %x\n", mount_count++); |
549 | super = kzalloc(sizeof(*super), GFP_KERNEL); | ||
550 | if (!super) | ||
551 | goto err0; | ||
552 | 549 | ||
553 | super->s_mtd = mtd; | 550 | super->s_mtd = mtd; |
554 | super->s_bdev = bdev; | 551 | super->s_bdev = bdev; |
@@ -603,20 +600,27 @@ static int logfs_get_sb(struct file_system_type *type, int flags, | |||
603 | const char *devname, void *data, struct vfsmount *mnt) | 600 | const char *devname, void *data, struct vfsmount *mnt) |
604 | { | 601 | { |
605 | ulong mtdnr; | 602 | ulong mtdnr; |
603 | struct logfs_super *super; | ||
604 | |||
605 | super = kzalloc(sizeof(*super), GFP_KERNEL); | ||
606 | if (!super) | ||
607 | return -ENOMEM; | ||
606 | 608 | ||
607 | if (!devname) | 609 | if (!devname) |
608 | return logfs_get_sb_bdev(type, flags, devname, mnt); | 610 | return logfs_get_sb_bdev(super, type, flags, devname, mnt); |
609 | if (strncmp(devname, "mtd", 3)) | 611 | if (strncmp(devname, "mtd", 3)) |
610 | return logfs_get_sb_bdev(type, flags, devname, mnt); | 612 | return logfs_get_sb_bdev(super, type, flags, devname, mnt); |
611 | 613 | ||
612 | { | 614 | { |
613 | char *garbage; | 615 | char *garbage; |
614 | mtdnr = simple_strtoul(devname+3, &garbage, 0); | 616 | mtdnr = simple_strtoul(devname+3, &garbage, 0); |
615 | if (*garbage) | 617 | if (*garbage) { |
618 | kfree(super); | ||
616 | return -EINVAL; | 619 | return -EINVAL; |
620 | } | ||
617 | } | 621 | } |
618 | 622 | ||
619 | return logfs_get_sb_mtd(type, flags, mtdnr, mnt); | 623 | return logfs_get_sb_mtd(super, type, flags, mtdnr, mnt); |
620 | } | 624 | } |
621 | 625 | ||
622 | static struct file_system_type logfs_fs_type = { | 626 | static struct file_system_type logfs_fs_type = { |