diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2011-05-04 12:23:58 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2011-05-10 09:21:46 -0400 |
commit | 4e33f9eab07e985282fece4121066c2db1d332ed (patch) | |
tree | 08161cabc013f0543d65d9c9ed63689f9f68803d /fs/nilfs2/ioctl.c | |
parent | 78eb64c2479e0f408b725c3c8e1cdf557857af48 (diff) |
nilfs2: implement resize ioctl
This adds resize ioctl which makes online resize possible.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/ioctl.c')
-rw-r--r-- | fs/nilfs2/ioctl.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index 6f617773a7f7..41d6743d303c 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c | |||
@@ -698,6 +698,31 @@ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp, | |||
698 | return 0; | 698 | return 0; |
699 | } | 699 | } |
700 | 700 | ||
701 | static int nilfs_ioctl_resize(struct inode *inode, struct file *filp, | ||
702 | void __user *argp) | ||
703 | { | ||
704 | __u64 newsize; | ||
705 | int ret = -EPERM; | ||
706 | |||
707 | if (!capable(CAP_SYS_ADMIN)) | ||
708 | goto out; | ||
709 | |||
710 | ret = mnt_want_write(filp->f_path.mnt); | ||
711 | if (ret) | ||
712 | goto out; | ||
713 | |||
714 | ret = -EFAULT; | ||
715 | if (copy_from_user(&newsize, argp, sizeof(newsize))) | ||
716 | goto out_drop_write; | ||
717 | |||
718 | ret = nilfs_resize_fs(inode->i_sb, newsize); | ||
719 | |||
720 | out_drop_write: | ||
721 | mnt_drop_write(filp->f_path.mnt); | ||
722 | out: | ||
723 | return ret; | ||
724 | } | ||
725 | |||
701 | static int nilfs_ioctl_set_alloc_range(struct inode *inode, void __user *argp) | 726 | static int nilfs_ioctl_set_alloc_range(struct inode *inode, void __user *argp) |
702 | { | 727 | { |
703 | struct the_nilfs *nilfs = inode->i_sb->s_fs_info; | 728 | struct the_nilfs *nilfs = inode->i_sb->s_fs_info; |
@@ -795,6 +820,8 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
795 | return nilfs_ioctl_clean_segments(inode, filp, cmd, argp); | 820 | return nilfs_ioctl_clean_segments(inode, filp, cmd, argp); |
796 | case NILFS_IOCTL_SYNC: | 821 | case NILFS_IOCTL_SYNC: |
797 | return nilfs_ioctl_sync(inode, filp, cmd, argp); | 822 | return nilfs_ioctl_sync(inode, filp, cmd, argp); |
823 | case NILFS_IOCTL_RESIZE: | ||
824 | return nilfs_ioctl_resize(inode, filp, argp); | ||
798 | case NILFS_IOCTL_SET_ALLOC_RANGE: | 825 | case NILFS_IOCTL_SET_ALLOC_RANGE: |
799 | return nilfs_ioctl_set_alloc_range(inode, argp); | 826 | return nilfs_ioctl_set_alloc_range(inode, argp); |
800 | default: | 827 | default: |