| .. | .. |
|---|
| 394 | 394 | data_size = zonefs_check_zone_condition(inode, zone, |
|---|
| 395 | 395 | false, false); |
|---|
| 396 | 396 | } |
|---|
| 397 | + } else if (sbi->s_mount_opts & ZONEFS_MNTOPT_ERRORS_RO && |
|---|
| 398 | + data_size > isize) { |
|---|
| 399 | + /* Do not expose garbage data */ |
|---|
| 400 | + data_size = isize; |
|---|
| 397 | 401 | } |
|---|
| 398 | 402 | |
|---|
| 399 | 403 | /* |
|---|
| .. | .. |
|---|
| 772 | 776 | |
|---|
| 773 | 777 | ret = submit_bio_wait(bio); |
|---|
| 774 | 778 | |
|---|
| 779 | + /* |
|---|
| 780 | + * If the file zone was written underneath the file system, the zone |
|---|
| 781 | + * write pointer may not be where we expect it to be, but the zone |
|---|
| 782 | + * append write can still succeed. So check manually that we wrote where |
|---|
| 783 | + * we intended to, that is, at zi->i_wpoffset. |
|---|
| 784 | + */ |
|---|
| 785 | + if (!ret) { |
|---|
| 786 | + sector_t wpsector = |
|---|
| 787 | + zi->i_zsector + (zi->i_wpoffset >> SECTOR_SHIFT); |
|---|
| 788 | + |
|---|
| 789 | + if (bio->bi_iter.bi_sector != wpsector) { |
|---|
| 790 | + zonefs_warn(inode->i_sb, |
|---|
| 791 | + "Corrupted write pointer %llu for zone at %llu\n", |
|---|
| 792 | + bio->bi_iter.bi_sector, zi->i_zsector); |
|---|
| 793 | + ret = -EIO; |
|---|
| 794 | + } |
|---|
| 795 | + } |
|---|
| 796 | + |
|---|
| 775 | 797 | zonefs_file_write_dio_end_io(iocb, size, ret, 0); |
|---|
| 776 | 798 | |
|---|
| 777 | 799 | out_release: |
|---|