From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BC0428B4F0; Wed, 11 Feb 2026 03:11:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770779480; cv=none; b=YODNBKhyq+GNUJkpOLwMf5Lgql+HUDVL8QT3+pHJDv56botNkblZ0S7BO0NEB06lsUHn9D3wMTmWuSVEnOSHSpdPjgm4Jdcksv77Z39fhn8D1RGsvLMvhEL3DbC3OxmaK/esssp7kTqWR4jyljeiAY1QEVRhYbIeaT7vgslt4Cc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770779480; c=relaxed/simple; bh=DCH2kn4IZ4HMYlAvNoIBmXepkZ5N3FUmnB4F34iLk38=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PTAGEiyEY4blhgb3O+8SQvst3pVavztBF/fTIgnvexDWjYd6HFzeCDdcsu1cxGtgZMUyPIdgognjMFlaTRLay63y/e++1tl+aIQA3Fb1NbT0A3/8vfUyLgwyEvcCXXPRMWgZDTQLPpUFM+5uJJejzbaPth6w/axTnMiqYlfdPuA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Xb+ziqc1; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Xb+ziqc1" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=FtKzJSaRWx0uyZoC4NpSdkDytjOu8nCUr6zTVUGfWDg=; b=Xb+ziqc1KtEIYvLc4DwJ2cA5Xq AmCCIlIvzQa+nWdYUMDDmyU67DzBmt02Q7XG1EfIh6f6cwaJR6wMwFRrCDfk5LrG/Yn2ySgwC2JAm YnWHObxmptaCfIoe2yuXKM3h7Z2l1lHAtXG4hzmUbLkXm9kSJBCrjSJOdAn5rPEYTQr2Lz4akLHn4 0WvVmHex0FKjpDCHC3UOu+BPKL82scMJ3QRIyxFo9VD8GaQaFPVEnq2q+ygx1rL6tzcckXF8Ery9b 4SQouLnv7QXFKTkzrEwqP1RBiG9/R0Rb6bjAwIFTMjID92QTN9pW6/PIVO0UA81LZciE9VfPfPKsI 2Me+ikGQ==; Received: from willy by casper.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1vq0dG-0000000C1Dk-19Ga; Wed, 11 Feb 2026 03:11:14 +0000 Date: Wed, 11 Feb 2026 03:11:14 +0000 From: Matthew Wilcox To: Joanne Koong Cc: Wei Gao , Sasha Levin , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 1/1] iomap: fix race between iomap_set_range_uptodate and folio_end_read Message-ID: References: <20251223223018.3295372-1-sashal@kernel.org> <20251223223018.3295372-2-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Feb 10, 2026 at 02:18:06PM -0800, Joanne Koong wrote: > spin_lock_irqsave(&ifs->state_lock, flags); > - uptodate = ifs_set_range_uptodate(folio, ifs, off, len); > + /* > + * If a read is in progress, we must NOT call > folio_mark_uptodate. > + * The read completion path (iomap_finish_folio_read or > + * iomap_read_end) will call folio_end_read() which uses XOR > + * semantics to set the uptodate bit. If we set it here, the XOR > + * in folio_end_read() will clear it, leaving the folio not > + * uptodate. > + */ > + uptodate = ifs_set_range_uptodate(folio, ifs, off, len) && > + !ifs->read_bytes_pending; > spin_unlock_irqrestore(&ifs->state_lock, flags); This can't possibly be the right fix. There's some horrible confusion here. It should not be possible to have read bytes pending _and_ the entire folio be uptodate. That's an invariant that should always be maintained.