Btrfs: mount ro and remount support
This patch adds mount ro and remount support. The main changes in patch are: adding btrfs_remount and related helper function; splitting the transaction related code out of close_ctree into btrfs_commit_super; updating allocator to properly handle read only block group. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
This commit is contained in:
@@ -378,6 +378,9 @@ static int btrfs_ioctl_resize(struct btrfs_root *root, void __user *arg)
|
||||
int namelen;
|
||||
int mod = 0;
|
||||
|
||||
if (root->fs_info->sb->s_flags & MS_RDONLY)
|
||||
return -EROFS;
|
||||
|
||||
vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS);
|
||||
|
||||
if (!vol_args)
|
||||
@@ -478,6 +481,9 @@ static noinline int btrfs_ioctl_snap_create(struct file *file,
|
||||
int namelen;
|
||||
int ret;
|
||||
|
||||
if (root->fs_info->sb->s_flags & MS_RDONLY)
|
||||
return -EROFS;
|
||||
|
||||
vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS);
|
||||
|
||||
if (!vol_args)
|
||||
@@ -534,6 +540,11 @@ static int btrfs_ioctl_defrag(struct file *file)
|
||||
{
|
||||
struct inode *inode = fdentry(file)->d_inode;
|
||||
struct btrfs_root *root = BTRFS_I(inode)->root;
|
||||
int ret;
|
||||
|
||||
ret = mnt_want_write(file->f_path.mnt);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
switch (inode->i_mode & S_IFMT) {
|
||||
case S_IFDIR:
|
||||
@@ -575,6 +586,9 @@ long btrfs_ioctl_rm_dev(struct btrfs_root *root, void __user *arg)
|
||||
struct btrfs_ioctl_vol_args *vol_args;
|
||||
int ret;
|
||||
|
||||
if (root->fs_info->sb->s_flags & MS_RDONLY)
|
||||
return -EROFS;
|
||||
|
||||
vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS);
|
||||
|
||||
if (!vol_args)
|
||||
@@ -621,6 +635,10 @@ long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, u64 off,
|
||||
* they don't overlap)?
|
||||
*/
|
||||
|
||||
ret = mnt_want_write(file->f_path.mnt);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
src_file = fget(srcfd);
|
||||
if (!src_file)
|
||||
return -EBADF;
|
||||
@@ -958,6 +976,10 @@ long btrfs_ioctl_trans_start(struct file *file)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = mnt_want_write(file->f_path.mnt);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
mutex_lock(&root->fs_info->trans_mutex);
|
||||
root->fs_info->open_ioctl_trans++;
|
||||
mutex_unlock(&root->fs_info->trans_mutex);
|
||||
|
Reference in New Issue
Block a user