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>
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 4d7cc7c..52863ce 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -378,6 +378,9 @@
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 @@
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 @@
{
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 @@
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 @@
* 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 @@
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);