* [PATCH] cifs: Fix TCP_Server_Info::credits to be signed
@ 2025-10-20 8:46 David Howells
2025-10-20 13:32 ` Enzo Matsumiya
0 siblings, 1 reply; 6+ messages in thread
From: David Howells @ 2025-10-20 8:46 UTC (permalink / raw)
To: Steve French
Cc: dhowells, Paulo Alcantara, linux-cifs, linux-fsdevel,
linux-kernel
Fix TCP_Server_Info::credits to be signed, just as echo_credits and
oplock_credits are. This also fixes what ought to get at least a
compilation warning if not an outright error in *get_credits_field() as a
pointer to the unsigned server->credits field is passed back as a pointer
to a signed int.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.org>
cc: linux-cifs@vger.kernel.org
---
fs/smb/client/cifsglob.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 8f6f567d7474..b91397dbb6aa 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -740,7 +740,7 @@ struct TCP_Server_Info {
bool nosharesock;
bool tcp_nodelay;
bool terminate;
- unsigned int credits; /* send no more requests at once */
+ int credits; /* send no more requests at once */
unsigned int max_credits; /* can override large 32000 default at mnt */
unsigned int in_flight; /* number of requests on the wire to server */
unsigned int max_in_flight; /* max number of requests that were on wire */
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] cifs: Fix TCP_Server_Info::credits to be signed
2025-10-20 8:46 [PATCH] cifs: Fix TCP_Server_Info::credits to be signed David Howells
@ 2025-10-20 13:32 ` Enzo Matsumiya
2025-10-20 14:08 ` David Howells
0 siblings, 1 reply; 6+ messages in thread
From: Enzo Matsumiya @ 2025-10-20 13:32 UTC (permalink / raw)
To: David Howells
Cc: Steve French, Paulo Alcantara, linux-cifs, linux-fsdevel,
linux-kernel
Hi David,
On 10/20, David Howells wrote:
>Fix TCP_Server_Info::credits to be signed, just as echo_credits and
>oplock_credits are. This also fixes what ought to get at least a
>compilation warning if not an outright error in *get_credits_field() as a
>pointer to the unsigned server->credits field is passed back as a pointer
>to a signed int.
Both semantically and technically, credits shouldn't go negative.
Shouldn't those other fields/functions become unsigned instead?
Cheers,
Enzo
>Signed-off-by: David Howells <dhowells@redhat.com>
>cc: Steve French <sfrench@samba.org>
>cc: Paulo Alcantara <pc@manguebit.org>
>cc: linux-cifs@vger.kernel.org
>---
> fs/smb/client/cifsglob.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
>index 8f6f567d7474..b91397dbb6aa 100644
>--- a/fs/smb/client/cifsglob.h
>+++ b/fs/smb/client/cifsglob.h
>@@ -740,7 +740,7 @@ struct TCP_Server_Info {
> bool nosharesock;
> bool tcp_nodelay;
> bool terminate;
>- unsigned int credits; /* send no more requests at once */
>+ int credits; /* send no more requests at once */
> unsigned int max_credits; /* can override large 32000 default at mnt */
> unsigned int in_flight; /* number of requests on the wire to server */
> unsigned int max_in_flight; /* max number of requests that were on wire */
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] cifs: Fix TCP_Server_Info::credits to be signed
2025-10-20 13:32 ` Enzo Matsumiya
@ 2025-10-20 14:08 ` David Howells
2025-10-20 14:45 ` Enzo Matsumiya
2025-10-20 16:58 ` Steve French
0 siblings, 2 replies; 6+ messages in thread
From: David Howells @ 2025-10-20 14:08 UTC (permalink / raw)
To: Enzo Matsumiya
Cc: dhowells, Steve French, Paulo Alcantara, linux-cifs,
linux-fsdevel, linux-kernel
Enzo Matsumiya <ematsumiya@suse.de> wrote:
> Both semantically and technically, credits shouldn't go negative.
> Shouldn't those other fields/functions become unsigned instead?
That's really a question for Steve, but it makes it easier to handle
underflow, and I'm guessing that the maximum credits isn't likely to exceed
2G.
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cifs: Fix TCP_Server_Info::credits to be signed
2025-10-20 14:08 ` David Howells
@ 2025-10-20 14:45 ` Enzo Matsumiya
2025-10-20 16:58 ` Steve French
1 sibling, 0 replies; 6+ messages in thread
From: Enzo Matsumiya @ 2025-10-20 14:45 UTC (permalink / raw)
To: David Howells
Cc: Steve French, Paulo Alcantara, linux-cifs, linux-fsdevel,
linux-kernel
On 10/20, David Howells wrote:
>Enzo Matsumiya <ematsumiya@suse.de> wrote:
>
>> Both semantically and technically, credits shouldn't go negative.
>> Shouldn't those other fields/functions become unsigned instead?
>
>That's really a question for Steve, but it makes it easier to handle
>underflow
But if there's an overflow somewhere the math should be checked instead
(I never seen it happen though).
> and I'm guessing that the maximum credits isn't likely to exceed
>2G.
Yes, it's capped at 60-65k (depends on the function...)
So yes, an unsigned short would be fine.
Cheers,
Enzo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cifs: Fix TCP_Server_Info::credits to be signed
2025-10-20 14:08 ` David Howells
2025-10-20 14:45 ` Enzo Matsumiya
@ 2025-10-20 16:58 ` Steve French
2025-10-24 11:56 ` Shyam Prasad N
1 sibling, 1 reply; 6+ messages in thread
From: Steve French @ 2025-10-20 16:58 UTC (permalink / raw)
To: David Howells
Cc: Enzo Matsumiya, Steve French, Paulo Alcantara, linux-cifs,
linux-fsdevel, linux-kernel, Pavel Shilovsky, ronnie sahlberg,
Bharath S M, Shyam Prasad
On Mon, Oct 20, 2025 at 9:08 AM David Howells <dhowells@redhat.com> wrote:
>
> Enzo Matsumiya <ematsumiya@suse.de> wrote:
>
> > Both semantically and technically, credits shouldn't go negative.
> > Shouldn't those other fields/functions become unsigned instead?
>
> That's really a question for Steve, but it makes it easier to handle
> underflow, and I'm guessing that the maximum credits isn't likely to exceed
> 2G.
>
> David
Interesting question - I do like the idea of keeping signed if it
makes it easier to check
for underflows but IIRC that hasn't been a problem in a long time (adding Pavel
and Ronnie in case they remember) but more important than the signed
vs. unsigned
in my opinion is at least keeping the field consistent.
I have seen a few stress related xfstests that often generate
reconnects, so we may want
to run with the tracepoint enabled
(smb3_reconnect_with_invalid_credits) to see if that
is actually happening (the underflow of credits)
I also was thinking that we should doublecheck that lease break acks
will never run out credits
(since that can deadlock servers for more than 30 seconds as they wait
for timeouts), even if
"lease break storms" are rare. Maybe we should allow e.g. lease
break acks to borrow echo
credits e.g. as minor improvement?
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cifs: Fix TCP_Server_Info::credits to be signed
2025-10-20 16:58 ` Steve French
@ 2025-10-24 11:56 ` Shyam Prasad N
0 siblings, 0 replies; 6+ messages in thread
From: Shyam Prasad N @ 2025-10-24 11:56 UTC (permalink / raw)
To: Steve French
Cc: David Howells, Enzo Matsumiya, Steve French, Paulo Alcantara,
linux-cifs, linux-fsdevel, linux-kernel, Pavel Shilovsky,
ronnie sahlberg, Bharath S M
On Mon, Oct 20, 2025 at 10:28 PM Steve French <smfrench@gmail.com> wrote:
>
> On Mon, Oct 20, 2025 at 9:08 AM David Howells <dhowells@redhat.com> wrote:
> >
> > Enzo Matsumiya <ematsumiya@suse.de> wrote:
> >
> > > Both semantically and technically, credits shouldn't go negative.
> > > Shouldn't those other fields/functions become unsigned instead?
> >
> > That's really a question for Steve, but it makes it easier to handle
> > underflow, and I'm guessing that the maximum credits isn't likely to exceed
> > 2G.
> >
> > David
>
> Interesting question - I do like the idea of keeping signed if it
> makes it easier to check
> for underflows but IIRC that hasn't been a problem in a long time (adding Pavel
> and Ronnie in case they remember) but more important than the signed
> vs. unsigned
> in my opinion is at least keeping the field consistent.
>
> I have seen a few stress related xfstests that often generate
> reconnects, so we may want
> to run with the tracepoint enabled
> (smb3_reconnect_with_invalid_credits) to see if that
> is actually happening (the underflow of credits)
>
> I also was thinking that we should doublecheck that lease break acks
> will never run out credits
> (since that can deadlock servers for more than 30 seconds as they wait
> for timeouts), even if
> "lease break storms" are rare. Maybe we should allow e.g. lease
> break acks to borrow echo
> credits e.g. as minor improvement?
>
> --
> Thanks,
>
> Steve
I agree with Steve.
I don't mind credits being a signed int. If credits go negative, it's
a clear indication of a bug and jumps out at you more than a large
integer would.
--
Regards,
Shyam
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-24 11:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-20 8:46 [PATCH] cifs: Fix TCP_Server_Info::credits to be signed David Howells
2025-10-20 13:32 ` Enzo Matsumiya
2025-10-20 14:08 ` David Howells
2025-10-20 14:45 ` Enzo Matsumiya
2025-10-20 16:58 ` Steve French
2025-10-24 11:56 ` Shyam Prasad N
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox