Skip to content

Commit bab08ab

Browse files
committed
ext4: enforce bigalloc restrictions (e.g., no online resizing, etc.)
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>
1 parent 281b599 commit bab08ab

4 files changed

Lines changed: 48 additions & 4 deletions

File tree

‎fs/ext4/indirect.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,13 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
699699
/*
700700
* Okay, we need to do block allocation.
701701
*/
702+
if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
703+
EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
704+
EXT4_ERROR_INODE(inode, "Can't allocate blocks for "
705+
"non-extent mapped inodes with bigalloc");
706+
return -ENOSPC;
707+
}
708+
702709
goal = ext4_find_goal(inode, map->m_lblk, partial);
703710

704711
/* the number of blocks need to allocate for [d,t]indirect blocks */

‎fs/ext4/inode.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3358,6 +3358,11 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
33583358
return -ENOTSUPP;
33593359
}
33603360

3361+
if (EXT4_SB(inode->i_sb)->s_cluster_ratio > 1) {
3362+
/* TODO: Add support for bigalloc file systems */
3363+
return -ENOTSUPP;
3364+
}
3365+
33613366
return ext4_ext_punch_hole(file, offset, length);
33623367
}
33633368

‎fs/ext4/ioctl.c‎

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2222
{
2323
struct inode *inode = filp->f_dentry->d_inode;
24+
struct super_block *sb = inode->i_sb;
2425
struct ext4_inode_info *ei = EXT4_I(inode);
2526
unsigned int flags;
2627

@@ -183,7 +184,6 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
183184
* Returns 1 if it slept, else zero.
184185
*/
185186
{
186-
struct super_block *sb = inode->i_sb;
187187
DECLARE_WAITQUEUE(wait, current);
188188
int ret = 0;
189189

@@ -199,7 +199,6 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
199199
#endif
200200
case EXT4_IOC_GROUP_EXTEND: {
201201
ext4_fsblk_t n_blocks_count;
202-
struct super_block *sb = inode->i_sb;
203202
int err, err2=0;
204203

205204
err = ext4_resize_begin(sb);
@@ -209,6 +208,13 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
209208
if (get_user(n_blocks_count, (__u32 __user *)arg))
210209
return -EFAULT;
211210

211+
if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
212+
EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
213+
ext4_msg(sb, KERN_ERR,
214+
"Online resizing not supported with bigalloc");
215+
return -EOPNOTSUPP;
216+
}
217+
212218
err = mnt_want_write(filp->f_path.mnt);
213219
if (err)
214220
return err;
@@ -250,6 +256,13 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
250256
goto mext_out;
251257
}
252258

259+
if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
260+
EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
261+
ext4_msg(sb, KERN_ERR,
262+
"Online defrag not supported with bigalloc");
263+
return -EOPNOTSUPP;
264+
}
265+
253266
err = mnt_want_write(filp->f_path.mnt);
254267
if (err)
255268
goto mext_out;
@@ -270,7 +283,6 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
270283

271284
case EXT4_IOC_GROUP_ADD: {
272285
struct ext4_new_group_data input;
273-
struct super_block *sb = inode->i_sb;
274286
int err, err2=0;
275287

276288
err = ext4_resize_begin(sb);
@@ -281,6 +293,13 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
281293
sizeof(input)))
282294
return -EFAULT;
283295

296+
if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
297+
EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
298+
ext4_msg(sb, KERN_ERR,
299+
"Online resizing not supported with bigalloc");
300+
return -EOPNOTSUPP;
301+
}
302+
284303
err = mnt_want_write(filp->f_path.mnt);
285304
if (err)
286305
return err;
@@ -337,7 +356,6 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
337356

338357
case FITRIM:
339358
{
340-
struct super_block *sb = inode->i_sb;
341359
struct request_queue *q = bdev_get_queue(sb->s_bdev);
342360
struct fstrim_range range;
343361
int ret = 0;
@@ -348,6 +366,13 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
348366
if (!blk_queue_discard(q))
349367
return -EOPNOTSUPP;
350368

369+
if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
370+
EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
371+
ext4_msg(sb, KERN_ERR,
372+
"FITRIM not supported with bigalloc");
373+
return -EOPNOTSUPP;
374+
}
375+
351376
if (copy_from_user(&range, (struct fstrim_range *)arg,
352377
sizeof(range)))
353378
return -EFAULT;

‎fs/ext4/super.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,6 +2701,13 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly)
27012701
return 0;
27022702
}
27032703
}
2704+
if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_BIGALLOC) &&
2705+
!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
2706+
ext4_msg(sb, KERN_ERR,
2707+
"Can't support bigalloc feature without "
2708+
"extents feature\n");
2709+
return 0;
2710+
}
27042711
return 1;
27052712
}
27062713

0 commit comments

Comments
 (0)