[PATCH 4/4] ext3 block reservation patch set -- dynamically increase reservation window

Mingming Cao
2004-04-14T00:54:01Z

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

> [patch 4]ext3_rsv_dw.patch: adjust the reservation window size
> dynamically:
> Start from the deault reservation window size, if the hit ration of
> the reservation window is more than 50%, we will double the reservation
> window size next time up to a certain upper limit.

diffstat ext3_rsv_dw.patch
fs/ext3/balloc.c | 13 ++++++++++++-
fs/ext3/ialloc.c | 3 ++-
fs/ext3/super.c | 1 +
include/linux/ext3_fs_i.h | 1 +
4 files changed, 16 insertions(+), 2 deletions(-)

[-- Attachment #2: ext3_rsv_dw.patch --]
[-- Type: text/x-patch, Size: 2912 bytes --]

diff -urNp 264-rsv-cleanup-base-mount/fs/ext3/balloc.c 264-rsv-cleanup-base-mount-dw/fs/ext3/balloc.c
--- 264-rsv-cleanup-base-mount/fs/ext3/balloc.c 2004-04-13 01:44:50.091477008 -0700
+++ 264-rsv-cleanup-base-mount-dw/fs/ext3/balloc.c 2004-04-12 22:15:12.128618008 -0700
@@ -148,6 +148,7 @@ static inline void rsv_window_remove(str
{
rsv->rsv_start = 0;
rsv->rsv_end = 0;
+ rsv->rsv_alloc_hit = 0;
list_del(&rsv->rsv_list);
INIT_LIST_HEAD(&rsv->rsv_list);
}
@@ -548,7 +549,8 @@ repeat:
goto fail_access;
goto repeat;
}
-
+ if (my_rsv)
+ my_rsv->rsv_alloc_hit++;
return goal;
fail_access:
return -1;
@@ -731,6 +733,15 @@ static int alloc_new_reservation(struct
start_block = my_rsv->rsv_end + 1;
search_head = list_entry(my_rsv->rsv_list.prev,
struct reserve_window, rsv_list);
+ if ((my_rsv->rsv_alloc_hit > (my_rsv->rsv_end - my_rsv->rsv_start + 1) / 2)) {
+ /*
+ * if we previously allocation hit ration is greater than half
+ * we double the size of reservation window next time
+ * otherwise keep the same
+ */
+ size = size * 2;
+ atomic_set(&my_rsv->rsv_goal_size, size);
+ }
rsv_window_remove(my_rsv);
}
else {
diff -urNp 264-rsv-cleanup-base-mount/fs/ext3/ialloc.c 264-rsv-cleanup-base-mount-dw/fs/ext3/ialloc.c
--- 264-rsv-cleanup-base-mount/fs/ext3/ialloc.c 2004-04-10 01:19:52.705503744 -0700
+++ 264-rsv-cleanup-base-mount-dw/fs/ext3/ialloc.c 2004-04-12 21:46:19.443026256 -0700
@@ -583,8 +583,9 @@ got:
ei->i_dir_acl = 0;
ei->i_dtime = 0;
ei->i_rsv_window.rsv_start = 0;
- ei->i_rsv_window.rsv_end= 0;
+ ei->i_rsv_window.rsv_end = 0;
atomic_set(&ei->i_rsv_window.rsv_goal_size, EXT3_DEFAULT_RESERVE_BLOCKS);
+ ei->i_rsv_window.rsv_alloc_hit = 0;
INIT_LIST_HEAD(&ei->i_rsv_window.rsv_list);
ei->i_block_group = group;

diff -urNp 264-rsv-cleanup-base-mount/fs/ext3/super.c 264-rsv-cleanup-base-mount-dw/fs/ext3/super.c
--- 264-rsv-cleanup-base-mount/fs/ext3/super.c 2004-04-10 01:19:52.719501616 -0700
+++ 264-rsv-cleanup-base-mount-dw/fs/ext3/super.c 2004-04-12 21:47:00.612767504 -0700
@@ -1312,6 +1312,7 @@ static int ext3_fill_super (struct super
INIT_LIST_HEAD(&sbi->s_rsv_window_head.rsv_list);
sbi->s_rsv_window_head.rsv_start = 0;
sbi->s_rsv_window_head.rsv_end = 0;
+ sbi->s_rsv_window_head.rsv_alloc_hit = 0;
atomic_set(&sbi->s_rsv_window_head.rsv_goal_size, 0);

/*
diff -urNp 264-rsv-cleanup-base-mount/include/linux/ext3_fs_i.h 264-rsv-cleanup-base-mount-dw/include/linux/ext3_fs_i.h
--- 264-rsv-cleanup-base-mount/include/linux/ext3_fs_i.h 2004-04-10 01:19:52.723501008 -0700
+++ 264-rsv-cleanup-base-mount-dw/include/linux/ext3_fs_i.h 2004-04-12 21:43:25.019542656 -0700
@@ -23,6 +23,7 @@ struct reserve_window{
__u32 rsv_start;
__u32 rsv_end;
atomic_t rsv_goal_size;
+ __u32 rsv_alloc_hit;
};

/*