Skip to content

Commit

Permalink
ceph: fix sync and dio writes across stripe boundaries
Browse files Browse the repository at this point in the history
We were iterating across stripe boundaries properly, but not moving the
write buffer pointer forward.  This caused us to rewrite the same data
after the break.  Fix by adjusting the data pointer forward, and
recalculating the io and buffer alignment after the break.

Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed Jun 13, 2011
1 parent 9bb0ce2 commit d7f124f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/ceph/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,6 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
else
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);
if (ret < 0)
return ret;
Expand All @@ -502,6 +499,8 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
* boundary. this isn't atomic, unfortunately. :(
*/
more:
io_align = pos & ~PAGE_MASK;
buf_align = (unsigned long)data & ~PAGE_MASK;
len = left;
if (file->f_flags & O_DIRECT) {
/* write from beginning of first page, regardless of
Expand Down Expand Up @@ -591,6 +590,7 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
pos += len;
written += len;
left -= len;
data += written;
if (left)
goto more;

Expand Down

0 comments on commit d7f124f

Please sign in to comment.