Skip to content

Commit f163aa8

Browse files
author
Trond Myklebust
committed
NFSv4: Avoid unnecessary scans of filesystems for expired delegations
The amount of looping through the list of delegations is occasionally leading to soft lockups. If the state manager was asked to reap the expired delegations, it should scan only those filesystems that hold delegations that need to be reaped. Fixes: 7f156ef ("NFSv4: Clean up nfs_delegation_reap_expired()") Signed-off-by: Trond Myklebust <[email protected]>
1 parent 35a566a commit f163aa8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

fs/nfs/delegation.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,7 @@ static void nfs_mark_test_expired_delegation(struct nfs_server *server,
12841284
return;
12851285
clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags);
12861286
set_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags);
1287+
set_bit(NFS4SERV_DELEGATION_EXPIRED, &server->delegation_flags);
12871288
set_bit(NFS4CLNT_DELEGATION_EXPIRED, &server->nfs_client->cl_state);
12881289
}
12891290

@@ -1362,6 +1363,9 @@ static int nfs_server_reap_expired_delegations(struct nfs_server *server,
13621363
nfs4_stateid stateid;
13631364
unsigned long gen = ++server->delegation_gen;
13641365

1366+
if (!test_and_clear_bit(NFS4SERV_DELEGATION_EXPIRED,
1367+
&server->delegation_flags))
1368+
return 0;
13651369
restart:
13661370
rcu_read_lock();
13671371
list_for_each_entry_rcu(delegation, &server->delegations, super_list) {
@@ -1391,6 +1395,9 @@ static int nfs_server_reap_expired_delegations(struct nfs_server *server,
13911395
goto restart;
13921396
}
13931397
nfs_inode_mark_test_expired_delegation(server,inode);
1398+
set_bit(NFS4SERV_DELEGATION_EXPIRED, &server->delegation_flags);
1399+
set_bit(NFS4CLNT_DELEGATION_EXPIRED,
1400+
&server->nfs_client->cl_state);
13941401
iput(inode);
13951402
return -EAGAIN;
13961403
}

include/linux/nfs_fs_sb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ struct nfs_server {
252252

253253
unsigned long delegation_flags;
254254
#define NFS4SERV_DELEGRETURN (1)
255+
#define NFS4SERV_DELEGATION_EXPIRED (2)
255256
unsigned long delegation_gen;
256257
unsigned long mig_gen;
257258
unsigned long mig_status;

0 commit comments

Comments
 (0)