Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 206443
b: refs/heads/master
c: fa0a212
h: refs/heads/master
i:
  206441: 434d1a0
  206439: 23abfc8
v: v3
  • Loading branch information
J. Bruce Fields committed Jul 27, 2010
1 parent 46724d8 commit 0db7f01
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: af4718f3f996925f770e540004ec9224243d1682
refs/heads/master: fa0a21269f807bb2e95b8b642c4a739714780172
62 changes: 38 additions & 24 deletions trunk/fs/nfsd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,6 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
loff_t offset, struct kvec *vec, int vlen, unsigned long *count)
{
struct inode *inode;
struct raparms *ra;
mm_segment_t oldfs;
__be32 err;
int host_err;
Expand All @@ -915,12 +914,6 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
if (svc_msnfs(fhp) && !lock_may_read(inode, offset, *count))
goto out;

/* Get readahead parameters */
ra = nfsd_get_raparms(inode->i_sb->s_dev, inode->i_ino);

if (ra && ra->p_set)
file->f_ra = ra->p_ra;

if (file->f_op->splice_read && rqstp->rq_splice_ok) {
struct splice_desc sd = {
.len = 0,
Expand All @@ -938,16 +931,6 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
set_fs(oldfs);
}

/* Write back readahead params */
if (ra) {
struct raparm_hbucket *rab = &raparm_hash[ra->p_hindex];
spin_lock(&rab->pb_lock);
ra->p_ra = file->f_ra;
ra->p_set = 1;
ra->p_count--;
spin_unlock(&rab->pb_lock);
}

if (host_err >= 0) {
nfsdstats.io_read += host_err;
*count = host_err;
Expand Down Expand Up @@ -1082,6 +1065,42 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
return err;
}

static __be32 nfsd_open_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
loff_t offset, struct kvec *vec, int vlen, unsigned long *count)
{
struct file *file;
struct inode *inode;
struct raparms *ra;
__be32 err;

err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file);
if (err)
return err;

inode = file->f_path.dentry->d_inode;

/* Get readahead parameters */
ra = nfsd_get_raparms(inode->i_sb->s_dev, inode->i_ino);

if (ra && ra->p_set)
file->f_ra = ra->p_ra;

err = nfsd_vfs_read(rqstp, fhp, file, offset, vec, vlen, count);

/* Write back readahead params */
if (ra) {
struct raparm_hbucket *rab = &raparm_hash[ra->p_hindex];
spin_lock(&rab->pb_lock);
ra->p_ra = file->f_ra;
ra->p_set = 1;
ra->p_count--;
spin_unlock(&rab->pb_lock);
}

nfsd_close(file);
return err;
}

/*
* Read data from a file. count must contain the requested read count
* on entry. On return, *count contains the number of bytes actually read.
Expand All @@ -1100,13 +1119,8 @@ nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
if (err)
goto out;
err = nfsd_vfs_read(rqstp, fhp, file, offset, vec, vlen, count);
} else {
err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file);
if (err)
goto out;
err = nfsd_vfs_read(rqstp, fhp, file, offset, vec, vlen, count);
nfsd_close(file);
}
} else
err = nfsd_open_read(rqstp, fhp, offset, vec, vlen, count);
out:
return err;
}
Expand Down

0 comments on commit 0db7f01

Please sign in to comment.