From patchwork Sat Sep 27 07:27:19 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akira Fujita X-Patchwork-Id: 1767 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 246D5DDD0C for ; Sat, 27 Sep 2008 17:27:26 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752130AbYI0H1Y (ORCPT ); Sat, 27 Sep 2008 03:27:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752051AbYI0H1X (ORCPT ); Sat, 27 Sep 2008 03:27:23 -0400 Received: from TYO201.gate.nec.co.jp ([202.32.8.193]:42387 "EHLO tyo201.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751629AbYI0H1V (ORCPT ); Sat, 27 Sep 2008 03:27:21 -0400 Received: from mailgate3.nec.co.jp ([10.7.69.197]) by tyo201.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id m8R7RJxL001798; Sat, 27 Sep 2008 16:27:19 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id m8R7RJf20813; Sat, 27 Sep 2008 16:27:19 +0900 (JST) Received: from kuichi.jp.nec.com (kuichi.jp.nec.com [10.26.220.17]) by mailsv4.nec.co.jp (8.13.8/8.13.4) with ESMTP id m8R7RJAL014549; Sat, 27 Sep 2008 16:27:19 +0900 (JST) Received: from [10.64.168.93] ([10.64.168.93] [10.64.168.93]) by mail.jp.nec.com with ESMTP; Sat, 27 Sep 2008 16:27:19 +0900 Message-ID: <48DDE057.4010703@rs.jp.nec.com> Date: Sat, 27 Sep 2008 16:27:19 +0900 From: Akira Fujita User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: linux-ext4@vger.kernel.org CC: linux-fsdevel@vger.kernel.org Subject: [RFC][PATCH 11/12]ext4: Add the EXT4_IOC_BLOCK_RELEASE ioctl Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org ext4: online defrag -- Add the EXT4_IOC_BLOCK_RELEASE ioctl. From: Akira Fujita The EXT4_IOC_BLOCK_RELEASE releases the reserved blocks which target inode holds. This ioctl is used if defrag failed and it was after the block reservation. The block reservation will be removed from defrag in the next version, so this ioctl also will go away. Signed-off-by: Akira Fujita Signed-off-by: Takashi Sato --- fs/ext4/defrag.c | 4 ++++ fs/ext4/ext4.h | 1 + fs/ext4/ioctl.c | 3 ++- 3 files changed, 7 insertions(+), 1 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/ext4/defrag.c b/fs/ext4/defrag.c index a2b17c5..bdfbb68 100644 --- a/fs/ext4/defrag.c +++ b/fs/ext4/defrag.c @@ -622,6 +622,10 @@ int ext4_defrag_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, err = ext4_defrag_move_victim(filp, &ext_info); + } else if (cmd == EXT4_IOC_BLOCK_RELEASE) { + down_write(&EXT4_I(inode)->i_data_sem); + ext4_discard_reservation(inode); + up_write(&EXT4_I(inode)->i_data_sem); } else if (cmd == EXT4_IOC_DEFRAG) { struct ext4_ext_defrag_data defrag; struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es; diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 4e54eb4..6ad86f9 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -314,6 +314,7 @@ struct ext4_new_group_data { #define EXT4_IOC_FIEMAP_INO _IOW('f', 19, struct fiemap_ino) #define EXT4_IOC_RESERVE_BLOCK _IOW('f', 20, struct ext4_extents_info) #define EXT4_IOC_MOVE_VICTIM _IOW('f', 21, struct ext4_extents_info) +#define EXT4_IOC_BLOCK_RELEASE _IO('f', 22) /* * ioctl commands in 32 bit emulation diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index a596785..329847f 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -262,7 +262,8 @@ setversion_out: case EXT4_IOC_FREE_BLOCKS_INFO: case EXT4_IOC_FIEMAP_INO: case EXT4_IOC_RESERVE_BLOCK: - case EXT4_IOC_MOVE_VICTIM: { + case EXT4_IOC_MOVE_VICTIM: + case EXT4_IOC_BLOCK_RELEASE: { return ext4_defrag_ioctl(inode, filp, cmd, arg); } case EXT4_IOC_GROUP_ADD: {