ext4: Add EXT4_IOC_CLR_GLOBAL_ALLOC_RULE clears block allocation restriction
Subsystems (2)
RFC PATCH 2/7 ext4: Add EXT4_IOC_CLR_GLOBAL_ALLOC_RULE clears block allocation restriction
ext4: Add EXT4_IOC_CLR_GLOBAL_ALLOC_RULE clears block allocation restriction
From: Akira Fujita <[email protected]>
Block allocation restriction is cleared with this ioctl or umount filesystem.
#define EXT4_IOC_CLR_GLOBAL_ALLOC_RULE _IOW('f', 17, struct ext4_alloc_rule); struct ext4_alloc_rule {
__u64 start; /* start physical offset to clear rule */
__u64 len; /* number of blocks to be clear */
__u32 alloc_flag; /* not used, should be zero */};
For example, block allocation restriction (1) has been already set on FS, and call EXT4_IOC_CLR_GLOBAL_ALLOC_RULE (2),
As a result, block allocation restriction is divided into two.
(1) start:5000, len:1000, flag:0
(2) start:5500, len:100
(3) start:5000, len:500, flag:0
(4) start:5600, len:400, flag:0
<Before>
BG#0 |-------------------------------|
0 |***********| 32767
5000 (1) 5999 <After>
BG#0 |-------------------------------|
0 |****| |***| 32767
5000 5499 5600 5999
(3) (4)--- fs/ext4/ext4.h | 3 + fs/ext4/ioctl.c | 16 +++++ fs/ext4/mballoc.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+), 0 deletions(-)
fs/ext4/ext4.h +3 -0
@@ -357,6 +357,7 @@ struct ext4_new_group_data {#define EXT4_IOC_ALLOC_DA_BLKS _IO('f', 12)#define EXT4_IOC_MOVE_EXT _IOWR('f', 15, struct move_extent)#define EXT4_IOC_ADD_GLOBAL_ALLOC_RULE _IOW('f', 16, struct ext4_alloc_rule) +#define EXT4_IOC_CLR_GLOBAL_ALLOC_RULE _IOW('f', 17, struct ext4_alloc_rule)/* * ioctl commands in 32 bit emulation
@@ -1386,6 +1387,8 @@ extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);extern void ext4_mb_put_buddy_cache_lock (struct super_block *,ext4_group_t ,int );extern int ext4_mb_add_global_arule (struct inode *,struct ext4_alloc_rule *); +extern int ext4_mb_del_global_arule (struct inode *,struct ext4_alloc_rule *); +extern void ext4_mb_release_arule_list (struct ext4_sb_info *);/* inode.c */ int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
fs/ext4/ioctl.c +16 -0
@@ -276,6 +276,22 @@ setversion_out:return err; } +case EXT4_IOC_CLR_GLOBAL_ALLOC_RULE : { +struct ext4_alloc_rule arule; +int err; + +if (copy_from_user (&arule, + (struct ext4_alloc_rule __user *)arg, +sizeof (arule))) +return -EFAULT ; + +if (!capable (CAP_SYS_ADMIN )) +return -EPERM ; + + err =ext4_mb_del_global_arule (inode, &arule); +return err; + } +case EXT4_IOC_GROUP_ADD : {struct ext4_new_group_data input;struct super_block *sb = inode->i_sb;
fs/ext4/mballoc.c +186 -0
201 lines not on this page · raw message
Quoted 9 lines · Akira Fujita
Block allocation restriction is cleared with this ioctl or umount filesystem.
#define
EXT4_IOC_CLR_GLOBAL_ALLOC_RULE_IOW('f', 17, struct ext4_alloc_rule);struct
ext4_alloc_rule{__u64 start; /* start physical offset to clear rule */ __u64 len; /* number of blocks to be clear */ __u32 alloc_flag; /* not used, should be zero */};
Why not call EXT4_IOC_ADD_GLOBAL_ALLOC_RULE with a "clear" flag?
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
Hi Andreas,
Quoted 5 lines · Andreas Dilger
Quoted 4 lines · Akira Fujita
Block allocation restriction is cleared with this ioctl or umount filesystem.
#define
EXT4_IOC_CLR_GLOBAL_ALLOC_RULE_IOW('f', 17, struct ext4_alloc_rule);
Quoted 7 lines
Quoted 5 lines
struct
ext4_alloc_rule{__u64 start; /* start physical offset to clear rule */ __u64 len; /* number of blocks to be clear */ __u32 alloc_flag; /* not used, should be zero */};
Why not call
EXT4_IOC_ADD_GLOBAL_ALLOC_RULEwith a "clear" flag?
Yes, having "clear" flag makes more sense
than implementing ioctls separately.
I will add "clear" flag (EXT4_MB_CLEAR_ALLOC_RULE) to alloc_flag and remove EXT4_IOC_CLR_GLOBAL_ALLOC_RULE ioctl in the next version.
Thanks,
Akira Fujita