Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 188704
b: refs/heads/master
c: 6a02658
h: refs/heads/master
v: v3
  • Loading branch information
Sage Weil committed Feb 11, 2010
1 parent f730de5 commit aa6c340
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 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: 68c283236a1e0772e1a469dd2ffc17afc300b07b
refs/heads/master: 6a026589ba333185c466c906376fe022a27a53f9
39 changes: 26 additions & 13 deletions trunk/fs/ceph/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ static void zero_page_vector_range(int off, int len, struct page **pages)
*/
static int striped_read(struct inode *inode,
u64 off, u64 len,
struct page **pages, int num_pages)
struct page **pages, int num_pages,
int *checkeof)
{
struct ceph_client *client = ceph_inode_to_client(inode);
struct ceph_inode_info *ci = ceph_inode(inode);
Expand Down Expand Up @@ -497,15 +498,7 @@ static int striped_read(struct inode *inode,
}

/* check i_size */
ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE);
if (ret < 0)
goto out;

/* hit EOF? */
if (pos >= inode->i_size)
goto out;

goto more;
*checkeof = 1;
}

out:
Expand All @@ -522,7 +515,7 @@ static int striped_read(struct inode *inode,
* If the read spans object boundary, just do multiple reads.
*/
static ssize_t ceph_sync_read(struct file *file, char __user *data,
unsigned len, loff_t *poff)
unsigned len, loff_t *poff, int *checkeof)
{
struct inode *inode = file->f_dentry->d_inode;
struct page **pages;
Expand Down Expand Up @@ -552,7 +545,7 @@ static ssize_t ceph_sync_read(struct file *file, char __user *data,
if (ret < 0)
goto done;

ret = striped_read(inode, off, len, pages, num_pages);
ret = striped_read(inode, off, len, pages, num_pages, checkeof);

if (ret >= 0 && (file->f_flags & O_DIRECT) == 0)
ret = copy_page_vector_to_user(pages, data, off, ret);
Expand Down Expand Up @@ -746,11 +739,14 @@ static ssize_t ceph_aio_read(struct kiocb *iocb, const struct iovec *iov,
size_t len = iov->iov_len;
struct inode *inode = filp->f_dentry->d_inode;
struct ceph_inode_info *ci = ceph_inode(inode);
void *base = iov->iov_base;
ssize_t ret;
int got = 0;
int checkeof = 0, read = 0;

dout("aio_read %p %llx.%llx %llu~%u trying to get caps on %p\n",
inode, ceph_vinop(inode), pos, (unsigned)len, inode);
again:
__ceph_do_pending_vmtruncate(inode);
ret = ceph_get_caps(ci, CEPH_CAP_FILE_RD, CEPH_CAP_FILE_CACHE,
&got, -1);
Expand All @@ -764,14 +760,31 @@ static ssize_t ceph_aio_read(struct kiocb *iocb, const struct iovec *iov,
(iocb->ki_filp->f_flags & O_DIRECT) ||
(inode->i_sb->s_flags & MS_SYNCHRONOUS))
/* hmm, this isn't really async... */
ret = ceph_sync_read(filp, iov->iov_base, len, ppos);
ret = ceph_sync_read(filp, base, len, ppos, &checkeof);
else
ret = generic_file_aio_read(iocb, iov, nr_segs, pos);

out:
dout("aio_read %p %llx.%llx dropping cap refs on %s = %d\n",
inode, ceph_vinop(inode), ceph_cap_string(got), (int)ret);
ceph_put_cap_refs(ci, got);

if (checkeof && ret >= 0) {
int statret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE);

/* hit EOF or hole? */
if (statret == 0 && *ppos < inode->i_size) {
dout("aio_read sync_read hit hole, reading more\n");
read += ret;
base += ret;
len -= ret;
checkeof = 0;
goto again;
}
}
if (ret >= 0)
ret += read;

return ret;
}

Expand Down

0 comments on commit aa6c340

Please sign in to comment.