1 ext4: online defrag: Add the EXT4_IOC_BLOCK_RELEASE ioctl.
3 From: Akira Fujita <a-fujita@rs.jp.nec.com>
5 The EXT4_IOC_BLOCK_RELEASE releases the reserved blocks
6 which target inode holds.
7 This ioctl is used if defrag failed and it was after the block reservation.
9 The block reservation will be removed from defrag in the next version,
10 so this ioctl also will go away.
12 Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
13 Signed-off-by: Takashi Sato <t-sato@yk.jp.nec.com>
15 fs/ext4/defrag.c | 4 ++++
17 fs/ext4/ioctl.c | 3 ++-
18 3 files changed, 7 insertions(+), 1 deletions(-)
20 diff --git a/fs/ext4/defrag.c b/fs/ext4/defrag.c
21 index a2b17c5..bdfbb68 100644
22 --- a/fs/ext4/defrag.c
23 +++ b/fs/ext4/defrag.c
24 @@ -622,6 +622,10 @@ int ext4_defrag_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
26 err = ext4_defrag_move_victim(filp, &ext_info);
28 + } else if (cmd == EXT4_IOC_BLOCK_RELEASE) {
29 + down_write(&EXT4_I(inode)->i_data_sem);
30 + ext4_discard_reservation(inode);
31 + up_write(&EXT4_I(inode)->i_data_sem);
32 } else if (cmd == EXT4_IOC_DEFRAG) {
33 struct ext4_ext_defrag_data defrag;
34 struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
35 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
36 index 4e54eb4..6ad86f9 100644
39 @@ -314,6 +314,7 @@ struct ext4_new_group_data {
40 #define EXT4_IOC_FIEMAP_INO _IOW('f', 19, struct fiemap_ino)
41 #define EXT4_IOC_RESERVE_BLOCK _IOW('f', 20, struct ext4_extents_info)
42 #define EXT4_IOC_MOVE_VICTIM _IOW('f', 21, struct ext4_extents_info)
43 +#define EXT4_IOC_BLOCK_RELEASE _IO('f', 22)
46 * ioctl commands in 32 bit emulation
47 diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
48 index a596785..329847f 100644
51 @@ -262,7 +262,8 @@ setversion_out:
52 case EXT4_IOC_FREE_BLOCKS_INFO:
53 case EXT4_IOC_FIEMAP_INO:
54 case EXT4_IOC_RESERVE_BLOCK:
55 - case EXT4_IOC_MOVE_VICTIM: {
56 + case EXT4_IOC_MOVE_VICTIM:
57 + case EXT4_IOC_BLOCK_RELEASE: {
58 return ext4_defrag_ioctl(inode, filp, cmd, arg);
60 case EXT4_IOC_GROUP_ADD: {
63 To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
64 the body of a message to majordomo@vger.kernel.org
65 More majordomo info at http://vger.kernel.org/majordomo-info.html