1616#include "orangefs-kernel.h"
1717#include "orangefs-bufmap.h"
1818
19- static int wait_for_matching_downcall (struct orangefs_kernel_op_s * , bool );
19+ static int wait_for_matching_downcall (struct orangefs_kernel_op_s * , long , bool );
2020static void orangefs_clean_up_interrupted_operation (struct orangefs_kernel_op_s * );
2121
2222/*
@@ -55,6 +55,7 @@ int service_operation(struct orangefs_kernel_op_s *op,
5555 const char * op_name ,
5656 int flags )
5757{
58+ long timeout = MAX_SCHEDULE_TIMEOUT ;
5859 /* flags to modify behavior */
5960 int ret = 0 ;
6061
@@ -102,15 +103,10 @@ int service_operation(struct orangefs_kernel_op_s *op,
102103 spin_unlock (& op -> lock );
103104 wake_up_interruptible (& orangefs_request_list_waitq );
104105 if (!__is_daemon_in_service ()) {
105- /*
106- * By incrementing the per-operation attempt counter, we
107- * directly go into the timeout logic while waiting for
108- * the matching downcall to be read
109- */
110106 gossip_debug (GOSSIP_WAIT_DEBUG ,
111107 "%s:client core is NOT in service.\n" ,
112108 __func__ );
113- op -> attempts ++ ;
109+ timeout = op_timeout_secs * HZ ;
114110 }
115111 spin_unlock (& orangefs_request_list_lock );
116112
@@ -124,33 +120,34 @@ int service_operation(struct orangefs_kernel_op_s *op,
124120 if (flags & ORANGEFS_OP_ASYNC )
125121 return 0 ;
126122
127- ret = wait_for_matching_downcall (op , flags & ORANGEFS_OP_INTERRUPTIBLE );
128-
129- if (ret < 0 ) {
130- /* failed to get matching downcall */
131- if (ret == - ETIMEDOUT ) {
132- gossip_err ("orangefs: %s -- wait timed out; aborting attempt.\n" ,
133- op_name );
134- }
135- orangefs_clean_up_interrupted_operation (op );
136- op -> downcall .status = ret ;
137- } else {
123+ ret = wait_for_matching_downcall (op , timeout ,
124+ flags & ORANGEFS_OP_INTERRUPTIBLE );
125+ if (!ret ) {
138126 spin_unlock (& op -> lock );
139127 /* got matching downcall; make sure status is in errno format */
140128 op -> downcall .status =
141129 orangefs_normalize_to_errno (op -> downcall .status );
142130 ret = op -> downcall .status ;
131+ goto out ;
143132 }
144133
145- BUG_ON (ret != op -> downcall .status );
134+ /* failed to get matching downcall */
135+ if (ret == - ETIMEDOUT ) {
136+ gossip_err ("orangefs: %s -- wait timed out; aborting attempt.\n" ,
137+ op_name );
138+ }
139+ orangefs_clean_up_interrupted_operation (op );
140+ op -> downcall .status = ret ;
146141 /* retry if operation has not been serviced and if requested */
147- if (!op_state_serviced (op ) && op -> downcall .status == - EAGAIN ) {
142+ if (ret == - EAGAIN ) {
143+ op -> attempts ++ ;
144+ timeout = op_timeout_secs * HZ ;
148145 gossip_debug (GOSSIP_WAIT_DEBUG ,
149146 "orangefs: tag %llu (%s)"
150147 " -- operation to be retried (%d attempt)\n" ,
151148 llu (op -> tag ),
152149 op_name ,
153- op -> attempts + 1 );
150+ op -> attempts );
154151
155152 if (!op -> uses_shared_memory )
156153 /*
@@ -221,6 +218,7 @@ int service_operation(struct orangefs_kernel_op_s *op,
221218 }
222219 }
223220
221+ out :
224222 gossip_debug (GOSSIP_WAIT_DEBUG ,
225223 "orangefs: service_operation %s returning: %d for %p.\n" ,
226224 op_name ,
@@ -328,11 +326,10 @@ static void orangefs_clean_up_interrupted_operation(struct orangefs_kernel_op_s
328326 * Returns with op->lock taken.
329327 */
330328static int wait_for_matching_downcall (struct orangefs_kernel_op_s * op ,
329+ long timeout ,
331330 bool interruptible )
332331{
333- long timeout , n ;
334-
335- timeout = op -> attempts ? op_timeout_secs * HZ : MAX_SCHEDULE_TIMEOUT ;
332+ long n ;
336333
337334 if (interruptible )
338335 n = wait_for_completion_interruptible_timeout (& op -> waitq , timeout );
@@ -354,7 +351,6 @@ static int wait_for_matching_downcall(struct orangefs_kernel_op_s *op,
354351 op );
355352 return - EINTR ;
356353 }
357- op -> attempts ++ ;
358354 if (op_state_purged (op )) {
359355 gossip_debug (GOSSIP_WAIT_DEBUG ,
360356 "*** %s:"
0 commit comments