Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3715065pxv; Mon, 26 Jul 2021 10:04:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5d4WSuuidGukZWDLxFUJ60kezcvf9sMdSsBUsk7j84wxkfla/E/oKizSJkVhApxKtkO3t X-Received: by 2002:a17:907:1b1b:: with SMTP id mp27mr17562818ejc.538.1627319088178; Mon, 26 Jul 2021 10:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627319088; cv=none; d=google.com; s=arc-20160816; b=Qp6GAMSdS16VkCT3v27eDhaArvItorYurYPBysw4B7e899gYB1CSFAgzq+YJFmNRFp rPMyNJ8EvX99d18wfj1Jvo2hi+cHraxNpm9kM/bTAuK3lBSlwL0RhxIGvODK00JBlKtC Oe+y00aN8cBmJxSIWDLDbJcfT+iaBeTJE58MyKIi+82zxce2uvo8jytSmj8deDqbYolK iLEt2PXwkPbkhJ/hzzw7w94LRrFWVhNOb+D0bxhW/KyFXN4StHuOq+sD03UxkiXE0IZ1 mC89lORXkkWT+u2lFdKc2tlveCCIziuOqts7RjhXdDZkF8r61faXTznQKYe5jTUllNmD m1vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bXECazGo56jRljp0w7XSk3xdh6pH8Gr72++cwJjLqEE=; b=t8QuXQzBXsMfveNWPYIRgl1amMIE6l4VTk6UVWTHPHv1vhj+XmreeSZNoyGRyCWrrk xMyuvVkOuQYxRkNMRHYWZDoPfN4GfEdOU+FAIeYVj+XIn3wHW140YuVheCHF6qkvTGXd RD34A3v2XbenLME7ZWqS+4/D8mj+TUSe9zEGUq1e0x1Rva+eKCFuPYl4t4DuYfvlk+jh TUANwAX+nVC7Cx23UeG/rG/HO5UCvKzH4YURdmgDE+qeu2ttA/geWqDjCUc9wMtJT8A1 PvB2X8QOJxZXm+7mCrYCrpZ2rj2cQlQsZbRruUDAQ4ZqxglgNkZoT5JcJyrRZ6T7A5vN t4VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TXyoeVi2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si499845edi.248.2021.07.26.10.04.23; Mon, 26 Jul 2021 10:04:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TXyoeVi2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237531AbhGZPmt (ORCPT + 99 others); Mon, 26 Jul 2021 11:42:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:38770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237683AbhGZPXt (ORCPT ); Mon, 26 Jul 2021 11:23:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D7B4960F5A; Mon, 26 Jul 2021 16:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315457; bh=3qaK4EwthAdOfpuaMjCBic6CN6+MFH5YR8Vzj3h6Bn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TXyoeVi2ZI+v1TbtqrAzYOJlUH3fG3GcswrkI5LomeNbKdOL86Cfl4VEt0+JuMJxs 1t82Na/FEuc2qhnIgNAPXqwQcFKujHkiZOdB/5+/A0MFsvDWuZlNvDJrH2A6S/Bzb+ nu4rVNQJLdFmpYumExg0uGtgZC+afVvLVqqPa0CE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronnie Sahlberg , Namjae Jeon , Steve French , Sasha Levin Subject: [PATCH 5.10 103/167] cifs: only write 64kb at a time when fallocating a small region of a file Date: Mon, 26 Jul 2021 17:38:56 +0200 Message-Id: <20210726153842.851690981@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153839.371771838@linuxfoundation.org> References: <20210726153839.371771838@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ronnie Sahlberg [ Upstream commit 2485bd7557a7edb4520b4072af464f0a08c8efe0 ] We only allow sending single credit writes through the SMB2_write() synchronous api so split this into smaller chunks. Fixes: 966a3cb7c7db ("cifs: improve fallocate emulation") Signed-off-by: Ronnie Sahlberg Reported-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/smb2ops.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index f6ceb79a995d..442bf422aa01 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -3466,7 +3466,7 @@ static int smb3_simple_fallocate_write_range(unsigned int xid, char *buf) { struct cifs_io_parms io_parms = {0}; - int nbytes; + int rc, nbytes; struct kvec iov[2]; io_parms.netfid = cfile->fid.netfid; @@ -3474,13 +3474,25 @@ static int smb3_simple_fallocate_write_range(unsigned int xid, io_parms.tcon = tcon; io_parms.persistent_fid = cfile->fid.persistent_fid; io_parms.volatile_fid = cfile->fid.volatile_fid; - io_parms.offset = off; - io_parms.length = len; - /* iov[0] is reserved for smb header */ - iov[1].iov_base = buf; - iov[1].iov_len = io_parms.length; - return SMB2_write(xid, &io_parms, &nbytes, iov, 1); + while (len) { + io_parms.offset = off; + io_parms.length = len; + if (io_parms.length > SMB2_MAX_BUFFER_SIZE) + io_parms.length = SMB2_MAX_BUFFER_SIZE; + /* iov[0] is reserved for smb header */ + iov[1].iov_base = buf; + iov[1].iov_len = io_parms.length; + rc = SMB2_write(xid, &io_parms, &nbytes, iov, 1); + if (rc) + break; + if (nbytes > len) + return -EINVAL; + buf += nbytes; + off += nbytes; + len -= nbytes; + } + return rc; } static int smb3_simple_fallocate_range(unsigned int xid, -- 2.30.2