Index: linus.10/fs/reiserfs/file.c
--- linus.10/fs/reiserfs/file.c Tue, 06 Nov 2001 15:47:39 -0500 root (linux/36_file.c 1.1 644)
+++ linus.10(w)/fs/reiserfs/file.c Tue, 27 Nov 2001 10:02:23 -0500 root (linux/36_file.c 1.1 644)
@@ -100,6 +100,20 @@
         if (inode_items_version(inode) == ITEM_VERSION_1 && 
 	    attr->ia_size > MAX_NON_LFS)
             return -EFBIG ;
+
+	/* fill in hole pointers in the expanding truncate case. */
+        if (attr->ia_size > inode->i_size) {
+	    error = generic_cont_expand(inode, attr->ia_size) ;
+	    if (inode->u.reiserfs_i.i_prealloc_count > 0) {
+		struct reiserfs_transaction_handle th ;
+		/* we're changing at most 2 bitmaps, inode + super */
+		journal_begin(&th, inode->i_sb, 4) ;
+		reiserfs_discard_prealloc (&th, inode);
+		journal_end(&th, inode->i_sb, 4) ;
+	    }
+	    if (error)
+	        return error ;
+	}
     }
 
     error = inode_change_ok(inode, attr) ;
Index: linus.10/fs/reiserfs/inode.c
--- linus.10/fs/reiserfs/inode.c Tue, 06 Nov 2001 15:52:42 -0500 root (linux/45_inode.c 1.2 644)
+++ linus.10(w)/fs/reiserfs/inode.c Mon, 26 Nov 2001 16:20:16 -0500 root (linux/45_inode.c 1.2 644)
@@ -1995,7 +1998,7 @@
     /* we test for O_SYNC here so we can commit the transaction
     ** for any packed tails the file might have had
     */
-    if (f->f_flags & O_SYNC) {
+    if (f && f->f_flags & O_SYNC) {
 	lock_kernel() ;
  	reiserfs_commit_for_inode(inode) ;
 	unlock_kernel();
Index: linus.10/fs/buffer.c
--- linus.10/fs/buffer.c Fri, 16 Nov 2001 10:39:17 -0500 root (linux/i/45_buffer.c 1.4 644)
+++ linus.10(w)/fs/buffer.c Mon, 26 Nov 2001 14:14:24 -0500 root (linux/i/45_buffer.c 1.4 644)
@@ -1758,6 +1758,46 @@
 	return 0;
 }
 
+int generic_cont_expand(struct inode *inode, loff_t size)
+{
+	struct address_space *mapping = inode->i_mapping;
+	struct page *page;
+	unsigned long index, offset, limit;
+	int err;
+
+	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+	if (limit != RLIM_INFINITY) {
+		if (size > limit) {
+			send_sig(SIGXFSZ, current, 0);
+			size = limit;
+		}
+	}
+	offset = (size & (PAGE_CACHE_SIZE-1)); /* Within page */
+
+	/* ugh.  in prepare/commit_write, if from==to==start of block, we 
+	** skip the prepare.  make sure we never send an offset for the start
+	** of a block
+	*/
+	if ((offset & (inode->i_sb->s_blocksize - 1)) == 0) {
+	    offset++ ;
+	}
+	index = size >> PAGE_CACHE_SHIFT;
+	err = -ENOMEM;
+	page = grab_cache_page(mapping, index);
+	if (!page)
+		goto out;
+	err = mapping->a_ops->prepare_write(NULL, page, offset, offset);
+	if (!err) {
+		err = mapping->a_ops->commit_write(NULL, page, offset, offset);
+	}
+	UnlockPage(page);
+	page_cache_release(page);
+	if (err > 0)
+		err = 0;
+out:
+	return err;
+}
+
 /*
  * For moronic filesystems that do not allow holes in file.
  * We may have to extend the file.
Index: linus.10/kernel/ksyms.c
--- linus.10/kernel/ksyms.c Tue, 06 Nov 2001 15:53:06 -0500 root (linux/m/c/25_ksyms.c 1.4 644)
+++ linus.10(w)/kernel/ksyms.c Mon, 26 Nov 2001 14:14:24 -0500 root (linux/m/c/25_ksyms.c 1.4 644)
@@ -203,6 +203,7 @@
 EXPORT_SYMBOL(block_read_full_page);
 EXPORT_SYMBOL(block_prepare_write);
 EXPORT_SYMBOL(block_sync_page);
+EXPORT_SYMBOL(generic_cont_expand);
 EXPORT_SYMBOL(cont_prepare_write);
 EXPORT_SYMBOL(generic_commit_write);
 EXPORT_SYMBOL(block_truncate_page);
Index: linus.10/include/linux/fs.h
--- linus.10/include/linux/fs.h Tue, 20 Nov 2001 10:02:20 -0500 root (linux/e/d/3_fs.h 1.2.1.1.1.1 644)
+++ linus.10(w)/include/linux/fs.h Mon, 26 Nov 2001 14:24:01 -0500 root (linux/e/d/3_fs.h 1.2.1.1.1.1 644)
@@ -1380,6 +1380,7 @@
 extern int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
 extern int cont_prepare_write(struct page*, unsigned, unsigned, get_block_t*,
 				unsigned long *);
+extern int generic_cont_expand(struct inode *inode, loff_t size) ;
 extern int block_commit_write(struct page *page, unsigned from, unsigned to);
 extern int block_sync_page(struct page *);
 
