From patchwork Wed Nov 29 16:56:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13473217 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 A26B6C4167B for ; Wed, 29 Nov 2023 16:56:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66D406B03C6; Wed, 29 Nov 2023 11:56:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EF576B03CC; Wed, 29 Nov 2023 11:56:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 390856B03CD; Wed, 29 Nov 2023 11:56:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2A2586B03C6 for ; Wed, 29 Nov 2023 11:56:36 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 05BE6120544 for ; Wed, 29 Nov 2023 16:56:35 +0000 (UTC) X-FDA: 81511595592.22.C55696D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 49BE140010 for ; Wed, 29 Nov 2023 16:56:33 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fvJsW8tH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=ElC8RAQdfN2Ln/hT1ay+FjIT1Y57onjWn6huuiDhwuM=; b=suOTmghStU5mC8lP0YZgvYEHLNh3ADFLjvOrgO65Pu9//A3iagPJVAPQRkpzOxPxXPoEJN ELKRB7Pwem4YzBeT1WjjyeM3CFrn3gKIIXRIIG4UAZk2ss5ajGO7C5rp5vMrboGn70Y0b/ k5Mq7WwLT3TAthUKyZtwh7Cbt770uO4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fvJsW8tH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=p2tVUrInMuF9YABiyErSq3dYI4RmhNwPE8oogqJntMIM97oZXAQiNatlQI4ApGWYWcQTQW LBEHq+3Iguv/Bp8RZ/7QoY6tRFUjL6sD/EBgWNF8IYQj66R0mkTAPASOrqtRRWJFLcZKdx ZfAerjOrLXVXeKER98VtBv2zuGvo5dw= 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=ElC8RAQdfN2Ln/hT1ay+FjIT1Y57onjWn6huuiDhwuM=; b=fvJsW8tHpliIE/T2tHtD2Co2yzRsKIBn4J4KgoL44WriaY6hP3ukrlrggPiCPY3hHgcWV7 G0rMBXumgCXMafU3DVoxR0ryfkl17R/jUAJip/uriX3ByANHbBVFJMJJluLMLjvJmhlDZV cyktq6rlnBmxTyUakeKsiNN44tYIOyw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-331-HkqjQLWeM0mvcv48uRBM8w-1; Wed, 29 Nov 2023 11:56:26 -0500 X-MC-Unique: HkqjQLWeM0mvcv48uRBM8w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 30CB7185A7A9; Wed, 29 Nov 2023 16:56:26 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.161]) by smtp.corp.redhat.com (Postfix) with ESMTP id B90BD112130A; Wed, 29 Nov 2023 16:56:24 +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 1/3] cifs: Fix FALLOC_FL_ZERO_RANGE by setting i_size if EOF moved Date: Wed, 29 Nov 2023 16:56:17 +0000 Message-ID: <20231129165619.2339490-2-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.3 X-Rspamd-Queue-Id: 49BE140010 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: pn9mqpfh77369cc8fuif8fb3ibu764ax X-HE-Tag: 1701276993-157312 X-HE-Meta: U2FsdGVkX1/QVWlbDV5s5jKkA4Hz/XKWO1FcaAmMdxTLF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H1wILulspstT6ReqEzvPgLwA8xfJSFDdzzv77FN8zIFxOFVY/mrFOr9Y+igvLZmZsQ/aK1dCCd6ZhAQ9UBfCmnTCqorh6Llt69ZjobTZNLzRIX+oz2PFRTwUbBmzJ0c67R1BTb5tAUo/ob7KrhWaUsIG54v0zLFL8XZwnp3rZlNof72L8m5qGKHb3HBnFt3HDaR+An86khWwUNC9fc+7RpvyRd1ptTFkmPcWFT87gP8hXGAPRIYORlC7EnMsidWZOoEYVStWEi8yROT4RxeqDfY4LgqABbw50CBcIgdl5ozPL+puO621qih+3ZiqICEo7nxbHgMgRteUit9y2WW0Yut7grZmlGbqW4ZT6G+h/EqG1h99mz0YWUEa96GBgLHHhngKDvIj61HPavModxdnsJaQpMMuwkyrfRY3G8uX7EjII= 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_ZERO_RANGE, in smb3_zero_range(), to set i_size after extending the file on the server. Fixes: 72c419d9b073 ("cifs: fix smb3_zero_range so it can expand the file-size when required") 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index a959ed2c9b22..572d2c22a703 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -3307,6 +3307,7 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, struct inode *inode = file_inode(file); struct cifsInodeInfo *cifsi = CIFS_I(inode); struct cifsFileInfo *cfile = file->private_data; + unsigned long long new_size; long rc; unsigned int xid; __le64 eof; @@ -3337,10 +3338,15 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, /* * do we also need to change the size of the file? */ - if (keep_size == false && i_size_read(inode) < offset + len) { - eof = cpu_to_le64(offset + len); + new_size = offset + len; + if (keep_size == false && (unsigned long long)i_size_read(inode) < new_size) { + eof = cpu_to_le64(new_size); rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, cfile->fid.volatile_fid, cfile->pid, &eof); + if (rc >= 0) { + truncate_setsize(inode, new_size); + fscache_resize_cookie(cifs_inode_cookie(inode), new_size); + } } zero_range_exit: