Skip to content

Commit 825b599

Browse files
committed
Merge tag '5.11-rc6-smb3' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French: "Three small smb3 fixes for stable" * tag '5.11-rc6-smb3' of git://git.samba.org/sfrench/cifs-2.6: cifs: report error instead of invalid when revalidating a dentry fails smb3: fix crediting for compounding when only one request in flight smb3: Fix out-of-bounds bug in SMB2_negotiate()
2 parents f7455e5 + 21b200d commit 825b599

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

fs/cifs/dir.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ static int
737737
cifs_d_revalidate(struct dentry *direntry, unsigned int flags)
738738
{
739739
struct inode *inode;
740+
int rc;
740741

741742
if (flags & LOOKUP_RCU)
742743
return -ECHILD;
@@ -746,8 +747,25 @@ cifs_d_revalidate(struct dentry *direntry, unsigned int flags)
746747
if ((flags & LOOKUP_REVAL) && !CIFS_CACHE_READ(CIFS_I(inode)))
747748
CIFS_I(inode)->time = 0; /* force reval */
748749

749-
if (cifs_revalidate_dentry(direntry))
750-
return 0;
750+
rc = cifs_revalidate_dentry(direntry);
751+
if (rc) {
752+
cifs_dbg(FYI, "cifs_revalidate_dentry failed with rc=%d", rc);
753+
switch (rc) {
754+
case -ENOENT:
755+
case -ESTALE:
756+
/*
757+
* Those errors mean the dentry is invalid
758+
* (file was deleted or recreated)
759+
*/
760+
return 0;
761+
default:
762+
/*
763+
* Otherwise some unexpected error happened
764+
* report it as-is to VFS layer
765+
*/
766+
return rc;
767+
}
768+
}
751769
else {
752770
/*
753771
* If the inode wasn't known to be a dfs entry when

fs/cifs/smb2pdu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ struct smb2_negotiate_req {
286286
__le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
287287
__le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */
288288
__le16 Reserved2;
289-
__le16 Dialects[1]; /* One dialect (vers=) at a time for now */
289+
__le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
290290
} __packed;
291291

292292
/* Dialects */

fs/cifs/transport.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,22 @@ wait_for_compound_request(struct TCP_Server_Info *server, int num,
666666

667667
if (*credits < num) {
668668
/*
669-
* Return immediately if not too many requests in flight since
670-
* we will likely be stuck on waiting for credits.
669+
* If the server is tight on resources or just gives us less
670+
* credits for other reasons (e.g. requests are coming out of
671+
* order and the server delays granting more credits until it
672+
* processes a missing mid) and we exhausted most available
673+
* credits there may be situations when we try to send
674+
* a compound request but we don't have enough credits. At this
675+
* point the client needs to decide if it should wait for
676+
* additional credits or fail the request. If at least one
677+
* request is in flight there is a high probability that the
678+
* server will return enough credits to satisfy this compound
679+
* request.
680+
*
681+
* Return immediately if no requests in flight since we will be
682+
* stuck on waiting for credits.
671683
*/
672-
if (server->in_flight < num - *credits) {
684+
if (server->in_flight == 0) {
673685
spin_unlock(&server->req_lock);
674686
trace_smb3_insufficient_credits(server->CurrentMid,
675687
server->hostname, scredits, sin_flight);

0 commit comments

Comments
 (0)