Shortcut in gfs2_write_alloc_require
PATCH 5/10 Shortcut in gfs2_write_alloc_require
Hi,
The gfs2_prepare_write function goes to a lot of trouble trying to figure out if a block allocation will be required for the write. This adds a shortcut: If you're trying to write past end of file, of course you need a new block. This saves us some time. This much safer than other alternatives I've put on the table.
Regards,
Bob Peterson
Red Hat GFS
Signed-off-by Bob Peterson <[email protected]>
--
.../fs/gfs2/bmap.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
gfs2-2.6.git.patch5/fs/gfs2/bmap.c renamed from gfs2-2.6.git.patch4/fs/gfs2/bmap.c +6 -1
@@ -1,6 +1,6 @@/* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. +* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions
@@ -1204,6 +1204,11 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, *alloc_required =0 ; +if (offset + len > ip->i_di.di_size) {/* writing past end of file */ + *alloc_required =1 ; +return 0 ; + } +if (!len)return 0 ;