summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorYan Zheng <zheng.yan@oracle.com>2008-11-12 14:34:12 -0500
committerChris Mason <chris.mason@oracle.com>2008-11-12 14:34:12 -0500
commitc146afad2c7fea6a366d4945c1bab9b03880f526 (patch)
treedd217139525a521895125843ca31f61cfbb49dca /fs/btrfs/ioctl.c
parentf3465ca44e2a51fd647c167045768a8ab5a96603 (diff)
downloadtalos-obmc-linux-c146afad2c7fea6a366d4945c1bab9b03880f526.tar.gz
talos-obmc-linux-c146afad2c7fea6a366d4945c1bab9b03880f526.zip
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>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 4d7cc7c504d0..52863cebd594 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -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);
OpenPOWER on IntegriCloud