[Cluster-devel] [GFS2] [Patch 5/10] Shortcut in gfs2_write_alloc_require
Bob Peterson
rpeterso at redhat.com
Wed Dec 12 01:07:34 UTC 2007
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 <rpeterso at redhat.com>
--
.../fs/gfs2/bmap.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/gfs2-2.6.git.patch4/fs/gfs2/bmap.c b/gfs2-2.6.git.patch5/fs/gfs2/bmap.c
index 4948602..4cdf4d4 100644
--- a/gfs2-2.6.git.patch4/fs/gfs2/bmap.c
+++ b/gfs2-2.6.git.patch5/fs/gfs2/bmap.c
@@ -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;
More information about the Cluster-devel
mailing list