Skip to content

Commit d7f124f

Browse files
committed
ceph: fix sync and dio writes across stripe boundaries
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]>
1 parent 9bb0ce2 commit d7f124f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/ceph/file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,6 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
476476
else
477477
pos = *offset;
478478

479-
io_align = pos & ~PAGE_MASK;
480-
buf_align = (unsigned long)data & ~PAGE_MASK;
481-
482479
ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + left);
483480
if (ret < 0)
484481
return ret;
@@ -502,6 +499,8 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
502499
* boundary. this isn't atomic, unfortunately. :(
503500
*/
504501
more:
502+
io_align = pos & ~PAGE_MASK;
503+
buf_align = (unsigned long)data & ~PAGE_MASK;
505504
len = left;
506505
if (file->f_flags & O_DIRECT) {
507506
/* write from beginning of first page, regardless of
@@ -591,6 +590,7 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
591590
pos += len;
592591
written += len;
593592
left -= len;
593+
data += written;
594594
if (left)
595595
goto more;
596596

0 commit comments

Comments
 (0)