@@ -432,6 +432,21 @@ xfs_rtfind_forw(
432432 return 0 ;
433433}
434434
435+ /* Log rtsummary counter at @infoword. */
436+ static inline void
437+ xfs_trans_log_rtsummary (
438+ struct xfs_trans * tp ,
439+ struct xfs_buf * bp ,
440+ unsigned int infoword )
441+ {
442+ size_t first , last ;
443+
444+ first = (void * )xfs_rsumblock_infoptr (bp , infoword ) - bp -> b_addr ;
445+ last = first + sizeof (xfs_suminfo_t ) - 1 ;
446+
447+ xfs_trans_log_buf (tp , bp , first , last );
448+ }
449+
435450/*
436451 * Read and/or modify the summary information for a given extent size,
437452 * bitmap block combination.
@@ -497,16 +512,14 @@ xfs_rtmodify_summary_int(
497512 infoword = xfs_rtsumoffs_to_infoword (mp , so );
498513 sp = xfs_rsumblock_infoptr (bp , infoword );
499514 if (delta ) {
500- uint first = (uint )((char * )sp - (char * )bp -> b_addr );
501-
502515 * sp += delta ;
503516 if (mp -> m_rsum_cache ) {
504517 if (* sp == 0 && log == mp -> m_rsum_cache [bbno ])
505518 mp -> m_rsum_cache [bbno ]++ ;
506519 if (* sp != 0 && log < mp -> m_rsum_cache [bbno ])
507520 mp -> m_rsum_cache [bbno ] = log ;
508521 }
509- xfs_trans_log_buf (tp , bp , first , first + sizeof ( * sp ) - 1 );
522+ xfs_trans_log_rtsummary (tp , bp , infoword );
510523 }
511524 if (sum )
512525 * sum = * sp ;
@@ -527,6 +540,22 @@ xfs_rtmodify_summary(
527540 delta , rbpp , rsb , NULL );
528541}
529542
543+ /* Log rtbitmap block from the word @from to the byte before @next. */
544+ static inline void
545+ xfs_trans_log_rtbitmap (
546+ struct xfs_trans * tp ,
547+ struct xfs_buf * bp ,
548+ unsigned int from ,
549+ unsigned int next )
550+ {
551+ size_t first , last ;
552+
553+ first = (void * )xfs_rbmblock_wordptr (bp , from ) - bp -> b_addr ;
554+ last = ((void * )xfs_rbmblock_wordptr (bp , next ) - 1 ) - bp -> b_addr ;
555+
556+ xfs_trans_log_buf (tp , bp , first , last );
557+ }
558+
530559/*
531560 * Set the given range of bitmap bits to the given value.
532561 * Do whatever I/O and logging is required.
@@ -548,6 +577,7 @@ xfs_rtmodify_range(
548577 int i ; /* current bit number rel. to start */
549578 int lastbit ; /* last useful bit in word */
550579 xfs_rtword_t mask ; /* mask o frelevant bits for value */
580+ unsigned int firstword ; /* first word used in the buffer */
551581 unsigned int word ; /* word number in the buffer */
552582
553583 /*
@@ -565,7 +595,7 @@ xfs_rtmodify_range(
565595 /*
566596 * Compute the starting word's address, and starting bit.
567597 */
568- word = xfs_rtx_to_rbmword (mp , start );
598+ firstword = word = xfs_rtx_to_rbmword (mp , start );
569599 first = b = xfs_rbmblock_wordptr (bp , word );
570600 bit = (int )(start & (XFS_NBWORD - 1 ));
571601 /*
@@ -599,15 +629,13 @@ xfs_rtmodify_range(
599629 * Log the changed part of this block.
600630 * Get the next one.
601631 */
602- xfs_trans_log_buf (tp , bp ,
603- (uint )((char * )first - (char * )bp -> b_addr ),
604- (uint )((char * )b - (char * )bp -> b_addr ));
632+ xfs_trans_log_rtbitmap (tp , bp , firstword , word );
605633 error = xfs_rtbuf_get (mp , tp , ++ block , 0 , & bp );
606634 if (error ) {
607635 return error ;
608636 }
609637
610- word = 0 ;
638+ firstword = word = 0 ;
611639 first = b = xfs_rbmblock_wordptr (bp , word );
612640 } else {
613641 /*
@@ -640,15 +668,13 @@ xfs_rtmodify_range(
640668 * Log the changed part of this block.
641669 * Get the next one.
642670 */
643- xfs_trans_log_buf (tp , bp ,
644- (uint )((char * )first - (char * )bp -> b_addr ),
645- (uint )((char * )b - (char * )bp -> b_addr ));
671+ xfs_trans_log_rtbitmap (tp , bp , firstword , word );
646672 error = xfs_rtbuf_get (mp , tp , ++ block , 0 , & bp );
647673 if (error ) {
648674 return error ;
649675 }
650676
651- word = 0 ;
677+ firstword = word = 0 ;
652678 first = b = xfs_rbmblock_wordptr (bp , word );
653679 } else {
654680 /*
@@ -673,15 +699,14 @@ xfs_rtmodify_range(
673699 * b |= mask ;
674700 else
675701 * b &= ~mask ;
702+ word ++ ;
676703 b ++ ;
677704 }
678705 /*
679706 * Log any remaining changed bytes.
680707 */
681708 if (b > first )
682- xfs_trans_log_buf (tp , bp ,
683- (uint )((char * )first - (char * )bp -> b_addr ),
684- (uint )((char * )b - (char * )bp -> b_addr - 1 ));
709+ xfs_trans_log_rtbitmap (tp , bp , firstword , word );
685710 return 0 ;
686711}
687712
0 commit comments