Commit 97288f2c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Chris Mason

Btrfs: corret fmode_t annotations

Make sure to propagate fmode_t properly and use the right constants for
it.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 6e430f94
...@@ -242,7 +242,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) ...@@ -242,7 +242,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
* All other options will be parsed on much later in the mount process and * All other options will be parsed on much later in the mount process and
* only when we need to allocate a new super block. * only when we need to allocate a new super block.
*/ */
static int btrfs_parse_early_options(const char *options, int flags, static int btrfs_parse_early_options(const char *options, fmode_t flags,
void *holder, char **subvol_name, void *holder, char **subvol_name,
struct btrfs_fs_devices **fs_devices) struct btrfs_fs_devices **fs_devices)
{ {
...@@ -418,18 +418,22 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, ...@@ -418,18 +418,22 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
struct super_block *s; struct super_block *s;
struct dentry *root; struct dentry *root;
struct btrfs_fs_devices *fs_devices = NULL; struct btrfs_fs_devices *fs_devices = NULL;
fmode_t mode = FMODE_READ;
int error = 0; int error = 0;
error = btrfs_parse_early_options(data, flags, fs_type, if (!(flags & MS_RDONLY))
mode |= FMODE_WRITE;
error = btrfs_parse_early_options(data, mode, fs_type,
&subvol_name, &fs_devices); &subvol_name, &fs_devices);
if (error) if (error)
goto error; goto error;
error = btrfs_scan_one_device(dev_name, flags, fs_type, &fs_devices); error = btrfs_scan_one_device(dev_name, mode, fs_type, &fs_devices);
if (error) if (error)
goto error_free_subvol_name; goto error_free_subvol_name;
error = btrfs_open_devices(fs_devices, flags, fs_type); error = btrfs_open_devices(fs_devices, mode, fs_type);
if (error) if (error)
goto error_free_subvol_name; goto error_free_subvol_name;
...@@ -591,7 +595,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, ...@@ -591,7 +595,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
len = strnlen(vol->name, BTRFS_PATH_NAME_MAX); len = strnlen(vol->name, BTRFS_PATH_NAME_MAX);
switch (cmd) { switch (cmd) {
case BTRFS_IOC_SCAN_DEV: case BTRFS_IOC_SCAN_DEV:
ret = btrfs_scan_one_device(vol->name, MS_RDONLY, ret = btrfs_scan_one_device(vol->name, FMODE_READ,
&btrfs_fs_type, &fs_devices); &btrfs_fs_type, &fs_devices);
break; break;
} }
......
...@@ -394,7 +394,7 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices) ...@@ -394,7 +394,7 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
} }
int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
int flags, void *holder) fmode_t flags, void *holder)
{ {
struct block_device *bdev; struct block_device *bdev;
struct list_head *head = &fs_devices->devices; struct list_head *head = &fs_devices->devices;
...@@ -469,7 +469,7 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, ...@@ -469,7 +469,7 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
error_brelse: error_brelse:
brelse(bh); brelse(bh);
error_close: error_close:
close_bdev_exclusive(bdev, MS_RDONLY); close_bdev_exclusive(bdev, FMODE_READ);
error: error:
continue; continue;
} }
...@@ -488,7 +488,7 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, ...@@ -488,7 +488,7 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
} }
int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
int flags, void *holder) fmode_t flags, void *holder)
{ {
int ret; int ret;
...@@ -507,7 +507,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, ...@@ -507,7 +507,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
return ret; return ret;
} }
int btrfs_scan_one_device(const char *path, int flags, void *holder, int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
struct btrfs_fs_devices **fs_devices_ret) struct btrfs_fs_devices **fs_devices_ret)
{ {
struct btrfs_super_block *disk_super; struct btrfs_super_block *disk_super;
...@@ -1008,7 +1008,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) ...@@ -1008,7 +1008,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
goto out; goto out;
} }
} else { } else {
bdev = open_bdev_exclusive(device_path, MS_RDONLY, bdev = open_bdev_exclusive(device_path, FMODE_READ,
root->fs_info->bdev_holder); root->fs_info->bdev_holder);
if (IS_ERR(bdev)) { if (IS_ERR(bdev)) {
ret = PTR_ERR(bdev); ret = PTR_ERR(bdev);
...@@ -1078,7 +1078,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) ...@@ -1078,7 +1078,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
BUG_ON(device->writeable); BUG_ON(device->writeable);
brelse(bh); brelse(bh);
if (bdev) if (bdev)
close_bdev_exclusive(bdev, MS_RDONLY); close_bdev_exclusive(bdev, FMODE_READ);
if (device->bdev) { if (device->bdev) {
close_bdev_exclusive(device->bdev, device->mode); close_bdev_exclusive(device->bdev, device->mode);
...@@ -1121,7 +1121,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) ...@@ -1121,7 +1121,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
} }
if (bdev) { if (bdev) {
/* one close for us */ /* one close for us */
close_bdev_exclusive(bdev, MS_RDONLY); close_bdev_exclusive(bdev, FMODE_READ);
} }
kfree(device->name); kfree(device->name);
kfree(device); kfree(device);
...@@ -1132,7 +1132,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) ...@@ -1132,7 +1132,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
brelse(bh); brelse(bh);
error_close: error_close:
if (bdev) if (bdev)
close_bdev_exclusive(bdev, MS_RDONLY); close_bdev_exclusive(bdev, FMODE_READ);
out: out:
mutex_unlock(&root->fs_info->volume_mutex); mutex_unlock(&root->fs_info->volume_mutex);
mutex_unlock(&uuid_mutex); mutex_unlock(&uuid_mutex);
...@@ -2913,7 +2913,7 @@ static int open_seed_devices(struct btrfs_root *root, u8 *fsid) ...@@ -2913,7 +2913,7 @@ static int open_seed_devices(struct btrfs_root *root, u8 *fsid)
goto out; goto out;
} }
ret = __btrfs_open_devices(fs_devices, MS_RDONLY, ret = __btrfs_open_devices(fs_devices, FMODE_READ,
root->fs_info->bdev_holder); root->fs_info->bdev_holder);
if (ret) if (ret)
goto out; goto out;
......
...@@ -135,8 +135,8 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, ...@@ -135,8 +135,8 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,
int mirror_num, int async_submit); int mirror_num, int async_submit);
int btrfs_read_super_device(struct btrfs_root *root, struct extent_buffer *buf); int btrfs_read_super_device(struct btrfs_root *root, struct extent_buffer *buf);
int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
int flags, void *holder); fmode_t flags, void *holder);
int btrfs_scan_one_device(const char *path, int flags, void *holder, int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
struct btrfs_fs_devices **fs_devices_ret); struct btrfs_fs_devices **fs_devices_ret);
int btrfs_close_devices(struct btrfs_fs_devices *fs_devices); int btrfs_close_devices(struct btrfs_fs_devices *fs_devices);
int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices); int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices);
......
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