Skip to content

Commit 619606a

Browse files
dhowellsbrauner
authored andcommitted
netfs: Fix writethrough-mode error handling
Fix the error return in netfs_perform_write() acting in writethrough-mode to return any cached error in the case that netfs_end_writethrough() returns 0. This can affect the use of O_SYNC/O_DSYNC/RWF_SYNC/RWF_DSYNC in 9p and afs. Fixes: 41d8e76 ("netfs: Implement a write-through caching option") Signed-off-by: David Howells <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jeff Layton <[email protected]> cc: Eric Van Hensbergen <[email protected]> cc: Latchesar Ionkov <[email protected]> cc: Dominique Martinet <[email protected]> cc: Christian Schoenebeck <[email protected]> cc: Marc Dionne <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 9b872cc commit 619606a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fs/netfs/buffered_write.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
164164
enum netfs_how_to_modify howto;
165165
enum netfs_folio_trace trace;
166166
unsigned int bdp_flags = (iocb->ki_flags & IOCB_SYNC) ? 0: BDP_ASYNC;
167-
ssize_t written = 0, ret;
167+
ssize_t written = 0, ret, ret2;
168168
loff_t i_size, pos = iocb->ki_pos, from, to;
169169
size_t max_chunk = PAGE_SIZE << MAX_PAGECACHE_ORDER;
170170
bool maybe_trouble = false;
@@ -395,10 +395,12 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
395395

396396
out:
397397
if (unlikely(wreq)) {
398-
ret = netfs_end_writethrough(wreq, iocb);
398+
ret2 = netfs_end_writethrough(wreq, iocb);
399399
wbc_detach_inode(&wbc);
400-
if (ret == -EIOCBQUEUED)
401-
return ret;
400+
if (ret2 == -EIOCBQUEUED)
401+
return ret2;
402+
if (ret == 0)
403+
ret = ret2;
402404
}
403405

404406
iocb->ki_pos += written;

0 commit comments

Comments
 (0)