Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1091757lqt; Fri, 7 Jun 2024 07:50:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWHW2G8xB5hJGV2hm4X9depgADpDu2V1yuTTrjQ/Zaw9tsrU5+Wv1eakTdo+r1jsEs8PMAuenuX+h2VCKMYRxFSBj7WwdPRsbpRCivirQ== X-Google-Smtp-Source: AGHT+IE4qzcDvJEGVBe0R+X3xiAKqc9rlBtHonMCe+T63gL6ke1rqJdQkkSmXj2Ib9DtRqDQhLOu X-Received: by 2002:a17:90a:9a1:b0:2c2:5418:caf with SMTP id 98e67ed59e1d1-2c2bcc8721dmr2402023a91.45.1717771833640; Fri, 07 Jun 2024 07:50:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717771833; cv=pass; d=google.com; s=arc-20160816; b=fcwY4N5GeiYIZjnvEAL6nHydksi1DXbPJl6/n/OE/z3EV3L9lkWJWV8GDMBp8iGD8g c36HiCD514sTqBuHNYl4lizprDr12cq27fXXvRMWXGYxfa+r9SgHLj5eSXq9DyAEBMhA GCNQLRRJVgrHXT7XQYUahygzDMun8CR9FdiklsWAZWHflT9S4atRCAkaS6W3wwLniEgz rCcAwlXeSXNauuFHfKYGq3bE0Igb9C3dBvy8Wsn50yc3NvCmqOn2hKbe/VoeVgjm/F+V cAD1+2Ea4Ron66HqrBsE0MH+exWJ9n929FeIX+g177rZIkAxcIa2Mp46rPLHALZqsfB4 QOOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=rgdTHijKUc24G63xh7A6xtPwKLa17EyJO5cOAyPJBgo=; fh=OUKZWod6C22emJS3X689dwhO5bDgGbDS06P/Z6+EGqk=; b=Nso2ohwoWoPN8tz1aO30f7uAJOJYEmeUGBklSxTwaO/DjoMsJknuvVfPX+i47od2Gk +gMks5XMYJAx2x8aV/Vcjv1lCnFBI9Iv2gqlvxJCSJJTz1KiQET2+NH9ZCLD5meN8foC aZSJ6BtUHZFcCx6M672OB5f/shBig+4jfvH818amLNcYLUnq8QEWbLoVl5+zu76Ak6vl tDvnG0cbEf5LetEyeyDEFU3OxzUBzhFTh+CLmEKdOaGmVdLwofeH8P+zBmWgfhCbsu9p 3COO4/SGgVSLvrGXuvYct7vH7YfTQP2eb7Op91csYBMRKcu/B+A+VTgwoLfg0IkUhtog BelQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3602-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c28066bc08si3712429a91.59.2024.06.07.07.50.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:50:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3602-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3602-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3D696B28657 for ; Fri, 7 Jun 2024 14:28:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8102196D87; Fri, 7 Jun 2024 14:27:16 +0000 (UTC) X-Original-To: linux-nfs@vger.kernel.org Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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 5D477196444 for ; Fri, 7 Jun 2024 14:27:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770436; cv=none; b=hyCusjC++5Yf8Z5nAbPlw1+1Hx9bQe+rYeXxT0bz8mCGjIjeCediyY/hcQWNpbC8XDQcryzz3vn1E/hRA11A1frjiEowWyGjmiiBsN2P40TOzDskuJFnNmhc2FiUCH3raE6osJJ42yRIMPgx7b+J5b7MwScV6HBTvJbjBfGrBa8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770436; c=relaxed/simple; bh=9AX1XzQR+3txaydZI7fw3uGSB8rPMIrUEwzrXKzmNwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jDBRdIPb3qQZa1E6gRSVsvkfHFg5i5nUUlG4Vxmg3GjJcOxraviy4V9Dwdm6T44j3iBem/DbqM6UojN0EBLriej10DjiGmvK+n8J6guZucOKNWaRIAcUTYOKEMjAuSpC7ZL4Ri49tXAHlJpbjJrqroPm8O6R/QhVLKjs8EeQnOs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=snitzer.net; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=snitzer.net Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-795186ae415so121973985a.2 for ; Fri, 07 Jun 2024 07:27:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717770434; x=1718375234; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rgdTHijKUc24G63xh7A6xtPwKLa17EyJO5cOAyPJBgo=; b=Wtb3WTK+ozA9cjti+SvI/iKIGzAjfGw5u0Di04h5vMRCUah6GKdKLT6lCwFIz8YzNT e2Jgy6kDD/0CEl6INor7L1FglVupVe1TT2BRSQXIZNYhO2n9CdDVMQL709a9TsHuwvBY p1rhXXk31y2vinyRATodrjkRuZ5P43BeXYjaeLeXIoFDs2azRz+DTR0VMPH73MfKxpCr FCbT6WWuXyBsmkEukt3I2Xqs+SuQBrwXAX9i5rJWQR6nGkDiQB4fDxcO7cR1yeUIHz0c EIpqSomvPz9G7b4w7UAv4Ft5YM9uaBWfFX8D0PuFlk/4q7PiUIL8SCs0yYGBzgLWd+eK NsGA== X-Gm-Message-State: AOJu0YwLRbUyY1roard7JkunOyn7/kcZpZ4ddfsDte3QEGVrWqIQMGGc W9NDFbLrzySETdqeZPyVANq1zgOx7o2sA1+dTmrrF9ekFaMYdHC57qAAx+YfO/JYbQfsH+JEzeb uVuI= X-Received: by 2002:a05:620a:1495:b0:793:fab:b503 with SMTP id af79cd13be357-7953c5eed48mr240753285a.64.1717770433979; Fri, 07 Jun 2024 07:27:13 -0700 (PDT) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id af79cd13be357-795328464bdsm171304485a.30.2024.06.07.07.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:27:13 -0700 (PDT) From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , snitzer@hammerspace.com Subject: [for-6.11 PATCH 17/29] NFS: Use completion rather than flush_work() in nfs_local_commit() Date: Fri, 7 Jun 2024 10:26:34 -0400 Message-ID: <20240607142646.20924-18-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240607142646.20924-1-snitzer@kernel.org> References: <20240607142646.20924-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Trond Myklebust Make the code consistent with other routines. Signed-off-by: Trond Myklebust Signed-off-by: Mike Snitzer --- fs/nfs/localio.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index d997f0a96627..d7918e26aeb6 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -60,6 +60,7 @@ struct nfs_local_fsync_ctx { struct nfs_commit_data *data; struct work_struct work; struct kref kref; + struct completion *done; }; static void nfs_local_fsync_work(struct work_struct *work); @@ -813,6 +814,7 @@ nfs_local_fsync_ctx_alloc(struct nfs_commit_data *data, struct file *filp, ctx->data = data; INIT_WORK(&ctx->work, nfs_local_fsync_work); kref_init(&ctx->kref); + ctx->done = NULL; } return ctx; } @@ -847,6 +849,8 @@ nfs_local_fsync_work(struct work_struct *work) status = nfs_local_run_commit(ctx->filp, ctx->data); nfs_local_commit_done(ctx->data, status); + if (ctx->done != NULL) + complete(ctx->done); nfs_local_fsync_ctx_free(ctx); } @@ -866,9 +870,13 @@ nfs_local_commit(struct nfs_client *clp, struct file *filp, nfs_local_init_commit(data, call_ops); kref_get(&ctx->kref); - queue_work(nfsiod_workqueue, &ctx->work); - if (how & FLUSH_SYNC) - flush_work(&ctx->work); + if (how & FLUSH_SYNC) { + DECLARE_COMPLETION_ONSTACK(done); + ctx->done = &done; + queue_work(nfsiod_workqueue, &ctx->work); + wait_for_completion(&done); + } else + queue_work(nfsiod_workqueue, &ctx->work); nfs_local_fsync_ctx_put(ctx); return 0; } -- 2.44.0