From patchwork Fri Dec 6 02:15:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13896278 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 61845144D0A for ; Fri, 6 Dec 2024 02:18:59 +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=1733451541; cv=none; b=vE6DX/PWu9skcuuqy1OLMs2cJ3uixLtbG5PDtnjHEA6EyQ1lE5msTEi2POf7BXBfIPaF4WBZQtBUKlw1ud7f+2e0+uuuLvig1rQgFBVVfM64gRp+wkjJLHI3VB6SCDAVEkqhdOIebdc+a/pgx0GFDoVvlcuppFdKlynDir3NpRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451541; c=relaxed/simple; bh=SA3JW+AA26fE0F/SCgxbjIalWKn4xyp6uWrjWeaubbg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GzEbK8nZg9EDxH/rQ9wYwsnN8PLS2VRRSdhYmugFlgJRKkwipenVBJEKq4IRm+oHi2VDbj/pomkB9mByk3jSCYVFc7GYpRJk4iPXMhmvsDWf2Vgy7kesF2BRdvu7V7KMl37vejGS9jCiwNanvqCBHnV2MA51D5SzzKAiSllP2c0= 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=jEb+/j43; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=2onqoU0b; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=jEb+/j43; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=2onqoU0b; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="jEb+/j43"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="2onqoU0b"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="jEb+/j43"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="2onqoU0b" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 937E221167; Fri, 6 Dec 2024 02:18:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451537; h=from:from:reply-to: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=PgamCzczPldmZUFP0T+S22CFvHf/ibs+mRyZ0EnLDQM=; b=jEb+/j43RIXIZxCgxmUSOKlVAFmca6ZSvppKJ/WoMXtgwJ1HrGNn+mASmqo1tjPMhRHJvp mU7RJnWcUaVWuPPGlKDIAvjKcaWRXwpc853FC3B5CvebLgnS5XmHA1GJ/LGKC+6n2S9rGg pDmSPRsEnqPQyGwJ0BqXA1SnIQksEzc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451537; h=from:from:reply-to: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=PgamCzczPldmZUFP0T+S22CFvHf/ibs+mRyZ0EnLDQM=; b=2onqoU0bn1JsTNSIUWYSzY8rk7XNSexa4ig2drTdP0+EBntBh374FHTInQhlvrLmXPLCKJ hh+Dc403RuNE43Cg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="jEb+/j43"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=2onqoU0b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451537; h=from:from:reply-to: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=PgamCzczPldmZUFP0T+S22CFvHf/ibs+mRyZ0EnLDQM=; b=jEb+/j43RIXIZxCgxmUSOKlVAFmca6ZSvppKJ/WoMXtgwJ1HrGNn+mASmqo1tjPMhRHJvp mU7RJnWcUaVWuPPGlKDIAvjKcaWRXwpc853FC3B5CvebLgnS5XmHA1GJ/LGKC+6n2S9rGg pDmSPRsEnqPQyGwJ0BqXA1SnIQksEzc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451537; h=from:from:reply-to: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=PgamCzczPldmZUFP0T+S22CFvHf/ibs+mRyZ0EnLDQM=; b=2onqoU0bn1JsTNSIUWYSzY8rk7XNSexa4ig2drTdP0+EBntBh374FHTInQhlvrLmXPLCKJ hh+Dc403RuNE43Cg== 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 5DD4F13A15; Fri, 6 Dec 2024 02:18:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id NsAXBRBfUmceJAAAD6G6ig (envelope-from ); Fri, 06 Dec 2024 02:18:56 +0000 From: NeilBrown To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 01/11] sunrpc: remove explicit barrier from rpc_make_runnable() Date: Fri, 6 Dec 2024 13:15:27 +1100 Message-ID: <20241206021830.3526922-2-neilb@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241206021830.3526922-1-neilb@suse.de> References: <20241206021830.3526922-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 937E221167 X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Flag: NO X-Spam-Level: The wake_up_bit() interface is fragile as a barrier is often required as is present here. clear_and_wake_up_bit() is a more robust interface as it includes the barrier and is appropriate here. This patch rearranges the code slightly and makes use of clear_and_wake_up_bit(). This removes some of the need to understand barriers. Signed-off-by: NeilBrown --- include/linux/sunrpc/sched.h | 2 ++ net/sunrpc/sched.c | 13 +++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index fec1e8a1570c..76e1c0194376 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h @@ -168,6 +168,8 @@ enum { #define RPC_IS_QUEUED(t) test_bit(RPC_TASK_QUEUED, &(t)->tk_runstate) #define rpc_set_queued(t) set_bit(RPC_TASK_QUEUED, &(t)->tk_runstate) #define rpc_clear_queued(t) clear_bit(RPC_TASK_QUEUED, &(t)->tk_runstate) +#define rpc_clear_and_wake_queued(t) clear_and_wake_up_bit(RPC_TASK_QUEUED, \ + &(t)->tk_runstate) #define RPC_IS_ACTIVATED(t) test_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate) diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index cef623ea1506..1b710ffc7ad6 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -361,17 +361,14 @@ EXPORT_SYMBOL_GPL(rpc_wait_for_completion_task); static void rpc_make_runnable(struct workqueue_struct *wq, struct rpc_task *task) { - bool need_wakeup = !rpc_test_and_set_running(task); - - rpc_clear_queued(task); - if (!need_wakeup) - return; - if (RPC_IS_ASYNC(task)) { + if (rpc_test_and_set_running(task)) + rpc_clear_queued(task); + else if (RPC_IS_ASYNC(task)) { + rpc_clear_queued(task); INIT_WORK(&task->u.tk_work, rpc_async_schedule); queue_work(wq, &task->u.tk_work); } else { - smp_mb__after_atomic(); - wake_up_bit(&task->tk_runstate, RPC_TASK_QUEUED); + rpc_clear_and_wake_queued(task); } } From patchwork Fri Dec 6 02:15:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13896279 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 F1AE92AE9A for ; Fri, 6 Dec 2024 02:19:07 +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=1733451549; cv=none; b=St97FSWshq8F+O6Pmb3SNI/UXggYYKgoKNTo+wXPkqoVZn1F0vv1cK4/WZN80raVKk3prwl5XSD3J7QexzRml3OeMgdvbMpHPLbq0N9rtyJYbrVzsl4FhQhCtRvHmvkg8N6keWYUFnrDAhgl8PPqcTBGOGf4ZpybbVxLP2C/C60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451549; c=relaxed/simple; bh=+YbWomCgnXXpUgzZuxQJh5i08zVqfcGb9CqxEHAzE/c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bxtXRg0xbN8lX0mf/Pyve7p9rplRdlmU5gu/my9exVov/u6UQndd/91B1kL0uKMBGbVCb85p5gkO6bTb1kczBfD15Wm60wa4JioSHicLe8SUJ/B6FE5lUCF2LOjXX2DMS3bxK1BXhDWK7I7Ib2LL9iL2x4L2m1/yGdpNsGH5u3w= 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=Aqd8ZJpL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=UzlC98a+; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Aqd8ZJpL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=UzlC98a+; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Aqd8ZJpL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="UzlC98a+"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Aqd8ZJpL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="UzlC98a+" Received: from imap1.dmz-prg2.suse.org (unknown [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 3B12F21167; Fri, 6 Dec 2024 02:19:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451546; h=from:from:reply-to: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=uNBC1gB/qOTmoV+IZiYV63k8b5K0HavsTnvteNXsQ44=; b=Aqd8ZJpLBtgS+I0VVNBzqwDpWtu6a6D7ONnXPz4vUqrwatJJMB9O5GR99IxFCBhymusAOV 7JAHRkGMSvPcINtMeQlrWaUjY1HJywelUoYFnS9Zi/TjceMcShfoIrDN0fs1zqXyN+OtTK PkXxsXRWWSAUINwlYSbWKM4buJtZbMM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451546; h=from:from:reply-to: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=uNBC1gB/qOTmoV+IZiYV63k8b5K0HavsTnvteNXsQ44=; b=UzlC98a+ve9nVX1wBAbiEcG+X9nAI0jd26xmc4Owo3l0HZfJKEVn0KDe2VqLcIy6A18nbE jcVRbKbJM0sx/OCw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451546; h=from:from:reply-to: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=uNBC1gB/qOTmoV+IZiYV63k8b5K0HavsTnvteNXsQ44=; b=Aqd8ZJpLBtgS+I0VVNBzqwDpWtu6a6D7ONnXPz4vUqrwatJJMB9O5GR99IxFCBhymusAOV 7JAHRkGMSvPcINtMeQlrWaUjY1HJywelUoYFnS9Zi/TjceMcShfoIrDN0fs1zqXyN+OtTK PkXxsXRWWSAUINwlYSbWKM4buJtZbMM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451546; h=from:from:reply-to: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=uNBC1gB/qOTmoV+IZiYV63k8b5K0HavsTnvteNXsQ44=; b=UzlC98a+ve9nVX1wBAbiEcG+X9nAI0jd26xmc4Owo3l0HZfJKEVn0KDe2VqLcIy6A18nbE jcVRbKbJM0sx/OCw== 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 0615B13A15; Fri, 6 Dec 2024 02:19:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 0a9AKxhfUmckJAAAD6G6ig (envelope-from ); Fri, 06 Dec 2024 02:19:04 +0000 From: NeilBrown To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 02/11] sunrpc: use clear_and_wake_up_bit() for XPRT_LOCKED. Date: Fri, 6 Dec 2024 13:15:28 +1100 Message-ID: <20241206021830.3526922-3-neilb@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241206021830.3526922-1-neilb@suse.de> References: <20241206021830.3526922-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email] X-Spam-Flag: NO X-Spam-Level: wake_up_bit() requires a full memory barrier between the bit being cleared and wake_up_bit() being called, else a race can result in wake up not being sent despite another task preparing to wait. Some paths between the clear_bit and the wake_up_bit do not have a full barrier, such as when xprt_reserve_xprt() finds that XPRT_WRITE_SPACE is set and clears XPRT_LOCKED before returning to xprt_release_write and thence xprt_autoclose(). This doesn't appear to be a problem in practice as no failure reports are known, but it seems prudent to send the wakeup immediately after the bit is cleared and to use clear_and_wake_up_bit() which includes the required barriers. In most cases, if nothing is waiting for the bit the waitqueue_active() test in wake_up_bit() will mean this does minimal extra work - though as the waitqueue can be shared, this is not guaranteed. Using clear_and_wake_up_bit() makes the code "obviously correct". Signed-off-by: NeilBrown --- net/sunrpc/xprt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 09f245cda526..40385362e982 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -248,7 +248,7 @@ static void xprt_clear_locked(struct rpc_xprt *xprt) { xprt->snd_task = NULL; if (!test_bit(XPRT_CLOSE_WAIT, &xprt->state)) - clear_bit_unlock(XPRT_LOCKED, &xprt->state); + clear_and_wake_up_bit(XPRT_LOCKED, &xprt->state); else queue_work(xprtiod_workqueue, &xprt->task_cleanup); } @@ -744,7 +744,6 @@ static void xprt_autoclose(struct work_struct *work) clear_bit(XPRT_CLOSE_WAIT, &xprt->state); xprt->ops->close(xprt); xprt_release_write(xprt, NULL); - wake_up_bit(&xprt->state, XPRT_LOCKED); memalloc_nofs_restore(pflags); } @@ -911,7 +910,6 @@ void xprt_unlock_connect(struct rpc_xprt *xprt, void *cookie) xprt_schedule_autodisconnect(xprt); out: spin_unlock(&xprt->transport_lock); - wake_up_bit(&xprt->state, XPRT_LOCKED); } EXPORT_SYMBOL_GPL(xprt_unlock_connect); From patchwork Fri Dec 6 02:15:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13896280 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 094F12AE9A for ; Fri, 6 Dec 2024 02:19:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451563; cv=none; b=Ic20U6ecxcziuTiKlmZjmkXPMeS7NlHIk32YGolYzYy5IyOQh4aCV18Jghz2xVEIwrOWKd7pq7qfVXSSe0vJA900ALSa4l3WY1L+yOG+D71btkg8/fUT6ZsRWJ3TAcMaARKXdUT5A05dDNjnoriLxdh6wzuQ0To7qWp3pmE5MLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451563; c=relaxed/simple; bh=fMs7Ryxx2ms7KtKf8sor1Xy8Wi2EcOBDcQZwLrUbWOU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cUaOtIKRrWrQaYKnf/Mn2qSuzuUsJW7frarqN829zByIn8jHISj/OzEbjyxqqRv2p4gXeh0pp1S8edk7ZZlxXeXybEr6d7L0lPxYltPYrNTG4qUBhxKBX3MErbR2rfJ5bUsQnPleifSwe1rBz6BVhMJaKNlJzw8OxP/1ei90yIE= 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=WNdsXBJs; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=GEkxdDVp; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Cbt0eyan; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=S4vSJ6pZ; arc=none smtp.client-ip=195.135.223.131 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="WNdsXBJs"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="GEkxdDVp"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Cbt0eyan"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="S4vSJ6pZ" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id D82EC1F38E; Fri, 6 Dec 2024 02:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451560; h=from:from:reply-to: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=dEz40ZY3HZX48Xkp2vdYkh+pYbW6M2CZCdj/9CszJ18=; b=WNdsXBJs7yuk37FiFFzplp4LOa4hES83q5/TB+QScdilIPW9f4vF+J1q6HMrMSExUs8C1T S0diQrEpivBiRLMqFkfMOy7DZ/f06p1fjehwtA0prKU+vYfBj2WMY+l26sLA1bGvSdzkJx 24/vFWq9LsmNmfH2w6MgdwVyyNOavJI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451560; h=from:from:reply-to: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=dEz40ZY3HZX48Xkp2vdYkh+pYbW6M2CZCdj/9CszJ18=; b=GEkxdDVpw0w5pVA4UtpHwVB8TjPqQCoEd+HkO8xUv8YLsq3GcBQQXg+oOer+1lC6MVMGcV 0pkw05e53i7R1PCg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Cbt0eyan; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=S4vSJ6pZ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451558; h=from:from:reply-to: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=dEz40ZY3HZX48Xkp2vdYkh+pYbW6M2CZCdj/9CszJ18=; b=Cbt0eyaneTMJM4ZJAilZ6rK/GJG2N2L5HXYA8RHFewR6eMv7ji3ublCP4cjbja4347u7g9 m+D4UmQmO29z34VxaXiU6ysZ0G0WZha/FqjDgO7Lhbq5sKfvMLvyBtaZGGHUDh+Tv6lgd+ bIZJ+n6p/uyFWE9sn9LnzEuOdrGgmqI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451558; h=from:from:reply-to: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=dEz40ZY3HZX48Xkp2vdYkh+pYbW6M2CZCdj/9CszJ18=; b=S4vSJ6pZLYqbL84RBsYrBycjrO95nrR/05sF3CuRTykJQITV335DaB/c1XLC2sIfwar979 oseBUtqxor5M85DA== 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 A009013A15; Fri, 6 Dec 2024 02:19:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id j684FSVfUmcuJAAAD6G6ig (envelope-from ); Fri, 06 Dec 2024 02:19:17 +0000 From: NeilBrown To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 03/11] nfs: use clear_and_wake_up_bit(). Date: Fri, 6 Dec 2024 13:15:29 +1100 Message-ID: <20241206021830.3526922-4-neilb@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241206021830.3526922-1-neilb@suse.de> References: <20241206021830.3526922-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: D82EC1F38E X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:email,suse.de:dkim,suse.de:mid] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Flag: NO In three places nfs clears a bit and then sends a wake_up_bit(). Using clear_and_wake_up_bit() makes this code cleaner and avoids the need for explicit barriers. In 2 cases the wake_up is conditional on a "congested" flag. For these we use the flag to select between clear_bit and clear_and_wake_up_bit. Signed-off-by: NeilBrown --- fs/nfs/inode.c | 4 +--- fs/nfs/pagelist.c | 14 ++++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 596f35170137..4c4c3ab57fcd 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1451,9 +1451,7 @@ int nfs_clear_invalid_mapping(struct address_space *mapping) ret = nfs_invalidate_mapping(inode, mapping); trace_nfs_invalidate_mapping_exit(inode, ret); - clear_bit_unlock(NFS_INO_INVALIDATING, bitlock); - smp_mb__after_atomic(); - wake_up_bit(bitlock, NFS_INO_INVALIDATING); + clear_and_wake_up_bit(NFS_INO_INVALIDATING, bitlock); out: return ret; } diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index e27c07bd8929..7f3914064cee 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -214,11 +214,10 @@ nfs_page_set_headlock(struct nfs_page *req) void nfs_page_clear_headlock(struct nfs_page *req) { - clear_bit_unlock(PG_HEADLOCK, &req->wb_flags); - smp_mb__after_atomic(); if (!test_bit(PG_CONTENDED1, &req->wb_flags)) - return; - wake_up_bit(&req->wb_flags, PG_HEADLOCK); + clear_bit_unlock(PG_HEADLOCK, &req->wb_flags); + else + clear_and_wake_up_bit(PG_HEADLOCK, &req->wb_flags); } /* @@ -519,11 +518,10 @@ nfs_create_subreq(struct nfs_page *req, */ void nfs_unlock_request(struct nfs_page *req) { - clear_bit_unlock(PG_BUSY, &req->wb_flags); - smp_mb__after_atomic(); if (!test_bit(PG_CONTENDED2, &req->wb_flags)) - return; - wake_up_bit(&req->wb_flags, PG_BUSY); + clear_bit_unlock(PG_BUSY, &req->wb_flags); + else + clear_and_wake_up_bit(PG_BUSY, &req->wb_flags); } /** From patchwork Fri Dec 6 02:15:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13896281 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 5E4D3156236 for ; Fri, 6 Dec 2024 02:19:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451567; cv=none; b=Sod/BByV6LZ9k7PRx5VSpUS/JBUe8lF63vQL+WSpVRbSmU+ECcXlw9TPe0i/h4bk9NuhJXz8JSHqbdVabyFN7FWs6i6ZVR+zA8dn6ReGfCGJXkshmOjTWsfkBHSRu4+Zh7Dtt7P9f4HmDH+aipZ8AOeNAW7G1ArwabNdCIlQnkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451567; c=relaxed/simple; bh=FXMX6/uAf/xzoF04GuV6091SWxGKRrjDouNC1So2xiA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iijAyMFzQons55m1e+lAgrPV3McrDMjGcBrGK6mnq/NAtFwdQixRKo0iygbrz9qpAqRSwj6XMpMnd7dQSztEFEI2Ez15UyQbHprhhCecZiD6c4SoV07Be4nJMIkhRKeD7dNInTNjFNZrZL+DCsYtHpOzqPBzHp2/SF/cLmTO7aM= 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=0GiwMKeP; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=GOu9TGU1; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=0GiwMKeP; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=GOu9TGU1; arc=none smtp.client-ip=195.135.223.131 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="0GiwMKeP"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="GOu9TGU1"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="0GiwMKeP"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="GOu9TGU1" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id 823701F394; Fri, 6 Dec 2024 02:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451563; h=from:from:reply-to: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=pQF/sT+iiJrJkYrPNV8viCwhns8T6ZZy5JjIW6cf+Dk=; b=0GiwMKePGheNN3HReRg/NN6vD7+CWcxyFX6cza5lvH+aRDqppsUhGruXQkZtHcUd5bc7so S3Nwk0s7vuDpbAmx9FqAmVfbyslrPl6z58Pj4Zmekim2m65BwUpxO6uC5qJeqcCJo4DhM7 cK4aYSsnC6Q3VuSJ/DeL5YVWcwF4YxQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451563; h=from:from:reply-to: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=pQF/sT+iiJrJkYrPNV8viCwhns8T6ZZy5JjIW6cf+Dk=; b=GOu9TGU1ql/GUd979saV+oK8uEjOSS5VB6mB9yZgDW6iJZ8/uF7PWK86Eag3fNN4TvyG03 BbIPeVjTYjnoQiDA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=0GiwMKeP; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=GOu9TGU1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451563; h=from:from:reply-to: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=pQF/sT+iiJrJkYrPNV8viCwhns8T6ZZy5JjIW6cf+Dk=; b=0GiwMKePGheNN3HReRg/NN6vD7+CWcxyFX6cza5lvH+aRDqppsUhGruXQkZtHcUd5bc7so S3Nwk0s7vuDpbAmx9FqAmVfbyslrPl6z58Pj4Zmekim2m65BwUpxO6uC5qJeqcCJo4DhM7 cK4aYSsnC6Q3VuSJ/DeL5YVWcwF4YxQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451563; h=from:from:reply-to: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=pQF/sT+iiJrJkYrPNV8viCwhns8T6ZZy5JjIW6cf+Dk=; b=GOu9TGU1ql/GUd979saV+oK8uEjOSS5VB6mB9yZgDW6iJZ8/uF7PWK86Eag3fNN4TvyG03 BbIPeVjTYjnoQiDA== 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 4ABFA13A15; Fri, 6 Dec 2024 02:19:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id fntfACpfUmc6JAAAD6G6ig (envelope-from ); Fri, 06 Dec 2024 02:19:22 +0000 From: NeilBrown To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 04/11] nfs: combine NFS_LAYOUT_RETURN and NFS_LAYOUT_RETURN_LOCK Date: Fri, 6 Dec 2024 13:15:30 +1100 Message-ID: <20241206021830.3526922-5-neilb@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241206021830.3526922-1-neilb@suse.de> References: <20241206021830.3526922-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 823701F394 X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:mid,suse.de:email] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Flag: NO X-Spam-Level: The flags NFS_LAYOUT_RETURN and NFS_LAYOUT_RETURN_LOCK are effectively identical. The only time either are cleared is in pnfs_clear_layoutreturn_waitbit(), and there both are cleared. The only time NFS_LAYOUT_RETURN is set is in pnfs_prepare_layoutreturn() immediately after NFS_LAYOUT_RETURN_LOCK was set. The only other time that NFS_LAYOUT_RETURN_LOCK is set is in pnfs_mark_layout_stateid_invalid() if NFS_LAYOUT_RETURN was set but NFS_LAYOUT_RETURN_LOCK was not set - but that is an impossible combination given that else where the flags are set or cleared together. So we only need one of these flags. This patch discards NFS_LAYOUT_RETURN_LOCK and does the test_and_set needed for exclusion with NFS_LAYOUT_RETURN. Also the wake_up_bit in pnfs_clear_layoutreturn_waitbit() is changed to clear_and_wake_up_bit() which includes all needed barriers internally. Signed-off-by: NeilBrown --- fs/nfs/pnfs.c | 15 ++++----------- fs/nfs/pnfs.h | 1 - 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 0d16b383a452..5963c0440e23 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -386,10 +386,7 @@ pnfs_clear_layoutreturn_info(struct pnfs_layout_hdr *lo) static void pnfs_clear_layoutreturn_waitbit(struct pnfs_layout_hdr *lo) { - clear_bit_unlock(NFS_LAYOUT_RETURN, &lo->plh_flags); - clear_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags); - smp_mb__after_atomic(); - wake_up_bit(&lo->plh_flags, NFS_LAYOUT_RETURN); + clear_and_wake_up_bit(NFS_LAYOUT_RETURN, &lo->plh_flags); rpc_wake_up(&NFS_SERVER(lo->plh_inode)->roc_rpcwaitq); } @@ -471,9 +468,6 @@ pnfs_mark_layout_stateid_invalid(struct pnfs_layout_hdr *lo, pnfs_clear_layoutreturn_info(lo); pnfs_free_returned_lsegs(lo, lseg_list, &range, 0); set_bit(NFS_LAYOUT_DRAIN, &lo->plh_flags); - if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags) && - !test_and_set_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags)) - pnfs_clear_layoutreturn_waitbit(lo); return !list_empty(&lo->plh_segs); } @@ -1310,9 +1304,8 @@ pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo, /* Serialise LAYOUTGET/LAYOUTRETURN */ if (atomic_read(&lo->plh_outstanding) != 0) return false; - if (test_and_set_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags)) + if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) return false; - set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags); pnfs_get_layout_hdr(lo); nfs4_stateid_copy(stateid, &lo->plh_stateid); *cred = get_cred(lo->plh_lc_cred); @@ -1454,7 +1447,7 @@ _pnfs_return_layout(struct inode *ino) /* Reference matched in nfs4_layoutreturn_release */ pnfs_get_layout_hdr(lo); /* Is there an outstanding layoutreturn ? */ - if (test_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags)) { + if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) { spin_unlock(&ino->i_lock); if (wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN, TASK_UNINTERRUPTIBLE)) @@ -1564,7 +1557,7 @@ bool pnfs_roc(struct inode *ino, goto out_noroc; } pnfs_get_layout_hdr(lo); - if (test_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags)) { + if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) { spin_unlock(&ino->i_lock); rcu_read_unlock(); wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN, diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 30d2613e912b..df914f17b927 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -100,7 +100,6 @@ enum { NFS_LAYOUT_RW_FAILED, /* get rw layout failed stop trying */ NFS_LAYOUT_BULK_RECALL, /* bulk recall affecting layout */ NFS_LAYOUT_RETURN, /* layoutreturn in progress */ - NFS_LAYOUT_RETURN_LOCK, /* Serialise layoutreturn */ NFS_LAYOUT_RETURN_REQUESTED, /* Return this layout ASAP */ NFS_LAYOUT_INVALID_STID, /* layout stateid id is invalid */ NFS_LAYOUT_FIRST_LAYOUTGET, /* Serialize first layoutget */ From patchwork Fri Dec 6 02:15:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13896282 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 F1ABF144D0A for ; Fri, 6 Dec 2024 02:19:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451571; cv=none; b=lcz5HQDEICG66NfMwk/fQvKpb8lPGlzl1TUynsgcqYHFu107pO1Vca0qm1ErM5NSAugX03+AotxDAc1PQDTeUuaibyJImOIPnV+YAsRef+PmYfzx7ATXC2g92+soZ/9BFmVz/CMrc214yoXII84rL4qLZ4qEo81q8Fs+RIdhPm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451571; c=relaxed/simple; bh=2s6W/0IxliIVmvW0NIPJbEldixOohfQLzcGZlv2Nn9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HK3j7TfW3Tx50i0rFscPiyDRMF1Ts6ngK176QL4YJmNi8JPmCz9WCs8P6nIjB3hXrRKaAQfPIgcUrBzwy6PhNoqkTg1tvG7/gXDoLq3y948xdX/K05KnV6/JjG2X/nrQJG9Mk0HfHFU9rvZCtKqhPrv5kY8wcJIul6dkO3HZPtk= 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=RdhcPUhl; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=Qmxop8XL; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=RdhcPUhl; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=Qmxop8XL; arc=none smtp.client-ip=195.135.223.131 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="RdhcPUhl"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Qmxop8XL"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="RdhcPUhl"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Qmxop8XL" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id 2D2701F394; Fri, 6 Dec 2024 02:19:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451568; h=from:from:reply-to: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=Jl39J4Nyot8HiS3DTwx4WMT1lrl5PmwM+SJxwteyKww=; b=RdhcPUhlctd83xt6MRxYZ4Y5L3Ebeg6UaU+DgzaoRpAU7hENkaQykflVT0iiXUgHABkQDp F4GoTsIttRZLwP9AsU3d4gw0LVVQiGXDLA37ugjGVtrjcLuEJohwfWY4cb01vXCF6jIl9g KeFvwwMLYEeKkmQaJdRVQr3Cq1iZg+8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451568; h=from:from:reply-to: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=Jl39J4Nyot8HiS3DTwx4WMT1lrl5PmwM+SJxwteyKww=; b=Qmxop8XLXoAekuzzT4vg4rQxZIG8Wox0BDs/c7mBlHU/UN5hpAzGjRZxBthM8CvO9s93F2 Vu30lnAVsEmUhKCA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=RdhcPUhl; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Qmxop8XL DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451568; h=from:from:reply-to: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=Jl39J4Nyot8HiS3DTwx4WMT1lrl5PmwM+SJxwteyKww=; b=RdhcPUhlctd83xt6MRxYZ4Y5L3Ebeg6UaU+DgzaoRpAU7hENkaQykflVT0iiXUgHABkQDp F4GoTsIttRZLwP9AsU3d4gw0LVVQiGXDLA37ugjGVtrjcLuEJohwfWY4cb01vXCF6jIl9g KeFvwwMLYEeKkmQaJdRVQr3Cq1iZg+8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451568; h=from:from:reply-to: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=Jl39J4Nyot8HiS3DTwx4WMT1lrl5PmwM+SJxwteyKww=; b=Qmxop8XLXoAekuzzT4vg4rQxZIG8Wox0BDs/c7mBlHU/UN5hpAzGjRZxBthM8CvO9s93F2 Vu30lnAVsEmUhKCA== 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 E9E0313A15; Fri, 6 Dec 2024 02:19:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id tGFNJy5fUmc+JAAAD6G6ig (envelope-from ); Fri, 06 Dec 2024 02:19:26 +0000 From: NeilBrown To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 05/11] nfs: use clear_and_wake_up_bit() in pnfs code Date: Fri, 6 Dec 2024 13:15:31 +1100 Message-ID: <20241206021830.3526922-6-neilb@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241206021830.3526922-1-neilb@suse.de> References: <20241206021830.3526922-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 2D2701F394 X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:mid,suse.de:email] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Flag: NO X-Spam-Level: The wake_up_bit() interface is fragile as it sometimes needs an explicit barrier before it is called. It is generally better to use the combined interfaces which have all necessary barriers. The usage of wake_up_bit() in NFS/pnfs IS safe as the required barriers are included. But it is ugly to need that explicit barrier. This patch changes to use clear_and_wake_up_bit() which transparently includes the required barrier. Also use test_and_clear_wake_up_bit() in one case. Signed-off-by: NeilBrown --- fs/nfs/pnfs.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 5963c0440e23..445ba09ba324 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -2034,9 +2034,8 @@ static void nfs_layoutget_begin(struct pnfs_layout_hdr *lo) static void nfs_layoutget_end(struct pnfs_layout_hdr *lo) { - if (atomic_dec_and_test(&lo->plh_outstanding) && - test_and_clear_bit(NFS_LAYOUT_DRAIN, &lo->plh_flags)) - wake_up_bit(&lo->plh_flags, NFS_LAYOUT_DRAIN); + if (atomic_dec_and_test(&lo->plh_outstanding)) + test_and_clear_wake_up_bit(NFS_LAYOUT_DRAIN, &lo->plh_flags); } static bool pnfs_is_first_layoutget(struct pnfs_layout_hdr *lo) @@ -2048,9 +2047,7 @@ static void pnfs_clear_first_layoutget(struct pnfs_layout_hdr *lo) { unsigned long *bitlock = &lo->plh_flags; - clear_bit_unlock(NFS_LAYOUT_FIRST_LAYOUTGET, bitlock); - smp_mb__after_atomic(); - wake_up_bit(bitlock, NFS_LAYOUT_FIRST_LAYOUTGET); + clear_and_wake_up_bit(NFS_LAYOUT_FIRST_LAYOUTGET, bitlock); } static void _add_to_server_list(struct pnfs_layout_hdr *lo, @@ -3221,9 +3218,7 @@ static void pnfs_clear_layoutcommitting(struct inode *inode) { unsigned long *bitlock = &NFS_I(inode)->flags; - clear_bit_unlock(NFS_INO_LAYOUTCOMMITTING, bitlock); - smp_mb__after_atomic(); - wake_up_bit(bitlock, NFS_INO_LAYOUTCOMMITTING); + clear_and_wake_up_bit(NFS_INO_LAYOUTCOMMITTING, bitlock); } /* From patchwork Fri Dec 6 02:15:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13896283 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 5ED411553A7 for ; Fri, 6 Dec 2024 02:19:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451575; cv=none; b=eTlTfOa/77Ou/cyVnQzEVuBDwUzkeh6aI7b0LJDM3i+cWFdDkxQHkQ+LeV1Q6ZDQzDOl78Q7BIaIKqe5P1TM0uLpsYUEghcuUK+yfU2lPQ9hdaybCS3gKlhjup+04IQCaijzEs8icTUBBpzzq9C/Hcg30CWCORcDowRiBbcdqMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451575; c=relaxed/simple; bh=DWZ/St+CP0QuIRVM1V/Cb8VydQulV9D4NKJot5WxD30=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mZN+q0KRd/AcHZDWpiRfTT9WFH2h2dzJrWnODV3GbZUtemfkqbYEXMiE98kLtxH+Y66CdcPDsZLx58O0Nz4JxvMpF1fbnVizE9RP1hMgMDS7zRSbzyNKxVs9Ur1GcplScDO6vHggiQjHn1SlmoyC+cIyF5MRbQBoIcSO6lPiarc= 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=eFTAEE98; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=r19Y3XNL; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=eFTAEE98; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=r19Y3XNL; arc=none smtp.client-ip=195.135.223.131 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="eFTAEE98"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="r19Y3XNL"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="eFTAEE98"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="r19Y3XNL" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id C96591F38E; Fri, 6 Dec 2024 02:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451572; h=from:from:reply-to: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=svBMtH4AAINyjWLO4QEAx/fGIJOMR3kJWC34oxf54gE=; b=eFTAEE982d8ObNVjWza+WHCuVKB3Y33rISjsgYPVi+9mK67RFC5bvaxWdgpG0D/POUaw5Z A/duCmwGyJsFOMa9OwPWzbF35t0lWAw6zRF0L+kFe9Rdla4mU9i8Yc9losyOYuZ4we25Xq k4QJF589urRyKIi/xl1qZoCcIGAflsA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451572; h=from:from:reply-to: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=svBMtH4AAINyjWLO4QEAx/fGIJOMR3kJWC34oxf54gE=; b=r19Y3XNLHqz2tfuh1LAIkJ/1T0SFt5pLHoMohkO0QX6VsCEW1DrtEi1L1aEZR6TtgmovJy 2ha/DXQ0SubMxYBg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=eFTAEE98; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=r19Y3XNL DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451572; h=from:from:reply-to: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=svBMtH4AAINyjWLO4QEAx/fGIJOMR3kJWC34oxf54gE=; b=eFTAEE982d8ObNVjWza+WHCuVKB3Y33rISjsgYPVi+9mK67RFC5bvaxWdgpG0D/POUaw5Z A/duCmwGyJsFOMa9OwPWzbF35t0lWAw6zRF0L+kFe9Rdla4mU9i8Yc9losyOYuZ4we25Xq k4QJF589urRyKIi/xl1qZoCcIGAflsA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451572; h=from:from:reply-to: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=svBMtH4AAINyjWLO4QEAx/fGIJOMR3kJWC34oxf54gE=; b=r19Y3XNLHqz2tfuh1LAIkJ/1T0SFt5pLHoMohkO0QX6VsCEW1DrtEi1L1aEZR6TtgmovJy 2ha/DXQ0SubMxYBg== 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 92CB613A15; Fri, 6 Dec 2024 02:19:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id E6wAEjNfUmdCJAAAD6G6ig (envelope-from ); Fri, 06 Dec 2024 02:19:31 +0000 From: NeilBrown To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 06/11] nfs: use store_release_wake_up() for clearing d_fsdata Date: Fri, 6 Dec 2024 13:15:32 +1100 Message-ID: <20241206021830.3526922-7-neilb@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241206021830.3526922-1-neilb@suse.de> References: <20241206021830.3526922-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: C96591F38E X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:email,suse.de:dkim,suse.de:mid] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Flag: NO The barrier provided by smp_store_release() is before the store, while wake_up_var() needs a full barrier *after* the store. The new store_release_wake_up() interface encodes all the barriers making this sort of bug harder to write. Signed-off-by: NeilBrown --- fs/nfs/dir.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 492cffd9d3d8..ded86facef8f 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1837,9 +1837,7 @@ static void block_revalidate(struct dentry *dentry) static void unblock_revalidate(struct dentry *dentry) { - /* store_release ensures wait_var_event() sees the update */ - smp_store_release(&dentry->d_fsdata, NULL); - wake_up_var(&dentry->d_fsdata); + store_release_wake_up(&dentry->d_fsdata, NULL); } /* From patchwork Fri Dec 6 02:15:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13896284 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 35FED15B0F2 for ; Fri, 6 Dec 2024 02:19:39 +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=1733451580; cv=none; b=Nqd3qfEUFMZFm5FxcFyWcuxjGZFLoj/eblfQVV65KxDZ54dOvVTltXKs1Dkl4gqLZ9SeZqIGLjNj6p4uJlbUQ/i+MLd7Ms9seXH6g5UjqM/qp1rrQZAQC9MjULP7wGClSUgjyGBMM81kmkeEvlRfE7ZQUK0y7JYQuWhR/IGQ+Cc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451580; c=relaxed/simple; bh=cVNSAV/8JQMWoju+MYo2Yf/t7TMOEgLlhBSFGtjzZ1c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j/nup21ltIDmyMK++havAUzlW1+GPanAGwC2Zdmdy9g+ZFGycftoLCLXyKVUkgwP3g4zPZC3qkUQH7QQJ0vDMZHofCwjHAA18D8ybyyemT1lq6T4krGXIivgB/R0VIQqL232MKWEJ+E+trgMjCjm9lcpwDgcMJJG+23kyNmDygA= 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=Fdfa36Zy; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=4/fQRaMK; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Fdfa36Zy; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=4/fQRaMK; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Fdfa36Zy"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="4/fQRaMK"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Fdfa36Zy"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="4/fQRaMK" Received: from imap1.dmz-prg2.suse.org (unknown [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 7D36121167; Fri, 6 Dec 2024 02:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451577; h=from:from:reply-to: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=UNb/uGc2lPIIxNp5vwEKRcfwzOVAv9zyFlaa3o15TvQ=; b=Fdfa36Zy7YdxOhjTAWV0ivW40Ycp7b2dowlAEmt3F9gOxyI5xX5ZkmMsrUFJVCzvS3mkW+ pULfPSEBAWBZl83NuM2C7sRBV/1X1n+aGVNYVCX/xyOaujZMC7KztB2Kyl6vHHfTbB2v/b oKaHKdeaODUVdUzOcKRS462w5cMykdg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451577; h=from:from:reply-to: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=UNb/uGc2lPIIxNp5vwEKRcfwzOVAv9zyFlaa3o15TvQ=; b=4/fQRaMK3AIjdUspzqcBrKrqCsr4YI1HsUFo6O5+ue0JMDJhKuwIvaKIZvO6dicryeU6pP J5RPp3ECo8ArqJCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451577; h=from:from:reply-to: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=UNb/uGc2lPIIxNp5vwEKRcfwzOVAv9zyFlaa3o15TvQ=; b=Fdfa36Zy7YdxOhjTAWV0ivW40Ycp7b2dowlAEmt3F9gOxyI5xX5ZkmMsrUFJVCzvS3mkW+ pULfPSEBAWBZl83NuM2C7sRBV/1X1n+aGVNYVCX/xyOaujZMC7KztB2Kyl6vHHfTbB2v/b oKaHKdeaODUVdUzOcKRS462w5cMykdg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451577; h=from:from:reply-to: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=UNb/uGc2lPIIxNp5vwEKRcfwzOVAv9zyFlaa3o15TvQ=; b=4/fQRaMK3AIjdUspzqcBrKrqCsr4YI1HsUFo6O5+ue0JMDJhKuwIvaKIZvO6dicryeU6pP J5RPp3ECo8ArqJCA== 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 4480713A15; Fri, 6 Dec 2024 02:19:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 0ZF6OjdfUmdSJAAAD6G6ig (envelope-from ); Fri, 06 Dec 2024 02:19:35 +0000 From: NeilBrown To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 07/11] sunrpc: discard rpc_wait_bit_killable() Date: Fri, 6 Dec 2024 13:15:33 +1100 Message-ID: <20241206021830.3526922-8-neilb@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241206021830.3526922-1-neilb@suse.de> References: <20241206021830.3526922-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 X-Spam-Flag: NO rpc_wait_bit_kill() currently differs from bit_wait() in the it returns -ERESTARTSYS rather then -EINTR. The sunrpc and nfs code never really care about the difference. The error could get up to user-space but it is only generated when a process is being killed, in which case there is no user-space to see the difference. Signed-off-by: NeilBrown --- net/sunrpc/sched.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 1b710ffc7ad6..0618dc586009 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -274,14 +274,6 @@ void rpc_destroy_wait_queue(struct rpc_wait_queue *queue) } EXPORT_SYMBOL_GPL(rpc_destroy_wait_queue); -static int rpc_wait_bit_killable(struct wait_bit_key *key, int mode) -{ - schedule(); - if (signal_pending_state(mode, current)) - return -ERESTARTSYS; - return 0; -} - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) || IS_ENABLED(CONFIG_TRACEPOINTS) static void rpc_task_set_debuginfo(struct rpc_task *task) { @@ -343,7 +335,7 @@ static int rpc_complete_task(struct rpc_task *task) int rpc_wait_for_completion_task(struct rpc_task *task) { return out_of_line_wait_on_bit(&task->tk_runstate, RPC_TASK_ACTIVE, - rpc_wait_bit_killable, TASK_KILLABLE|TASK_FREEZABLE_UNSAFE); + bit_wait, TASK_KILLABLE|TASK_FREEZABLE_UNSAFE); } EXPORT_SYMBOL_GPL(rpc_wait_for_completion_task); @@ -982,12 +974,12 @@ static void __rpc_execute(struct rpc_task *task) /* sync task: sleep here */ trace_rpc_task_sync_sleep(task, task->tk_action); status = out_of_line_wait_on_bit(&task->tk_runstate, - RPC_TASK_QUEUED, rpc_wait_bit_killable, + RPC_TASK_QUEUED, bit_wait, TASK_KILLABLE|TASK_FREEZABLE); if (status < 0) { /* * When a sync task receives a signal, it exits with - * -ERESTARTSYS. In order to catch any callbacks that + * -EINTR. In order to catch any callbacks that * clean up after sleeping on some queue, we don't * break the loop here, but go around once more. */ From patchwork Fri Dec 6 02:15:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13896285 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 1A685156236 for ; Fri, 6 Dec 2024 02:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451586; cv=none; b=Syh0nyclBIXHTLf1reQ2K3g3nEn6Vwu2jtFDlkq+9f5+YW9R981fshr/cQF3LtYsD7Wb85ybtg2MQcw6QbycCNycrZPvGEV01WX22PUS6xEVD8WuxcMwcBjySVuBtx9w6R7xEU+D/sORSmMbHc3ZJwtXxQdFQi/7bdciK86aNcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451586; c=relaxed/simple; bh=dGxEauQ5AiclfhaDNdq2WobA3iP6WuROfPZD4be0tTY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SLtVqyqcet7mFthW90VY/WSxcmMC/QqcHxyT23tkmgtOsDLZoiufMpzq0P/WLckmVGOMDt4jhzlPiVovTj7QAKO5GcNcB+AGN3/agGBga3lzr1oJxWK5Ci5EUcutES00BQiSCuMUFQDaj2F3EMMpMUR7L2NeonnyD0eq7DA8PsE= 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=rsiikS2J; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=xAnRmVxq; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Wi/sJ+7u; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=TglHwA/1; arc=none smtp.client-ip=195.135.223.131 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="rsiikS2J"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="xAnRmVxq"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Wi/sJ+7u"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="TglHwA/1" Received: from imap1.dmz-prg2.suse.org (unknown [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-out2.suse.de (Postfix) with ESMTPS id 2E54F1F38E; Fri, 6 Dec 2024 02:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451583; h=from:from:reply-to: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=bEzXuyO84He5M3buB+jg1R0KA4CrI62RrWSXlq5lffg=; b=rsiikS2Jt3aHhbv1xyC9zAc30AsrsAP5BPTsKwmqPcUzZVHxGwqL8BMM7ReFo94+/rhuV+ wnxHNRCRX85OsV8tw85x8jFwk+VSoDUA0iZ7CAb82IAlTrRvoRLk1ZetdenpiPEjF75xoM nwAbH//DxqpN5wza7hEzG5bM6j9O5ts= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451583; h=from:from:reply-to: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=bEzXuyO84He5M3buB+jg1R0KA4CrI62RrWSXlq5lffg=; b=xAnRmVxq4whUTPbC5Iblm29L7ie7V730Fnp0+6f8hdLrPzRFvQQJYNTupnA0JRWlpOyAje gX/1bFXE+I892bCQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451582; h=from:from:reply-to: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=bEzXuyO84He5M3buB+jg1R0KA4CrI62RrWSXlq5lffg=; b=Wi/sJ+7u+7aB1m0WGDxdQ/NfHvMRdyvreBzm1YLzAnIuorJ3QRdyhgJe7OnD1jcF9ZMxML H+DBssMFOQLM4IJFK3L3eKsTfT9Lvq5jPpPrPup5+mQZ5fsqRWZ+sFGO4Ew9diQkrrQmVN 32Zp2uzd/bMMLgPB1T0JCGqIP1663V8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451582; h=from:from:reply-to: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=bEzXuyO84He5M3buB+jg1R0KA4CrI62RrWSXlq5lffg=; b=TglHwA/1XiwwCk2MB3rhslLgXwXAAyUxb1K9ZZaHObHlTDX/bVpWB9m/fwKscDGRQJkbB7 XVzx2YfnRvZMzpBg== 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 EB3A913A15; Fri, 6 Dec 2024 02:19:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id HaKBJzxfUmdbJAAAD6G6ig (envelope-from ); Fri, 06 Dec 2024 02:19:40 +0000 From: NeilBrown To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 08/11] nfs: discard nfs_wait_bit_killable() Date: Fri, 6 Dec 2024 13:15:34 +1100 Message-ID: <20241206021830.3526922-9-neilb@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241206021830.3526922-1-neilb@suse.de> References: <20241206021830.3526922-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 X-Spam-Flag: NO This patch changes NFS to use wait_on_bit() instead of wait_on_bit_action() nfs_wait_bit_killable() is identical to bit_wait() except that it returns -ERESTARTSYS instead of -EINTR. NFS doesn't care about this distinction. The status will often get back to user-space but it will only be sent when the process is being killed in which case there is no user-space to care. Signed-off-by: NeilBrown --- fs/nfs/file.c | 5 ++--- fs/nfs/inode.c | 14 ++------------ fs/nfs/internal.h | 1 - fs/nfs/nfs4state.c | 5 ++--- fs/nfs/pnfs.c | 9 +++------ 5 files changed, 9 insertions(+), 25 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 1bb646752e46..0fafdfec5886 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -607,9 +607,8 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf) goto out; } - wait_on_bit_action(&NFS_I(inode)->flags, NFS_INO_INVALIDATING, - nfs_wait_bit_killable, - TASK_KILLABLE|TASK_FREEZABLE_UNSAFE); + wait_on_bit(&NFS_I(inode)->flags, NFS_INO_INVALIDATING, + TASK_KILLABLE|TASK_FREEZABLE_UNSAFE); folio_lock(folio); mapping = folio->mapping; diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 4c4c3ab57fcd..2f1b4f11a056 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -72,15 +72,6 @@ nfs_fattr_to_ino_t(struct nfs_fattr *fattr) return nfs_fileid_to_ino_t(fattr->fileid); } -int nfs_wait_bit_killable(struct wait_bit_key *key, int mode) -{ - schedule(); - if (signal_pending_state(mode, current)) - return -ERESTARTSYS; - return 0; -} -EXPORT_SYMBOL_GPL(nfs_wait_bit_killable); - /** * nfs_compat_user_ino64 - returns the user-visible inode number * @fileid: 64-bit fileid @@ -1419,9 +1410,8 @@ int nfs_clear_invalid_mapping(struct address_space *mapping) * the bit lock here if it looks like we're going to be doing that. */ for (;;) { - ret = wait_on_bit_action(bitlock, NFS_INO_INVALIDATING, - nfs_wait_bit_killable, - TASK_KILLABLE|TASK_FREEZABLE_UNSAFE); + ret = wait_on_bit(bitlock, NFS_INO_INVALIDATING, + TASK_KILLABLE|TASK_FREEZABLE_UNSAFE); if (ret) goto out; smp_rmb(); /* pairs with smp_wmb() below */ diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index e564bd11ba60..1ec10fa50830 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -451,7 +451,6 @@ extern void nfs_evict_inode(struct inode *); extern void nfs_zap_acl_cache(struct inode *inode); extern void nfs_set_cache_invalid(struct inode *inode, unsigned long flags); extern bool nfs_check_cache_invalid(struct inode *, unsigned long); -extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode); #if IS_ENABLED(CONFIG_NFS_LOCALIO) /* localio.c */ diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 9a9f60a2291b..556b521f17eb 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1313,9 +1313,8 @@ int nfs4_wait_clnt_recover(struct nfs_client *clp) might_sleep(); refcount_inc(&clp->cl_count); - res = wait_on_bit_action(&clp->cl_state, NFS4CLNT_MANAGER_RUNNING, - nfs_wait_bit_killable, - TASK_KILLABLE|TASK_FREEZABLE_UNSAFE); + res = wait_on_bit(&clp->cl_state, NFS4CLNT_MANAGER_RUNNING, + TASK_KILLABLE|TASK_FREEZABLE_UNSAFE); if (res) goto out; if (clp->cl_cons_state < 0) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 445ba09ba324..400f409f45fa 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -2022,9 +2022,8 @@ static int pnfs_prepare_to_retry_layoutget(struct pnfs_layout_hdr *lo) * reference */ pnfs_layoutcommit_inode(lo->plh_inode, false); - return wait_on_bit_action(&lo->plh_flags, NFS_LAYOUT_RETURN, - nfs_wait_bit_killable, - TASK_KILLABLE|TASK_FREEZABLE_UNSAFE); + return wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN, + TASK_KILLABLE|TASK_FREEZABLE_UNSAFE); } static void nfs_layoutget_begin(struct pnfs_layout_hdr *lo) @@ -3319,9 +3318,8 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync) if (test_and_set_bit(NFS_INO_LAYOUTCOMMITTING, &nfsi->flags)) { if (!sync) goto out; - status = wait_on_bit_lock_action(&nfsi->flags, + status = wait_on_bit_lock(&nfsi->flags, NFS_INO_LAYOUTCOMMITTING, - nfs_wait_bit_killable, TASK_KILLABLE|TASK_FREEZABLE_UNSAFE); if (status) goto out; @@ -3369,7 +3367,6 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync) } } - status = nfs4_proc_layoutcommit(data, sync); out: if (status) From patchwork Fri Dec 6 02:15:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13896286 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 9AEBE149E1A for ; Fri, 6 Dec 2024 02:19:52 +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=1733451594; cv=none; b=Mu4uthEhntdZZi+rCesShUUiFBzOMALgTSUokF4RfXvM0fkUMY5SgylK2NATaf6ePkeamGpXPeSYGjSKWkfShrA9qhx1eVDpuTDmOHut6uXZBrreE/vFF0K5nA4y3aekJHdzVn+XRc12XlYfEWvqQRj3VCibMICniQlVt0AWQmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451594; c=relaxed/simple; bh=OrTTmtRg6G9tqsvy+Cwuia24zNh303uPtcluolBh2rw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rlRwGp6YOwoqoqT4ZPRi+MLzvQDAIkxTCN9RInolylwfPCIPGqFgqxBwbli2WNirv3Z9BeIfeLdUxydB/HnXmEzgC2sIovMjdT7S7HPBExkl6NkgGiSoJd5KkOAWUBh0YXXEg8udyr0AFyJMuI9jNQu6Sc1QVma7/pxYoGFglzg= 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=gR4qaz/4; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=Tayg5DCs; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=gR4qaz/4; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=Tayg5DCs; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="gR4qaz/4"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Tayg5DCs"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="gR4qaz/4"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Tayg5DCs" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 CB96121167; Fri, 6 Dec 2024 02:19:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451590; h=from:from:reply-to: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=Ea7lS4kOxBzi0yj9Ar1Y+7O4UKHILi353AR0tZkBeSE=; b=gR4qaz/4tMIh83sMO/cAVLaU/XBifgcfF6J13fE6CtKgLEq4R+5le5iCn9LozZmvid9vwa BKHNYBAUXwV2xx3392Du+mIyHeCWDs5ShO+7/RheMGDP1bBwOaqWOkYJGMEOlf3P2RjomG 7tqq0SXts43nLn9eEDW7lSSI/E0s6Vc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451590; h=from:from:reply-to: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=Ea7lS4kOxBzi0yj9Ar1Y+7O4UKHILi353AR0tZkBeSE=; b=Tayg5DCspjNQYosQ2weMiIqNqng8kMY6c1dJNDYcx5w2RdIbf8W3to29RRwo/DaM6sD/4O 3q3Jb/1e0RpRrnCg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="gR4qaz/4"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Tayg5DCs DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451590; h=from:from:reply-to: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=Ea7lS4kOxBzi0yj9Ar1Y+7O4UKHILi353AR0tZkBeSE=; b=gR4qaz/4tMIh83sMO/cAVLaU/XBifgcfF6J13fE6CtKgLEq4R+5le5iCn9LozZmvid9vwa BKHNYBAUXwV2xx3392Du+mIyHeCWDs5ShO+7/RheMGDP1bBwOaqWOkYJGMEOlf3P2RjomG 7tqq0SXts43nLn9eEDW7lSSI/E0s6Vc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451590; h=from:from:reply-to: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=Ea7lS4kOxBzi0yj9Ar1Y+7O4UKHILi353AR0tZkBeSE=; b=Tayg5DCspjNQYosQ2weMiIqNqng8kMY6c1dJNDYcx5w2RdIbf8W3to29RRwo/DaM6sD/4O 3q3Jb/1e0RpRrnCg== 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 9536B13A15; Fri, 6 Dec 2024 02:19:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 9cGZEkVfUmdgJAAAD6G6ig (envelope-from ); Fri, 06 Dec 2024 02:19:49 +0000 From: NeilBrown To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 09/11] nfs: add memory barrier before calling wake_up_var on cl_state Date: Fri, 6 Dec 2024 13:15:35 +1100 Message-ID: <20241206021830.3526922-10-neilb@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241206021830.3526922-1-neilb@suse.de> References: <20241206021830.3526922-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: CB96121167 X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:email,suse.de:dkim,suse.de:mid] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Flag: NO After setting NFS4CLNT_RUN_MANAGER we need a full memory barrier before it is safe to call wake_up_var(). As that setting is "atomic" it is sufficient to use smp_mb__after_atomic(). Signed-off-by: NeilBrown --- fs/nfs/nfs4proc.c | 1 + fs/nfs/nfs4state.c | 1 + 2 files changed, 2 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 405f17e6e0b4..37c8aa1f3e1b 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -10847,6 +10847,7 @@ static void nfs4_disable_swap(struct inode *inode) set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state); clear_bit(NFS4CLNT_MANAGER_AVAILABLE, &clp->cl_state); + smp_mb__after_atomic(); wake_up_var(&clp->cl_state); } diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 556b521f17eb..189d7b57cb74 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1207,6 +1207,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp) swapon = !test_and_set_bit(NFS4CLNT_MANAGER_AVAILABLE, &clp->cl_state); if (!swapon) { + smp_mb__after_atomic(); wake_up_var(&clp->cl_state); return; } From patchwork Fri Dec 6 02:15:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13896287 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 128EF1552F5 for ; Fri, 6 Dec 2024 02:20:01 +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=1733451602; cv=none; b=qhp35pXuctG/9lQWxJuUvS2jlmvuzrT8nPW6TExXIkTdZFwAcfQ4lFLKRhDT35KGK9MNMVVM7lcitWMVZp+r8Y76hZIVHXgnyxAFD+d8qEKYpQHyAaVLBeY13Z2eo1uyMoc54iKX7w241LlZMhFqfQ+80dD86LEBY0kk8USZ3QE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451602; c=relaxed/simple; bh=OEIix47lsgUsH65VfPAQ/F35ZGfY9LfZNRUHhKTlLgA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fwVEwKopzaUAb2eHQl0UVcysdJoD4mHBYCg0pIpiwwv6OdLLElI65R7PkY9J/5umfKbpdxOmAhNGyeTAxPmiLU6aY7Xfq6q50GevNTDwI61bcWhcxojjlLUHen4YvLM4kF5CBW9uF/zDrG/DvujgZe4cHO/PJooB2jTdy2KXrlI= 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=hqiugIFv; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=kptQAseT; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=hqiugIFv; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=kptQAseT; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="hqiugIFv"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kptQAseT"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="hqiugIFv"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kptQAseT" Received: from imap1.dmz-prg2.suse.org (unknown [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 8734D21167; Fri, 6 Dec 2024 02:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451599; h=from:from:reply-to: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=qQYsArZVCxQ9KLyhSii2t67THJLbro2ryY8Mm5r1D24=; b=hqiugIFvMYH9YEIDtnlLPjpRwdKj8t8j3cmdS/xARVIlcFGffKLANAqVaSoNRHsFOYBOi6 Q5Ix8t+wjicqqD9MbY89vfkYCOaHYbGGkWacaluc4l46UWHhuPYcGouKDIxHiAnQlYP25p UD8ZjRfVoOT/OS5s7SIaBiR37+W5szQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451599; h=from:from:reply-to: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=qQYsArZVCxQ9KLyhSii2t67THJLbro2ryY8Mm5r1D24=; b=kptQAseT7seWPLyDXdGzt3K8038k8bXeokoqHlTzEJ+V5MbMsNnwkPbKiXxkeer/0WSWpn brU8Tl6rt8yTikBA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451599; h=from:from:reply-to: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=qQYsArZVCxQ9KLyhSii2t67THJLbro2ryY8Mm5r1D24=; b=hqiugIFvMYH9YEIDtnlLPjpRwdKj8t8j3cmdS/xARVIlcFGffKLANAqVaSoNRHsFOYBOi6 Q5Ix8t+wjicqqD9MbY89vfkYCOaHYbGGkWacaluc4l46UWHhuPYcGouKDIxHiAnQlYP25p UD8ZjRfVoOT/OS5s7SIaBiR37+W5szQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451599; h=from:from:reply-to: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=qQYsArZVCxQ9KLyhSii2t67THJLbro2ryY8Mm5r1D24=; b=kptQAseT7seWPLyDXdGzt3K8038k8bXeokoqHlTzEJ+V5MbMsNnwkPbKiXxkeer/0WSWpn brU8Tl6rt8yTikBA== 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 45BFF13A15; Fri, 6 Dec 2024 02:19:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id YYLJOk1fUmdpJAAAD6G6ig (envelope-from ); Fri, 06 Dec 2024 02:19:57 +0000 From: NeilBrown To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 10/11] nfs: use atomic_dec_and_wake_up() Date: Fri, 6 Dec 2024 13:15:36 +1100 Message-ID: <20241206021830.3526922-11-neilb@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241206021830.3526922-1-neilb@suse.de> References: <20241206021830.3526922-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 X-Spam-Flag: NO In two places nfs uses wake_up_var() after atomic_dec_and_test() on the same var. This is correct as no extra barriers are needed in this case. This can be made more clear by using the atomic_dec_and_wake_up() interface. Signed-off-by: NeilBrown --- fs/nfs/pagelist.c | 3 +-- fs/nfs/write.c | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 7f3914064cee..a1b4c77cbc68 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -557,8 +557,7 @@ static void nfs_clear_request(struct nfs_page *req) req->wb_page = NULL; } if (l_ctx != NULL) { - if (atomic_dec_and_test(&l_ctx->io_count)) { - wake_up_var(&l_ctx->io_count); + if (atomic_dec_and_wake_up(&l_ctx->io_count)) { ctx = l_ctx->open_context; if (test_bit(NFS_CONTEXT_UNLOCK, &ctx->flags)) rpc_wake_up(&NFS_SERVER(d_inode(ctx->dentry))->uoc_rpcwaitq); diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 50fa539611f5..3b709cfff0da 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1658,11 +1658,7 @@ void nfs_commit_begin(struct nfs_mds_commit_info *cinfo) bool nfs_commit_end(struct nfs_mds_commit_info *cinfo) { - if (atomic_dec_and_test(&cinfo->rpcs_out)) { - wake_up_var(&cinfo->rpcs_out); - return true; - } - return false; + return atomic_dec_and_wake_up(&cinfo->rpcs_out); } void nfs_commitdata_release(struct nfs_commit_data *data) From patchwork Fri Dec 6 02:15:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13896288 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 211221428E3 for ; Fri, 6 Dec 2024 02:20:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451616; cv=none; b=jakzURbOJbXdKqX9iROSE+2UdVa8+YcOpcwp+h4fk2AHKwXKAT1Q6h+cRW7qrgFIl2BUecAccyuEGAKsCGO56kFfXYGMwwx2HibN5ukhH+fweF2PVVmx4ecVKjctHt5DEIeervaTWl9XKxHZWjPdy37v8DCFMpS/KtphSchPAgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733451616; c=relaxed/simple; bh=mgUkSi+iOmIPOrUFAnGg+mO7wfK2wHIOc4c6RGRrJPw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YvkAHPjmgPuAbBlrFngw1hLhn0M5xlvL2sOxTwCNCuPRxgdIRBJ5RGbd4H+Ez3a3gbnw5KzUNsW0uXLCpzEWyKPktXwf325XbQ2AG1CMwQYS+3/Sj9t/knjOYFQeqiIPE1gXPPUnQLWKMkG15bSl83IhDUTrDGj+bWlVBtiQgCY= 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=o3VQ/v7U; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=VT714B5e; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=WyaMRsZN; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=T0M9AoAE; arc=none smtp.client-ip=195.135.223.131 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="o3VQ/v7U"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="VT714B5e"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="WyaMRsZN"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="T0M9AoAE" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id 2A6C21F394; Fri, 6 Dec 2024 02:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451613; h=from:from:reply-to: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=A+H+BSVv/PJGSn4Su4E/Gn+xx7zEXtD9QuI+AYe1ciA=; b=o3VQ/v7UiaPmeumXJRinfPCIUvQWplkkklo5KmXuWpV/0xPrat65hZmVYezULCVYsh51df /ET4CwZ/6HwG5gYD3OagIN4fA+N7CDn3q9PAjdoe7PtR6AF8AoPIGjZ/RczMXcKsWduOsN gMnh1UWIguvt1og6KPj8pgsucnPn0rw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451613; h=from:from:reply-to: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=A+H+BSVv/PJGSn4Su4E/Gn+xx7zEXtD9QuI+AYe1ciA=; b=VT714B5eK9zS/9meahDzB5DgyigtEbDCXTn2VfDAq/KUUEQClFWQcFHpO13wCZIT3ywEDg yMMRRLRZP+VpAyAQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=WyaMRsZN; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=T0M9AoAE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733451612; h=from:from:reply-to: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=A+H+BSVv/PJGSn4Su4E/Gn+xx7zEXtD9QuI+AYe1ciA=; b=WyaMRsZNHQi00m5TPjob6hWtAPKJaf95WfoXy4MD41H1UXxQeN+tmVE36Q0sOj4pzHwBTo PfpTj43/Wiq3U60X0xSscUo9QAzoAuSg3qv0UQbzcBhSOC3pZPZvj+f+M6J3onjpkwmxkh 19A4n5UhVxfmno/ks3WGW1ZTJipPdrA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733451612; h=from:from:reply-to: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=A+H+BSVv/PJGSn4Su4E/Gn+xx7zEXtD9QuI+AYe1ciA=; b=T0M9AoAE0n12xO5LaJRRl/4P2Zqj3bAmbFOb95oPYuA1ulePNwns8TasYvsRRrIHX7o4hF sDunz1U4ltBW5CCg== 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 E7C0713A15; Fri, 6 Dec 2024 02:20:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id kgu8JlpfUmd6JAAAD6G6ig (envelope-from ); Fri, 06 Dec 2024 02:20:10 +0000 From: NeilBrown To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 11/11] nfs: use wait_var_event_spinlock() to wait for nfsi->layout to change. Date: Fri, 6 Dec 2024 13:15:37 +1100 Message-ID: <20241206021830.3526922-12-neilb@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241206021830.3526922-1-neilb@suse.de> References: <20241206021830.3526922-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 2A6C21F394 X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim,suse.de:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Flag: NO The recently added interface wait_var_event_spinlock() is designed for waiting for events that can only be checked under a spinlock. This matches the requirements for waiting for nfsi->layout so we can change to using wait_var_event_spinlock(). This avoids a use of plain wake_up_var() which always needs to be checked for correct barrier usage. Signed-off-by: NeilBrown --- fs/nfs/pnfs.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 400f409f45fa..04be1165a1c5 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -306,7 +306,6 @@ void pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo) { struct inode *inode; - unsigned long i_state; if (!lo) return; @@ -317,12 +316,11 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo) if (!list_empty(&lo->plh_segs)) WARN_ONCE(1, "NFS: BUG unfreed layout segments.\n"); pnfs_detach_layout_hdr(lo); - i_state = inode->i_state; + /* Notify pnfs_destroy_layout_final() that we're done */ + if (inode->i_state & (I_FREEING | I_CLEAR)) + wake_up_var_locked(lo, &inode->i_lock); spin_unlock(&inode->i_lock); pnfs_free_layout_hdr(lo); - /* Notify pnfs_destroy_layout_final() that we're done */ - if (i_state & (I_FREEING | I_CLEAR)) - wake_up_var(lo); } } @@ -795,23 +793,16 @@ void pnfs_destroy_layout(struct nfs_inode *nfsi) } EXPORT_SYMBOL_GPL(pnfs_destroy_layout); -static bool pnfs_layout_removed(struct nfs_inode *nfsi, - struct pnfs_layout_hdr *lo) -{ - bool ret; - - spin_lock(&nfsi->vfs_inode.i_lock); - ret = nfsi->layout != lo; - spin_unlock(&nfsi->vfs_inode.i_lock); - return ret; -} - void pnfs_destroy_layout_final(struct nfs_inode *nfsi) { struct pnfs_layout_hdr *lo = __pnfs_destroy_layout(nfsi); - if (lo) - wait_var_event(lo, pnfs_layout_removed(nfsi, lo)); + if (lo) { + spin_lock(&nfsi->vfs_inode.i_lock); + wait_var_event_spinlock(lo, nfsi->layout != lo, + &nfsi->vfs_inode.i_lock); + spin_unlock(&nfsi->vfs_inode.i_lock); + } } static bool