From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796304775; b=uCMycggtJJ7go5Uy90LYS382tv+Dnp74UMnzuvbvph796ahgTFlaRiIHOeCzLBrJRHzr CwQaQoT2074Eo7Oermdv9fHJsIlGululc0ppdGp2JoDV5JbvjI2i9e7YGpjlH9TuAafMY kF+0aTBaepSRyRqUCLlPIsdqQ8H1cNolQGUqoUQvft2BOnrN2Ge4Y2I6pfR5MS4FHFcX0 a6SfCvhId34zlTBfSrSR8GtiNFL/h6VgqBaJCN7AuXHW/4ePmv+faP3kl5aw7/3xxY6mV U34Z+0op3X61seneeXwz2RtZIwIhkiFR92sI+we9G/v8bQ2rvIwlnQ6T+fPanTP0cGw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796304775; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=7RrmsWGmddmqFGps6g2zqOqnbbuNoeWtfyVG6nGPm0M=; b=xj40Z/sSfuPMWukksVxCaxQdDKOeRUMMf5PA1XRiogEGYw5YEV/CctNIuzjpEf/AzdPi COtECGqBi+nj6uIatOSf0iRND06q4xQIeUEI2/BffltgUDqccUD5hRV2f55N33+ii7gee jMv+a5zdPONZULgUcfglIfuOhGc9+jf2OK0MSmzA+3A1oHf17LbHy0CKbnH/zwT7FTDE8 Cky79lKJzcLdUgyKlE3uTppaQnx0eNgt2G4xjcgHV11S3jO84duF3FTWS6TVccC/0stnZ ptazr9cEGRpfU7Pz56wJT7fkDtNGWJ+6iJGQPQdyfg56tsrNmL81153kbKGxezN2SAw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GCcDsuuQ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02408606A322 for ; Thu, 3 Dec 2026 13:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GCcDsuuQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EA251F00896; Thu, 3 Dec 2026 13:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796304774; bh=7RrmsWGmddmqFGps6g2zqOqnbbuNoeWtfyVG6nGPm0M=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=GCcDsuuQUOtDyZpvA3B+krwB0Z5eS5ecBX+RdHQsXfcddyRI60tQzg45A6JrV1fIb FHUV4OTaB/dd5PpfCHurCCeYCwf2ZaiunErZbvR4AEY57pM3zpB1ohVJQ7g67U+wrb u8f6gD+ixekY3RZzKUAJXrSANSFmywWvFvjPmf/jXTviKm/LLbcgBTxMUhf3n0ZxnJ zt8NR9MdkWBw7r+6XjKvsuN1BhjOLjHZKvnoh/9rCr1fT+82Jl/x1WlD0hnIcB6f5d A0vVd57DEvz2TzLwHLlH2pEzzIaVCtKEp7L4iDGrGbRqC7QAJ0mRDwTOyKVKL8B25r RYccSr7bom/XQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 2/2] ext4: punch hole beyond i_size Reply-To: sashiko-reviews@lists.linux.dev To: "Ding Feng" Cc: linux-ext4@vger.kernel.org, tytso@mit.edu In-Reply-To: <20261203130608.64892-3-dingf3ng@gmail.com> References: <20261203130608.64892-1-dingf3ng@gmail.com> <20261203130608.64892-3-dingf3ng@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 13:32:54 +0000 X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ext4: ext4_punch_hole() advances i_disksize on punch at offset =3D=3D i_size -- commit 2e70b22512cf9036462d361406187d89e988b04d Author: Ding Feng ext4: punch hole beyond i_size This commit updates ext4_punch_hole() to remove extents beyond i_size inste= ad of returning early or stopping at the block holding i_size, while limiting partial-block zeroing to ranges starting below i_size. > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 26cf00ff8630a..f7d0a2e9941cb 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c [ ... ] > @@ -5371,19 +5372,22 @@ int ext4_punch_hole(struct file *file, loff_t off= set, loff_t length) > if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) > max_end =3D EXT4_SB(sb)->s_bitmap_maxbytes - sb->s_blocksize; > =20 > - /* No need to punch hole beyond i_size */ > - if (offset >=3D inode->i_size || offset >=3D max_end) > + if (offset >=3D max_end) > return 0; > - > /* > - * If the hole extends beyond i_size, set the hole to end after > - * the block that contains i_size to save pointless tail block zeroing. > + * A hole that reaches i_size covers the rest of the block that holds > + * i_size, so that block is freed rather than zeroed. > */ > if (end >=3D inode->i_size) > - end =3D round_up(inode->i_size, sb->s_blocksize); > + end =3D max_t(loff_t, end, round_up(inode->i_size, sb->s_blocksize)); > if (end > max_end) > end =3D max_end; > length =3D end - offset; > + /* > + * Blocks past i_size (from FALLOC_FL_KEEP_SIZE) are removed too, but > + * nothing after the block that contains i_size needs zeroing. > + */ > + zero_end =3D min_t(loff_t, end, round_up(inode->i_size, sb->s_blocksize= )); > =20 > ret =3D ext4_update_disksize_before_punch(inode, offset, length); > if (ret) [Severity: Medium] Can ext4_update_disksize_before_punch() now advance i_disksize when a hole starts at offset =3D=3D i_size? After an appending buffered delalloc write, i_disksize lags behind i_size until writeback. Because ext4_update_disksize_before_punch() only returns early for offset > size, a punch at offset =3D=3D i_size falls through, sta= rts a journal transaction, and advances i_disksize to i_size. If the journal commits and the system crashes before writeback flushes the dirty pages below i_size, crash recovery exposes a file of size i_size fill= ed with zero bytes instead of the prior on-disk size. Guarding the call with offset < inode->i_size (or checking offset >=3D size in the helper) avoids = this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203130608.6489= 2-1-dingf3ng@gmail.com?part=3D2