mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-01 00:58:39 +02:00 
			
		
		
		
	nfsd: allocate new session-based DRC slots on demand.
If a client ever uses the highest available slot for a given session, attempt to allocate more slots so there is room for the client to use them if wanted. GFP_NOWAIT is used so if there is not plenty of free memory, failure is expected - which is what we want. It also allows the allocation while holding a spinlock. Each time we increase the number of slots by 20% (rounded up). This allows fairly quick growth while avoiding excessive over-shoot. We would expect to stablise with around 10% more slots available than the client actually uses. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
		
							parent
							
								
									601c8cb349
								
							
						
					
					
						commit
						60aa656431
					
				
					 1 changed files with 32 additions and 5 deletions
				
			
		|  | @ -4235,11 +4235,6 @@ nfsd4_sequence(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
| 	slot = xa_load(&session->se_slots, seq->slotid); | ||||
| 	dprintk("%s: slotid %d\n", __func__, seq->slotid); | ||||
| 
 | ||||
| 	/* We do not negotiate the number of slots yet, so set the
 | ||||
| 	 * maxslots to the session maxreqs which is used to encode | ||||
| 	 * sr_highest_slotid and the sr_target_slot id to maxslots */ | ||||
| 	seq->maxslots = session->se_fchannel.maxreqs; | ||||
| 
 | ||||
| 	trace_nfsd_slot_seqid_sequence(clp, seq, slot); | ||||
| 	status = check_slot_seqid(seq->seqid, slot->sl_seqid, | ||||
| 					slot->sl_flags & NFSD4_SLOT_INUSE); | ||||
|  | @ -4289,6 +4284,38 @@ nfsd4_sequence(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
| 	cstate->session = session; | ||||
| 	cstate->clp = clp; | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * If the client ever uses the highest available slot, | ||||
| 	 * gently try to allocate another 20%.  This allows | ||||
| 	 * fairly quick growth without grossly over-shooting what | ||||
| 	 * the client might use. | ||||
| 	 */ | ||||
| 	if (seq->slotid == session->se_fchannel.maxreqs - 1 && | ||||
| 	    session->se_fchannel.maxreqs < NFSD_MAX_SLOTS_PER_SESSION) { | ||||
| 		int s = session->se_fchannel.maxreqs; | ||||
| 		int cnt = DIV_ROUND_UP(s, 5); | ||||
| 
 | ||||
| 		do { | ||||
| 			/*
 | ||||
| 			 * GFP_NOWAIT both allows allocation under a | ||||
| 			 * spinlock, and only succeeds if there is | ||||
| 			 * plenty of memory. | ||||
| 			 */ | ||||
| 			slot = kzalloc(slot_bytes(&session->se_fchannel), | ||||
| 				       GFP_NOWAIT); | ||||
| 			if (slot && | ||||
| 			    !xa_is_err(xa_store(&session->se_slots, s, slot, | ||||
| 						GFP_NOWAIT))) { | ||||
| 				s += 1; | ||||
| 				session->se_fchannel.maxreqs = s; | ||||
| 			} else { | ||||
| 				kfree(slot); | ||||
| 				slot = NULL; | ||||
| 			} | ||||
| 		} while (slot && --cnt > 0); | ||||
| 	} | ||||
| 	seq->maxslots = session->se_fchannel.maxreqs; | ||||
| 
 | ||||
| out: | ||||
| 	switch (clp->cl_cb_state) { | ||||
| 	case NFSD4_CB_DOWN: | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 NeilBrown
						NeilBrown