All of lore.kernel.org
 help / color / mirror / Atom feed
* [v4.14.y PATCH] errseq: Always report a writeback error once
@ 2018-05-06 15:59 Jeff Layton
  2018-05-06 19:02 ` Matthew Wilcox
  2018-05-07  1:15 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Jeff Layton @ 2018-05-06 15:59 UTC (permalink / raw)
  To: stable; +Cc: willy

From: Matthew Wilcox <willy@infradead.org>

The errseq_t infrastructure assumes that errors which occurred before
the file descriptor was opened are of no interest to the application.
This turns out to be a regression for some applications, notably Postgres.

Before errseq_t, a writeback error would be reported exactly once (as
long as the inode remained in memory), so Postgres could open a file,
call fsync() and find out whether there had been a writeback error on
that file from another process.

This patch changes the errseq infrastructure to report errors to all
file descriptors which are opened after the error occurred, but before
it was reported to any file descriptor.  This restores the user-visible
behaviour.

[ jlayton: fix up conflicts in comments ]

Cc: stable@vger.kernel.org
Fixes: 5660e13d2fd6 ("fs: new infrastructure for writeback error handling and reporting")
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
(cherry picked from commit b4678df184b314a2bd47d2329feca2c2534aa12b)
---
 lib/errseq.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

This is a backport to the v4.14 stable series. The only merge conflict
was due to an earlier patch by Willy to flesh out the comments. There
were no code changes necessary.

diff --git a/lib/errseq.c b/lib/errseq.c
index 79cc66897db4..b6ed81ec788d 100644
--- a/lib/errseq.c
+++ b/lib/errseq.c
@@ -111,25 +111,22 @@ EXPORT_SYMBOL(errseq_set);
  * errseq_sample - grab current errseq_t value
  * @eseq: pointer to errseq_t to be sampled
  *
- * This function allows callers to sample an errseq_t value, marking it as
- * "seen" if required.
+ * This function allows callers to initialise their errseq_t variable.
+ * If the error has been "seen", new callers will not see an old error.
+ * If there is an unseen error in @eseq, the caller of this function will
+ * see it the next time it checks for an error.
+ *
+ * Context: Any context.
+ * Return: The current errseq value.
  */
 errseq_t errseq_sample(errseq_t *eseq)
 {
 	errseq_t old = READ_ONCE(*eseq);
-	errseq_t new = old;
 
-	/*
-	 * For the common case of no errors ever having been set, we can skip
-	 * marking the SEEN bit. Once an error has been set, the value will
-	 * never go back to zero.
-	 */
-	if (old != 0) {
-		new |= ERRSEQ_SEEN;
-		if (old != new)
-			cmpxchg(eseq, old, new);
-	}
-	return new;
+	/* If nobody has seen this error yet, then we can be the first. */
+	if (!(old & ERRSEQ_SEEN))
+		old = 0;
+	return old;
 }
 EXPORT_SYMBOL(errseq_sample);
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [v4.14.y PATCH] errseq: Always report a writeback error once
  2018-05-06 15:59 [v4.14.y PATCH] errseq: Always report a writeback error once Jeff Layton
@ 2018-05-06 19:02 ` Matthew Wilcox
  2018-05-07  1:15 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2018-05-06 19:02 UTC (permalink / raw)
  To: Jeff Layton; +Cc: stable

On Sun, May 06, 2018 at 11:59:57AM -0400, Jeff Layton wrote:
> From: Matthew Wilcox <willy@infradead.org>
> 
> The errseq_t infrastructure assumes that errors which occurred before
> the file descriptor was opened are of no interest to the application.
> This turns out to be a regression for some applications, notably Postgres.
> 
> Before errseq_t, a writeback error would be reported exactly once (as
> long as the inode remained in memory), so Postgres could open a file,
> call fsync() and find out whether there had been a writeback error on
> that file from another process.
> 
> This patch changes the errseq infrastructure to report errors to all
> file descriptors which are opened after the error occurred, but before
> it was reported to any file descriptor.  This restores the user-visible
> behaviour.
> 
> [ jlayton: fix up conflicts in comments ]

Thanks!  I was just getting to this conflict :-)

I agree this resolution is the best one for 4.14.x

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [v4.14.y PATCH] errseq: Always report a writeback error once
  2018-05-06 15:59 [v4.14.y PATCH] errseq: Always report a writeback error once Jeff Layton
  2018-05-06 19:02 ` Matthew Wilcox
@ 2018-05-07  1:15 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2018-05-07  1:15 UTC (permalink / raw)
  To: Jeff Layton; +Cc: stable, willy

On Sun, May 06, 2018 at 11:59:57AM -0400, Jeff Layton wrote:
> From: Matthew Wilcox <willy@infradead.org>
> 
> The errseq_t infrastructure assumes that errors which occurred before
> the file descriptor was opened are of no interest to the application.
> This turns out to be a regression for some applications, notably Postgres.
> 
> Before errseq_t, a writeback error would be reported exactly once (as
> long as the inode remained in memory), so Postgres could open a file,
> call fsync() and find out whether there had been a writeback error on
> that file from another process.
> 
> This patch changes the errseq infrastructure to report errors to all
> file descriptors which are opened after the error occurred, but before
> it was reported to any file descriptor.  This restores the user-visible
> behaviour.
> 
> [ jlayton: fix up conflicts in comments ]
> 
> Cc: stable@vger.kernel.org
> Fixes: 5660e13d2fd6 ("fs: new infrastructure for writeback error handling and reporting")
> Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
> Reviewed-by: Jeff Layton <jlayton@kernel.org>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> (cherry picked from commit b4678df184b314a2bd47d2329feca2c2534aa12b)
> ---
>  lib/errseq.c | 25 +++++++++++--------------
>  1 file changed, 11 insertions(+), 14 deletions(-)
> 
> This is a backport to the v4.14 stable series. The only merge conflict
> was due to an earlier patch by Willy to flesh out the comments. There
> were no code changes necessary.

Thanks for the backport, now queued up.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-07 13:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-06 15:59 [v4.14.y PATCH] errseq: Always report a writeback error once Jeff Layton
2018-05-06 19:02 ` Matthew Wilcox
2018-05-07  1:15 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.