From: Chris Mason <mason@suse.com>

Enable preallocation for reiserfs_file_write when the write size is smaller
than the default preallocation size.


---

 25-akpm/fs/reiserfs/file.c  |    8 +++++++-
 25-akpm/fs/reiserfs/super.c |    4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff -puN fs/reiserfs/file.c~reiserfs-prealloc fs/reiserfs/file.c
--- 25/fs/reiserfs/file.c~reiserfs-prealloc	Wed Mar 24 15:14:44 2004
+++ 25-akpm/fs/reiserfs/file.c	Wed Mar 24 15:14:44 2004
@@ -215,7 +215,13 @@ int reiserfs_allocate_blocks_for_region(
     hint.key = key.on_disk_key; // on disk key of file.
     hint.block = inode->i_blocks>>(inode->i_sb->s_blocksize_bits-9); // Number of disk blocks this file occupies already.
     hint.formatted_node = 0; // We are allocating blocks for unformatted node.
-    hint.preallocate = 0; // We do not do any preallocation for now.
+
+    /* only preallocate if this is a small write */
+    if (blocks_to_allocate <
+        REISERFS_SB(inode->i_sb)->s_alloc_options.preallocsize)
+        hint.preallocate = 1;
+    else
+        hint.preallocate = 0;
 
     /* Call block allocator to allocate blocks */
     res = reiserfs_allocate_blocknrs(&hint, allocated_blocks, blocks_to_allocate, blocks_to_allocate);
diff -puN fs/reiserfs/super.c~reiserfs-prealloc fs/reiserfs/super.c
--- 25/fs/reiserfs/super.c~reiserfs-prealloc	Wed Mar 24 15:14:44 2004
+++ 25-akpm/fs/reiserfs/super.c	Wed Mar 24 15:14:44 2004
@@ -1298,8 +1298,8 @@ static int reiserfs_fill_super (struct s
     REISERFS_SB(s)->s_alloc_options.bits = ( 1 << 5);
     /* If file grew past 4 blocks, start preallocation blocks for it. */
     REISERFS_SB(s)->s_alloc_options.preallocmin = 4;
-    /* Preallocate by 8 blocks (9-1) at once */
-    REISERFS_SB(s)->s_alloc_options.preallocsize = 9;
+    /* Preallocate by 16 blocks (17-1) at once */
+    REISERFS_SB(s)->s_alloc_options.preallocsize = 17;
 
     jdev_name = NULL;
     if (reiserfs_parse_options (s, (char *) data, &(sbi->s_mount_opt), &blocks, &jdev_name, &commit_max_age) == 0) {

_