aboutsummaryrefslogtreecommitdiffstats
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)
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)
378 int namelen; 378 int namelen;
379 int mod = 0; 379 int mod = 0;
380 380
381 if (root->fs_info->sb->s_flags & MS_RDONLY)
382 return -EROFS;
383
381 vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS); 384 vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS);
382 385
383 if (!vol_args) 386 if (!vol_args)
@@ -478,6 +481,9 @@ static noinline int btrfs_ioctl_snap_create(struct file *file,
478 int namelen; 481 int namelen;
479 int ret; 482 int ret;
480 483
484 if (root->fs_info->sb->s_flags & MS_RDONLY)
485 return -EROFS;
486
481 vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS); 487 vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS);
482 488
483 if (!vol_args) 489 if (!vol_args)
@@ -534,6 +540,11 @@ static int btrfs_ioctl_defrag(struct file *file)
534{ 540{
535 struct inode *inode = fdentry(file)->d_inode; 541 struct inode *inode = fdentry(file)->d_inode;
536 struct btrfs_root *root = BTRFS_I(inode)->root; 542 struct btrfs_root *root = BTRFS_I(inode)->root;
543 int ret;
544
545 ret = mnt_want_write(file->f_path.mnt);
546 if (ret)
547 return ret;
537 548
538 switch (inode->i_mode & S_IFMT) { 549 switch (inode->i_mode & S_IFMT) {
539 case S_IFDIR: 550 case S_IFDIR:
@@ -575,6 +586,9 @@ long btrfs_ioctl_rm_dev(struct btrfs_root *root, void __user *arg)
575 struct btrfs_ioctl_vol_args *vol_args; 586 struct btrfs_ioctl_vol_args *vol_args;
576 int ret; 587 int ret;
577 588
589 if (root->fs_info->sb->s_flags & MS_RDONLY)
590 return -EROFS;
591
578 vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS); 592 vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS);
579 593
580 if (!vol_args) 594 if (!vol_args)
@@ -621,6 +635,10 @@ long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, u64 off,
621 * they don't overlap)? 635 * they don't overlap)?
622 */ 636 */
623 637
638 ret = mnt_want_write(file->f_path.mnt);
639 if (ret)
640 return ret;
641
624 src_file = fget(srcfd); 642 src_file = fget(srcfd);
625 if (!src_file) 643 if (!src_file)
626 return -EBADF; 644 return -EBADF;
@@ -958,6 +976,10 @@ long btrfs_ioctl_trans_start(struct file *file)
958 goto out; 976 goto out;
959 } 977 }
960 978
979 ret = mnt_want_write(file->f_path.mnt);
980 if (ret)
981 goto out;
982
961 mutex_lock(&root->fs_info->trans_mutex); 983 mutex_lock(&root->fs_info->trans_mutex);
962 root->fs_info->open_ioctl_trans++; 984 root->fs_info->open_ioctl_trans++;
963 mutex_unlock(&root->fs_info->trans_mutex); 985 mutex_unlock(&root->fs_info->trans_mutex);