gfs2_grow: write one rindex entry and then the rest
PATCH 1/1 gfs2_grow: write one rindex entry and then the rest
There is a problem with gfs2_grow when the rindex file is stuffed, or the filesystem blocksize is smaller than the pagesize. When gfs2_grow writes out all the rindex entries at once, there needs to be enough space left for it to be able to write the first page of data without doing any allocations. If there isn't gfs2_grow will fail, even though there is space for additional resrouce groups in the last block of the rindex file. This patch makes gfs2_grow write one rindex entry frist, to grow the filesystem by one resource group's worth of space. Then it writes the rest. Since the code guarantees that there will always be enough space in the rindex file for one more rindex entry, the first write will never require an allocation.
--- gfs2/mkfs/main_grow.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
gfs2/mkfs/main_grow.c +12 -2
@@ -244,8 +244,18 @@ static void fix_rindex(struct gfs2_sbd *sdp, int rindex_fd, int old_rg_count) }/* Now write the new RGs to the end of the rindex */ lseek (rindex_fd,0 ,SEEK_END ); - count =write (rindex_fd, buf, writelen); -if (count != writelen) { + count =write (rindex_fd, buf,sizeof (struct gfs2_rindex )); +if (count !=sizeof (struct gfs2_rindex )) { +log_crit ("Error writing first new rindex entry;" +"aborted.\n" ); +if (count >0 ) + goto trunc; +else + goto out; + } + count =write (rindex_fd, buf +sizeof (struct gfs2_rindex ), + writelen -sizeof (struct gfs2_rindex )); +if (count != writelen -sizeof (struct gfs2_rindex )) {log_crit ("Error writing new rindex entries;" "aborted.\n" );if (count >0 )
Signature · 1 line
1.5.3.3
PATCH 1/1 gfs2_grow: write one rindex entry and then the rest
Hi,
Looks good to me,
Steve.
Quoted 42 lines · Benjamin Marzinski
There is a problem with
gfs2_growwhen the rindex file is stuffed, or the filesystem blocksize is smaller than the pagesize. Whengfs2_growwrites out all the rindex entries at once, there needs to be enough space left for it to be able to write the first page of data without doing any allocations. If there isn'tgfs2_growwill fail, even though there is space for additional resrouce groups in the last block of the rindex file. This patch makesgfs2_growwrite one rindex entry frist, to grow the filesystem by one resource group's worth of space. Then it writes the rest. Since the code guarantees that there will always be enough space in the rindex file for one more rindex entry, the first write will never require an allocation.Signed-off-by Benjamin Marzinski <[email protected]>--- gfs2/mkfs/main_grow.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)gfs2/mkfs/main_grow.c +12
-2@@ -244,8 +244,18 @@ static void fix_rindex(struct gfs2_sbd *sdp, int rindex_fd, int old_rg_count) }/* Now write the new RGs to the end of the rindex */ lseek (rindex_fd,0 ,SEEK_END ); - count =write (rindex_fd, buf, writelen); -if (count != writelen) { + count =write (rindex_fd, buf,sizeof (struct gfs2_rindex )); +if (count !=sizeof (struct gfs2_rindex )) { +log_crit ("Error writing first new rindex entry;" +"aborted.\n" ); +if (count >0 ) + goto trunc; +else + goto out; + } + count =write (rindex_fd, buf +sizeof (struct gfs2_rindex ), + writelen -sizeof (struct gfs2_rindex )); +if (count != writelen -sizeof (struct gfs2_rindex )) {log_crit ("Error writing new rindex entries;" "aborted.\n" );if (count >0 )