Skip to content

Commit cb3f6d8

Browse files
Paulo Alcantarasmfrench
authored andcommitted
cifs: don't refresh cached referrals from unactive mounts
There is no point refreshing cached referrals from unactive mounts as they will no longer be used and new mounts will either create or refresh them anyway. Signed-off-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent a1c0d00 commit cb3f6d8

File tree

1 file changed

+1
-72
lines changed

1 file changed

+1
-72
lines changed

fs/cifs/dfs_cache.c

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,74 +1549,6 @@ static void refresh_mounts(struct cifs_ses **sessions)
15491549
}
15501550
}
15511551

1552-
static void refresh_cache(struct cifs_ses **sessions)
1553-
{
1554-
int i;
1555-
struct cifs_ses *ses;
1556-
unsigned int xid;
1557-
char *ref_paths[CACHE_MAX_ENTRIES];
1558-
int count = 0;
1559-
struct cache_entry *ce;
1560-
1561-
/*
1562-
* Refresh all cached entries. Get all new referrals outside critical section to avoid
1563-
* starvation while performing SMB2 IOCTL on broken or slow connections.
1564-
1565-
* The cache entries may cover more paths than the active mounts
1566-
* (e.g. domain-based DFS referrals or multi tier DFS setups).
1567-
*/
1568-
down_read(&htable_rw_lock);
1569-
for (i = 0; i < CACHE_HTABLE_SIZE; i++) {
1570-
struct hlist_head *l = &cache_htable[i];
1571-
1572-
hlist_for_each_entry(ce, l, hlist) {
1573-
if (count == ARRAY_SIZE(ref_paths))
1574-
goto out_unlock;
1575-
if (hlist_unhashed(&ce->hlist) || !cache_entry_expired(ce) ||
1576-
IS_ERR(find_ipc_from_server_path(sessions, ce->path)))
1577-
continue;
1578-
ref_paths[count++] = kstrdup(ce->path, GFP_ATOMIC);
1579-
}
1580-
}
1581-
1582-
out_unlock:
1583-
up_read(&htable_rw_lock);
1584-
1585-
for (i = 0; i < count; i++) {
1586-
char *path = ref_paths[i];
1587-
struct dfs_info3_param *refs = NULL;
1588-
int numrefs = 0;
1589-
int rc = 0;
1590-
1591-
if (!path)
1592-
continue;
1593-
1594-
ses = find_ipc_from_server_path(sessions, path);
1595-
if (IS_ERR(ses))
1596-
goto next_referral;
1597-
1598-
xid = get_xid();
1599-
rc = get_dfs_referral(xid, ses, path, &refs, &numrefs);
1600-
free_xid(xid);
1601-
1602-
if (!rc) {
1603-
down_write(&htable_rw_lock);
1604-
ce = lookup_cache_entry(path);
1605-
/*
1606-
* We need to re-check it because other tasks might have it deleted or
1607-
* updated.
1608-
*/
1609-
if (!IS_ERR(ce) && cache_entry_expired(ce))
1610-
update_cache_entry_locked(ce, refs, numrefs);
1611-
up_write(&htable_rw_lock);
1612-
}
1613-
1614-
next_referral:
1615-
kfree(path);
1616-
free_dfs_info_array(refs, numrefs);
1617-
}
1618-
}
1619-
16201552
/*
16211553
* Worker that will refresh DFS cache and active mounts based on lowest TTL value from a DFS
16221554
* referral.
@@ -1654,11 +1586,8 @@ static void refresh_cache_worker(struct work_struct *work)
16541586
i += count;
16551587
}
16561588

1657-
if (sessions[0]) {
1658-
/* Refresh all active mounts and cached entries */
1589+
if (sessions[0])
16591590
refresh_mounts(sessions);
1660-
refresh_cache(sessions);
1661-
}
16621591

16631592
list_for_each_entry_safe(mg, tmp_mg, &mglist, refresh_list) {
16641593
list_del_init(&mg->refresh_list);

0 commit comments

Comments
 (0)