Add missing patches (centralize-proc-functions and make-proc-generic)
[ext4-patch-queue.git] / hook_migrate_interface_to_setflags_ioctl
blobe47478c6afb22e63527c88c940f1295c9147f817
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>
12 ---
13  fs/ext4/ext4.h  |    2 +-
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
19 --- a/fs/ext4/ext4.h
20 +++ b/fs/ext4/ext4.h
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 */
28  /*
29   * Inode dynamic state flags
30 diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
31 index 6e02967..94cdd02 100644
32 --- a/fs/ext4/ioctl.c
33 +++ b/fs/ext4/ioctl.c
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;
38 -               int err;
39 +               int err, migrate = 0;
40                 struct ext4_iloc iloc;
41                 unsigned int oldflags;
42                 unsigned int jflag;
43 @@ -82,6 +82,17 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
44                         if (!capable(CAP_SYS_RESOURCE))
45                                 goto flags_out;
46                 }
47 +               if (oldflags & EXT4_EXTENTS_FL) {
48 +                       /* We don't support clearning extent flags */
49 +                       if (!(flags & EXT4_EXTENTS_FL)) {
50 +                               err = -EOPNOTSUPP;
51 +                               goto flags_out;
52 +                       }
53 +               } else if (flags & EXT4_EXTENTS_FL) {
54 +                       /* migrate the file */
55 +                       migrate = 1;
56 +                       flags &= ~EXT4_EXTENTS_FL;
57 +               }
59                 handle = ext4_journal_start(inode, 1);
60                 if (IS_ERR(handle)) {
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);
65 +               if (err)
66 +                       goto flags_out;
67 +               if (migrate)
68 +                       err = ext4_ext_migrate(inode);
69  flags_out:
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