Received: by 10.192.165.148 with SMTP id m20csp3855847imm; Mon, 23 Apr 2018 13:43:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx49PAnRe/Oew7168KEkMnPdvFKuDhZhZ4/wlM3dSq/EEDSREDdt5wlg6pm8AMBK9iCN5M1si X-Received: by 10.99.124.20 with SMTP id x20mr18244683pgc.161.1524516218556; Mon, 23 Apr 2018 13:43:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524516218; cv=none; d=google.com; s=arc-20160816; b=tM8Rd+hihU91OVXk3iqe5hbtXQkYLNQFMdFB8giGNOOwp8iYBjlSdD/uBPCCwfUBZe tRFGPm3ySaowq9OXuwz8sJL0f4r0jVU0JknDp29SASwMe+RztYD7BVqW3BBe3EqskNLl d5o/8dK0oapPCQ8l6V99T6vteCFd3m8d0sqyLcO4won3NLepHkuYQFq2bBQxVRjblRrN Aff2U5GGpeB6OFnvmL5oessnfPqST8sH7LIViy/81vYD4TVi2hqUSDaY2nUV1TQ35La0 KpZVhWZKIgoXZBjE6e2914+XA8zIQu7qp4T8t8k85ijBkq+wc5W7X4/SgOEGSCO+/l91 GStg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=EwT7L9o/WKqkY2D9a+qe8SkAWb0nHMFIXUV9H/Cw0r4=; b=OtdWYpIC0tXdvIKwT+bgXPWgtupTLlQt/764nDyLh7eOnsSq3Zw8d7I0H5wDOGZT28 RLvGj2IifJn9m6WFaRQHyUnYfpj6CcHGljYLocnfoXr4+KCZcZ/hr7C+7CuKy9+lIz2r buKX9cqLY/01RomCS1iocJoCfKEXkexYdEzzW6VvAEX5pO/b1rrqb5ySr3zOzWMF5Byj yJTaEHrHajPxQPcVu78r3RFE8v58we4c/EdbTCGCyzUg5B96Qsypye8OzABoOndSgTn6 /hRDKNI0ROniezkYPys/lDQd9IbwPeOOTyT1UTZz+WhrnXL+TMVVrzdysaWyCzwaI0ax 1Cog== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fwh42UG5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12-v6si10320102ply.353.2018.04.23.13.43.23; Mon, 23 Apr 2018 13:43:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fwh42UG5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932335AbeDWUmM (ORCPT + 99 others); Mon, 23 Apr 2018 16:42:12 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48160 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932254AbeDWUmJ (ORCPT ); Mon, 23 Apr 2018 16:42:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Type:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EwT7L9o/WKqkY2D9a+qe8SkAWb0nHMFIXUV9H/Cw0r4=; b=fwh42UG5OH3t95Wc8HbkLqAc5V EjfkHSoaVfx3WGAJsb2k4XUoixCaZ/YChDBnrvsJVbIoUj0hQUWMS3IsdwWoud2aSHrKf5F1ab7T0 n+LZdQ9CTrPFb3isuTjplriUKZsLBTBU9p+yXHN69h/JKvX0K0ZYME5cXqyhtOnoFBehVpAIOrLYt XjsSVQUEyomWs/68h7avcVABSBtKx6QFX0kBRCHtPS4WZzV/y7ID25XKm0ZUE50FQmVobtpfV0KMp jEM/cOEVyN8hDSnFBxbJNlMZ0ATz3tP20Vpw0iz0U6ce4HU7MphsN8CcqnnBiudogcd0CS8CDOtLC ztRlGJGw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fAiHo-0000H1-P0; Mon, 23 Apr 2018 20:42:08 +0000 Date: Mon, 23 Apr 2018 13:42:08 -0700 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, Jeff Layton , linux-kernel@vger.kernel.org Cc: Andres Freund Subject: [PATCH] Always report a writeback error once Message-ID: <20180423204208.GG13383@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 restores that behaviour by reporting errors to file descriptors which are opened after the error occurred, but before it was reported to any file descriptor. Cc: stable@vger.kernel.org Fixes: 5660e13d2fd6 ("fs: new infrastructure for writeback error handling and reporting") Signed-off-by: Matthew Wilcox diff --git a/lib/errseq.c b/lib/errseq.c index df782418b333..093f1fba4ee0 100644 --- a/lib/errseq.c +++ b/lib/errseq.c @@ -119,19 +119,11 @@ EXPORT_SYMBOL(errseq_set); 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);