aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2008-10-08 23:34:06 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-10-08 23:34:06 -0400
commit4db46fc266b84a04b73b7a4c6ebe8a543a62a2ff (patch)
tree603429d04ff87a2ffbcd311420aa1a2b2ba54d41 /fs
parent2a43a878001cc5cb7c3c7be2e8dad0a1aeb939b0 (diff)
ext4: hook the ext3 migration interface to the EXT4_IOC_SETFLAGS ioctl
This patch hooks the ext3 to ext4 migrate interface to EXT4_IOC_SETFLAGS ioctl. The userspace interface is via chattr +e. We only allow setting extent flags. Clearing extent flag (migrating from ext4 to ext3) is not supported. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/ext4.h2
-rw-r--r--fs/ext4/ioctl.c17
2 files changed, 17 insertions, 2 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 9b6ad8f19bc9..068adc1d5607 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -245,7 +245,7 @@ struct flex_groups {
245#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */ 245#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
246 246
247#define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */ 247#define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
248#define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */ 248#define EXT4_FL_USER_MODIFIABLE 0x000B80FF /* User modifiable flags */
249 249
250/* 250/*
251 * Inode dynamic state flags 251 * Inode dynamic state flags
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 9f3044ac6994..3e14060b398e 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -34,7 +34,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34 return put_user(flags, (int __user *) arg); 34 return put_user(flags, (int __user *) arg);
35 case EXT4_IOC_SETFLAGS: { 35 case EXT4_IOC_SETFLAGS: {
36 handle_t *handle = NULL; 36 handle_t *handle = NULL;
37 int err; 37 int err, migrate = 0;
38 struct ext4_iloc iloc; 38 struct ext4_iloc iloc;
39 unsigned int oldflags; 39 unsigned int oldflags;
40 unsigned int jflag; 40 unsigned int jflag;
@@ -82,6 +82,17 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
82 if (!capable(CAP_SYS_RESOURCE)) 82 if (!capable(CAP_SYS_RESOURCE))
83 goto flags_out; 83 goto flags_out;
84 } 84 }
85 if (oldflags & EXT4_EXTENTS_FL) {
86 /* We don't support clearning extent flags */
87 if (!(flags & EXT4_EXTENTS_FL)) {
88 err = -EOPNOTSUPP;
89 goto flags_out;
90 }
91 } else if (flags & EXT4_EXTENTS_FL) {
92 /* migrate the file */
93 migrate = 1;
94 flags &= ~EXT4_EXTENTS_FL;
95 }
85 96
86 handle = ext4_journal_start(inode, 1); 97 handle = ext4_journal_start(inode, 1);
87 if (IS_ERR(handle)) { 98 if (IS_ERR(handle)) {
@@ -109,6 +120,10 @@ flags_err:
109 120
110 if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) 121 if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL))
111 err = ext4_change_inode_journal_flag(inode, jflag); 122 err = ext4_change_inode_journal_flag(inode, jflag);
123 if (err)
124 goto flags_out;
125 if (migrate)
126 err = ext4_ext_migrate(inode);
112flags_out: 127flags_out:
113 mutex_unlock(&inode->i_mutex); 128 mutex_unlock(&inode->i_mutex);
114 mnt_drop_write(filp->f_path.mnt); 129 mnt_drop_write(filp->f_path.mnt);