From patchwork Sat Jan 20 23:08:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 1888829 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pT/6M0S1; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=qwh/+t6V; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4THXHD5n9Jz23fW for ; Sun, 21 Jan 2024 10:09:12 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nKVb9XPwF4nUJsTWdgp6o/SI4Kw9d6Jcb0641d463O8=; b=pT/6M0S11FJW3X Ny5QbigX8TrPyKAPT/iJEuU4RKj++UfT6BUwjA7BGKN7x1Aom3b7IGRyU3C2yw87QaWq+j66+4dCA ZrJctzuEc9SZJ8rKeRvY/OFLvcVNK8LZrzA7ka+7YG/wavsvvk1ZDukxcCQ9p9q+6EZVXwZkrdT0m u/T1IrmQxqw7lUanllXcTwUud1ZIQgth9KKc5hb+MIxs8kct/4NIpEBV3TJ9CVFEahZocYKeppTP2 cRna6zhF9xCYFnRMLdPqQddoqVwPBU5xJtSZBZi/wBy7Haim7BBEZxZj4Y6SaLUsw2H3BCD91UEKp Qd/L5YFAsKqJiPNE9ZXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rRKS5-008ZLC-0H; Sat, 20 Jan 2024 23:08:37 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rRKRx-008ZI4-1g for linux-mtd@bombadil.infradead.org; Sat, 20 Jan 2024 23:08:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=XkaHGMGt53SwjvP38fxIGwhU3n+LAaDVWYrWt4x1lLk=; b=qwh/+t6VGbMzPwT954U9+opLGO VxH6WuCucZRU5DkSfTUOMXxraAshL73pJihDm7n5wB79X1J6Ko8DqI4/k6wEvM0iwk9b/NGhTAado 8vac6fELjzGCvjxXl6AnygIGtmsf6eIaDp1wQKw7j4zVhiIYQQJ3ndAcqvAMEYztIYEznT/VETr6E ADsrK5mqCgiMbH2JlWLqw/IMpedOP46b0icbbA9a2PKzK5i6BbeaqAW+sGB+6Op7Gmu2GoXRV/N9V IFDiOHA5AWCsmNiutWSsl7cZJpFSMtzoi+SK6Ww/nTwaCm1GmFXwlfb7juL8vxqsO93yfT30XEmtf nU60UYEw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rRKRu-0000000AzVy-3QZr; Sat, 20 Jan 2024 23:08:26 +0000 From: "Matthew Wilcox (Oracle)" To: Richard Weinberger Cc: "Matthew Wilcox (Oracle)" , linux-mtd@lists.infradead.org, stable@vger.kernel.org Subject: [PATCH 01/15] ubifs: Set page uptodate in the correct place Date: Sat, 20 Jan 2024 23:08:09 +0000 Message-ID: <20240120230824.2619716-2-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240120230824.2619716-1-willy@infradead.org> References: <20240120230824.2619716-1-willy@infradead.org> MIME-Version: 1.0 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Page cache reads are lockless, so setting the freshly allocated page uptodate before we've overwritten it with the data it's supposed to have in it will allow a simultaneous reader to see old data. Move the call to SetPageUptodate into ubifs_write_end(), which is after we copied the new data into the page. Fixes: 1e51764a3c2a ("UBIFS: add new flash file system") Cc: stable@vger.kernel.org Signed-off-by: Matthew Wilcox (Oracle) --- fs/ubifs/file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 5029eb3390a5..40a9b03ef821 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -463,9 +463,6 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, return err; } } - - SetPageUptodate(page); - ClearPageError(page); } err = allocate_budget(c, page, ui, appending); @@ -569,6 +566,9 @@ static int ubifs_write_end(struct file *file, struct address_space *mapping, goto out; } + if (len == PAGE_SIZE) + SetPageUptodate(page); + if (!PagePrivate(page)) { attach_page_private(page, (void *)1); atomic_long_inc(&c->dirty_pg_cnt);