From: Mingming Cao Allow user shut down reservation-based allocation(using ioctl) on a specific file(e.g. for seeky random write). Signed-off-by: Andrew Morton --- 25-akpm/fs/ext3/balloc.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff -puN fs/ext3/balloc.c~ext3-reservation-allow-turn-off-for-specifed-file fs/ext3/balloc.c --- 25/fs/ext3/balloc.c~ext3-reservation-allow-turn-off-for-specifed-file Mon Oct 18 16:46:07 2004 +++ 25-akpm/fs/ext3/balloc.c Mon Oct 18 16:46:07 2004 @@ -1136,6 +1136,7 @@ int ext3_new_block(handle_t *handle, str struct ext3_super_block *es; struct ext3_sb_info *sbi; struct reserve_window_node *my_rsv = NULL; + struct reserve_window_node *rsv = &EXT3_I(inode)->i_rsv_window; #ifdef EXT3FS_DEBUG static int goal_hits, goal_attempts; #endif @@ -1157,8 +1158,18 @@ int ext3_new_block(handle_t *handle, str sbi = EXT3_SB(sb); es = EXT3_SB(sb)->s_es; ext3_debug("goal=%lu.\n", goal); - if (test_opt(sb, RESERVATION) && S_ISREG(inode->i_mode)) - my_rsv = &EXT3_I(inode)->i_rsv_window; + /* + * Allocate a block from reservation only when + * filesystem is mounted with reservation(default,-o reservation), and + * it's a regular file, and + * the desired window size is greater than 0 (One could use ioctl + * command EXT3_IOC_SETRSVSZ to set the window size to 0 to turn off + * reservation on that particular file) + */ + if (test_opt(sb, RESERVATION) && + S_ISREG(inode->i_mode) && + (atomic_read(&rsv->rsv_goal_size) > 0)) + my_rsv = rsv; if (!ext3_has_free_blocks(sbi)) { *errp = -ENOSPC; goto out; _