1 ext4: wite the migrate interface to the EXT4_IOC_SETFLAGS ioctl
3 From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
5 This patch hooks the ext3 to ext4 migrate interface to
6 EXT4_IOC_SETFLAGS ioctl. The userspace interface is via
7 chattr +e. We only allow setting extent flags. Clearing
8 extent flag (migrating from ext4 to ext3) is not supported.
10 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
11 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
14 fs/ext4/ioctl.c | 17 ++++++++++++++++-
15 2 files changed, 17 insertions(+), 2 deletions(-)
17 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
18 index 103892b..70e8486 100644
21 @@ -250,7 +250,7 @@ struct flex_groups {
22 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
24 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
25 -#define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
26 +#define EXT4_FL_USER_MODIFIABLE 0x000B80FF /* User modifiable flags */
29 * Inode dynamic state flags
30 diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
31 index 6e02967..94cdd02 100644
34 @@ -34,7 +34,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35 return put_user(flags, (int __user *) arg);
36 case EXT4_IOC_SETFLAGS: {
37 handle_t *handle = NULL;
39 + int err, migrate = 0;
40 struct ext4_iloc iloc;
41 unsigned int oldflags;
43 @@ -82,6 +82,17 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
44 if (!capable(CAP_SYS_RESOURCE))
47 + if (oldflags & EXT4_EXTENTS_FL) {
48 + /* We don't support clearning extent flags */
49 + if (!(flags & EXT4_EXTENTS_FL)) {
53 + } else if (flags & EXT4_EXTENTS_FL) {
54 + /* migrate the file */
56 + flags &= ~EXT4_EXTENTS_FL;
59 handle = ext4_journal_start(inode, 1);
61 @@ -109,6 +120,10 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
63 if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL))
64 err = ext4_change_inode_journal_flag(inode, jflag);
68 + err = ext4_ext_migrate(inode);
70 mutex_unlock(&inode->i_mutex);
71 mnt_drop_write(filp->f_path.mnt);
73 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
74 the body of a message to majordomo@vger.kernel.org
75 More majordomo info at http://vger.kernel.org/majordomo-info.html