From patchwork Wed Nov 29 16:56:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13473216 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B035C10DAA for ; Wed, 29 Nov 2023 16:56:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B592B6B03C2; Wed, 29 Nov 2023 11:56:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B0A306B03C6; Wed, 29 Nov 2023 11:56:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D2DA6B03CC; Wed, 29 Nov 2023 11:56:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 904266B03C2 for ; Wed, 29 Nov 2023 11:56:35 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5598A14059D for ; Wed, 29 Nov 2023 16:56:35 +0000 (UTC) X-FDA: 81511595550.05.B33C36C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 739188001C for ; Wed, 29 Nov 2023 16:56:33 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E1SVpREi; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701276993; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dPjSTDvJjKZvQqpuoRax99jzMiuqvHWjt5D7woIueGo=; b=6hEyJjhNSH8udM/ilxVLF3CNE2QfrR78f6e91Uut5trjq2PpeRCI7X45a6Q1OkxBmTd+Ly Ji7GECLYNprP4GffK5iqTdo2wikBznt1hRJAnXWJoLyvBTqrh5SPUYm3HZpa8cd+yGxQwk wJc622uKswYwpIA3r794fwgwgym3j68= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E1SVpREi; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701276993; a=rsa-sha256; cv=none; b=Ix25BYBOlG02/MlT504Ed0em4tmX2Jvi+HChDg3asAgf73un/BSTZvhlHeoMR0rfab9qBo XeMGUb99IVWGVITfuCi6lnkLpWabhIZYTAbGahcRLyfrkOIqdnFKSspigXSuGyKytapa4f IjYPg0FqlWL04SNcnleXKam7mbivqXU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701276992; 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: in-reply-to:in-reply-to:references:references; bh=dPjSTDvJjKZvQqpuoRax99jzMiuqvHWjt5D7woIueGo=; b=E1SVpREi48e1BMrMM3+zthfshN/G648ofe9LB9kQ+tOYKyTAe20v69/CAk0i1qw9MWEz+h v9QVxFFzWb5hbm8XwbndUk7ttqzSDiG5l8eMj6+RPqxa1ZekgGSdiqcN+JdjTVLpFn8qzb OIl/4vSINNdZbBn4ul87N+NPU95TUaM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-508-1kcZMNfDO66ZvxPfVdWQfg-1; Wed, 29 Nov 2023 11:56:29 -0500 X-MC-Unique: 1kcZMNfDO66ZvxPfVdWQfg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 888851C0BB75; Wed, 29 Nov 2023 16:56:28 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.161]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF0D3C15886; Wed, 29 Nov 2023 16:56:26 +0000 (UTC) From: David Howells To: Steve French Cc: David Howells , Paulo Alcantara , Shyam Prasad N , Rohith Surabattula , Matthew Wilcox , Jeff Layton , linux-cifs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 2/3] cifs: Fix FALLOC_FL_INSERT_RANGE by setting i_size after EOF moved Date: Wed, 29 Nov 2023 16:56:18 +0000 Message-ID: <20231129165619.2339490-3-dhowells@redhat.com> In-Reply-To: <20231129165619.2339490-1-dhowells@redhat.com> References: <20231129165619.2339490-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspamd-Queue-Id: 739188001C X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: fm3zw1y1dmumaprje8fog4onsr7i9ifb X-HE-Tag: 1701276993-554364 X-HE-Meta: U2FsdGVkX19STVBW4RNYdvphNkfQUIt9U60U6N6537asn1Z3Zpa7t3owX46Xya4D5hkeE1NgESSuY7+V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VtX5AlcXEKMF7RrgJC6Oir0xMjZhTz6hJTkJo+iyARLN+uV9bhmFYEaKtju5WRUeJCn/SMhMGFOjVIzGO99iJ9cfSWvG463akKmx5bcUsL9oGMBRz9z9hrN3AGliTUNo5vMVsLtoJJUW43NwualgfFilkse2RyOw6KyEfL/F36eqJqx2IGhmWGUFDwA/qOI/A5M98dFlLMYBly6hAjv4/buFYEsTucF/TMP+Xrxk5eAYfFU9dYJlsUQEFvSiuUmur8ojN5jqIFn/+8YyZXXaV8Je9/XQHhdfl58H8vxIqkgeWzgBWPGC4odxe1YfC+MqfWrQ5OLbDwDuAe+bIyXi3miwj+BPheB3kNSJkA9mq5qpcNiwEucO9iWhF8XL3C18h2PZM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Fix the cifs filesystem implementations of FALLOC_FL_INSERT_RANGE, in smb3_insert_range(), to set i_size after extending the file on the server and before we do the copy to open the gap (as we don't clean up the EOF marker if the copy fails). Fixes: 7fe6fe95b936 ("cifs: add FALLOC_FL_INSERT_RANGE support") Signed-off-by: David Howells cc: Steve French cc: Paulo Alcantara cc: Shyam Prasad N cc: Rohith Surabattula cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: linux-mm@kvack.org Acked-by: Paulo Alcantara (SUSE) --- fs/smb/client/smb2ops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 572d2c22a703..65a00c8b8494 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -3741,6 +3741,9 @@ static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon, if (rc < 0) goto out_2; + truncate_setsize(inode, old_eof + len); + fscache_resize_cookie(cifs_inode_cookie(inode), i_size_read(inode)); + rc = smb2_copychunk_range(xid, cfile, cfile, off, count, off + len); if (rc < 0) goto out_2;