Skip to content

Commit 121782a

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client: ceph: fix sync and dio writes across stripe boundaries libceph: fix page calculation for non-page-aligned io ceph: fix page alignment corrections
2 parents a8728d3 + d7f124f commit 121782a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

fs/ceph/file.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ static int striped_read(struct inode *inode,
290290
struct ceph_inode_info *ci = ceph_inode(inode);
291291
u64 pos, this_len;
292292
int io_align, page_align;
293-
int page_off = off & ~PAGE_CACHE_MASK; /* first byte's offset in page */
294293
int left, pages_left;
295294
int read;
296295
struct page **page_pos;
@@ -326,12 +325,11 @@ static int striped_read(struct inode *inode,
326325
ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : "");
327326

328327
if (ret > 0) {
329-
int didpages =
330-
((pos & ~PAGE_CACHE_MASK) + ret) >> PAGE_CACHE_SHIFT;
328+
int didpages = (page_align + ret) >> PAGE_CACHE_SHIFT;
331329

332330
if (read < pos - off) {
333331
dout(" zero gap %llu to %llu\n", off + read, pos);
334-
ceph_zero_page_vector_range(page_off + read,
332+
ceph_zero_page_vector_range(page_align + read,
335333
pos - off - read, pages);
336334
}
337335
pos += ret;
@@ -356,7 +354,7 @@ static int striped_read(struct inode *inode,
356354
left = inode->i_size - pos;
357355

358356
dout("zero tail %d\n", left);
359-
ceph_zero_page_vector_range(page_off + read, left,
357+
ceph_zero_page_vector_range(page_align + read, left,
360358
pages);
361359
read += left;
362360
}
@@ -478,9 +476,6 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
478476
else
479477
pos = *offset;
480478

481-
io_align = pos & ~PAGE_MASK;
482-
buf_align = (unsigned long)data & ~PAGE_MASK;
483-
484479
ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + left);
485480
if (ret < 0)
486481
return ret;
@@ -504,6 +499,8 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
504499
* boundary. this isn't atomic, unfortunately. :(
505500
*/
506501
more:
502+
io_align = pos & ~PAGE_MASK;
503+
buf_align = (unsigned long)data & ~PAGE_MASK;
507504
len = left;
508505
if (file->f_flags & O_DIRECT) {
509506
/* write from beginning of first page, regardless of
@@ -593,6 +590,7 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
593590
pos += len;
594591
written += len;
595592
left -= len;
593+
data += written;
596594
if (left)
597595
goto more;
598596

net/ceph/osd_client.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
477477
calc_layout(osdc, vino, layout, off, plen, req, ops);
478478
req->r_file_layout = *layout; /* keep a copy */
479479

480-
/* in case it differs from natural alignment that calc_layout
481-
filled in for us */
480+
/* in case it differs from natural (file) alignment that
481+
calc_layout filled in for us */
482+
req->r_num_pages = calc_pages_for(page_align, *plen);
482483
req->r_page_alignment = page_align;
483484

484485
ceph_osdc_build_request(req, off, plen, ops,
@@ -2027,8 +2028,9 @@ static struct ceph_msg *get_reply(struct ceph_connection *con,
20272028
int want = calc_pages_for(req->r_page_alignment, data_len);
20282029

20292030
if (unlikely(req->r_num_pages < want)) {
2030-
pr_warning("tid %lld reply %d > expected %d pages\n",
2031-
tid, want, m->nr_pages);
2031+
pr_warning("tid %lld reply has %d bytes %d pages, we"
2032+
" had only %d pages ready\n", tid, data_len,
2033+
want, req->r_num_pages);
20322034
*skip = 1;
20332035
ceph_msg_put(m);
20342036
m = NULL;

0 commit comments

Comments
 (0)