| .. | .. |
|---|
| 39 | 39 | XFS_I(ioend->io_inode)->i_d.di_size; |
|---|
| 40 | 40 | } |
|---|
| 41 | 41 | |
|---|
| 42 | | -STATIC int |
|---|
| 43 | | -xfs_setfilesize_trans_alloc( |
|---|
| 44 | | - struct iomap_ioend *ioend) |
|---|
| 45 | | -{ |
|---|
| 46 | | - struct xfs_mount *mp = XFS_I(ioend->io_inode)->i_mount; |
|---|
| 47 | | - struct xfs_trans *tp; |
|---|
| 48 | | - int error; |
|---|
| 49 | | - |
|---|
| 50 | | - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp); |
|---|
| 51 | | - if (error) |
|---|
| 52 | | - return error; |
|---|
| 53 | | - |
|---|
| 54 | | - ioend->io_private = tp; |
|---|
| 55 | | - |
|---|
| 56 | | - /* |
|---|
| 57 | | - * We may pass freeze protection with a transaction. So tell lockdep |
|---|
| 58 | | - * we released it. |
|---|
| 59 | | - */ |
|---|
| 60 | | - __sb_writers_release(ioend->io_inode->i_sb, SB_FREEZE_FS); |
|---|
| 61 | | - /* |
|---|
| 62 | | - * We hand off the transaction to the completion thread now, so |
|---|
| 63 | | - * clear the flag here. |
|---|
| 64 | | - */ |
|---|
| 65 | | - xfs_trans_clear_context(tp); |
|---|
| 66 | | - return 0; |
|---|
| 67 | | -} |
|---|
| 68 | | - |
|---|
| 69 | 42 | /* |
|---|
| 70 | 43 | * Update on-disk file size now that data has been written to disk. |
|---|
| 71 | 44 | */ |
|---|
| .. | .. |
|---|
| 191 | 164 | error = xfs_reflink_end_cow(ip, offset, size); |
|---|
| 192 | 165 | else if (ioend->io_type == IOMAP_UNWRITTEN) |
|---|
| 193 | 166 | error = xfs_iomap_write_unwritten(ip, offset, size, false); |
|---|
| 194 | | - else |
|---|
| 195 | | - ASSERT(!xfs_ioend_is_append(ioend) || ioend->io_private); |
|---|
| 196 | 167 | |
|---|
| 168 | + if (!error && xfs_ioend_is_append(ioend)) |
|---|
| 169 | + error = xfs_setfilesize(ip, ioend->io_offset, ioend->io_size); |
|---|
| 197 | 170 | done: |
|---|
| 198 | | - if (ioend->io_private) |
|---|
| 199 | | - error = xfs_setfilesize_ioend(ioend, error); |
|---|
| 200 | 171 | iomap_finish_ioends(ioend, error); |
|---|
| 201 | 172 | memalloc_nofs_restore(nofs_flag); |
|---|
| 202 | 173 | } |
|---|
| .. | .. |
|---|
| 246 | 217 | |
|---|
| 247 | 218 | static inline bool xfs_ioend_needs_workqueue(struct iomap_ioend *ioend) |
|---|
| 248 | 219 | { |
|---|
| 249 | | - return ioend->io_private || |
|---|
| 220 | + return xfs_ioend_is_append(ioend) || |
|---|
| 250 | 221 | ioend->io_type == IOMAP_UNWRITTEN || |
|---|
| 251 | 222 | (ioend->io_flags & IOMAP_F_SHARED); |
|---|
| 252 | 223 | } |
|---|
| .. | .. |
|---|
| 258 | 229 | struct iomap_ioend *ioend = bio->bi_private; |
|---|
| 259 | 230 | struct xfs_inode *ip = XFS_I(ioend->io_inode); |
|---|
| 260 | 231 | unsigned long flags; |
|---|
| 261 | | - |
|---|
| 262 | | - ASSERT(xfs_ioend_needs_workqueue(ioend)); |
|---|
| 263 | 232 | |
|---|
| 264 | 233 | spin_lock_irqsave(&ip->i_ioend_lock, flags); |
|---|
| 265 | 234 | if (list_empty(&ip->i_ioend_list)) |
|---|
| .. | .. |
|---|
| 509 | 478 | status = xfs_reflink_convert_cow(XFS_I(ioend->io_inode), |
|---|
| 510 | 479 | ioend->io_offset, ioend->io_size); |
|---|
| 511 | 480 | } |
|---|
| 512 | | - |
|---|
| 513 | | - /* Reserve log space if we might write beyond the on-disk inode size. */ |
|---|
| 514 | | - if (!status && |
|---|
| 515 | | - ((ioend->io_flags & IOMAP_F_SHARED) || |
|---|
| 516 | | - ioend->io_type != IOMAP_UNWRITTEN) && |
|---|
| 517 | | - xfs_ioend_is_append(ioend) && |
|---|
| 518 | | - !ioend->io_private) |
|---|
| 519 | | - status = xfs_setfilesize_trans_alloc(ioend); |
|---|
| 520 | 481 | |
|---|
| 521 | 482 | memalloc_nofs_restore(nofs_flag); |
|---|
| 522 | 483 | |
|---|