cifs: support share failover when remounting
Subsystems (2)
PATCH 1/1 cifs: support share failover when remounting
When remouting a DFS share, force a new DFS referral of the path and if the currently cached targets do not match any of the new targets or there was no cached targets, then mark it for reconnect.
For example:
$ mount //dom/dfs/link /mnt -o username=foo,password=bar
$ ls /mnt
oldfile.txtchange target share of 'link' in server settings
$ mount /mnt -o remount,username=foo,password=bar $ ls /mnt
newfile.txt
Signed-off-by Paulo Alcantara (SUSE) <[email protected]>
--- fs/cifs/connect.c | 4 +- fs/cifs/dfs_cache.c | 229 ++++++++++++++++++++++++++++++++++++------- fs/cifs/dfs_cache.h | 3 + fs/cifs/fs_context.c | 7 ++ 4 files changed, 203 insertions(+), 40 deletions(-)
fs/cifs/connect.c +2 -2
@@ -220,7 +220,7 @@ cifs_reconnect(struct TCP_Server_Info *server)#ifdef CONFIG_CIFS_DFS_UPCALL struct super_block *sb =NULL ;struct cifs_sb_info *cifs_sb =NULL ; -struct dfs_cache_tgt_list tgt_list = {0 }; +struct dfs_cache_tgt_list tgt_list =DFS_CACHE_TGT_LIST_INIT (tgt_list);struct dfs_cache_tgt_iterator *tgt_it =NULL ;#endif
@@ -3126,7 +3126,7 @@ static int do_dfs_failover(const char *path, const char *full_path, struct cifs_ {int rc;char *npath =NULL ; -struct dfs_cache_tgt_list tgt_list = {0 }; +struct dfs_cache_tgt_list tgt_list =DFS_CACHE_TGT_LIST_INIT (tgt_list);struct dfs_cache_tgt_iterator *tgt_it =NULL ;struct smb3_fs_context tmp_ctx = {NULL };
fs/cifs/dfs_cache.c +191 -38
260 lines not on this page · raw message
fs/cifs/dfs_cache.h +3 -0
@@ -13,6 +13,8 @@#include <linux/uuid.h> #include "cifsglob.h" +#define DFS_CACHE_TGT_LIST_INIT (var) { .tl_numtgts = 0, .tl_list = LIST_HEAD_INIT((var).tl_list), } +struct dfs_cache_tgt_list {int tl_numtgts;struct list_head tl_list;
@@ -44,6 +46,7 @@ int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it,void dfs_cache_put_refsrv_sessions (const uuid_t *mount_id);void dfs_cache_add_refsrv_session (const uuid_t *mount_id,struct cifs_ses *ses);char *dfs_cache_canonical_path (const char *path,const struct nls_table *cp,int remap); +int dfs_cache_remount_fs (struct cifs_sb_info *cifs_sb);static inline struct dfs_cache_tgt_iterator * dfs_cache_get_next_tgt(struct dfs_cache_tgt_list *tl,
fs/cifs/fs_context.c +7 -0
@@ -13,6 +13,9 @@#include <linux/magic.h> #include <linux/security.h> #include <net/net_namespace.h> +#ifdef CONFIG_CIFS_DFS_UPCALL +#include "dfs_cache.h" +#endif */ #include <linux/ctype.h>
@@ -779,6 +782,10 @@ static int smb3_reconfigure(struct fs_context *fc)smb3_cleanup_fs_context_contents (cifs_sb->ctx); rc =smb3_fs_context_dup (cifs_sb->ctx, ctx);smb3_update_mnt_flags (cifs_sb); +#ifdef CONFIG_CIFS_DFS_UPCALL +if (!rc) + rc =dfs_cache_remount_fs (cifs_sb); +#endif return rc; }
Signature · 1 line
2.32.0