Commit 121782a2 authored by Linus Torvalds's avatar Linus Torvalds

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
parents a8728d35 d7f124f1
...@@ -290,7 +290,6 @@ static int striped_read(struct inode *inode, ...@@ -290,7 +290,6 @@ static int striped_read(struct inode *inode,
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
u64 pos, this_len; u64 pos, this_len;
int io_align, page_align; int io_align, page_align;
int page_off = off & ~PAGE_CACHE_MASK; /* first byte's offset in page */
int left, pages_left; int left, pages_left;
int read; int read;
struct page **page_pos; struct page **page_pos;
...@@ -326,12 +325,11 @@ static int striped_read(struct inode *inode, ...@@ -326,12 +325,11 @@ static int striped_read(struct inode *inode,
ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : ""); ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : "");
if (ret > 0) { if (ret > 0) {
int didpages = int didpages = (page_align + ret) >> PAGE_CACHE_SHIFT;
((pos & ~PAGE_CACHE_MASK) + ret) >> PAGE_CACHE_SHIFT;
if (read < pos - off) { if (read < pos - off) {
dout(" zero gap %llu to %llu\n", off + read, pos); dout(" zero gap %llu to %llu\n", off + read, pos);
ceph_zero_page_vector_range(page_off + read, ceph_zero_page_vector_range(page_align + read,
pos - off - read, pages); pos - off - read, pages);
} }
pos += ret; pos += ret;
...@@ -356,7 +354,7 @@ static int striped_read(struct inode *inode, ...@@ -356,7 +354,7 @@ static int striped_read(struct inode *inode,
left = inode->i_size - pos; left = inode->i_size - pos;
dout("zero tail %d\n", left); dout("zero tail %d\n", left);
ceph_zero_page_vector_range(page_off + read, left, ceph_zero_page_vector_range(page_align + read, left,
pages); pages);
read += left; read += left;
} }
...@@ -478,9 +476,6 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data, ...@@ -478,9 +476,6 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
else else
pos = *offset; pos = *offset;
io_align = pos & ~PAGE_MASK;
buf_align = (unsigned long)data & ~PAGE_MASK;
ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + left); ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + left);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -504,6 +499,8 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data, ...@@ -504,6 +499,8 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
* boundary. this isn't atomic, unfortunately. :( * boundary. this isn't atomic, unfortunately. :(
*/ */
more: more:
io_align = pos & ~PAGE_MASK;
buf_align = (unsigned long)data & ~PAGE_MASK;
len = left; len = left;
if (file->f_flags & O_DIRECT) { if (file->f_flags & O_DIRECT) {
/* write from beginning of first page, regardless of /* 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, ...@@ -593,6 +590,7 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
pos += len; pos += len;
written += len; written += len;
left -= len; left -= len;
data += written;
if (left) if (left)
goto more; goto more;
......
...@@ -477,8 +477,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, ...@@ -477,8 +477,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
calc_layout(osdc, vino, layout, off, plen, req, ops); calc_layout(osdc, vino, layout, off, plen, req, ops);
req->r_file_layout = *layout; /* keep a copy */ req->r_file_layout = *layout; /* keep a copy */
/* in case it differs from natural alignment that calc_layout /* in case it differs from natural (file) alignment that
filled in for us */ calc_layout filled in for us */
req->r_num_pages = calc_pages_for(page_align, *plen);
req->r_page_alignment = page_align; req->r_page_alignment = page_align;
ceph_osdc_build_request(req, off, plen, ops, ceph_osdc_build_request(req, off, plen, ops,
...@@ -2027,8 +2028,9 @@ static struct ceph_msg *get_reply(struct ceph_connection *con, ...@@ -2027,8 +2028,9 @@ static struct ceph_msg *get_reply(struct ceph_connection *con,
int want = calc_pages_for(req->r_page_alignment, data_len); int want = calc_pages_for(req->r_page_alignment, data_len);
if (unlikely(req->r_num_pages < want)) { if (unlikely(req->r_num_pages < want)) {
pr_warning("tid %lld reply %d > expected %d pages\n", pr_warning("tid %lld reply has %d bytes %d pages, we"
tid, want, m->nr_pages); " had only %d pages ready\n", tid, data_len,
want, req->r_num_pages);
*skip = 1; *skip = 1;
ceph_msg_put(m); ceph_msg_put(m);
m = NULL; m = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment