Skip to content

Commit 3fea12f

Browse files
Paulo Alcantarasmfrench
authored andcommitted
smb: client: introduce DFS_CACHE_TGT_LIST()
Add new helper which declares and initialises target list of a DFS referral rather having to do both separately. No functional changes. Signed-off-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 706a741 commit 3fea12f

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

fs/smb/client/connect.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,10 @@ static int reconnect_target_unlocked(struct TCP_Server_Info *server, struct dfs_
453453

454454
static int reconnect_dfs_server(struct TCP_Server_Info *server)
455455
{
456-
int rc = 0;
457-
struct dfs_cache_tgt_list tl = DFS_CACHE_TGT_LIST_INIT(tl);
458456
struct dfs_cache_tgt_iterator *target_hint = NULL;
457+
DFS_CACHE_TGT_LIST(tl);
459458
int num_targets = 0;
459+
int rc = 0;
460460

461461
/*
462462
* Determine the number of dfs targets the referral path in @cifs_sb resolves to.

fs/smb/client/dfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static int __dfs_mount_share(struct cifs_mount_ctx *mnt_ctx)
174174
}
175175

176176
do {
177-
struct dfs_cache_tgt_list tl = DFS_CACHE_TGT_LIST_INIT(tl);
177+
DFS_CACHE_TGT_LIST(tl);
178178

179179
rc = dfs_get_referral(mnt_ctx, ref_path + 1, NULL, &tl);
180180
if (rc) {
@@ -426,7 +426,7 @@ static int __tree_connect_dfs_target(const unsigned int xid, struct cifs_tcon *t
426426
/* Try to tree connect to all dfs targets */
427427
for (; tit; tit = dfs_cache_get_next_tgt(tl, tit)) {
428428
const char *target = dfs_cache_get_tgt_name(tit);
429-
struct dfs_cache_tgt_list ntl = DFS_CACHE_TGT_LIST_INIT(ntl);
429+
DFS_CACHE_TGT_LIST(ntl);
430430

431431
kfree(share);
432432
kfree(prefix);
@@ -520,7 +520,7 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
520520
int rc;
521521
struct TCP_Server_Info *server = tcon->ses->server;
522522
const struct smb_version_operations *ops = server->ops;
523-
struct dfs_cache_tgt_list tl = DFS_CACHE_TGT_LIST_INIT(tl);
523+
DFS_CACHE_TGT_LIST(tl);
524524
struct cifs_sb_info *cifs_sb = NULL;
525525
struct super_block *sb = NULL;
526526
struct dfs_info3_param ref = {0};

fs/smb/client/dfs_cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,9 +1177,9 @@ static bool is_ses_good(struct cifs_ses *ses)
11771177
/* Refresh dfs referral of tcon and mark it for reconnect if needed */
11781178
static int __refresh_tcon(const char *path, struct cifs_ses *ses, bool force_refresh)
11791179
{
1180-
struct dfs_cache_tgt_list old_tl = DFS_CACHE_TGT_LIST_INIT(old_tl);
1181-
struct dfs_cache_tgt_list new_tl = DFS_CACHE_TGT_LIST_INIT(new_tl);
11821180
struct TCP_Server_Info *server = ses->server;
1181+
DFS_CACHE_TGT_LIST(old_tl);
1182+
DFS_CACHE_TGT_LIST(new_tl);
11831183
bool needs_refresh = false;
11841184
struct cache_entry *ce;
11851185
unsigned int xid;

fs/smb/client/dfs_cache.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
extern struct workqueue_struct *dfscache_wq;
1717
extern atomic_t dfs_cache_ttl;
1818

19-
#define DFS_CACHE_TGT_LIST_INIT(var) { .tl_numtgts = 0, .tl_list = LIST_HEAD_INIT((var).tl_list), }
19+
#define DFS_CACHE_TGT_LIST_INIT(var) \
20+
{ .tl_numtgts = 0, .tl_list = LIST_HEAD_INIT((var).tl_list), }
21+
22+
#define DFS_CACHE_TGT_LIST(var) \
23+
struct dfs_cache_tgt_list var = DFS_CACHE_TGT_LIST_INIT(var)
2024

2125
struct dfs_cache_tgt_list {
2226
int tl_numtgts;

0 commit comments

Comments
 (0)