patch-2.4.0-test12 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
- Lines: 185
- Date:
Mon Dec 11 09:19:20 2000
- Orig file:
v2.4.0-test11/linux/fs/nfs/read.c
- Orig date:
Sun Nov 19 18:44:19 2000
diff -u --recursive --new-file v2.4.0-test11/linux/fs/nfs/read.c linux/fs/nfs/read.c
@@ -36,7 +36,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 */
@@ -82,10 +82,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 = NULL;
struct nfs_fattr fattr;
loff_t offset = page_offset(page);
char *buffer;
@@ -97,6 +96,9 @@
dprintk("NFS: nfs_readpage_sync(%p)\n", page);
+ if (file)
+ cred = nfs_file_cred(file);
+
/*
* This works now because the socket layer never tries to DMA
* into this buffer directly.
@@ -106,16 +108,16 @@
if (count < rsize)
rsize = 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),
(long long)offset, rsize, buffer);
lock_kernel();
- result = NFS_PROTO(inode)->read(file, &fattr, flags, offset,
- rsize, buffer, &eof);
- unlock_kernel();
+ result = NFS_PROTO(inode)->read(inode, cred, &fattr, flags,
+ offset, rsize, buffer, &eof);
nfs_refresh_inode(inode, &fattr);
+ unlock_kernel();
/*
* Even if we had a partial success we can't mark the page
@@ -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;
spin_lock(&nfs_wreq_lock);
if (list_empty(&req->wb_list)) {
@@ -196,9 +198,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;
@@ -228,7 +229,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;
}
@@ -264,9 +265,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 = page_offset(req->wb_page) + req->wb_offset;
data->args.count = count;
data->res.fattr = &data->fattr;
@@ -292,9 +293,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;
@@ -328,9 +328,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);
@@ -355,7 +355,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;
}
@@ -429,8 +429,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",
@@ -451,9 +450,9 @@
kunmap(page);
UnlockPage(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,
(long long)(page_offset(page) + req->wb_offset));
nfs_unlock_request(req);
@@ -473,9 +472,19 @@
int
nfs_readpage(struct file *file, struct page *page)
{
- struct inode *inode = file->f_dentry->d_inode;
+ struct inode *inode;
int error;
+ if (!file) {
+ struct address_space *mapping = page->mapping;
+ if (!mapping)
+ BUG();
+ inode = (struct inode *)mapping->host;
+ } else
+ inode = file->f_dentry->d_inode;
+ if (!inode)
+ BUG();
+
dprintk("NFS: nfs_readpage (%p %ld@%lu)\n",
page, PAGE_CACHE_SIZE, page->index);
/*
@@ -491,11 +500,11 @@
error = -1;
if (!PageError(page) && NFS_SERVER(inode)->rsize >= PAGE_CACHE_SIZE)
- error = nfs_readpage_async(file, page);
+ 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("Aiee.. nfs swap-in of page failed!\n");
out:
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)