diff options
Diffstat (limited to 'fs/super.c')
-rw-r--r-- | fs/super.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/super.c b/fs/super.c index e931ae9511fe..0d77ac20d03e 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -760,9 +760,13 @@ int get_sb_bdev(struct file_system_type *fs_type, | |||
760 | { | 760 | { |
761 | struct block_device *bdev; | 761 | struct block_device *bdev; |
762 | struct super_block *s; | 762 | struct super_block *s; |
763 | fmode_t mode = FMODE_READ; | ||
763 | int error = 0; | 764 | int error = 0; |
764 | 765 | ||
765 | bdev = open_bdev_excl(dev_name, flags, fs_type); | 766 | if (!(flags & MS_RDONLY)) |
767 | mode |= FMODE_WRITE; | ||
768 | |||
769 | bdev = open_bdev_exclusive(dev_name, mode, fs_type); | ||
766 | if (IS_ERR(bdev)) | 770 | if (IS_ERR(bdev)) |
767 | return PTR_ERR(bdev); | 771 | return PTR_ERR(bdev); |
768 | 772 | ||
@@ -785,11 +789,12 @@ int get_sb_bdev(struct file_system_type *fs_type, | |||
785 | goto error_bdev; | 789 | goto error_bdev; |
786 | } | 790 | } |
787 | 791 | ||
788 | close_bdev_excl(bdev); | 792 | close_bdev_exclusive(bdev, mode); |
789 | } else { | 793 | } else { |
790 | char b[BDEVNAME_SIZE]; | 794 | char b[BDEVNAME_SIZE]; |
791 | 795 | ||
792 | s->s_flags = flags; | 796 | s->s_flags = flags; |
797 | s->s_mode = mode; | ||
793 | strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); | 798 | strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); |
794 | sb_set_blocksize(s, block_size(bdev)); | 799 | sb_set_blocksize(s, block_size(bdev)); |
795 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); | 800 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
@@ -807,7 +812,7 @@ int get_sb_bdev(struct file_system_type *fs_type, | |||
807 | error_s: | 812 | error_s: |
808 | error = PTR_ERR(s); | 813 | error = PTR_ERR(s); |
809 | error_bdev: | 814 | error_bdev: |
810 | close_bdev_excl(bdev); | 815 | close_bdev_exclusive(bdev, mode); |
811 | error: | 816 | error: |
812 | return error; | 817 | return error; |
813 | } | 818 | } |
@@ -817,10 +822,11 @@ EXPORT_SYMBOL(get_sb_bdev); | |||
817 | void kill_block_super(struct super_block *sb) | 822 | void kill_block_super(struct super_block *sb) |
818 | { | 823 | { |
819 | struct block_device *bdev = sb->s_bdev; | 824 | struct block_device *bdev = sb->s_bdev; |
825 | fmode_t mode = sb->s_mode; | ||
820 | 826 | ||
821 | generic_shutdown_super(sb); | 827 | generic_shutdown_super(sb); |
822 | sync_blockdev(bdev); | 828 | sync_blockdev(bdev); |
823 | close_bdev_excl(bdev); | 829 | close_bdev_exclusive(bdev, mode); |
824 | } | 830 | } |
825 | 831 | ||
826 | EXPORT_SYMBOL(kill_block_super); | 832 | EXPORT_SYMBOL(kill_block_super); |