kernels/linux-2.4.0/fs/nfs/write.c
/*
 * Create a write request.
 * Page must be locked by the caller. This makes sure we never create
 * two different requests for the same page, and avoids possible deadlock
 * when we reach the hard limit on the number of dirty pages.
 * It should be safe to sleep here.
 */
Create a write request.
Page must be locked by the caller. This makes sure we never create
two different requests for the same page, and avoids possible deadlock
when we reach the hard limit on the number of dirty pages.
It should be safe to sleep here.
Create a write request . Page must be locked by the caller . This makes sure we never create two different requests for the same page and avoids possible deadlock when we reach the hard limit on the number of dirty pages . It should be safe to sleep here .
struct nfs_page *nfs_create_request(struct file *file, struct inode *inode,
				    struct page *page,
				    unsigned int offset, unsigned int count)
{
	struct nfs_reqlist	*cache = NFS_REQUESTLIST(inode);
	struct nfs_page		*req = NULL;
	long			timeout;
	do {
		if (atomic_read(&nfs_nr_requests) >= MAX_REQUEST_SOFT) {
			dprintk("NFS:      hit soft limit (%d requests)\n",
				atomic_read(&nfs_nr_requests));
			if (!cache->task)
				nfs_reqlist_init(NFS_SERVER(inode));
			nfs_wake_flushd();
		}
		if (atomic_read(&cache->nr_requests) < MAX_REQUEST_HARD) {
			req = nfs_page_alloc();
			if (req != NULL)
				break;
		}
		dprintk("NFS:      create_request sleeping (total %d pid %d)\n",
			atomic_read(&cache->nr_requests), current->pid);
		timeout = 1 * HZ;
		if (NFS_SERVER(inode)->flags & NFS_MOUNT_INTR) {
			interruptible_sleep_on_timeout(&cache->request_wait,
						       timeout);
			if (signalled())
				break;
		} else
			sleep_on_timeout(&cache->request_wait, timeout);
		dprintk("NFS:      create_request waking up (tot %d pid %d)\n",
			atomic_read(&cache->nr_requests), current->pid);
	} while (!req);
	if (!req)
		return NULL;
	req->wb_page    = page;
	page_cache_get(page);
	req->wb_offset  = offset;
	req->wb_bytes   = count;
	req->wb_file    = file;
	if (file) {
		get_file(file);
		req->wb_cred	= nfs_file_cred(file);
	} else
		req->wb_cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0);
	req->wb_inode   = inode;
	req->wb_count   = 1;
	atomic_inc(&cache->nr_requests);
	atomic_inc(&nfs_nr_requests);
	return req;
}
struct nfs_page * nfs_create_request ( struct file * file , struct inode * inode , struct page * page , unsigned int offset , unsigned int count ) { struct nfs_reqlist * cache = NFS_REQUESTLIST ( inode ) ; struct nfs_page * req = NULL ; long timeout ; do { if ( atomic_read ( & nfs_nr_requests ) >= MAX_REQUEST_SOFT ) { dprintk ( " \n " , atomic_read ( & nfs_nr_requests ) ) ; if ( ! cache -> task ) nfs_reqlist_init ( NFS_SERVER ( inode ) ) ; nfs_wake_flushd ( ) ; } if ( atomic_read ( & cache -> nr_requests ) < MAX_REQUEST_HARD ) { req = nfs_page_alloc ( ) ; if ( req != NULL ) break ; } dprintk ( " \n " , atomic_read ( & cache -> nr_requests ) , current -> pid ) ; timeout = 1 * HZ ; if ( NFS_SERVER ( inode ) -> flags & NFS_MOUNT_INTR ) { interruptible_sleep_on_timeout ( & cache -> request_wait , timeout ) ; if ( signalled ( ) ) break ; } else sleep_on_timeout ( & cache -> request_wait , timeout ) ; dprintk ( " \n " , atomic_read ( & cache -> nr_requests ) , current -> pid ) ; } while ( ! req ) ; if ( ! req ) return NULL ; req -> wb_page = page ; page_cache_get ( page ) ; req -> wb_offset = offset ; req -> wb_bytes = count ; req -> wb_file = file ; if ( file ) { get_file ( file ) ; req -> wb_cred = nfs_file_cred ( file ) ; } else req -> wb_cred = rpcauth_lookupcred ( NFS_CLIENT ( inode ) -> cl_auth , 0 ) ; req -> wb_inode = inode ; req -> wb_count = 1 ; atomic_inc ( & cache -> nr_requests ) ; atomic_inc ( & nfs_nr_requests ) ; return req ; }
Create a write request.
Create a write request .
/* Deal with hard/soft limits.
	 */ /* If we're over the global soft limit, wake up all requests */ /* If we haven't reached the local hard limit yet,
		 * try to allocate the request struct */ /* We're over the hard limit. Wait for better times */ /* Initialize the request struct. Initially, we assume a
	 * long write-back delay. This will be adjusted in
	 * update_nfs_request below if the region is not locked. */ /* If we have a struct file, use its cached credentials
	 * else cache the current process' credentials. */ /* register request's existence */