@@ -2139,7 +2139,7 @@ MODULE_PARM_DESC(nfs_access_max_cachesize, "NFS access maximum total cache lengt
21392139
21402140static void nfs_access_free_entry (struct nfs_access_entry * entry )
21412141{
2142- put_rpccred (entry -> cred );
2142+ put_cred (entry -> cred );
21432143 kfree_rcu (entry , rcu_head );
21442144 smp_mb__before_atomic ();
21452145 atomic_long_dec (& nfs_access_nr_entries );
@@ -2265,25 +2265,26 @@ void nfs_access_zap_cache(struct inode *inode)
22652265}
22662266EXPORT_SYMBOL_GPL (nfs_access_zap_cache );
22672267
2268- static struct nfs_access_entry * nfs_access_search_rbtree (struct inode * inode , struct rpc_cred * cred )
2268+ static struct nfs_access_entry * nfs_access_search_rbtree (struct inode * inode , const struct cred * cred )
22692269{
22702270 struct rb_node * n = NFS_I (inode )-> access_cache .rb_node ;
2271- struct nfs_access_entry * entry ;
22722271
22732272 while (n != NULL ) {
2274- entry = rb_entry (n , struct nfs_access_entry , rb_node );
2273+ struct nfs_access_entry * entry =
2274+ rb_entry (n , struct nfs_access_entry , rb_node );
2275+ int cmp = cred_fscmp (cred , entry -> cred );
22752276
2276- if (cred < entry -> cred )
2277+ if (cmp < 0 )
22772278 n = n -> rb_left ;
2278- else if (cred > entry -> cred )
2279+ else if (cmp > 0 )
22792280 n = n -> rb_right ;
22802281 else
22812282 return entry ;
22822283 }
22832284 return NULL ;
22842285}
22852286
2286- static int nfs_access_get_cached (struct inode * inode , struct rpc_cred * cred , struct nfs_access_entry * res , bool may_block )
2287+ static int nfs_access_get_cached (struct inode * inode , const struct cred * cred , struct nfs_access_entry * res , bool may_block )
22872288{
22882289 struct nfs_inode * nfsi = NFS_I (inode );
22892290 struct nfs_access_entry * cache ;
@@ -2326,7 +2327,7 @@ static int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, str
23262327 return - ENOENT ;
23272328}
23282329
2329- static int nfs_access_get_cached_rcu (struct inode * inode , struct rpc_cred * cred , struct nfs_access_entry * res )
2330+ static int nfs_access_get_cached_rcu (struct inode * inode , const struct cred * cred , struct nfs_access_entry * res )
23302331{
23312332 /* Only check the most recently returned cache entry,
23322333 * but do it without locking.
@@ -2363,15 +2364,17 @@ static void nfs_access_add_rbtree(struct inode *inode, struct nfs_access_entry *
23632364 struct rb_node * * p = & root_node -> rb_node ;
23642365 struct rb_node * parent = NULL ;
23652366 struct nfs_access_entry * entry ;
2367+ int cmp ;
23662368
23672369 spin_lock (& inode -> i_lock );
23682370 while (* p != NULL ) {
23692371 parent = * p ;
23702372 entry = rb_entry (parent , struct nfs_access_entry , rb_node );
2373+ cmp = cred_fscmp (set -> cred , entry -> cred );
23712374
2372- if (set -> cred < entry -> cred )
2375+ if (cmp < 0 )
23732376 p = & parent -> rb_left ;
2374- else if (set -> cred > entry -> cred )
2377+ else if (cmp > 0 )
23752378 p = & parent -> rb_right ;
23762379 else
23772380 goto found ;
@@ -2395,7 +2398,7 @@ void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set)
23952398 if (cache == NULL )
23962399 return ;
23972400 RB_CLEAR_NODE (& cache -> rb_node );
2398- cache -> cred = get_rpccred (set -> cred );
2401+ cache -> cred = get_cred (set -> cred );
23992402 cache -> mask = set -> mask ;
24002403
24012404 /* The above field assignments must be visible
@@ -2459,7 +2462,7 @@ void nfs_access_set_mask(struct nfs_access_entry *entry, u32 access_result)
24592462}
24602463EXPORT_SYMBOL_GPL (nfs_access_set_mask );
24612464
2462- static int nfs_do_access (struct inode * inode , struct rpc_cred * cred , int mask )
2465+ static int nfs_do_access (struct inode * inode , const struct cred * cred , int mask )
24632466{
24642467 struct nfs_access_entry cache ;
24652468 bool may_block = (mask & MAY_NOT_BLOCK ) == 0 ;
@@ -2523,7 +2526,7 @@ static int nfs_open_permission_mask(int openflags)
25232526 return mask ;
25242527}
25252528
2526- int nfs_may_open (struct inode * inode , struct rpc_cred * cred , int openflags )
2529+ int nfs_may_open (struct inode * inode , const struct cred * cred , int openflags )
25272530{
25282531 return nfs_do_access (inode , cred , nfs_open_permission_mask (openflags ));
25292532}
@@ -2548,7 +2551,7 @@ static int nfs_execute_ok(struct inode *inode, int mask)
25482551
25492552int nfs_permission (struct inode * inode , int mask )
25502553{
2551- struct rpc_cred * cred ;
2554+ const struct cred * cred = current_cred () ;
25522555 int res = 0 ;
25532556
25542557 nfs_inc_stats (inode , NFSIOS_VFSACCESS );
@@ -2582,20 +2585,11 @@ int nfs_permission(struct inode *inode, int mask)
25822585
25832586 /* Always try fast lookups first */
25842587 rcu_read_lock ();
2585- cred = rpc_lookup_cred_nonblock ();
2586- if (!IS_ERR (cred ))
2587- res = nfs_do_access (inode , cred , mask |MAY_NOT_BLOCK );
2588- else
2589- res = PTR_ERR (cred );
2588+ res = nfs_do_access (inode , cred , mask |MAY_NOT_BLOCK );
25902589 rcu_read_unlock ();
25912590 if (res == - ECHILD && !(mask & MAY_NOT_BLOCK )) {
25922591 /* Fast lookup failed, try the slow way */
2593- cred = rpc_lookup_cred ();
2594- if (!IS_ERR (cred )) {
2595- res = nfs_do_access (inode , cred , mask );
2596- put_rpccred (cred );
2597- } else
2598- res = PTR_ERR (cred );
2592+ res = nfs_do_access (inode , cred , mask );
25992593 }
26002594out :
26012595 if (!res && (mask & MAY_EXEC ))
0 commit comments