From patchwork Mon Jun 17 22:01:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13701476 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 3B09DC27C79 for ; Mon, 17 Jun 2024 22:03:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2E226B0295; Mon, 17 Jun 2024 18:03:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E1C596B0296; Mon, 17 Jun 2024 18:03:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD0756B0297; Mon, 17 Jun 2024 18:03:33 -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 9AD036B0295 for ; Mon, 17 Jun 2024 18:03:33 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 523CC16015C for ; Mon, 17 Jun 2024 22:03:33 +0000 (UTC) X-FDA: 82241757906.07.65D6203 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf16.hostedemail.com (Postfix) with ESMTP id 8FAC018000C for ; Mon, 17 Jun 2024 22:03:30 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ds2owe1f; spf=pass (imf16.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718661804; 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:references:dkim-signature; bh=OthT64InZoPSjxn4tC63hXPySB5WxWKH+1+hvHHCkCU=; b=CmHlB9k0cbmqyHKCHpe94299UEKbQhL7Jm1qT0awnw5rsx3kRbK5HQfgF64oRDx9LH4fzh 4qk/0NTq0wQcPfKTHugltkp3eXnWFKixV5tcvJkt6+Z3iROzFowqhhWXwyLwrCDTove46h Ts/lbUwk3aOUG7Z6Ud3n+w5jmX1D2ds= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718661804; a=rsa-sha256; cv=none; b=lL3NdZpvWNdSCtGYBWcajmJnPQZyXcG9+9nJyt6U5TrT/0/nGqqL/PXDTbWWINXz1KTHkZ 9o9EFTordSPBlJsPPzUwllGM5+c0vAMEtV7uHLw10eA6u7zK1hGjzmq84Ub7U80+6+kyzw XuKYak6jK0XQwEbhpUApps/8AS3hSnQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ds2owe1f; spf=pass (imf16.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-7042cb2abc8so3506751b3a.0 for ; Mon, 17 Jun 2024 15:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718661809; x=1719266609; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OthT64InZoPSjxn4tC63hXPySB5WxWKH+1+hvHHCkCU=; b=ds2owe1f0YUkrvtTywC1j7ytIw5gRWh/gtJU/I1b8kMW7luGQ0w/5OjF4AFR88wW7B GZD4tnvtm0QQ5L5Vzq5iF+B/SMyHCre3zEdpRkpdDkcDHFzItNfHFHTQLXdxEMaZO3Ag wYot3PkbrL+6ioeONdLNt/4iomHzbW+9zOStaA7Nq93j9TXp6Qtv9wLB642sLnIlqq6b jV6fcYaRsanZcxjmjrpwP7n1z3EKVgvEwI2UA18Ake/dVHwwTX1IMfUVFHSFVkdSPDtv v7cF8oKA2pjgj5rwUso1FR4qM6OToUI8j21sIBWH2agPjPUsfUrnseZ4DzL7mU8aKBEG 6Y0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718661809; x=1719266609; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OthT64InZoPSjxn4tC63hXPySB5WxWKH+1+hvHHCkCU=; b=MqvYtlKQ1WkKgiqZNGHzgVPu6IEI2JYKUZU7hXHUf0VjnzFQzQwpYS9sQOz2lZ36qv MzvYA80p8ILTvXVD9jUkzAzKYrRcr5YTExNVInlReGUfS7dJlpyfI+vo4OD0IJuxkWkh 7odXDqy3CBdKbik3RJ7Qsnws6smUfwQN04YlEJaJsB6H+7ITjbOsCqkcAh44ewKb12We pnFdABaJStqtrT4jqAlNr8+DckPOyZIUqp8GE8Vy9b8lA3+6w8ARBpQvE0uF7Iomm2f+ 5RWWNbbQfhxiz4LRefKHiMrKfn3Al1uYfUf9yMlVWf+GzfC/aT6MGN6fogZlk5exLlOW G/OA== X-Forwarded-Encrypted: i=1; AJvYcCXeefEtMJK0FopHAMTQ/i/KgHbu3pwWSTfWd90or7mTjcM3LRTZ7pas1PFovbgLbBR/+Qgbrj4uXcIciyTzzBioROY= X-Gm-Message-State: AOJu0Yy240GXTw9XMAEtBtho6mTOWmA1TSnA/pz360d5SFmy6jIDWy90 HjZdZBMBYcVYh1ZGG3pV709sdqbp1H70Tv706U4hqJS6oyCPxbb/ X-Google-Smtp-Source: AGHT+IG9I5vkz7rxNTFokc77oylq1cp4BaWMyV8LYpDzB0f5nXtaQTES9UcpoMyRf5qpPVLsCCExLA== X-Received: by 2002:a05:6a21:6da3:b0:1b4:4370:60f with SMTP id adf61e73a8af0-1bae7e1c9e6mr11360428637.1.1718661809341; Mon, 17 Jun 2024 15:03:29 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705cc91dc5csm8079864b3a.10.2024.06.17.15.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 15:03:28 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org Cc: linux-cifs@vger.kernel.org, sfrench@samba.org, Barry Song , Christoph Hellwig , NeilBrown , Anna Schumaker , Trond Myklebust , Chuanhua Han , Ryan Roberts , Chris Li , "Huang, Ying" , Jeff Layton , stable@vger.kernel.org Subject: [PATCH] nfs: fix the incorrect assertion in nfs_swap_rw() Date: Tue, 18 Jun 2024 10:01:35 +1200 Message-Id: <20240617220135.43563-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Stat-Signature: 8pxk3fi7hzx9eumfdjydpd1nidyfgqum X-Rspamd-Queue-Id: 8FAC018000C X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1718661810-745204 X-HE-Meta: U2FsdGVkX1/oJG7FS3uXXD4n2D1KXU1lgk3V0bvIjgAXaPOlqeDxPVxOWObQTNkoO+9m9s92H8OPT0oP2yCjyETO2qH9BNPhsjDHUnLhPkEz2/sdgzsODO/ep6O498mL/p44qaBiJMaG3WDAgM/xGTgwmfH/zl6m6Sb8mupos1UbLlLUyfvvURJfQFUei8KUHLWLqtqSzME0jpaHXfyZvg6pE0A5343pnRvBgz87NXw3+PiPzIuR72U5qsYhtIoXwRuy8xPjr/12E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3blc0hQdgDzMgR8DzdE+A/W+S+w8PIhjJ/M9NLFyVdMR9Z8ezZ4DwLhieuZccvNZd0256bZVP+V3Lem/IjPF6mY48dyKPF/+gzaYH4iBOcDLP2x6kQdgmWIEItN2r2cLLKuWj1BaPRB71/DwRMnkh6JOz9xrFMr0EGge260LQBa50gAFn91SS9wW7FOnJ9dCOxOGUh52DOBZLu4JO9vHa/efAZIfIYT98i/f+vjAX4vkkUuZRhUxK/E7jX6oh/TbdhJjnk+PNB/DQgQ/uSKNS+wxYyrkGqZ4OYEcagLdP0WeQOfDYtFkDK1LAxzoOsfpwFFgwvIkw== 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: From: Barry Song Since commit 2282679fb20b ("mm: submit multipage write for SWP_FS_OPS swap-space"), we can plug multiple pages then unplug them all together. That means iov_iter_count(iter) could be way bigger than PAGE_SIZE, it actually equals the size of iov_iter_npages(iter, INT_MAX). Note this issue has nothing to do with large folios as we don't support THP_SWPOUT to non-block devices. Fixes: 2282679fb20b ("mm: submit multipage write for SWP_FS_OPS swap-space") Reported-by: Christoph Hellwig Closes: https://lore.kernel.org/linux-mm/20240617053201.GA16852@lst.de/ Cc: NeilBrown Cc: Anna Schumaker Cc: Steve French Cc: Trond Myklebust Cc: Chuanhua Han Cc: Ryan Roberts Cc: Chris Li Cc: "Huang, Ying" Cc: Jeff Layton Cc: Signed-off-by: Barry Song --- fs/nfs/direct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index bb2f583eb28b..a1bfa86f467a 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -141,7 +141,7 @@ int nfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter) { ssize_t ret; - VM_BUG_ON(iov_iter_count(iter) != PAGE_SIZE); + VM_WARN_ON(iov_iter_count(iter) != iov_iter_npages(iter, INT_MAX) * PAGE_SIZE); if (iov_iter_rw(iter) == READ) ret = nfs_file_direct_read(iocb, iter, true);