From patchwork Tue May 3 21:36:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 12836374 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE009C433F5 for ; Tue, 3 May 2022 21:37:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242970AbiECVkv (ORCPT ); Tue, 3 May 2022 17:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbiECVku (ORCPT ); Tue, 3 May 2022 17:40:50 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6150A31921 for ; Tue, 3 May 2022 14:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651613836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=aStIUsv3bUno6wgnE6p+ahkgDftecN0R+3tSGZd7L94=; b=WniRSMG3ChlbCSqFqS8ZOF4kRx8v2NJj/kyP7E5TxTueu77WIDjwWcUnkIEiZKZgqwVJ8W beafl306Nholpm3eJ9zaPPME/7cYXEQtjHjoCAGeVdwt+Gnk6kTFCyDX4YFCGuR3EOozDk G2i9LnDLhSfdVrf1aEqyEPzkvIO9hPE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-347-wXiZ68ZPOoa8tNLWueJUVA-1; Tue, 03 May 2022 17:36:49 -0400 X-MC-Unique: wXiZ68ZPOoa8tNLWueJUVA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0B82F94A2B5; Tue, 3 May 2022 21:36:48 +0000 (UTC) Received: from max.localdomain (unknown [10.40.194.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id C14CF1546E0B; Tue, 3 May 2022 21:36:46 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , "Darrick J . Wong" Cc: Linus Torvalds , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andreas Gruenbacher Subject: [PATCH] iomap: iomap_write_failed fix Date: Tue, 3 May 2022 23:36:45 +0200 Message-Id: <20220503213645.3273828-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The @lend parameter of truncate_pagecache_range() should be the offset of the last byte of the hole, not the first byte beyond it. Fixes: ae259a9c8593 ("fs: introduce iomap infrastructure") Signed-off-by: Andreas Gruenbacher Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/iomap/buffered-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 8ce8720093b9..358ee1fb6f0d 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -531,7 +531,8 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len) * write started inside the existing inode size. */ if (pos + len > i_size) - truncate_pagecache_range(inode, max(pos, i_size), pos + len); + truncate_pagecache_range(inode, max(pos, i_size), + pos + len - 1); } static int iomap_read_folio_sync(loff_t block_start, struct folio *folio,