]> git.baikalelectronics.ru Git - kernel.git/commitdiff
NFSv4: Clean up nfs_delegation_reap_unclaimed()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 27 Feb 2020 14:08:25 +0000 (09:08 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 16 Mar 2020 12:34:30 +0000 (08:34 -0400)
Convert nfs_delegation_reap_unclaimed() to use nfs_client_for_each_server()
for efficiency.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/delegation.c

index 19f66d3e58e8a4701c1a7572b36e7a59b78423cc..cb03ba99ae51789fd984bb75156fe843e2441a19 100644 (file)
@@ -1092,53 +1092,51 @@ void nfs_delegation_mark_reclaim(struct nfs_client *clp)
        rcu_read_unlock();
 }
 
-/**
- * nfs_delegation_reap_unclaimed - reap unclaimed delegations after reboot recovery is done
- * @clp: nfs_client to process
- *
- */
-void nfs_delegation_reap_unclaimed(struct nfs_client *clp)
+static int nfs_server_reap_unclaimed_delegations(struct nfs_server *server,
+               void __always_unused *data)
 {
        struct nfs_delegation *delegation;
-       struct nfs_server *server;
        struct inode *inode;
-
 restart:
        rcu_read_lock();
-       list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
-               list_for_each_entry_rcu(delegation, &server->delegations,
-                                                               super_list) {
-                       if (test_bit(NFS_DELEGATION_INODE_FREEING,
-                                               &delegation->flags) ||
-                           test_bit(NFS_DELEGATION_RETURNING,
-                                               &delegation->flags) ||
-                           test_bit(NFS_DELEGATION_NEED_RECLAIM,
-                                               &delegation->flags) == 0)
-                               continue;
-                       if (!nfs_sb_active(server->super))
-                               break; /* continue in outer loop */
-                       inode = nfs_delegation_grab_inode(delegation);
-                       if (inode == NULL) {
-                               rcu_read_unlock();
-                               nfs_sb_deactive(server->super);
-                               goto restart;
-                       }
-                       delegation = nfs_start_delegation_return_locked(NFS_I(inode));
-                       rcu_read_unlock();
-                       if (delegation != NULL) {
-                               if (nfs_detach_delegation(NFS_I(inode), delegation,
-                                                       server) != NULL)
-                                       nfs_free_delegation(delegation);
-                               /* Match nfs_start_delegation_return_locked */
-                               nfs_put_delegation(delegation);
-                       }
-                       iput(inode);
-                       nfs_sb_deactive(server->super);
-                       cond_resched();
-                       goto restart;
+restart_locked:
+       list_for_each_entry_rcu(delegation, &server->delegations, super_list) {
+               if (test_bit(NFS_DELEGATION_INODE_FREEING,
+                                       &delegation->flags) ||
+                   test_bit(NFS_DELEGATION_RETURNING,
+                                       &delegation->flags) ||
+                   test_bit(NFS_DELEGATION_NEED_RECLAIM,
+                                       &delegation->flags) == 0)
+                       continue;
+               inode = nfs_delegation_grab_inode(delegation);
+               if (inode == NULL)
+                       goto restart_locked;
+               delegation = nfs_start_delegation_return_locked(NFS_I(inode));
+               rcu_read_unlock();
+               if (delegation != NULL) {
+                       if (nfs_detach_delegation(NFS_I(inode), delegation,
+                                               server) != NULL)
+                               nfs_free_delegation(delegation);
+                       /* Match nfs_start_delegation_return_locked */
+                       nfs_put_delegation(delegation);
                }
+               iput(inode);
+               cond_resched();
+               goto restart;
        }
        rcu_read_unlock();
+       return 0;
+}
+
+/**
+ * nfs_delegation_reap_unclaimed - reap unclaimed delegations after reboot recovery is done
+ * @clp: nfs_client to process
+ *
+ */
+void nfs_delegation_reap_unclaimed(struct nfs_client *clp)
+{
+       nfs_client_for_each_server(clp, nfs_server_reap_unclaimed_delegations,
+                       NULL);
 }
 
 static inline bool nfs4_server_rebooted(const struct nfs_client *clp)