@@ -710,24 +710,6 @@ static int z_erofs_attach_page(struct z_erofs_decompress_frontend *fe,
710710 return ret ;
711711}
712712
713- static void z_erofs_try_to_claim_pcluster (struct z_erofs_decompress_frontend * f )
714- {
715- struct z_erofs_pcluster * pcl = f -> pcl ;
716- z_erofs_next_pcluster_t * owned_head = & f -> owned_head ;
717-
718- /* type 1, nil pcluster (this pcluster doesn't belong to any chain.) */
719- if (cmpxchg (& pcl -> next , Z_EROFS_PCLUSTER_NIL ,
720- * owned_head ) == Z_EROFS_PCLUSTER_NIL ) {
721- * owned_head = & pcl -> next ;
722- /* so we can attach this pcluster to our submission chain. */
723- f -> mode = Z_EROFS_PCLUSTER_FOLLOWED ;
724- return ;
725- }
726-
727- /* type 2, it belongs to an ongoing chain */
728- f -> mode = Z_EROFS_PCLUSTER_INFLIGHT ;
729- }
730-
731713static int z_erofs_register_pcluster (struct z_erofs_decompress_frontend * fe )
732714{
733715 struct erofs_map_blocks * map = & fe -> map ;
@@ -803,7 +785,6 @@ static int z_erofs_pcluster_begin(struct z_erofs_decompress_frontend *fe)
803785 int ret ;
804786
805787 DBG_BUGON (fe -> pcl );
806-
807788 /* must be Z_EROFS_PCLUSTER_TAIL or pointed to previous pcluster */
808789 DBG_BUGON (fe -> owned_head == Z_EROFS_PCLUSTER_NIL );
809790
@@ -823,7 +804,15 @@ static int z_erofs_pcluster_begin(struct z_erofs_decompress_frontend *fe)
823804
824805 if (ret == - EEXIST ) {
825806 mutex_lock (& fe -> pcl -> lock );
826- z_erofs_try_to_claim_pcluster (fe );
807+ /* check if this pcluster hasn't been linked into any chain. */
808+ if (cmpxchg (& fe -> pcl -> next , Z_EROFS_PCLUSTER_NIL ,
809+ fe -> owned_head ) == Z_EROFS_PCLUSTER_NIL ) {
810+ /* .. so it can be attached to our submission chain */
811+ fe -> owned_head = & fe -> pcl -> next ;
812+ fe -> mode = Z_EROFS_PCLUSTER_FOLLOWED ;
813+ } else { /* otherwise, it belongs to an inflight chain */
814+ fe -> mode = Z_EROFS_PCLUSTER_INFLIGHT ;
815+ }
827816 } else if (ret ) {
828817 return ret ;
829818 }
0 commit comments