@@ -121,7 +121,6 @@ backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
121121 size_t read_len = 0 ;
122122 XLogRecPtr page_lsn ;
123123 int try_checksum = 100 ;
124- bool is_zero_page = false;
125124
126125 header .block = blknum ;
127126 offset = blknum * BLCKSZ ;
@@ -152,30 +151,29 @@ backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
152151 int i ;
153152 /* Check if the page is zeroed. */
154153 for (i = 0 ; i < BLCKSZ && page .data [i ] == 0 ; i ++ );
154+
155+ /* Page is zeroed. No need to check header and checksum. */
155156 if (i == BLCKSZ )
156157 {
157- is_zero_page = true;
158- try_checksum = 0 ;
159158 elog (LOG , "File: %s blknum %u, empty page" , file -> path , blknum );
159+ break ;
160160 }
161161
162162 /*
163163 * If page is not completely empty and we couldn't parse it,
164164 * try again several times. If it didn't help, throw error
165165 */
166- if (!is_zero_page )
166+
167+ /* Try to read and verify this page again several times. */
168+ if (try_checksum )
167169 {
168- /* Try to read and verify this page again several times. */
169- if (try_checksum )
170- {
171- elog (WARNING , "File: %s blknum %u have wrong page header, try again" ,
172- file -> path , blknum );
173- usleep (100 );
174- continue ;
175- }
176- else
177- elog (ERROR , "File: %s blknum %u have wrong page header." , file -> path , blknum );
170+ elog (WARNING , "File: %s blknum %u have wrong page header, try again" ,
171+ file -> path , blknum );
172+ usleep (100 );
173+ continue ;
178174 }
175+ else
176+ elog (ERROR , "File: %s blknum %u have wrong page header." , file -> path , blknum );
179177 }
180178
181179 /* If the page hasn't changed since previous backup, don't backup it. */
@@ -188,25 +186,31 @@ backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
188186 }
189187
190188 /* Verify checksum */
191- if (current .checksum_version && ! is_zero_page )
189+ if (current .checksum_version )
192190 {
193191 /*
194192 * If checksum is wrong, sleep a bit and then try again
195193 * several times. If it didn't help, throw error
196194 */
197- if (pg_checksum_page (page .data , file -> segno * RELSEG_SIZE + blknum ) != ((PageHeader ) page .data )-> pd_checksum )
195+ if (pg_checksum_page (page .data , file -> segno * RELSEG_SIZE + blknum )
196+ != ((PageHeader ) page .data )-> pd_checksum )
198197 {
199198 if (try_checksum )
200199 {
201200 elog (WARNING , "File: %s blknum %u have wrong checksum, try again" ,
202201 file -> path , blknum );
203202 usleep (100 );
203+ continue ;
204204 }
205205 else
206206 elog (ERROR , "File: %s blknum %u have wrong checksum." ,
207207 file -> path , blknum );
208208 }
209+ else
210+ break ; /* page header and checksum are correct */
209211 }
212+ else
213+ break ; /* page header is correct and checksum check is disabled */
210214 }
211215
212216 file -> read_size += read_len ;
0 commit comments