cifs: introduce helper for finding referral server to improve DFS target resolution
[platform/kernel/linux-starfive.git] / fs / cifs / dfs_cache.c
index 4950ab0..098b4bc 100644 (file)
@@ -37,11 +37,12 @@ struct cache_dfs_tgt {
 struct cache_entry {
        struct hlist_node hlist;
        const char *path;
-       int ttl;
-       int srvtype;
-       int flags;
+       int hdr_flags; /* RESP_GET_DFS_REFERRAL.ReferralHeaderFlags */
+       int ttl; /* DFS_REREFERRAL_V3.TimeToLive */
+       int srvtype; /* DFS_REREFERRAL_V3.ServerType */
+       int ref_flags; /* DFS_REREFERRAL_V3.ReferralEntryFlags */
        struct timespec64 etime;
-       int path_consumed;
+       int path_consumed; /* RESP_GET_DFS_REFERRAL.PathConsumed */
        int numtgts;
        struct list_head tlist;
        struct cache_dfs_tgt *tgthint;
@@ -166,14 +167,11 @@ static int dfscache_proc_show(struct seq_file *m, void *v)
                                continue;
 
                        seq_printf(m,
-                                  "cache entry: path=%s,type=%s,ttl=%d,etime=%ld,"
-                                  "interlink=%s,path_consumed=%d,expired=%s\n",
-                                  ce->path,
-                                  ce->srvtype == DFS_TYPE_ROOT ? "root" : "link",
-                                  ce->ttl, ce->etime.tv_nsec,
-                                  IS_INTERLINK_SET(ce->flags) ? "yes" : "no",
-                                  ce->path_consumed,
-                                  cache_entry_expired(ce) ? "yes" : "no");
+                                  "cache entry: path=%s,type=%s,ttl=%d,etime=%ld,hdr_flags=0x%x,ref_flags=0x%x,interlink=%s,path_consumed=%d,expired=%s\n",
+                                  ce->path, ce->srvtype == DFS_TYPE_ROOT ? "root" : "link",
+                                  ce->ttl, ce->etime.tv_nsec, ce->ref_flags, ce->hdr_flags,
+                                  IS_INTERLINK_SET(ce->hdr_flags) ? "yes" : "no",
+                                  ce->path_consumed, cache_entry_expired(ce) ? "yes" : "no");
 
                        list_for_each_entry(t, &ce->tlist, list) {
                                seq_printf(m, "  %s%s\n",
@@ -236,11 +234,12 @@ static inline void dump_tgts(const struct cache_entry *ce)
 
 static inline void dump_ce(const struct cache_entry *ce)
 {
-       cifs_dbg(FYI, "cache entry: path=%s,type=%s,ttl=%d,etime=%ld,interlink=%s,path_consumed=%d,expired=%s\n",
+       cifs_dbg(FYI, "cache entry: path=%s,type=%s,ttl=%d,etime=%ld,hdr_flags=0x%x,ref_flags=0x%x,interlink=%s,path_consumed=%d,expired=%s\n",
                 ce->path,
                 ce->srvtype == DFS_TYPE_ROOT ? "root" : "link", ce->ttl,
                 ce->etime.tv_nsec,
-                IS_INTERLINK_SET(ce->flags) ? "yes" : "no",
+                ce->hdr_flags, ce->ref_flags,
+                IS_INTERLINK_SET(ce->hdr_flags) ? "yes" : "no",
                 ce->path_consumed,
                 cache_entry_expired(ce) ? "yes" : "no");
        dump_tgts(ce);
@@ -381,7 +380,8 @@ static int copy_ref_data(const struct dfs_info3_param *refs, int numrefs,
        ce->ttl = refs[0].ttl;
        ce->etime = get_expire_time(ce->ttl);
        ce->srvtype = refs[0].server_type;
-       ce->flags = refs[0].ref_flag;
+       ce->hdr_flags = refs[0].flags;
+       ce->ref_flags = refs[0].ref_flag;
        ce->path_consumed = refs[0].path_consumed;
 
        for (i = 0; i < numrefs; i++) {
@@ -799,7 +799,8 @@ static int setup_referral(const char *path, struct cache_entry *ce,
        ref->path_consumed = ce->path_consumed;
        ref->ttl = ce->ttl;
        ref->server_type = ce->srvtype;
-       ref->ref_flag = ce->flags;
+       ref->ref_flag = ce->ref_flags;
+       ref->flags = ce->hdr_flags;
 
        return 0;