mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
cifs: fix charset issue in reconnection
We need to specify charset, like "iocharset=utf-8", in mount options for Chinese path if the nls_default don't support it, such as iso8859-1, the default value for CONFIG_NLS_DEFAULT. But now in reconnection the nls_default is used, instead of the one we specified and used in mount, and this can lead to mount failure. Signed-off-by: Winston Wen <wentao@uniontech.com> Reviewed-by: Paulo Alcantara <pc@manguebit.com> Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
parent
c1ed39ec11
commit
a43f95fdd3
5 changed files with 9 additions and 4 deletions
|
@ -1062,6 +1062,7 @@ struct cifs_ses {
|
||||||
unsigned long chans_need_reconnect;
|
unsigned long chans_need_reconnect;
|
||||||
/* ========= end: protected by chan_lock ======== */
|
/* ========= end: protected by chan_lock ======== */
|
||||||
struct cifs_ses *dfs_root_ses;
|
struct cifs_ses *dfs_root_ses;
|
||||||
|
struct nls_table *local_nls;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
|
|
@ -129,7 +129,7 @@ again:
|
||||||
}
|
}
|
||||||
spin_unlock(&server->srv_lock);
|
spin_unlock(&server->srv_lock);
|
||||||
|
|
||||||
nls_codepage = load_nls_default();
|
nls_codepage = ses->local_nls;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* need to prevent multiple threads trying to simultaneously
|
* need to prevent multiple threads trying to simultaneously
|
||||||
|
@ -200,7 +200,6 @@ out:
|
||||||
rc = -EAGAIN;
|
rc = -EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
unload_nls(nls_codepage);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1842,6 +1842,10 @@ static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx)
|
||||||
CIFS_MAX_PASSWORD_LEN))
|
CIFS_MAX_PASSWORD_LEN))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(ctx->local_nls->charset, ses->local_nls->charset))
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2286,6 +2290,7 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
|
||||||
|
|
||||||
ses->sectype = ctx->sectype;
|
ses->sectype = ctx->sectype;
|
||||||
ses->sign = ctx->sign;
|
ses->sign = ctx->sign;
|
||||||
|
ses->local_nls = load_nls(ctx->local_nls->charset);
|
||||||
|
|
||||||
/* add server as first channel */
|
/* add server as first channel */
|
||||||
spin_lock(&ses->chan_lock);
|
spin_lock(&ses->chan_lock);
|
||||||
|
|
|
@ -95,6 +95,7 @@ sesInfoFree(struct cifs_ses *buf_to_free)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unload_nls(buf_to_free->local_nls);
|
||||||
atomic_dec(&sesInfoAllocCount);
|
atomic_dec(&sesInfoAllocCount);
|
||||||
kfree(buf_to_free->serverOS);
|
kfree(buf_to_free->serverOS);
|
||||||
kfree(buf_to_free->serverDomain);
|
kfree(buf_to_free->serverDomain);
|
||||||
|
|
|
@ -242,7 +242,7 @@ again:
|
||||||
}
|
}
|
||||||
spin_unlock(&server->srv_lock);
|
spin_unlock(&server->srv_lock);
|
||||||
|
|
||||||
nls_codepage = load_nls_default();
|
nls_codepage = ses->local_nls;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* need to prevent multiple threads trying to simultaneously
|
* need to prevent multiple threads trying to simultaneously
|
||||||
|
@ -324,7 +324,6 @@ out:
|
||||||
rc = -EAGAIN;
|
rc = -EAGAIN;
|
||||||
}
|
}
|
||||||
failed:
|
failed:
|
||||||
unload_nls(nls_codepage);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue