From patchwork Thu Sep 24 12:56:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 11797227 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 657F559D for ; Thu, 24 Sep 2020 12:56:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26C4B2220D for ; Thu, 24 Sep 2020 12:56:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ZVoNKJMb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727748AbgIXM4M (ORCPT ); Thu, 24 Sep 2020 08:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727705AbgIXM4M (ORCPT ); Thu, 24 Sep 2020 08:56:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11A0CC0613CE; Thu, 24 Sep 2020 05:56:12 -0700 (PDT) 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: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=KcaULLngGKYc43FW42wqAsfRajrBy4rZ/2aGJia67F0=; b=ZVoNKJMb8IEiCO/0cxGWmCo8jt Leax5D/eDKScQ7Hv/iUV4+K/im0UjklPC3Me3yfFh7fAEsI768yxYLhk2uriMqQhvS828oy27/S+A Y/PR+p31Nb3MZ3awTY3XEvVFkmqybwpYQ3k0GmScz48v+SgoZJazLC665CBbQfTzX1tdVZIeAXIWd DhzU09qL0CzUzLejqLwZJAQescnWxRLu0KAS77JmSEMGOCtOmO80StSbF8lMdAYT/e3IpME/Jumqi /3iOhJucQqVnFjJ3w5V+0Rm16EsfxgZ4FS7jm1UrvxvVtMNyjusbB7zPHwYIlaVi0RFGWaAqKbXdt xGk4o8ig==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLQnB-00088T-Lu; Thu, 24 Sep 2020 12:56:09 +0000 From: "Matthew Wilcox (Oracle)" To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , "Darrick J. Wong" , Christoph Hellwig , Qian Cai , Brian Foster Subject: [PATCH] iomap: Set all uptodate bits for an Uptodate page Date: Thu, 24 Sep 2020 13:56:08 +0100 Message-Id: <20200924125608.31231-1-willy@infradead.org> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org For filesystems with block size < page size, we need to set all the per-block uptodate bits if the page was already uptodate at the time we create the per-block metadata. This can happen if the page is invalidated (eg by a write to drop_caches) but ultimately not removed from the page cache. This is a data corruption issue as page writeback skips blocks which are marked !uptodate. Fixes: 9dc55f1389f9 ("iomap: add support for sub-pagesize buffered I/O without buffer heads") Signed-off-by: Matthew Wilcox (Oracle) Reported-by: Qian Cai Cc: Brian Foster Reviewed-by: Gao Xiang Signed-off-by: Matthew Wilcox (Oracle) Reported-by: Qian Cai Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/iomap/buffered-io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 8b6cca7e34e4..8180061b9e16 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -60,6 +60,8 @@ iomap_page_create(struct inode *inode, struct page *page) iop = kzalloc(struct_size(iop, uptodate, BITS_TO_LONGS(nr_blocks)), GFP_NOFS | __GFP_NOFAIL); spin_lock_init(&iop->uptodate_lock); + if (PageUptodate(page)) + bitmap_fill(iop->uptodate, nr_blocks); attach_page_private(page, iop); return iop; }