diff options
Diffstat (limited to 'fs/ceph/file.c')
-rw-r--r-- | fs/ceph/file.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 203252d88d9f..9542f07d0b93 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -191,7 +191,8 @@ int ceph_open(struct inode *inode, struct file *file) | |||
191 | err = PTR_ERR(req); | 191 | err = PTR_ERR(req); |
192 | goto out; | 192 | goto out; |
193 | } | 193 | } |
194 | req->r_inode = igrab(inode); | 194 | req->r_inode = inode; |
195 | ihold(inode); | ||
195 | req->r_num_caps = 1; | 196 | req->r_num_caps = 1; |
196 | err = ceph_mdsc_do_request(mdsc, parent_inode, req); | 197 | err = ceph_mdsc_do_request(mdsc, parent_inode, req); |
197 | if (!err) | 198 | if (!err) |
@@ -282,7 +283,7 @@ int ceph_release(struct inode *inode, struct file *file) | |||
282 | static int striped_read(struct inode *inode, | 283 | static int striped_read(struct inode *inode, |
283 | u64 off, u64 len, | 284 | u64 off, u64 len, |
284 | struct page **pages, int num_pages, | 285 | struct page **pages, int num_pages, |
285 | int *checkeof, bool align_to_pages, | 286 | int *checkeof, bool o_direct, |
286 | unsigned long buf_align) | 287 | unsigned long buf_align) |
287 | { | 288 | { |
288 | struct ceph_fs_client *fsc = ceph_inode_to_client(inode); | 289 | struct ceph_fs_client *fsc = ceph_inode_to_client(inode); |
@@ -307,7 +308,7 @@ static int striped_read(struct inode *inode, | |||
307 | io_align = off & ~PAGE_MASK; | 308 | io_align = off & ~PAGE_MASK; |
308 | 309 | ||
309 | more: | 310 | more: |
310 | if (align_to_pages) | 311 | if (o_direct) |
311 | page_align = (pos - io_align + buf_align) & ~PAGE_MASK; | 312 | page_align = (pos - io_align + buf_align) & ~PAGE_MASK; |
312 | else | 313 | else |
313 | page_align = pos & ~PAGE_MASK; | 314 | page_align = pos & ~PAGE_MASK; |
@@ -317,10 +318,10 @@ more: | |||
317 | ci->i_truncate_seq, | 318 | ci->i_truncate_seq, |
318 | ci->i_truncate_size, | 319 | ci->i_truncate_size, |
319 | page_pos, pages_left, page_align); | 320 | page_pos, pages_left, page_align); |
320 | hit_stripe = this_len < left; | ||
321 | was_short = ret >= 0 && ret < this_len; | ||
322 | if (ret == -ENOENT) | 321 | if (ret == -ENOENT) |
323 | ret = 0; | 322 | ret = 0; |
323 | hit_stripe = this_len < left; | ||
324 | was_short = ret >= 0 && ret < this_len; | ||
324 | dout("striped_read %llu~%u (read %u) got %d%s%s\n", pos, left, read, | 325 | dout("striped_read %llu~%u (read %u) got %d%s%s\n", pos, left, read, |
325 | ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : ""); | 326 | ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : ""); |
326 | 327 | ||
@@ -345,20 +346,22 @@ more: | |||
345 | } | 346 | } |
346 | 347 | ||
347 | if (was_short) { | 348 | if (was_short) { |
348 | /* was original extent fully inside i_size? */ | 349 | /* did we bounce off eof? */ |
349 | if (pos + left <= inode->i_size) { | 350 | if (pos + left > inode->i_size) |
350 | dout("zero tail\n"); | 351 | *checkeof = 1; |
351 | ceph_zero_page_vector_range(page_off + read, len - read, | 352 | |
353 | /* zero trailing bytes (inside i_size) */ | ||
354 | if (left > 0 && pos < inode->i_size) { | ||
355 | if (pos + left > inode->i_size) | ||
356 | left = inode->i_size - pos; | ||
357 | |||
358 | dout("zero tail %d\n", left); | ||
359 | ceph_zero_page_vector_range(page_off + read, left, | ||
352 | pages); | 360 | pages); |
353 | read = len; | 361 | read += left; |
354 | goto out; | ||
355 | } | 362 | } |
356 | |||
357 | /* check i_size */ | ||
358 | *checkeof = 1; | ||
359 | } | 363 | } |
360 | 364 | ||
361 | out: | ||
362 | if (ret >= 0) | 365 | if (ret >= 0) |
363 | ret = read; | 366 | ret = read; |
364 | dout("striped_read returns %d\n", ret); | 367 | dout("striped_read returns %d\n", ret); |
@@ -658,7 +661,7 @@ out: | |||
658 | 661 | ||
659 | /* hit EOF or hole? */ | 662 | /* hit EOF or hole? */ |
660 | if (statret == 0 && *ppos < inode->i_size) { | 663 | if (statret == 0 && *ppos < inode->i_size) { |
661 | dout("aio_read sync_read hit hole, reading more\n"); | 664 | dout("aio_read sync_read hit hole, ppos %lld < size %lld, reading more\n", *ppos, inode->i_size); |
662 | read += ret; | 665 | read += ret; |
663 | base += ret; | 666 | base += ret; |
664 | len -= ret; | 667 | len -= ret; |