From patchwork Fri Aug 23 16:12:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13775477 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 65152C5321D for ; Fri, 23 Aug 2024 16:12:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6FC06B02DC; Fri, 23 Aug 2024 12:12:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1DF1800A4; Fri, 23 Aug 2024 12:12:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9993A6B02DE; Fri, 23 Aug 2024 12:12:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7333E6B02DC for ; Fri, 23 Aug 2024 12:12:39 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 65B98AA1D8 for ; Fri, 23 Aug 2024 16:12:36 +0000 (UTC) X-FDA: 82484003112.20.711DF0B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 9DBC318001E for ; Fri, 23 Aug 2024 16:12:34 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E4YH4ZAk; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724429537; 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=BgDxF6Y2BCwscRMX/1nHWh5c3+O9vNtYrvIJazlGbCw=; b=0qtaeXjyRPTi98IjioNzOY3CBa2Yl80FIv75rDdnjQxqboJpybK5oHQwdXTxPkBZ/hZQvG pl/pHH68ZfCTTHOgvF2LPY4jbPTkz1U3AeMMEWkjemNt18FTTNd2aINMgOzKLwl/uSH6/G 3WhuV54InFNbFWphqAz3y7cmcxWNCvg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E4YH4ZAk; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724429537; a=rsa-sha256; cv=none; b=ql1v/mp4QPZCpwEzxlzOlDpS9bcsdhvJ6lSR8Mw8eiEp15BEvU9Hn15OZI3JW9npcyZ0GY cPHPuCBaEHIBErYhS2XnYMRGCHw2gQ5G88XXQyZhl/LHWBsjdEyY/9bQE9o//YrGTMYodh 9BcQ1kh4PB8S6eafj8LpT26hcR4lW7I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724429554; 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=BgDxF6Y2BCwscRMX/1nHWh5c3+O9vNtYrvIJazlGbCw=; b=E4YH4ZAkzouIzyTrNuZp6xiEqf+Q3S1CSyLdJUkv6vT7Pi2B6fdWNsbOgKRkd1C9rKjA/a bv2l6Fvc0pSXb1o4SauI8a5e8Bolo62Xrqr/e7uE7fLPRbdepWjjyMTvyG7EGAurLpSlIt Tfayw2bltJvxYtiF50zZ3oX8QgsPyi8= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-77-w4BHTpKQMVyxJPieBikXbA-1; Fri, 23 Aug 2024 12:12:27 -0400 X-MC-Unique: w4BHTpKQMVyxJPieBikXbA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1319F1955D45; Fri, 23 Aug 2024 16:12:24 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9FC54300019C; Fri, 23 Aug 2024 16:12:17 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Pankaj Raghav , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Steve French , Paulo Alcantara , Shyam Prasad N Subject: [PATCH 1/5] cifs: Fix FALLOC_FL_PUNCH_HOLE support Date: Fri, 23 Aug 2024 17:12:02 +0100 Message-ID: <20240823161209.434705-2-dhowells@redhat.com> In-Reply-To: <20240823161209.434705-1-dhowells@redhat.com> References: <20240823161209.434705-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspam-User: X-Stat-Signature: 6ijm4knm5j3fkeshgt9as533kgpx3k5s X-Rspamd-Queue-Id: 9DBC318001E X-Rspamd-Server: rspam11 X-HE-Tag: 1724429554-326740 X-HE-Meta: U2FsdGVkX1+gs89jPXO6Aamp6JTpGjmsundoCNXmyTgGSas1Qkc7uSYuXw4M3mIV3Tu1njgkTEQBPmra9Wc0Sg2lpPAlcwwT96Q9OQzq1TezUzK/eUtSQWQS0VnYBvcxy0ym9uauynlUN1aEwJUYCczxnHBYuegz5QRPvMX+SDRj3Hez2IXEOfpDm/SQgKD5yHOswyEucyyfmMsBFxVLswwjgaLRwP+0ygyWjFYCzWjS4Uzd/JPEIihvFeiHpSriHNU/Yd+0mrVliQSevBTq/oTRPSgDDX/AbaVliB2gLpKjPTTiZYp6mVx/LXfBvUEALrmEpdbq00H52yfA0Y0xJKKLcKucJEzqUpA2jKuaS24JevAfaApMHeT9oTctvNn9FSiTgDS/xdSrFNxBpkvSdeCJeM3c6tNrXQQWBPJ+zxGH5+CczoeVYlqb3oU1ShhpvR3Cp0K5/2BwDyKYXiEWENZeB/U/rNdG4pJ7+AoiRx1hxfT0HiqVNGh9dtwnREbuZ1hB12uq6u8Wl54Q+rF+MiEEg/2kyJikzkIiy9j+A81Kw1UiOshwCzUi0IXeUe/8vGbozVGKpf2h6MBfLqPOI/2vBGK1kNXYSXJeAaSkaw4JITmNOHKAhpBFiCSg8T8NQVvQMCh6v0WtopRTDl+rQqK+oaad8sf951IvC1BEsVbrAc8xBrHftqx8J1f22wB4c3QawJvym4RwKFxBwV9MFMTuoA8d6tXilOmWTt/LpCDQgG9a8JG3I4ZODGPdo5kxloIJvK4q7UkBDIbyj8Zr6fSlC+wokIzNCd+ixIKyERyyUpej0Bwhh+JfWEtj9lJ9Xluv/MHVSWUsxa0C7xO+iTQVR82MifyUBYyM+Z0CIb1vYonjfXlJh8z3/2eSHE6FpsiSXhj13TdqpQmkxIQ9BtCWkeljJCNzCl783rsUEfqvIW/3xXp1xXBHKBFS8Yu0iuQNlqsMbV1+oFsgEW+ 6ExbPP7N AQEka/kvwAXyYttHgJjQIlhg69rBiJLtMYdLpL4N5uShlVcI61Oh0Br69SQBJoYFVB4kGrB+jmAkO3ueeNSrZcorjl5IdFILaOLZWCHH/3RupO+z+5Kz0Db18VjwgGxo7rMlXbioN4makC0qBsNQfwBVNvgntqnI6B7o9riYvfqph6VedK/UKjgQC+hIDHQR4rK/DA6fpaWNNkepgAz+AbkXxZDLN5XfxZwYk2GfseAHc4N803aiJbSVX/89+tb3zfZO11gKNmUhRr9YApbosrB+s+yUnFyoX0qsnVKRDUtYi25k9f3Xa1NwTvOeAWK+CUwdkRMCpEhrhyYq24RPGtq90A4aMvTmCyMd0c+aRBBS6MxU+rf2x8OKMnzyt25dHN7cKtZo6DoaMAcEs5SjXpLSvkCY8PdTo81GGeEgDyas23DMO0ytEtdddBsQ3J9Mxn3QPvyzBAIKcNR/RDwmD7JAD46XijYM7fZ5Jb3SaXezt4Fr/bEVwuTlcrNw6ajzTDaKBm6UVOMKdHg6cYNqbW0dbxx7YTADY+yIo6xYotVSONTs= 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: The cifs filesystem doesn't quite emulate FALLOC_FL_PUNCH_HOLE correctly (note that due to lack of protocol support, it can't actually implement it directly). Whilst it will (partially) invalidate dirty folios in the pagecache, it doesn't write them back first, and so the EOF marker on the server may be lower than inode->i_size. This presents a problem, however, as if the punched hole invalidates the tail of the locally cached dirty data, writeback won't know it needs to move the EOF over to account for the hole punch (which isn't supposed to move the EOF). We could just write zeroes over the punched out region of the pagecache and write that back - but this is supposed to be a deallocatory operation. Fix this by manually moving the EOF over on the server after the operation if the hole punched would corrupt it. Note that the FSCTL_SET_ZERO_DATA RPC and the setting of the EOF should probably be compounded to stop a third party interfering (or, at least, massively reduce the chance). This was reproducible occasionally by using fsx with the following script: truncate 0x0 0x375e2 0x0 punch_hole 0x2f6d3 0x6ab5 0x375e2 truncate 0x0 0x3a71f 0x375e2 mapread 0xee05 0xcf12 0x3a71f write 0x2078e 0x5604 0x3a71f write 0x3ebdf 0x1421 0x3a71f * punch_hole 0x379d0 0x8630 0x40000 * mapread 0x2aaa2 0x85b 0x40000 fallocate 0x1b401 0x9ada 0x40000 read 0x15f2 0x7d32 0x40000 read 0x32f37 0x7a3b 0x40000 * The second "write" should extend the EOF to 0x40000, and the "punch_hole" should operate inside of that - but that depends on whether the VM gets in and writes back the data first. If it doesn't, the file ends up 0x3a71f in size, not 0x40000. Fixes: 31742c5a3317 ("enable fallocate punch hole ("fallocate -p") for SMB3") Signed-off-by: David Howells cc: Steve French cc: Paulo Alcantara cc: Shyam Prasad N cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev --- fs/smb/client/smb2ops.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 322cabc69c6f..763a17e62750 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -3305,6 +3305,7 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon, struct inode *inode = file_inode(file); struct cifsFileInfo *cfile = file->private_data; struct file_zero_data_information fsctl_buf; + unsigned long long end = offset + len, i_size, remote_i_size; long rc; unsigned int xid; __u8 set_sparse = 1; @@ -3336,6 +3337,29 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon, (char *)&fsctl_buf, sizeof(struct file_zero_data_information), CIFSMaxBufSize, NULL, NULL); + + if (rc) + goto unlock; + + /* If there's dirty data in the buffer that would extend the EOF if it + * were written, then we need to move the EOF marker over to the lower + * of the high end of the hole and the proposed EOF. The problem is + * that we locally hole-punch the tail of the dirty data, the proposed + * EOF update will end up in the wrong place. + */ + i_size = i_size_read(inode); + remote_i_size = netfs_inode(inode)->remote_i_size; + if (end > remote_i_size && i_size > remote_i_size) { + unsigned long long extend_to = umin(end, i_size); + rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, + cfile->fid.volatile_fid, cfile->pid, extend_to); + if (rc >= 0) { + netfs_inode(inode)->remote_i_size = extend_to; + trace_netfs_set_size(inode, netfs_size_trace_punch_hole); + } + } + +unlock: filemap_invalidate_unlock(inode->i_mapping); out: inode_unlock(inode); From patchwork Fri Aug 23 16:12:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13775478 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 66349C5321D for ; Fri, 23 Aug 2024 16:12:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F41246B02E2; Fri, 23 Aug 2024 12:12:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC8896B02EC; Fri, 23 Aug 2024 12:12:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D41DC6B02EA; Fri, 23 Aug 2024 12:12:43 -0400 (EDT) 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 AC0C36B02E2 for ; Fri, 23 Aug 2024 12:12:43 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 71314C1E8B for ; Fri, 23 Aug 2024 16:12:39 +0000 (UTC) X-FDA: 82484003238.16.D26D12F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 94D0920025 for ; Fri, 23 Aug 2024 16:12:37 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=L9uhWjlj; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724429476; 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=/lptOZHiOn8uWw0ALny7F0H/3F9qROuXGja+3Wq36Fc=; b=TL/9fxTp3oREFwb0jcJO5nth+Nxr5Y1zcHYlwzX6lhGb6g1KygoDr/is5lL7v0JW1ip1OW Ev6TFijqiseXmibrgsESpie+V2o6HUDr41h92/dU93fs9Ns/yZA0SJ0h/jlWvJ2gxkfKoH pdAKdYHtpzLq/QhsiTRCe0mUKONTg3E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724429476; a=rsa-sha256; cv=none; b=H/2299FbiGX5UnjNmk+fnrquc9qeUekFE9+IIBgKnjRgYEjiCjPWpvHRQmWBplsSd7eflO t+Bmzghz5miJYwe1R+6n6mSlrj23/aBLHkofRXb6XANYxs8sK+inf+Z7ue8UxdbpC5qM5z 427E8EFcV1bl7qnX4CiYAWvK72MuVns= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=L9uhWjlj; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724429556; 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=/lptOZHiOn8uWw0ALny7F0H/3F9qROuXGja+3Wq36Fc=; b=L9uhWjljXFpKrLT11SS/uoA9MnaHiTcOsxn9IumKavvaBj/MigPz44743LQD5sg719W74Q lmfcWR9GmrkohqI/Tlh8BqhlGvmwJy95woMNmseaqrojXEz2fpfID4iJW/0zhwPQaGSOjy vHWUw+lrO5RuUFdvcoEAzSVVfgOnelU= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-zwK_gHXDOoy8ylOCoGXt0g-1; Fri, 23 Aug 2024 12:12:33 -0400 X-MC-Unique: zwK_gHXDOoy8ylOCoGXt0g-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 65F331954B06; Fri, 23 Aug 2024 16:12:30 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 699EC19560A3; Fri, 23 Aug 2024 16:12:25 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Pankaj Raghav , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Steve French , Paulo Alcantara Subject: [PATCH 2/5] netfs, cifs: Improve some debugging bits Date: Fri, 23 Aug 2024 17:12:03 +0100 Message-ID: <20240823161209.434705-3-dhowells@redhat.com> In-Reply-To: <20240823161209.434705-1-dhowells@redhat.com> References: <20240823161209.434705-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspamd-Queue-Id: 94D0920025 X-Stat-Signature: rpo8affmamdte465pueoz9t4o8p7ndos X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724429557-581947 X-HE-Meta: U2FsdGVkX18s7GQQo1/hWt/ydjW1eQt1JZ1JWz/kicn0IASjVW6YWZXfMKbzGWXMqsGZMMVojkRBl+R+MJJq64BmDCGp/aCNxvDHR62UXkNWMg9JhLg++OL/hRe2sEfpdkibwmL62J357lK5Xdx8ozKob9VwPrnAZxp3LtX0jDDft5/FJqXP1s71ZDSnAc2umzIb1EjAMSq22xCm76fm5ZqzYpkVbo4VJWzLPV/WPxr4KG3E7q59dbULpnZu5FCkbo7fA1DVta5VZEwsCzjIlk1HtGDDbttDyOMNkHkJA03m7/0iuRThWvxAooIHm/A9w3XiRnInIbqWqkYyAGkx3uq+ed3C3z4IkHh3CTeA+ROpCCIZyeL1E/Syu7qVEe0p/1bCcXjLy3jpfmKhLrT4mitBHe2EYy6ZAy/EnJfgozqA7O/C8EDbCIrnMs7aSIKwoyCYH6ddoqGl/A/DOEWRqyBY4a9THDTsa5pwyBOsDCzXhQZ15O2laVAZxANWt1smg+/7YeT782GgrmrfuL99vrw3r6Me1udkZ1gEr1h/CYNtBK1ao2Q45Im0c1KWgslExWdu5P/ebhqECd8s1voz1WcPOowQhwznGLQn7e0hgtYClsj1kQ0rl+NTKbZQ55WKw6mxMQbq9ES0rwbd5m0b4pUfLEEKxhr6u8OCE3b77oZxlQwwIvuyTR17fkwtyBFKZXwBvqQDVUaNy66C3pknFwTdzqXF0AgJQfKE30xnBs0dwy+3BKeqnbF8pC2v7uvsjh7TlzLmsgsWE3RGKScpm8w4ZMoM86PVMMt/FTgs2/2JJkcT9JcZKQmGVtFiX3boH9zCDc+IApYRhNShaprO4/srbr1qtvYg5QIxS5B/EGNTfjqSsl39Ej70hjmgsbNs+i+WVNmGmOQEBoSk9iOQNUbwhfZaVGWlbWOVOZ30NIlFnCKXhoYjdM1gg8MRiY1ZmxXFLzXjLhs7dsxAmp7 lPyGmR3i tyj5MjsYWunBWPCcHRzfXjghiVYobEuZYMePyLPdqPGH2B6BX7xSUmduJaBRwtNbzN9SdQhh9iWRf9I2KBTCtb9lxknSmPXHEfoSt9Jc7VYV6R4KnIFD+txGe7qagXzSABeVODua+vw1JbQkuBzynYlzZXL1D/Z+kXYedcpiJ5PJvgdtr5VxzGWZA+uTaFOik4wjjGnE2AQWFRlg9Nu7YlC8lSg1vBvj3wn/wQ0Wz4DGuNqfum6g6YQLgdqpeaCEx59yFVn2ZNribAUvTtTj29RfdDk23Yku6W4eoC4whzoot4405SWm21JcZxGER0YwB4k9BhIIwPlbiIstRodZ838TmjF072NAJVZvGQJrT84+xw2qS2eNSX3vVo0xUhUCJcTqMo/KKNu6wzWLvgueTHNRH5ArFU1Z+uyyRCMObzM6iZVTWdPGFBSicyMlgJvZVIpZ/IFbKpO7sbp9HSrMTqc8DzyDIyjHai46r 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: Improve some debugging bits: (1) The netfslib _debug() macro doesn't need a newline in its format string. (2) Display the request debug ID and subrequest index in messages emitted in smb2_adjust_credits() to make it easier to reference in traces. Signed-off-by: David Howells cc: Steve French cc: Paulo Alcantara cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/netfs/io.c | 2 +- fs/smb/client/smb2ops.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/netfs/io.c b/fs/netfs/io.c index d6510a9385dc..605b667fe3a6 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -270,7 +270,7 @@ static void netfs_reset_subreq_iter(struct netfs_io_request *rreq, if (count == remaining) return; - _debug("R=%08x[%u] ITER RESUB-MISMATCH %zx != %zx-%zx-%llx %x\n", + _debug("R=%08x[%u] ITER RESUB-MISMATCH %zx != %zx-%zx-%llx %x", rreq->debug_id, subreq->debug_index, iov_iter_count(&subreq->io_iter), subreq->transferred, subreq->len, rreq->i_size, diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 763a17e62750..20e674990760 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -316,7 +316,8 @@ smb2_adjust_credits(struct TCP_Server_Info *server, cifs_trace_rw_credits_no_adjust_up); trace_smb3_too_many_credits(server->CurrentMid, server->conn_id, server->hostname, 0, credits->value - new_val, 0); - cifs_server_dbg(VFS, "request has less credits (%d) than required (%d)", + cifs_server_dbg(VFS, "R=%x[%x] request has less credits (%d) than required (%d)", + subreq->rreq->debug_id, subreq->subreq.debug_index, credits->value, new_val); return -EOPNOTSUPP; @@ -338,8 +339,9 @@ smb2_adjust_credits(struct TCP_Server_Info *server, trace_smb3_reconnect_detected(server->CurrentMid, server->conn_id, server->hostname, scredits, credits->value - new_val, in_flight); - cifs_server_dbg(VFS, "trying to return %d credits to old session\n", - credits->value - new_val); + cifs_server_dbg(VFS, "R=%x[%x] trying to return %d credits to old session\n", + subreq->rreq->debug_id, subreq->subreq.debug_index, + credits->value - new_val); return -EAGAIN; } From patchwork Fri Aug 23 16:12:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13775479 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 3C891C5321E for ; Fri, 23 Aug 2024 16:12:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1C9B6B0303; Fri, 23 Aug 2024 12:12:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA55B6B0307; Fri, 23 Aug 2024 12:12:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1F1E6B0308; Fri, 23 Aug 2024 12:12:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 90AC26B0303 for ; Fri, 23 Aug 2024 12:12:46 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 690D2121DFA for ; Fri, 23 Aug 2024 16:12:45 +0000 (UTC) X-FDA: 82484003490.12.3F6F1D4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 3EDAD1C0016 for ; Fri, 23 Aug 2024 16:12:43 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=B4jNADsy; spf=pass (imf18.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724429454; 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=UF1dQkOHc38/CxHdvA+HTnp1kknbAHEKTFkwj9qcOQo=; b=jsz7RV8ppcxpVtVsLqBQ8MRBReFY91aBU/gJApmQ36PuZooulm0kYWixlHvEWUHbdLF0ia myoQ6iPsixyEsmDr0BVzjBiyyJaQKhEKGmK9UVCdPl0H/11qVMNqg3cHiq8EDbt1dcktjO nBa/TjmrqZ2barpg1PTFIEROnH3OV4k= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=B4jNADsy; spf=pass (imf18.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724429454; a=rsa-sha256; cv=none; b=NyeIQqSQsEFkO1QbzfDxF2Up0EvQMtNW4u+uQ3LSZpg8K55wNO+UodNo4Ki3Er0T4Mq4Px F9DUyGG9dvCmqD62i8LzoH/ptESjPopJm3PHLwxA7SuAkzKGoUTQJEMfAsUzJ6tKrCae9h vNTBokHV94hGku+O4PT4upWJKKuHiAw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724429562; 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=UF1dQkOHc38/CxHdvA+HTnp1kknbAHEKTFkwj9qcOQo=; b=B4jNADsyyUT10rwVOUheZYf9TMziINehSlVUcl2UlTxjqBFP4fELN2WWHDintqE0DXdhk3 6reXGxbWXoPSUBTSHKMYI3N9Zm9uCLMf07FNM1kLyy2SWnLDLXeIBUlVQYDhT0/YfsF5kK oYqqhPIn9Thg2mnHkT4d5YcWqBzWYpY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-99-8smGqBV2N5OacPwQdgxAmQ-1; Fri, 23 Aug 2024 12:12:39 -0400 X-MC-Unique: 8smGqBV2N5OacPwQdgxAmQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 571C51955D4E; Fri, 23 Aug 2024 16:12:36 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 11C6819560AA; Fri, 23 Aug 2024 16:12:31 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Pankaj Raghav , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Steve French , Paulo Alcantara Subject: [PATCH 3/5] netfs: Fix missing iterator reset on retry of short read Date: Fri, 23 Aug 2024 17:12:04 +0100 Message-ID: <20240823161209.434705-4-dhowells@redhat.com> In-Reply-To: <20240823161209.434705-1-dhowells@redhat.com> References: <20240823161209.434705-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3EDAD1C0016 X-Stat-Signature: 65tqwh17ixihpfbknqxwd1ocxcs3c9nb X-Rspam-User: X-HE-Tag: 1724429562-220574 X-HE-Meta: U2FsdGVkX18RdiczZ9Dx2w+YNY1hMTZwAIEn8B7M54NgDAe0uwsBcx4QxTGnGP64Pipd9IGPvpUxNKurtI3EvqrTZhdsSdge9/ZceTormesz0+54WNKaPp2r5V43Xi+JxQLLd0KxQ/ANuA5i0NyqY/1EXchcR82dFCsoR1vQ7HQS6M2cLga2z/cexaRYOZea30sNkkeWKsNHXLUlt4vrQBO9AnVdxqK87oZzPmZMbTxjviokLRGpl5x/kbDl3ni8TlS0beWN4iNklkTkISk281XSOfwryCUJGemfIFxrRgN13AouC0a8vDff3Q+dRfNrVx4JhFxj/f1mpgh72BclOUqHl317knNOkBUTxsoOFKWKmh8FLXVzjpvIQdP3P3GmXtepzmTrULOx1BAIIGnqZfu8Ru7cbG8DzdHGMOK7TRoL3qTUzBpcrPzPwpkK6MzbE2Zb8Q2IMP2BY9ljQGhjks9tL0tuyIy3sIy3sHYbfhUgKcCqDCNwM6shEQcli7kJPMXMXhAKHBzgbM0iyaQ4fNuZ5tavjgybzmY559SNSUXClQ9VKkb3ol5FUjKVqYl522t3ODqzejAfrJr5Nc6Yg5MoHtSVp8ne5wvkIJM7ALe7cB+A/37C7iEgBDJNN2bZJa6bVkXv65CGZ72YLD6k7hZgkxCuMclnqRwme8sPe0NlnE6rnOMgzTBwUVJlvELLPiJwkSD41CTIn3Ksx1zc7wIFs1PxW5+/F1j62x6Jql3myrBIC8KW+8xYicweIaAkmhSGzdc1hrjVcPtz+sCDMIY+HfkWqOD0RNDRzPUN1A/iVgaFn+ACgXs27S0VWfCao4jB7IAvQ0zUf8c6HJwqf9yH1++N4fm++QGoKcUlIL0cqDzQivqkXLMNrBjP2KIpZ7neHASbmRq3pFf+jXFD/czA1Ngq9Q6VcqDwYWcDOh/KSI5bVEfa/uSrshyHie2vADyfxjm1TOFWxy2Ig6r uADAXn7x BRredTbvMGMpgh6bmmcaXHf3/HCV8tvyl0h4ggqBzC20ANHjIpCzECsUY4BKV6QsKqi3qmn3THawqkLvoAdPMggYbUhjT5+uvmzvIwVbrUaoCvOeBu/2PVgDmduVKVtvKMoPIN88AlCLr7FZGecklJQFD2qLZtVbIgw8gqzzo952ZuvSVEo0K1aWnSMPKiXtKV0rwRhIJ6AYt10HNcA+FcfGLCiaFWZYIWK9wpQ3hR45pAhA3B5bDonFZY5ggNyk2XKS+sulN7g2zo1ad3YM4YXcmAhOQKtU3uugVulcnnuJm07mpDJdbylGua9Gk0IiMc0i25t22lZr424SM3CRW8zCocpl80mc+wERxCsL5ZRHlxMCVG/xU1mJAUbJgLKcsfKBjDyEJZvrKdxUIOoU8ZjqJbrFmFYFqK7arVLrV/EwtkGMZ25kcBypIplbxxVTxoI5Sv5y7nJ77NSNDVbsK3s2idtd1lyMNesws 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 netfs_rreq_perform_resubmissions() to reset before retrying a short read, otherwise the wrong part of the output buffer will be used. Fixes: 92b6cc5d1e7c ("netfs: Add iov_iters to (sub)requests to describe various buffers") Signed-off-by: David Howells cc: Steve French cc: Paulo Alcantara cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/netfs/io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/netfs/io.c b/fs/netfs/io.c index 605b667fe3a6..d6ada4eba744 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -315,6 +315,7 @@ static bool netfs_rreq_perform_resubmissions(struct netfs_io_request *rreq) netfs_read_from_server(rreq, subreq); } else if (test_bit(NETFS_SREQ_SHORT_IO, &subreq->flags)) { __set_bit(NETFS_SREQ_RETRYING, &subreq->flags); + netfs_reset_subreq_iter(rreq, subreq); netfs_rreq_short_read(rreq, subreq); } } From patchwork Fri Aug 23 16:12:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13775480 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 2F4A1C52D7C for ; Fri, 23 Aug 2024 16:12:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE2D46B0341; Fri, 23 Aug 2024 12:12:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B92286B0342; Fri, 23 Aug 2024 12:12:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5A156B0343; Fri, 23 Aug 2024 12:12:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 852FB6B0341 for ; Fri, 23 Aug 2024 12:12:55 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 19E0481DB7 for ; Fri, 23 Aug 2024 16:12:55 +0000 (UTC) X-FDA: 82484003910.20.F27DEAA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id AFB8F1C001F for ; Fri, 23 Aug 2024 16:12:52 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LpWj2SkP; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1724429512; a=rsa-sha256; cv=none; b=wGDSEwrV8uojBbzxNuSYfQMtazFRrAkC2EhzEK3ya4opKWKBLPsN4GFZHchbOMK5OXc2QK M2Yil2IDupmSLPVZhg3DsVk6tARHPIfk7zST6HCYqd+x7zC1qNXOCXz0axa8FpSWo6Dc0V WSvXO+2N6U0vSk9OIKGuNDxEaf9lymI= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LpWj2SkP; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1724429512; 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=C4kdxje9pJwe2F8kxgsN+SQonQ75sAMbOz8YwNBazmI=; b=O8ldGcECRQv7XBeW64X6MiSnnEgDLsro8ocusI3q55pm0YDRCK8SQ28YA7r4REkithi1Mn zw/29bB3RxJQLr91FGc/ZRecfT1XCEiP//B4Htmt0gwEo1QeSOoKhk5tEoavKfKC2mMZAO /dw7H2E/W+wurdlX2Ex35Y7U2E76NpE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724429571; 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=C4kdxje9pJwe2F8kxgsN+SQonQ75sAMbOz8YwNBazmI=; b=LpWj2SkP51jpUmkjArjNRAdXzF9hZhS/XCQwcbfMJ5Dv6DNul3TkRGeA/VBqXAOSSaGLY6 3eSmKPU43PAwi5Ue9CsxbVZRAtobdLsuCu6nHWj6AERw6wwEkUnVf7ewW5dkYA44mCBq1R 7ECo28grhBTUnRaCfNtoLwZ0Xst5I18= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-542-tWlcgTiVMRa8lhTgu6q_UA-1; Fri, 23 Aug 2024 12:12:44 -0400 X-MC-Unique: tWlcgTiVMRa8lhTgu6q_UA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CFCD01955D47; Fri, 23 Aug 2024 16:12:41 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9B46D19560A3; Fri, 23 Aug 2024 16:12:37 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Pankaj Raghav , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Steve French , Paulo Alcantara Subject: [PATCH 4/5] cifs: Fix short read handling Date: Fri, 23 Aug 2024 17:12:05 +0100 Message-ID: <20240823161209.434705-5-dhowells@redhat.com> In-Reply-To: <20240823161209.434705-1-dhowells@redhat.com> References: <20240823161209.434705-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspamd-Queue-Id: AFB8F1C001F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: y8ktbj4yqc6ome5niet7h6t9isedpbmu X-HE-Tag: 1724429572-828907 X-HE-Meta: U2FsdGVkX19++F5BMSROhYpLZi97nparqKEUCz4saAVWKcjiW786lyqRsP8tucMEUnB/8JBoiY750wWWkxSnp4R+Epj20K+4GjS0hVc2tRg+Lz2jeJtGwESGoi8HBlR2g71ZoDj/i1bOSzLq3BQVPp8YalkckSrWs38FTIbuRmPRqW8Y+RC8WZgwDRwLkYDk92VP1SNwOoKPGt3g3Oh2n9c++Fvp66JRl5clD4c4rC8jOPCeqL3eCVpueer2LAlLmhgowIYGaKpYp7fxV69pSClemLlCQUv1GUorDs1khnhgldJ/a/wduBpk0UN24AkAbYAIvmfRY+iICx+QihmBffyUWeKuwCx3qM2LATzL7d5hLPTwnffqJpaR7ThE38rixihdqpEZk0/mda4N4ok2PGhiqAY46KgBybfT3dGSuy+wjskENYLWZsQ0zDVJlYd7/KIzos8E0d/7m7I/ln803z1LBiysrW4L8ado5b7nd2dnvZm+wZWiZYOTpqeK1gbja8CYqdNZB1CJCN57/8ijIAPXP81kQ6/G3XsgaI0Y2jMt+LhwD6YCn/8XixoIjVobNV0gqX6+vuC0UYYYpXIG4ioSCV9JyKHLut+Pzf88O/nAvrE+yCOlHLTKr1vihhjTm6rwZTq7K935rOPlQMnQl2gWkL/6wX+SMRXhsMsrY6Bx2fblI39aAAax9Wn42ZG1tfEKRmqhGmxnheiSyaK8e8SMlBq0UwVRwRm3/lscRyouvBxr+y/q9O/CqQSNJDwkghsOhSmfQ4Oc8RvPj/wKBWZuBPyVeRngTKOzHRVvZFiJUVM5Qxpb45SaXrX4eqxWfUHG8C+bQYBYnbJPqCGd69NTEhN0yNocPM+6dViDAjYJP/hpOdfOvP/QJYuMqHkMFuSIQsCQ2+/bd5W/vba229u0gxiXpRYjaYwPe5tV4lceKDCzB64nRP8gT52xgeGc5aY/87JdMii7LETnhcw QgO0Haxa 05Z73r9gplWiIILnTqHNJBMfCId3xV2lJmSjdGg7pGAY+inK0tm30NZvaETRx2uaZepV8jMlQny0kgNARIDGX3Qv3OP3J3hs4UEPyjVsgj7BtDmFZDEPR81shV0Cqv1pL6Cki1WynD5Uw/n4LJccHSwFo0PskqRmQzogxbkwQmKuKCH+aRLWYnInn0hlkiD+WixYzQgENPS7jFibY0BE8fehEmj0FW8EdvA0zQMlzo1w3rlTYfjk4OEPZlGVOQpO27WeWraGWGqJADZIFKCk1+51mhDPU4MYJ7duze3AUA9eaK330QWskKO0voUFqlG1E2yd3vtAA3XgPqqZBm5zYN11MWvQIBm0QvFGikQtafOEjKK/797ygp99Vn0WkABFmMqdpZMyeOAFS4UxpD4mz0Fx1htJ5uDSusE9iriI9hB4pAgw9wjdWxBfmPcEhFAjwnoTh2fz4sD/E2/zqRahhASl8P8OEOF8JJcdf 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 smb2_readv_callback() to always take -ENODATA as indicating we hit EOF and to always set the NETFS_SREQ_HIT_EOF flag rather than only doing it under some circumstances. Fixes: 942ad91e2956 ("netfs, cifs: Fix handling of short DIO read") Signed-off-by: David Howells cc: Steve French cc: Paulo Alcantara cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/smb/client/smb2pdu.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index e182fdbec887..9829784e8ec5 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -4601,16 +4601,8 @@ smb2_readv_callback(struct mid_q_entry *mid) rdata->got_bytes); if (rdata->result == -ENODATA) { - /* We may have got an EOF error because fallocate - * failed to enlarge the file. - */ - if (rdata->subreq.start + rdata->subreq.transferred < rdata->subreq.rreq->i_size) - rdata->result = 0; - if (rdata->subreq.start + rdata->subreq.transferred + rdata->got_bytes >= - ictx->remote_i_size) { - __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); - rdata->result = 0; - } + __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); + rdata->result = 0; } else { if (rdata->got_bytes < rdata->actual_len && rdata->subreq.start + rdata->subreq.transferred + rdata->got_bytes == From patchwork Fri Aug 23 16:12:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13775481 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 476EFC5321D for ; Fri, 23 Aug 2024 16:13:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1B896B034F; Fri, 23 Aug 2024 12:13:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCC946B0350; Fri, 23 Aug 2024 12:13:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6BCB6B0351; Fri, 23 Aug 2024 12:13:00 -0400 (EDT) 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 98A9A6B034F for ; Fri, 23 Aug 2024 12:13:00 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3CB05161DD3 for ; Fri, 23 Aug 2024 16:13:00 +0000 (UTC) X-FDA: 82484004120.09.D91FBD9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 65B8A4000A for ; Fri, 23 Aug 2024 16:12:58 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YesoxUeY; spf=pass (imf12.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724429497; 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=FBChvUZyQ988u9TYFlpOvF0mis7ud805n023OENZupc=; b=bo6dRevHsK+AY1tJRCofE6wejuSKS0Q5HTT6zDWLwvspGLM3LfcZ6nUVcbNu5rRXoEJWNb dSG+k30XkuI49vofBBZi4US4DZnjvOG6GToFuLrzHIUer1L3Gb7pFls9vraKYrCmJGGQUe wIAQaAAxu3JsHQ8KXv8JC2ZzrocbfWY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724429497; a=rsa-sha256; cv=none; b=MuXHZPACanzBm3dGncdfTpsWAgzYgJN/cqyWM6B+OzzZaYxWDPRGIodu4e4B5k4PyXOc5x 5UQQrT0N/BZ2Z+A5zpmr3cjS/rjCbFT7Ob4RraeidPUMO83ZOjYwtKXCEJ0AdfAx4plkao ICtD1LSHQGHkP4H+Zkc3WyupTcFWPuU= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YesoxUeY; spf=pass (imf12.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724429577; 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=FBChvUZyQ988u9TYFlpOvF0mis7ud805n023OENZupc=; b=YesoxUeYcrPLAIqw7/dK0mAtqn8BaIzhq9MadzAGfBJvnJKAP5vcPOkb/d4K4k849ACozh gHZnT+kgtNpG2FBrq4bL5Z6POzgHWLcegeFD3v2fFWjADkCA7LLXX4S4QFYVswluShYNQU Oz2j8/Px4/SffFc7CcLrHmL3lSezWTk= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-HzxncWQrPICf3GrzTUMYmQ-1; Fri, 23 Aug 2024 12:12:49 -0400 X-MC-Unique: HzxncWQrPICf3GrzTUMYmQ-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3CFB61954B02; Fri, 23 Aug 2024 16:12:47 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 368AE19560A3; Fri, 23 Aug 2024 16:12:43 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Pankaj Raghav , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Steve French , Paulo Alcantara Subject: [PATCH 5/5] cifs: Fix credit handling Date: Fri, 23 Aug 2024 17:12:06 +0100 Message-ID: <20240823161209.434705-6-dhowells@redhat.com> In-Reply-To: <20240823161209.434705-1-dhowells@redhat.com> References: <20240823161209.434705-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspamd-Queue-Id: 65B8A4000A X-Stat-Signature: kijkyre8rn6cskboka575red3d3nnh3u X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724429578-142899 X-HE-Meta: U2FsdGVkX19EdUULeqa4KmTkd3hz7u/oTsvrp5+MJzbEG2eD59xLtsz5v8NSdZ46Zv4o1tQwSDN3jev6DGBwIOrsGHhArHM3XOMmSkl7IMyYuH5nQVHtJKCd+Ofzr8BsN29YTV16C6YhxE6zXqKbad0Ln5OpzwmZXbBLDFS1Uu64dT0ijvzZd16ifpI5j71NqY0SHBp96nTBV//TBN1wrX2kzpoiQ9JaGGvDpS5T/83OVuU+e7HOdw8lvJtJEp0bCnR9r1H8VW0UuY9fyQlucvBzwOKwPVew8T+tLLchrdrOOpPyOt9OxRsdMThVC4ODqKAJ5eg931wjUql6y/l8LmDGVUzRbDufUg2XLbzeQUQY6ZVMOHxV54K7Kny4nTxwIjuXU0HdsvGoHttomCJdb99OIjebucwOes2huJ+BnSjwmoMsYxlgwnnAU4QoCFvIowB8M8N4RsAih23DSBzT6JCHielkQ7TWMhd4Md8YhEgfv5NyC0T15YJTaTFx/a1b/zJOlHAM85Dq09B/txCIIwykZuSfSN4v2I1sPyTMidtP3jyye3BNcw0PuJ2zQDBenLUb5hWZt9pIvM3KUu794PVZT+cyWGacJE4TncyUnoYlyII16bm2M/yYrh2HNCvNKijyGE7BEuJ5YQs4iit1/Pp/0QfepU0hdo5oI2ufZhP8J91b2jo3+M09dvGICli2pjq7Mji+PyDw/pKO+bI80r65nXn2iZDqXSEmzOZWNsEUZZ8pQlXNoQNUJG1J8Uct9fB8y9ojB7lvFzYScx2GPqY3+mPkTesh4Sz+vMCzao7XpVofTTMmTSaZ2bcubRAjAVupxwbajTa6+d4KgAgxfrC+EdzfgRHdduJ7DXglrANxenbpDytvFedMtNP7YMZAnaBRNK57yAyOMKGDOxm0iiGYNybQQazt0HgZ3zmBfuvwprYqkq+TJG5FARHwm448kWMaOmaNvLjyolnRHrN 4+Vbw2GQ g4+5eOv9rmZEZsXKEQ5/CTNCi5DUpxmFWDo8NSXfHIElVIa6BYnM/zW/VtB3uw7+56HZ375MbzX6s2HURiXkz2E07ACh/HNuW9zS5Qa3K+ygr9YBHLNZnw9JjLK70CPLTOn04daDDAz2/ZX4uv+8OfCu8l/GZGC7Rk12anVroIgJW2B3FrISSLNN6pR38b/0damWoWGhRyF4ctfmEjp9uql0DbImH16PHc3cksD21vOcDXVC7Z2S22w5Xn7/OAKnfzs5NdVA+NOY3Jqho7/JQbtZVGoFVwxFZuGze3Jiy1AZQvfiI6iG4UOSoorvzrcniK3c552/gfXlLyui9PGzwy3pLYTick0amZ0wWhGob+f3p9bfQw2UhxBvsKKEoeovC7Izddce5g2m1QGTIixY1rV/ANNfgrNxW5JTHTNek86JS0bqS0zBNSOvJSVwRGbhXsopek/88EPWx2S2iOnPUwVU02P6oC4Z8ioAj 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 some bits of credit handling: (1) Use the ->actual_len value rather than the total subrequest length in smb2_adjust_credits() so that we don't trip the error message that we don't have sufficient credits allocated in a retry. (2) Set wdata->actual_len in writes as smb2_adjust_credits() now expects to see it set. (3) Reset the in_flight_check flag on a retry as we're doing a new read. (4) Add a missing credit resubmission trace. Fixes: 82d55e76bf2f ("cifs: Fix lack of credit renegotiation on read retry") Signed-off-by: David Howells cc: Steve French cc: Paulo Alcantara cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/smb/client/file.c | 9 +++++++++ fs/smb/client/smb2ops.c | 2 +- fs/smb/client/trace.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 493c16e7c4ab..b94802438c62 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -111,6 +111,7 @@ static void cifs_issue_write(struct netfs_io_subrequest *subreq) goto fail; } + wdata->actual_len = wdata->subreq.len; rc = adjust_credits(wdata->server, wdata, cifs_trace_rw_credits_issue_write_adjust); if (rc) goto fail; @@ -227,6 +228,14 @@ static void cifs_req_issue_read(struct netfs_io_subrequest *subreq) &rdata->credits); if (rc) goto out; + + rdata->credits.in_flight_check = 1; + + trace_smb3_rw_credits(rdata->rreq->debug_id, + rdata->subreq.debug_index, + rdata->credits.value, + server->credits, server->in_flight, 0, + cifs_trace_rw_credits_read_resubmit); } if (req->cfile->invalidHandle) { diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 20e674990760..5090088ba727 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -301,7 +301,7 @@ smb2_adjust_credits(struct TCP_Server_Info *server, unsigned int /*enum smb3_rw_credits_trace*/ trace) { struct cifs_credits *credits = &subreq->credits; - int new_val = DIV_ROUND_UP(subreq->subreq.len, SMB2_MAX_BUFFER_SIZE); + int new_val = DIV_ROUND_UP(subreq->actual_len, SMB2_MAX_BUFFER_SIZE); int scredits, in_flight; if (!credits->value || credits->value == new_val) diff --git a/fs/smb/client/trace.h b/fs/smb/client/trace.h index 0f0c10c7ada7..8e9964001e2a 100644 --- a/fs/smb/client/trace.h +++ b/fs/smb/client/trace.h @@ -30,6 +30,7 @@ EM(cifs_trace_rw_credits_old_session, "old-session") \ EM(cifs_trace_rw_credits_read_response_add, "rd-resp-add") \ EM(cifs_trace_rw_credits_read_response_clear, "rd-resp-clr") \ + EM(cifs_trace_rw_credits_read_resubmit, "rd-resubmit") \ EM(cifs_trace_rw_credits_read_submit, "rd-submit ") \ EM(cifs_trace_rw_credits_write_prepare, "wr-prepare ") \ EM(cifs_trace_rw_credits_write_response_add, "wr-resp-add") \