Re: [PATCH] ksmbd: don't terminate inactive sessions after a few seconds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2023-03-24 12:50 GMT+09:00, Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>:
> On (23/03/21 22:33), Namjae Jeon wrote:
> [..]
>> @@ -335,14 +336,23 @@ static int ksmbd_tcp_readv(struct tcp_transport *t,
>> struct kvec *iov_orig,
>>  		} else if (conn->status == KSMBD_SESS_NEED_RECONNECT) {
>>  			total_read = -EAGAIN;
>>  			break;
>> -		} else if ((length == -ERESTARTSYS || length == -EAGAIN) &&
>> -			   max_retry) {
>> +		} else if (length == -ERESTARTSYS || length == -EAGAIN) {
>> +			/*
>> +			 * If max_retries is negative, Allow unlimited
>> +			 * retries to keep connection with inactive sessions.
>> +			 */
>> +			if (max_retries == 0) {
>> +				total_read = length;
>> +				break;
>> +			} else if (max_retries > 0) {
>> +				max_retries--;
>> +			}
>> +
>>  			usleep_range(1000, 2000);
>>  			length = 0;
>> -			max_retry--;
>>  			continue;
>>  		} else if (length <= 0) {
>> -			total_read = -EAGAIN;
>> +			total_read = length;
>>  			break;
>>  		}
>>  	}
>
> By the way, ksmbd_tcp_readv() calls kvec_array_init() on each iteration.
> Shouldn't we call it only if length > 0? That is only if the most recent
> call to kernel_recvmsg() has read some data.
If length == to_read is equal then it is not called. And in case
length < to_read, we have to call it which reinitialize io vec again
for reading the rest of the data.
>



[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux