ext4: enforce bigalloc restrictions (e.g., no online resizing, etc.)
authorTheodore Ts'o <tytso@mit.edu>
Fri, 9 Sep 2011 22:36:51 +0000 (18:36 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 9 Sep 2011 22:36:51 +0000 (18:36 -0400)
At least initially if the bigalloc feature is enabled, we will not
support non-extent mapped inodes, online resizing, online defrag, or
the FITRIM ioctl.  This simplifies the initial implementation.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/indirect.c
fs/ext4/inode.c
fs/ext4/ioctl.c
fs/ext4/super.c

index ea704dff866987655ee8a41ab88c260fcd634b86..3cfc73fbca8efee96de0d78ab594794340b9c0e5 100644 (file)
@@ -699,6 +699,13 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
        /*
         * Okay, we need to do block allocation.
        */
+       if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
+                                      EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
+               EXT4_ERROR_INODE(inode, "Can't allocate blocks for "
+                                "non-extent mapped inodes with bigalloc");
+               return -ENOSPC;
+       }
+
        goal = ext4_find_goal(inode, map->m_lblk, partial);
 
        /* the number of blocks need to allocate for [d,t]indirect blocks */
index 6ecc93979e48168d5d62f98de49445152f74a58b..904a9a623dab5e6b6d25925412aee7542837b5a8 100644 (file)
@@ -3358,6 +3358,11 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
                return -ENOTSUPP;
        }
 
+       if (EXT4_SB(inode->i_sb)->s_cluster_ratio > 1) {
+               /* TODO: Add support for bigalloc file systems */
+               return -ENOTSUPP;
+       }
+
        return ext4_ext_punch_hole(file, offset, length);
 }
 
index f18bfe37aff845cedd3dd3acf6c9d0e2225926ae..2046d699b4a7456139e31ec03553ccdbea474209 100644 (file)
@@ -21,6 +21,7 @@
 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
        struct inode *inode = filp->f_dentry->d_inode;
+       struct super_block *sb = inode->i_sb;
        struct ext4_inode_info *ei = EXT4_I(inode);
        unsigned int flags;
 
@@ -183,7 +184,6 @@ setversion_out:
                 * Returns 1 if it slept, else zero.
                 */
                {
-                       struct super_block *sb = inode->i_sb;
                        DECLARE_WAITQUEUE(wait, current);
                        int ret = 0;
 
@@ -199,7 +199,6 @@ setversion_out:
 #endif
        case EXT4_IOC_GROUP_EXTEND: {
                ext4_fsblk_t n_blocks_count;
-               struct super_block *sb = inode->i_sb;
                int err, err2=0;
 
                err = ext4_resize_begin(sb);
@@ -209,6 +208,13 @@ setversion_out:
                if (get_user(n_blocks_count, (__u32 __user *)arg))
                        return -EFAULT;
 
+               if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
+                              EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
+                       ext4_msg(sb, KERN_ERR,
+                                "Online resizing not supported with bigalloc");
+                       return -EOPNOTSUPP;
+               }
+
                err = mnt_want_write(filp->f_path.mnt);
                if (err)
                        return err;
@@ -250,6 +256,13 @@ setversion_out:
                        goto mext_out;
                }
 
+               if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
+                              EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
+                       ext4_msg(sb, KERN_ERR,
+                                "Online defrag not supported with bigalloc");
+                       return -EOPNOTSUPP;
+               }
+
                err = mnt_want_write(filp->f_path.mnt);
                if (err)
                        goto mext_out;
@@ -270,7 +283,6 @@ mext_out:
 
        case EXT4_IOC_GROUP_ADD: {
                struct ext4_new_group_data input;
-               struct super_block *sb = inode->i_sb;
                int err, err2=0;
 
                err = ext4_resize_begin(sb);
@@ -281,6 +293,13 @@ mext_out:
                                sizeof(input)))
                        return -EFAULT;
 
+               if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
+                              EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
+                       ext4_msg(sb, KERN_ERR,
+                                "Online resizing not supported with bigalloc");
+                       return -EOPNOTSUPP;
+               }
+
                err = mnt_want_write(filp->f_path.mnt);
                if (err)
                        return err;
@@ -337,7 +356,6 @@ mext_out:
 
        case FITRIM:
        {
-               struct super_block *sb = inode->i_sb;
                struct request_queue *q = bdev_get_queue(sb->s_bdev);
                struct fstrim_range range;
                int ret = 0;
@@ -348,6 +366,13 @@ mext_out:
                if (!blk_queue_discard(q))
                        return -EOPNOTSUPP;
 
+               if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
+                              EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
+                       ext4_msg(sb, KERN_ERR,
+                                "FITRIM not supported with bigalloc");
+                       return -EOPNOTSUPP;
+               }
+
                if (copy_from_user(&range, (struct fstrim_range *)arg,
                    sizeof(range)))
                        return -EFAULT;
index 823e7d9deee273f7d66a31845dc6658c58a880f2..25a4bfe3f39f45925b102679a74a71cc601910ba 100644 (file)
@@ -2701,6 +2701,13 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly)
                        return 0;
                }
        }
+       if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_BIGALLOC) &&
+           !EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
+               ext4_msg(sb, KERN_ERR,
+                        "Can't support bigalloc feature without "
+                        "extents feature\n");
+               return 0;
+       }
        return 1;
 }