Message ID | 20240328163424.2781320-18-dhowells@redhat.com |
---|---|
State | New |
Headers | show |
Series | [01/26] cifs: Fix duplicate fscache cookie warnings | expand |
On Thu, 2024-03-28 at 16:34 +0000, David Howells wrote: > 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. > > Signed-off-by: David Howells <dhowells@redhat.com> > cc: Jeff Layton <jlayton@kernel.org> > cc: netfs@lists.linux.dev > cc: linux-fsdevel@vger.kernel.org > --- > fs/netfs/buffered_write.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c > index 8e4a3fb287e3..db4ad158948b 100644 > --- a/fs/netfs/buffered_write.c > +++ b/fs/netfs/buffered_write.c > @@ -188,7 +188,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter, > enum netfs_how_to_modify howto; > enum netfs_folio_trace trace; > unsigned int bdp_flags = (iocb->ki_flags & IOCB_SYNC) ? 0: BDP_ASYNC; > - ssize_t written = 0, ret; > + ssize_t written = 0, ret, ret2; > loff_t i_size, pos = iocb->ki_pos, from, to; > size_t max_chunk = PAGE_SIZE << MAX_PAGECACHE_ORDER; > bool maybe_trouble = false; > @@ -409,10 +409,12 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter, > > out: > if (unlikely(wreq)) { > - ret = netfs_end_writethrough(wreq, iocb); > + ret2 = netfs_end_writethrough(wreq, iocb); > wbc_detach_inode(&wbc); > - if (ret == -EIOCBQUEUED) > - return ret; > + if (ret2 == -EIOCBQUEUED) > + return ret2; > + if (ret == 0) > + ret = ret2; > } > > iocb->ki_pos += written; > Should this be merged independently? It looks like a bug that's present now. Reviewed-by: Jeff Layton <jlayton@kernel.org>
Jeff Layton <jlayton@kernel.org> wrote: > Should this be merged independently? It looks like a bug that's present > now. Yes. I've just posted that as a separate fix for Christian to pick up. I still need to keep it in this set, though, until it is upstream. David
diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index 8e4a3fb287e3..db4ad158948b 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -188,7 +188,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter, enum netfs_how_to_modify howto; enum netfs_folio_trace trace; unsigned int bdp_flags = (iocb->ki_flags & IOCB_SYNC) ? 0: BDP_ASYNC; - ssize_t written = 0, ret; + ssize_t written = 0, ret, ret2; loff_t i_size, pos = iocb->ki_pos, from, to; size_t max_chunk = PAGE_SIZE << MAX_PAGECACHE_ORDER; bool maybe_trouble = false; @@ -409,10 +409,12 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter, out: if (unlikely(wreq)) { - ret = netfs_end_writethrough(wreq, iocb); + ret2 = netfs_end_writethrough(wreq, iocb); wbc_detach_inode(&wbc); - if (ret == -EIOCBQUEUED) - return ret; + if (ret2 == -EIOCBQUEUED) + return ret2; + if (ret == 0) + ret = ret2; } iocb->ki_pos += written;
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. Signed-off-by: David Howells <dhowells@redhat.com> cc: Jeff Layton <jlayton@kernel.org> cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/netfs/buffered_write.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)