patch-2.2.19 linux/fs/nfs/read.c

Next file: linux/fs/nfs/symlink.c
Previous file: linux/fs/nfs/proc.c
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.18/fs/nfs/read.c linux/fs/nfs/read.c
@@ -42,7 +42,7 @@
 
 struct nfs_read_data {
 	struct rpc_task		task;
-	struct dentry		*dentry;
+	struct inode		*inode;
 	struct rpc_cred		*cred;
 	struct nfs_readargs	args;	/* XDR argument struct */
 	struct nfs_readres	res;	/* ... and result struct */
@@ -87,11 +87,9 @@
  * Read a page synchronously.
  */
 static int
-nfs_readpage_sync(struct file *file, struct page *page)
+nfs_readpage_sync(struct file *file, struct inode *inode, struct page *page)
 {
-	struct dentry	*dentry = file->f_dentry;
-	struct inode	*inode = dentry->d_inode;
-	struct rpc_cred	*cred = nfs_file_cred(file);
+	struct rpc_cred	*cred = NULL;
 	struct nfs_fattr fattr;
 	unsigned long	offset = nfs_page_offset(page);
 	char		*buffer = (char *) page_address(page);
@@ -104,19 +102,23 @@
 		flags |= NFS_RPC_SWAPFLAGS;
 
 	dprintk("NFS: nfs_readpage_sync(%p)\n", page);
+
+	if (file)
+		cred = nfs_file_cred(file);
+
 	clear_bit(PG_error, &page->flags);
 
 	do {
 		if ((chunk = rsize) > count)
 			chunk = count;
 
-		dprintk("NFS: nfs_proc_read(%s, (%s/%s), %ld, %d, %p)\n",
+		dprintk("NFS: nfs_proc_read(%s, (%x/%Ld), %ld, %d, %p)\n",
 			NFS_SERVER(inode)->hostname,
-			dentry->d_parent->d_name.name, dentry->d_name.name,
+			inode->i_dev, (long long)NFS_FILEID(inode),
 			offset, chunk, buffer);
 
-		result = NFS_CALL(read, inode, (dentry, &fattr, cred, flags,
-						offset, chunk, buffer, &eof));
+		result = NFS_PROTO(inode)->read(inode, cred, &fattr, flags,
+						offset, chunk, buffer, &eof);
 		nfs_refresh_inode(inode, &fattr);
 
 		/*
@@ -180,7 +182,7 @@
 static inline void
 nfs_mark_request_read(struct nfs_page *req)
 {
-	struct inode *inode = req->wb_dentry->d_inode;
+	struct inode *inode = req->wb_inode;
 
 	if (list_empty(&req->wb_list)) {
 		nfs_list_add_request(req, &inode->u.nfs_i.read);
@@ -190,9 +192,8 @@
 }
 
 static int
-nfs_readpage_async(struct file *file, struct page *page)
+nfs_readpage_async(struct file *file, struct inode *inode, struct page *page)
 {
-	struct inode	*inode = file->f_dentry->d_inode;
 	struct nfs_page	*req, *new = NULL;
 	int		result;
 
@@ -222,7 +223,7 @@
 		}
 
 		result = -ENOMEM;
-		new = nfs_create_request(file, page, 0, PAGE_CACHE_SIZE);
+		new = nfs_create_request(file, inode, page, 0, PAGE_CACHE_SIZE);
 		if (!new)
 			break;
 	}
@@ -258,9 +259,9 @@
 		data->args.nriov++;
 	}
 	req = nfs_list_entry(data->pages.next);
-	data->dentry	  = req->wb_dentry;
+	data->inode	  = req->wb_inode;
 	data->cred	  = req->wb_cred;
-	data->args.fh     = NFS_FH(req->wb_dentry);
+	data->args.fh     = NFS_FH(req->wb_inode);
 	data->args.offset = nfs_page_offset(req->wb_page) + req->wb_offset;
 	data->args.count  = count;
 	data->res.fattr   = &data->fattr;
@@ -286,9 +287,8 @@
 }
 
 static int
-nfs_pagein_one(struct list_head *head, struct dentry *dentry)
+nfs_pagein_one(struct list_head *head, struct inode *inode)
 {
-	struct inode		*inode = dentry->d_inode;
 	struct rpc_task		*task;
 	struct rpc_clnt		*clnt = NFS_CLIENT(inode);
 	struct nfs_read_data	*data;
@@ -322,9 +322,9 @@
 	msg.rpc_cred = data->cred;
 
 	/* Start the async call */
-	dprintk("NFS: %4d initiated read call (req %s/%s count %d nriov %d.\n",
+	dprintk("NFS: %4d initiated read call (req %x/%Ld count %d nriov %d.\n",
 		task->tk_pid,
-		dentry->d_parent->d_name.name, dentry->d_name.name,
+		inode->i_dev, (long long)NFS_FILEID(inode),
 		data->args.count, data->args.nriov);
 
 	rpc_clnt_sigmask(clnt, &oldset);
@@ -349,7 +349,7 @@
 	while (!list_empty(head)) {
 		pages += nfs_coalesce_requests(head, &one_request, rpages);
 		req = nfs_list_entry(one_request.next);
-		error = nfs_pagein_one(&one_request, req->wb_dentry);
+		error = nfs_pagein_one(&one_request, req->wb_inode);
 		if (error < 0)
 			break;
 	}
@@ -419,8 +419,7 @@
 nfs_readpage_result(struct rpc_task *task)
 {
 	struct nfs_read_data	*data = (struct nfs_read_data *) task->tk_calldata;
-	struct dentry		*dentry = data->dentry;
-	struct inode		*inode = dentry->d_inode;
+	struct inode		*inode = data->inode;
 	int			count = data->res.count;
 
 	dprintk("NFS: %4d nfs_readpage_result, (status %d)\n",
@@ -440,9 +439,9 @@
 			set_bit(PG_error, &page->flags);
 		nfs_unlock_page(page);
 
-		dprintk("NFS: read (%s/%s %d@%ld)\n",
-                        req->wb_dentry->d_parent->d_name.name,
-                        req->wb_dentry->d_name.name,
+		dprintk("NFS: read (%x/%Ld %d@%ld)\n",
+			req->wb_inode->i_dev,
+			(long long)NFS_FILEID(req->wb_inode),
                         req->wb_bytes,
                         (nfs_page_offset(page) + req->wb_offset));
 		nfs_unlock_request(req);
@@ -465,16 +464,19 @@
 int
 nfs_readpage(struct file *file, struct page *page)
 {
-	struct dentry *dentry = file->f_dentry;
-	struct inode *inode = dentry->d_inode;
-	int		error = 0,
-			rsize = NFS_SERVER(inode)->rsize;
+	struct inode *inode;
+	int		error = 0;
 
 	while (!nfs_lock_page(page))
 		wait_on_page(page);
 
-	dprintk("NFS: nfs_readpage (%p %d@%ld)\n",
-		page, rsize, page->offset);
+	if (!file)
+		inode = page->inode;
+	else
+		inode = file->f_dentry->d_inode;
+
+	dprintk("NFS: nfs_readpage (%p %ld@%lu)\n",
+		page, PAGE_CACHE_SIZE, page->offset);
 
 	/*
 	 * Try to flush any pending writes to the file
@@ -484,13 +486,13 @@
 		goto out_unlock;
 
 	error = -1;
-	if (!IS_SWAPFILE(inode) && !PageError(page) && rsize >= PAGE_CACHE_SIZE)
-		error = nfs_readpage_async(file, page);
+	if (!PageError(page) && NFS_SERVER(inode)->rsize >= PAGE_CACHE_SIZE)
+		error = nfs_readpage_async(file, inode, page);
 
 	if (error >= 0)
 		goto out;
 
-	error = nfs_readpage_sync(file, page);
+	error = nfs_readpage_sync(file, inode, page);
 	if (error < 0 && IS_SWAPFILE(inode))
 		printk(KERN_ERR "Aiee.. nfs swap-in of page failed!\n");
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)