gfs2_grow: Fix gfs2_grow when only one RG is present
PATCH 1/1 gfs2_grow: Fix gfs2_grow when only one RG is present
If there is only one RG in the filesystem gfs2_grow will make a subtraction using a null pointer to check the RG size returning a invalide RG size value.
This patch avoid this substraction if there is only one RG in the filesystem.
--- gfs2/mkfs/main_grow.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
gfs2/mkfs/main_grow.c +5 -1
@@ -133,7 +133,11 @@ static void figure_out_rgsize(struct gfs2_sbd *sdp, unsigned int *orgsize) r1 = osi_list_entry(head->next->next, struct rgrp_list, list); r2 = osi_list_entry(head->next->next->next, struct rgrp_list, list); - *orgsize = r2->ri.ri_addr - r1->ri.ri_addr; +if (r2->ri.ri_addr){ + *orgsize = r2->ri.ri_addr - r1->ri.ri_addr; + }else { + *orgsize = r1->ri.ri_addr; + } }/**
Signature · 1 line
1.7.5.2
PATCH 1/1 gfs2_grow: Fix gfs2_grow when only one RG is present
Hi,
Quoted 17 lines · Carlos Maiolino
If there is only one RG in the filesystem
gfs2_growwill make a subtraction using a null pointer to check the RG size returning a invalide RG size value.
This patch avoid this substraction if there is only one RG in the filesystem.--- gfs2/mkfs/main_grow.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)gfs2/mkfs/main_grow.c +0
-0@@ -133,7 +133,11 @@ static void figure_out_rgsize(struct gfs2_sbd *sdp, unsigned int *orgsize) r1 = osi_list_entry(head->next->next, struct rgrp_list, list); r2 = osi_list_entry(head->next->next->next, struct rgrp_list, list);
gfs2/mkfs/main_grow.c static void figure_out_rgsize(struct gfs2_sbd *sdp, unsigned int *orgsize) · line 143
Quoted 10 lines
gfs2/mkfs/main_grow.c +5
-1- *orgsize = r2->ri.ri_addr - r1->ri.ri_addr; +if (r2->ri.ri_addr){ + *orgsize = r2->ri.ri_addr - r1->ri.ri_addr; + }else { + *orgsize = r1->ri.ri_addr; + } }/**
If this is trying to figure out the length of the rgrp, then it doesn't look quite right to me... ri_addr is the location of the rgrp header on disk, which is fair enough. However when you have only a single rgrp, the size should be something like ri_length + ri_data since ri_length is the size of the rgrp header itself and ri_data is the number of data blocks. The result may have to be suitably aligned in order to match what mkfs would do.
Also, the advantage of computing it like that is that only a single rgrp is needed, so that the case of using two and subtracting the two starting addresses can go away then making the code rather simpler,
Steve.