gfs2: Special-case rindex for gfs2_grow
Andreas Gruenbacher
maintainerPATCH 1/1 gfs2: Special-case rindex for gfs2_grow
To speed up the common case of appending to a file, gfs2_write_alloc_required presumes that writing beyond the end of a file will always require additional blocks to be allocated. This assumption is incorrect for preallocates files, but there are no negative consequences as long as *some* space is still left on the filesystem.
One special file that always has some space preallocated beyond the end of the file is the rindex: when growing a filesystem, gfs2_grow adds one or more new resource groups and appends records describing those resource groups to the rindex; the preallocated space ensures that this is always possible.
However, when a filesystem is completely full, gfs2_write_alloc_required will indicate that an additional allocation is required, and appending the next record to the rindex will fail even though space for that record has already been preallocated. To fix that, skip the incorrect optimization in gfs2_write_alloc_required, but for the rindex only. Other writes to preallocated space beyond the end of the file are still allowed to fail on completely full filesystems.
--- fs/gfs2/bmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/bmap.c +1 -1
@@ -2316,7 +2316,7 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, end_of_file = (i_size_read (&ip->i_inode) + sdp->sd_sb.sb_bsize -1 ) >> shift; lblock = offset >> shift; lblock_stop = (offset + len + sdp->sd_sb.sb_bsize -1 ) >> shift; -if (lblock_stop > end_of_file) +if (lblock_stop > end_of_file && ip !=GFS2_I (sdp->sd_rindex))return 1 ; size = (lblock_stop - lblock) << shift;
Signature · 1 line
2.17.1
PATCH 1/1 gfs2: Special-case rindex for gfs2_grow
----- Original Message -----
Quoted 20 lines
To speed up the common case of appending to a file,
gfs2_write_alloc_requiredpresumes that writing beyond the end of a file will always require additional blocks to be allocated. This assumption is incorrect for preallocates files, but there are no negative consequences as long as *some* space is still left on the filesystem.One special file that always has some space preallocated beyond the end of the file is the rindex: when growing a filesystem,
gfs2_growadds one or more new resource groups and appends records describing those resource groups to the rindex; the preallocated space ensures that this is always possible.However, when a filesystem is completely full,
gfs2_write_alloc_requiredwill indicate that an additional allocation is required, and appending the next record to the rindex will fail even though space for that record has already been preallocated. To fix that, skip the incorrect optimization ingfs2_write_alloc_required, but for the rindex only. Other writes to preallocated space beyond the end of the file are still allowed to fail on completely full filesystems.
Quoted 1 line
Signed-off-by Andreas Gruenbacher <[email protected]>
Hi,
ACK. Yeah, we need this.
Bob Peterson