Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2253048rbb; Tue, 27 Feb 2024 16:25:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWWGJM8oKoAyTfGzK5p1/GhLXBIvj119DaQrCFKU89dcAnEFSxk/Z+XbKU3cJorLcfzBINH2de2Tx7JZkMswKCAEAjOo/jTChF0hvWaBA== X-Google-Smtp-Source: AGHT+IGSfHPfQyyvLFsHsn8A8B23SNYXiS0hHmPuEGJUb6cpr/yAhfmFVwQbF4P6UlmguMTiVk+l X-Received: by 2002:a92:901:0:b0:363:d9eb:c2de with SMTP id y1-20020a920901000000b00363d9ebc2demr12532686ilg.6.1709079904833; Tue, 27 Feb 2024 16:25:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709079904; cv=pass; d=google.com; s=arc-20160816; b=XO1ksod/OS16qUsv7x8ymbCXotjLPioFbD7xKJQnF+NHYZM0RkWJmqJdqgzyB8kFhO iUmZPw8118vIwpSL/HfVI0H67PzfS+9ZsT+wNoVJajiMPtCpGyM/jdP9KN2K5OFbWmE/ Z1jSGKoQGG0NMi3Mkvk/0F25u4VxGcMf5WK5claVcUstUWzgRZh9hHGbkDLwxQOTUkR7 9K44j4cdOdi95QHbR+pv2VMn12uyVi97h2EY8J256/jffGkE2CQNpPkkSBNkuU40+tXx EgF0aoYaGoBIy6ZHoyt5TwC4infAv7IUwqormCLHzRwd7B+gX6HkxYnorbqRBs0+0XdY cDnw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:content-transfer-encoding :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=np7Bgl/K1HiTGRZETEpBk0qEuVap46E8TdO05uQ4SN4=; fh=xbabF+mn0TVz9Hozl9CxqYqc2nUtFPLUz4LTfMwHcT8=; b=jorMN2hk0oA+kaHp4gGhj0tWIv8VYtxCd3g0tbS4TipJhR5pMCevYWZJ6yrBIhukh8 mdKTNZW1oq5zvdczBXNde5cVoHVxu1aOHgO6zU81whhrcoxAb/VEeglSRPjeBIorahEJ Zj1WSMTSWOuVWWbUT10qQFHPN3BLh6dKU0qZbfswy3dhKMEQrMJCEHSZZNFo3hfoNSp+ eAs7/cRCkR5uxh80X3yOi1AcNQxDDb2Lng1eEIhmZWL4a/j1MAiDlSfluGblJ1wSY7vF 1mFUw28AWCephDWgnwMfQV91rjNPiVkdTnGWlEXuaE1UYdZNTxMvCFH2SCTpPCKegD6t RzUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OUw4FIzy; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OUw4FIzy; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-nfs+bounces-2102-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2102-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t17-20020a056a0021d100b006e52dd10e3dsi4294650pfj.81.2024.02.27.16.25.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 16:25:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-2102-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OUw4FIzy; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OUw4FIzy; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-nfs+bounces-2102-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2102-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6394428149F for ; Wed, 28 Feb 2024 00:25:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1DB3363; Wed, 28 Feb 2024 00:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OUw4FIzy"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="C0lDIc9m"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OUw4FIzy"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="C0lDIc9m" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15D03184 for ; Wed, 28 Feb 2024 00:25:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709079902; cv=none; b=SySj2HRj+PIeyGmMopmXZsEyzwXd++dkMZnR6tlxAx1wgbC+c7ulF83ZcWamZZFe0WeZUhPrI870FyMuPRNk/OPCBwHkUtO5oyCI26APEMY/i99PFr1/0PLknNa75QzdQm6mTQau1LjtivGF0Kvm1qcFuW0EaiVz3AK1y1fy1Nc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709079902; c=relaxed/simple; bh=igJyEQTpVNTdKf7KAHb0EcAe4ePu0xrKZf0E1P3VQ9s=; h=Content-Type:MIME-Version:From:To:Cc:Subject:Date:Message-id; b=jeX8aRgEsbAhIS92ROfG9WmMQy+5wv0tEkjZpi7/Sq6En1oUgQYpl57fbxTQqvSsK0JnzicZwV+LS+KEBT6aPPlVmmTp+aCfFPqyQdQ2IAefVQUkbSDMv23qOaV3/8kyZ8kxan/QSneOxojToPqhzkYwCYXA/4AZshhw1vWT++g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=OUw4FIzy; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=C0lDIc9m; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=OUw4FIzy; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=C0lDIc9m; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 133DD22837; Wed, 28 Feb 2024 00:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709079899; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=np7Bgl/K1HiTGRZETEpBk0qEuVap46E8TdO05uQ4SN4=; b=OUw4FIzy1yogFhAXwXToJtzrx2YNSpK32a8vwQ9+dSpRdStogBSbnYr8/cVNDelgkdmmEJ LjosvaOkqJGxFbTVZpZmtCt3Cjq90cuUiuombIBtZ477wy7m4UkQo886FL54Nu9O96XdyR geqSNQRIgPeoDiZOM4O2a82Q7T0EjCM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709079899; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=np7Bgl/K1HiTGRZETEpBk0qEuVap46E8TdO05uQ4SN4=; b=C0lDIc9mbYIbhbHHEljNy7ju08rwAH8BPM8USerEYXlW2wsHwls3cZglqAg780iurSW5bl fdnnGaj4J7IoImAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709079899; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=np7Bgl/K1HiTGRZETEpBk0qEuVap46E8TdO05uQ4SN4=; b=OUw4FIzy1yogFhAXwXToJtzrx2YNSpK32a8vwQ9+dSpRdStogBSbnYr8/cVNDelgkdmmEJ LjosvaOkqJGxFbTVZpZmtCt3Cjq90cuUiuombIBtZ477wy7m4UkQo886FL54Nu9O96XdyR geqSNQRIgPeoDiZOM4O2a82Q7T0EjCM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709079899; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=np7Bgl/K1HiTGRZETEpBk0qEuVap46E8TdO05uQ4SN4=; b=C0lDIc9mbYIbhbHHEljNy7ju08rwAH8BPM8USerEYXlW2wsHwls3cZglqAg780iurSW5bl fdnnGaj4J7IoImAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8AE5013A58; Wed, 28 Feb 2024 00:24:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id /g3LC1l93mXcQAAAD6G6ig (envelope-from ); Wed, 28 Feb 2024 00:24:57 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "NeilBrown" To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH] NFS: avoid infinite loop in pnfs_update_layout. Date: Wed, 28 Feb 2024 11:24:53 +1100 Message-id: <170907989347.24797.3598114887801119723@noble.neil.brown.name> Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -1.30 X-Spamd-Result: default: False [-1.30 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[39.99%] X-Spam-Flag: NO If pnfsd_update_layout() is called on a file for which recovery has failed it will enter a tight infinite loop. NFS_LAYOUT_INVALID_STID will be set, nfs4_select_rw_stateid() will return -EIO, and nfs4_schedule_stateid_recovery() will do nothing, so nfs4_client_recover_expired_lease() will not wait. So the code will loop indefinitely. Break the loop by testing the validity of the open stateid at the top of the loop. Signed-off-by: NeilBrown --- fs/nfs/pnfs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 0c0fed1ecd0b..a5cc6199127f 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1999,6 +1999,14 @@ pnfs_update_layout(struct inode *ino, } lookup_again: + if (!nfs4_valid_open_stateid(ctx->state)) { + trace_pnfs_update_layout(ino, pos, count, + iomode, lo, lseg, + PNFS_UPDATE_LAYOUT_INVALID_OPEN); + lseg = ERR_PTR(-EIO); + goto out; + } + lseg = ERR_PTR(nfs4_client_recover_expired_lease(clp)); if (IS_ERR(lseg)) goto out; -- 2.43.0