From patchwork Wed Aug 14 20:38:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13763958 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC3FEC531DC for ; Wed, 14 Aug 2024 20:40:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CA8A6B00A3; Wed, 14 Aug 2024 16:40:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 37BA26B00A4; Wed, 14 Aug 2024 16:40:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F4F66B00A5; Wed, 14 Aug 2024 16:40:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F1DC56B00A3 for ; Wed, 14 Aug 2024 16:40:25 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id AB31C1A0D8C for ; Wed, 14 Aug 2024 20:40:25 +0000 (UTC) X-FDA: 82452018810.25.AE9DECB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id E782E18001E for ; Wed, 14 Aug 2024 20:40:23 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TJZZRgZL; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723667951; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Ysayb5RXeXC3/aarWcnK8uuWcOM3GXCwJSpymUE1G5c=; b=qtpiqfCAGFE5ao4GGL46FODXlS0iLZsfUo9ILfu74PXXYyAsefHgFwDwWNaoOrPNl61PD1 ZBTWyL8+w6oLSvS12gbGN+aMv9Kd2YIreGCQdq4rO3nRxIY11fn6psLLp7illFBblg1JxO SFmGFQg7q39JcA418CVMk5lzJ9pyvXw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723667951; a=rsa-sha256; cv=none; b=nyzzP9DKdcWKMwfxF7HQtbnx6pXhL6RkFs0RTS0iZbYFmGSXpZWi3rr7zx195JKWESztej 4qvdcBOB6DGYAwcidM8FSboHXYh0NOJGu0kZNzbI14THk1005tyskqcbTBh1OAOEBNUFMW IsFSDOokfDqms8/180Robzwcztzq+WM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TJZZRgZL; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723668023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ysayb5RXeXC3/aarWcnK8uuWcOM3GXCwJSpymUE1G5c=; b=TJZZRgZLgYx7iXT2F/Rc44BppaBRAQBinh+6ZVpo2ZWVZxXFhenb14hrgmHEPLuQbvYlv8 qt5ueyQKRie+oIin3BGKrh0BoyDJfQ1widsyAMzx9N7mo8+ILDanHoyDFO5na14Kp9NPJa PDpeKPf/NUvtzGJaPfmOX8fXLWoaTls= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-375-LKaV8qK4MgahAHzEnVal2w-1; Wed, 14 Aug 2024 16:40:21 -0400 X-MC-Unique: LKaV8qK4MgahAHzEnVal2w-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4EC7918EB232; Wed, 14 Aug 2024 20:40:18 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B01791955E8C; Wed, 14 Aug 2024 20:40:12 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 10/25] netfs: Set the request work function upon allocation Date: Wed, 14 Aug 2024 21:38:30 +0100 Message-ID: <20240814203850.2240469-11-dhowells@redhat.com> In-Reply-To: <20240814203850.2240469-1-dhowells@redhat.com> References: <20240814203850.2240469-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E782E18001E X-Stat-Signature: 9f6p9r79xgrq9w91u9ybjfsb7yzh568f X-HE-Tag: 1723668023-598462 X-HE-Meta: U2FsdGVkX1/X6qB0fR/JhDFRfw57AiWNQ303jw9f8zQKXkEAvqpKWunrKZcHRoAsCME+/b7kVzerHhCC6UtqvxE/Ng4YB3NZxIQAmfUAFs03TSNSe7/89gytnKOOLo+TXexotWFLcy0avtOW4ocKxiMqGd3iG79b+R/ut71/bQLyLX5S4HuNAmyxrPnqDwAQhj8nB5wv2uOOn2Ct71G6BcM93XppEPZhInNuViRiUickHh8qgab8OAwmd5Ch0TCczUJGER6j5zMza1p0ZEl+BIqWbkDAvsWKM+GIsR2sIkIiJ6Evh09ejo3xiOggQSuj2Xd/UQkvcqzyu/GIiacr3HDnHPNi+LNWXkrBYrdef+IzYX2klamWoioT8PqeUddDG7P+LQKNliWzVObNKPSO64FJTb88jOoWh8wfAaiIdBBZC6TAMwb9JkUPge6cp5P89tyjnpQ1bZ4R+m1FC/dLDhS+2Di5xzhEJLMiDdwqZP6WfW7LUJITbbwYZxvOvl47eKOtJOtKieEhFiXfP0lYxeKUa0B81U7Sm//Mw9jvkVFZi16vMXQPBQda7Ar163tl2Dvmpl9tMqERNNxHPBMuxcOPFpd3A8Suji6ZHH2BTOFDpypc1eintUfcPCc0nUWHGAN3HFbjPAotqZ8J0osRL9lsFGuzWE8qK+4h1vHV1DhMHoCAXsolFLdc8u7G3UjWZbLPJpwsYXVyKZCBkmam7IhRY99EE3eTFyVYAI5B3qjF1O3B+5RpxzVLEScHmwxcOgTfTBJyw2w5cd7VMZiyvdWR8IDiEGh1X9vK8x284wFhNfRLTLbfLZ0tKgq5W49DHit/CSX4Bk6IAjwAcMLMuQubnJhDQEOEBuNwcecppWzGTCpWts6PUAWYbuu3pRFR48RS9xiR9KmwD6n6Eg+FY/X7adJYMfcXcmmLLen9Fcx3Zx85p5EkI4jAfQE4K6a/lLcBUi5kBV7tYfNITdC xA/o2mpz 8IjVBHmBU5aaevL3CJnZtQAG0QxfyblCkJztfUW6u9IZZPDNm/cGv7ABKxI7TVTxAOFF+jANrKcMuPSOLRXEw+/AcZaMGemthllg0vL6ahTFARlHp4j96EUlRKW9bckbbL+wZ8BWEI8MayGamExj+rFpvUxGnUos47i5X3jrlADuQ6rhXuHE5kYavclSLypTH1x3PwZ+yMK50spHHHG/HfJ1rjoVKP3xmpbdvFvbe3damuMJkZM+Z/nmDaq009jmn0OdEOcIVYoyPVsDVjWwNVp9yRWmc3H0EEG5eb+1N83VIuB127Nw5klzSsVyn6EYNhNB7/qPPlXttCtpFSiIw1gMEsIUSnK/UaaMbEmFHR46PpWI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Set the work function in the netfs_io_request work_struct when we allocate the request rather than doing this later. This reduces the number of places we need to set it in future code. Signed-off-by: David Howells cc: Jeff Layton cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/netfs/internal.h | 1 + fs/netfs/io.c | 4 +--- fs/netfs/objects.c | 9 ++++++++- fs/netfs/write_issue.c | 1 - 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/netfs/internal.h b/fs/netfs/internal.h index 9e6e0e59d7e4..f2920b4ee726 100644 --- a/fs/netfs/internal.h +++ b/fs/netfs/internal.h @@ -29,6 +29,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio, /* * io.c */ +void netfs_rreq_work(struct work_struct *work); int netfs_begin_read(struct netfs_io_request *rreq, bool sync); /* diff --git a/fs/netfs/io.c b/fs/netfs/io.c index ce3e821b4e4f..8b9aaa99d787 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -422,7 +422,7 @@ static void netfs_rreq_assess(struct netfs_io_request *rreq, bool was_async) netfs_rreq_completed(rreq, was_async); } -static void netfs_rreq_work(struct work_struct *work) +void netfs_rreq_work(struct work_struct *work) { struct netfs_io_request *rreq = container_of(work, struct netfs_io_request, work); @@ -734,8 +734,6 @@ int netfs_begin_read(struct netfs_io_request *rreq, bool sync) // TODO: Use bounce buffer if requested rreq->io_iter = rreq->iter; - INIT_WORK(&rreq->work, netfs_rreq_work); - /* Chop the read into slices according to what the cache and the netfs * want and submit each one. */ diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c index 0294df70c3ff..d6e9785ce7a3 100644 --- a/fs/netfs/objects.c +++ b/fs/netfs/objects.c @@ -48,9 +48,16 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping, INIT_LIST_HEAD(&rreq->io_streams[0].subrequests); INIT_LIST_HEAD(&rreq->io_streams[1].subrequests); INIT_LIST_HEAD(&rreq->subrequests); - INIT_WORK(&rreq->work, NULL); refcount_set(&rreq->ref, 1); + if (origin == NETFS_READAHEAD || + origin == NETFS_READPAGE || + origin == NETFS_READ_FOR_WRITE || + origin == NETFS_DIO_READ) + INIT_WORK(&rreq->work, netfs_rreq_work); + else + INIT_WORK(&rreq->work, netfs_write_collection_worker); + __set_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags); if (file && file->f_flags & O_NONBLOCK) __set_bit(NETFS_RREQ_NONBLOCK, &rreq->flags); diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c index 34e541afd79b..41db709ca1d3 100644 --- a/fs/netfs/write_issue.c +++ b/fs/netfs/write_issue.c @@ -109,7 +109,6 @@ struct netfs_io_request *netfs_create_write_req(struct address_space *mapping, wreq->contiguity = wreq->start; wreq->cleaned_to = wreq->start; - INIT_WORK(&wreq->work, netfs_write_collection_worker); wreq->io_streams[0].stream_nr = 0; wreq->io_streams[0].source = NETFS_UPLOAD_TO_SERVER;