From patchwork Fri Oct 13 15:56:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13421067 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 D8DF6CDB47E for ; Fri, 13 Oct 2023 15:57:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 512048001C; Fri, 13 Oct 2023 11:57:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49ACA8D0015; Fri, 13 Oct 2023 11:57:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 314CD8001C; Fri, 13 Oct 2023 11:57:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1A1D18D0015 for ; Fri, 13 Oct 2023 11:57:55 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DCEAE1CA90E for ; Fri, 13 Oct 2023 15:57:54 +0000 (UTC) X-FDA: 81340894068.10.5D19E51 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 368B42000F for ; Fri, 13 Oct 2023 15:57:53 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FwUB5UZN; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697212673; 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=KKwIDnJBdKbpqLQU76AV5hRxBgMKROUmlCRt7k06nqI=; b=DXhSh9zXBwAW36uyfEikcZk3/6xUd6XnETd5f3gBPU2yiZjhHNALDaWhUmOB+8OBC5a2Hj 0EIaXFKBz5V1NG/gYVSFzkHps7Y0tF3Ke4REAbsoKPkEYIewEKitB/xpc+49n5948ofsSM DYQa1TrTHRfGmlP0kjIqNNU9JKZg07Y= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FwUB5UZN; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697212673; a=rsa-sha256; cv=none; b=qQAtyrD+nuWBI2dJ+GUFUC0L303+ppkNGNr6OU+bM0SQ5Giq+T6iZ+CnkaWwOZEMaT7J1/ 04K/veiNUFmWTSU5uCEvRo1uIVhLOBKQ7CUfpVTBshRGl43mzzjcfTaJuu8ATF+IaCYKM5 5a1YBCVSIg/FGd1ctBeSINq360PtUFo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697212672; 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=KKwIDnJBdKbpqLQU76AV5hRxBgMKROUmlCRt7k06nqI=; b=FwUB5UZN6bqGT0PtCD0yq8cfRecz76YWjJNhawSUL5vXkSP5tyqGTUGrXC5U0GVUtfqMbB Xdzb1hMso/D4FNql7r5+Eak123q7V/h1AiIye1IwzZ+nC7iMCgsEOHqmJ7A0QAcCXL7qNE hxpokZ3P1BxGAvd+UrTEDA1tRjX4LHo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-68-Ms_dVTLZOQ6OiPqMgiGRuA-1; Fri, 13 Oct 2023 11:57:37 -0400 X-MC-Unique: Ms_dVTLZOQ6OiPqMgiGRuA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 979E8185A7B4; Fri, 13 Oct 2023 15:57:35 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6E11492BE0; Fri, 13 Oct 2023 15:57:32 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Dominique Martinet , Ilya Dryomov , Christian Brauner , 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-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cachefs@redhat.com Subject: [RFC PATCH 01/53] netfs: Add a procfile to list in-progress requests Date: Fri, 13 Oct 2023 16:56:34 +0100 Message-ID: <20231013155727.2217781-2-dhowells@redhat.com> In-Reply-To: <20231013155727.2217781-1-dhowells@redhat.com> References: <20231013155727.2217781-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 368B42000F X-Stat-Signature: petntcdoub9kacg5prw3bya4y38g49m4 X-HE-Tag: 1697212673-744629 X-HE-Meta: U2FsdGVkX1/F9hnY74Udp9whAvwp8qbbi7DXP6+Kpw1KDhwR/9EgCaxXdBs7BroUaZF8hV4NhJpY0LsCPrISxfYSVwngRq1qjQFTpP0un73rbIE7OZ47LbX9Zxa5D9lhMXEbk2cViGIQrC0vKNPukLn8Lol2HpBT9GuLtrRz96isRIbpcBkPf6W6M/IKvkiJOmXOUajDLpgzl7ICy9jnnqdQ1197URSUfy/wUl3peit+a0VsZ0OqoZgOAJ7+Ut31nlqUznfMkBxI5blW2iHUI4ksttOGBWh2Lkmb/gGvxzAtn6lA+zMnw7/bw/qhzke7iJRh+ClX0q9hIcwnw2y1QaCefYejkP7eMtI2M1D/y8OTIAuue5Z2ePl+INuVTCOj4zF9zME4btyMsgOIhdP9yDWgJGjqepeqjZxLK24Vyzwf8nTnnh1Xj5RkC9OAz7lgfDDW2/JD7cCd9OivS4XGuaYbeO20ISRppHyt9aTJ0ravhS5YalXh6j94OgRC5E9U+9Wzau5vPx1xtbHvQA81aPOD6zlc1RySAxiPbJ+hCr+HLE4CTlDt8N9Ilv0O1NnwKBl/77hTUYUYTg41nJQ8MLI+L/mIS5rgysqJDV4GheLuSEapNYyYgbaWB/5abKzgj8fnzdF4g3D0H397KUjtCc2Svw4/5+QAcy5JfKOjoAaB0Q1IkxnZmNqpJykSJXUlD28XWaMqCJYjv/tC7xPW8gn+hktvQ1Nieo+TpvWePAke11WifOA8BBzNp0mDt5rKqNCeFf44EtQMu7pAe+t/tQfMWzDeKk1hB2BPJpcPj9mjJZLVKlJ+wI5RWordNNjyHSjJndTnq2gnsrBALOzEszHzCw1b/QXMBFYhhXi9j3YKRbyKeDrtkoLR5DCpMV6ycVuXlBTxemt+Js1vVAdc/ozYTVWjNkBM4ab33gUONWCsW9kG2LAp2BapeZ+KuQ/8gyksG8B9IzfCHdtrsKU smr1uXVn NteOQHakZA09l+3/wY7L+RRY1jss5U/7AFSFnIOW1zoXRIhKSMxN626ABO7sqTMOpB6UCds7EyF+N1SOQ5FGw2QQDegtHrGQ+7tcJsOWa4KaG2afmHqmqP3i9ao+GxZANiv+XQOB8akH4zqGyNirk2daFgcXSL555HTooQ5PD+Mvul+uEvL/hx0w3Va3jjAjdZwldnW4NlfPNGXfTkkVu5QK4Wtmz9E0+mKxbTZzUfZsrgM+zIYgemuU1KGzUDGRSsj/K0h8lrKcYZzKaJHI0asIr+5MdCBmGq16oq2bGKWIt1WU= 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: Add a procfile, /proc/fs/netfs/requests, to list in-progress netfslib I/O requests. Signed-off-by: David Howells cc: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/netfs/internal.h | 22 +++++++++++ fs/netfs/main.c | 91 +++++++++++++++++++++++++++++++++++++++++++ fs/netfs/objects.c | 4 +- include/linux/netfs.h | 6 ++- 4 files changed, 121 insertions(+), 2 deletions(-) diff --git a/fs/netfs/internal.h b/fs/netfs/internal.h index 43fac1b14e40..1f067aa96c50 100644 --- a/fs/netfs/internal.h +++ b/fs/netfs/internal.h @@ -29,6 +29,28 @@ int netfs_begin_read(struct netfs_io_request *rreq, bool sync); * main.c */ extern unsigned int netfs_debug; +extern struct list_head netfs_io_requests; +extern spinlock_t netfs_proc_lock; + +#ifdef CONFIG_PROC_FS +static inline void netfs_proc_add_rreq(struct netfs_io_request *rreq) +{ + spin_lock(&netfs_proc_lock); + list_add_tail_rcu(&rreq->proc_link, &netfs_io_requests); + spin_unlock(&netfs_proc_lock); +} +static inline void netfs_proc_del_rreq(struct netfs_io_request *rreq) +{ + if (!list_empty(&rreq->proc_link)) { + spin_lock(&netfs_proc_lock); + list_del_rcu(&rreq->proc_link); + spin_unlock(&netfs_proc_lock); + } +} +#else +static inline void netfs_proc_add_rreq(struct netfs_io_request *rreq) {} +static inline void netfs_proc_del_rreq(struct netfs_io_request *rreq) {} +#endif /* * objects.c diff --git a/fs/netfs/main.c b/fs/netfs/main.c index 068568702957..21f814eee6af 100644 --- a/fs/netfs/main.c +++ b/fs/netfs/main.c @@ -7,6 +7,8 @@ #include #include +#include +#include #include "internal.h" #define CREATE_TRACE_POINTS #include @@ -18,3 +20,92 @@ MODULE_LICENSE("GPL"); unsigned netfs_debug; module_param_named(debug, netfs_debug, uint, S_IWUSR | S_IRUGO); MODULE_PARM_DESC(netfs_debug, "Netfs support debugging mask"); + +#ifdef CONFIG_PROC_FS +LIST_HEAD(netfs_io_requests); +DEFINE_SPINLOCK(netfs_proc_lock); + +static const char *netfs_origins[] = { + [NETFS_READAHEAD] = "RA", + [NETFS_READPAGE] = "RP", + [NETFS_READ_FOR_WRITE] = "RW", +}; + +/* + * Generate a list of I/O requests in /proc/fs/netfs/requests + */ +static int netfs_requests_seq_show(struct seq_file *m, void *v) +{ + struct netfs_io_request *rreq; + + if (v == &netfs_io_requests) { + seq_puts(m, + "REQUEST OR REF FL ERR OPS COVERAGE\n" + "======== == === == ==== === =========\n" + ); + return 0; + } + + rreq = list_entry(v, struct netfs_io_request, proc_link); + seq_printf(m, + "%08x %s %3d %2lx %4d %3d @%04llx %zx/%zx", + rreq->debug_id, + netfs_origins[rreq->origin], + refcount_read(&rreq->ref), + rreq->flags, + rreq->error, + atomic_read(&rreq->nr_outstanding), + rreq->start, rreq->submitted, rreq->len); + seq_putc(m, '\n'); + return 0; +} + +static void *netfs_requests_seq_start(struct seq_file *m, loff_t *_pos) + __acquires(rcu) +{ + rcu_read_lock(); + return seq_list_start_head(&netfs_io_requests, *_pos); +} + +static void *netfs_requests_seq_next(struct seq_file *m, void *v, loff_t *_pos) +{ + return seq_list_next(v, &netfs_io_requests, _pos); +} + +static void netfs_requests_seq_stop(struct seq_file *m, void *v) + __releases(rcu) +{ + rcu_read_unlock(); +} + +static const struct seq_operations netfs_requests_seq_ops = { + .start = netfs_requests_seq_start, + .next = netfs_requests_seq_next, + .stop = netfs_requests_seq_stop, + .show = netfs_requests_seq_show, +}; +#endif /* CONFIG_PROC_FS */ + +static int __init netfs_init(void) +{ + if (!proc_mkdir("fs/netfs", NULL)) + goto error; + + if (!proc_create_seq("fs/netfs/requests", S_IFREG | 0444, NULL, + &netfs_requests_seq_ops)) + goto error_proc; + + return 0; + +error_proc: + remove_proc_entry("fs/netfs", NULL); +error: + return -ENOMEM; +} +fs_initcall(netfs_init); + +static void __exit netfs_exit(void) +{ + remove_proc_entry("fs/netfs", NULL); +} +module_exit(netfs_exit); diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c index e17cdf53f6a7..85f428fc52e6 100644 --- a/fs/netfs/objects.c +++ b/fs/netfs/objects.c @@ -45,6 +45,7 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping, } } + netfs_proc_add_rreq(rreq); netfs_stat(&netfs_n_rh_rreq); return rreq; } @@ -76,12 +77,13 @@ static void netfs_free_request(struct work_struct *work) container_of(work, struct netfs_io_request, work); trace_netfs_rreq(rreq, netfs_rreq_trace_free); + netfs_proc_del_rreq(rreq); netfs_clear_subrequests(rreq, false); if (rreq->netfs_ops->free_request) rreq->netfs_ops->free_request(rreq); if (rreq->cache_resources.ops) rreq->cache_resources.ops->end_operation(&rreq->cache_resources); - kfree(rreq); + kfree_rcu(rreq, rcu); netfs_stat_d(&netfs_n_rh_rreq); } diff --git a/include/linux/netfs.h b/include/linux/netfs.h index b11a84f6c32b..b447cb67f599 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -175,10 +175,14 @@ enum netfs_io_origin { * operations to a variety of data stores and then stitch the result together. */ struct netfs_io_request { - struct work_struct work; + union { + struct work_struct work; + struct rcu_head rcu; + }; struct inode *inode; /* The file being accessed */ struct address_space *mapping; /* The mapping being accessed */ struct netfs_cache_resources cache_resources; + struct list_head proc_link; /* Link in netfs_iorequests */ struct list_head subrequests; /* Contributory I/O operations */ void *netfs_priv; /* Private data for the netfs */ unsigned int debug_id; From patchwork Fri Oct 13 15:56:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13421066 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 18492C41513 for ; Fri, 13 Oct 2023 15:57:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A9138D0165; Fri, 13 Oct 2023 11:57:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 70B848D0015; Fri, 13 Oct 2023 11:57:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55DD58D0165; Fri, 13 Oct 2023 11:57:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 402D58D0015 for ; Fri, 13 Oct 2023 11:57:48 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E5DB61202E5 for ; Fri, 13 Oct 2023 15:57:47 +0000 (UTC) X-FDA: 81340893774.09.96DEBDC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 3EBAB180022 for ; Fri, 13 Oct 2023 15:57:46 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LX5qOz7s; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697212666; 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=ybL5Z84E2MKfw9/KPwUGR/SMS/5stuqwlJ261jfXYyg=; b=JYH774hZkIAwnHhuMctrlnAO7o33PJ7BRn5NALsmIVvUEzBLLxH+qnpDtBEqDCYqdBWqrI S4YoJPvYKzPuOCkwP1uBLHByOAFD+W2s5xSn8Qv8fya0biH4b7E6mPEBVxGbgF8gZoR1sy gx/0NPC7e2LV8Xx8RkqWdwh5yekJp0U= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LX5qOz7s; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697212666; a=rsa-sha256; cv=none; b=Xja4zSZlIc/LzdUY4KVPVDSCjXvdmcbfk3+jBdUPJNHQFmos6MFBEhyD0x9PmDpHBMjJwa jzBgk9sPrfdjm077nG80rrMkCcz2DhZ4OgvbkcBCjRDUgcr+q6p/QWwOZf4Bav5/W/v9/o A/lAhpskL++a/gFq96eJNJs4eM6mevA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697212665; 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=ybL5Z84E2MKfw9/KPwUGR/SMS/5stuqwlJ261jfXYyg=; b=LX5qOz7sWtaDh5wudt+NVUMQjlseMWJbXX/mS/BuH6m9fU0/ZT50KCvnm+8XoFPCNtdEDf SBraSJAmCPFA+3sdniRFiyeryeWnsC6+L66a6byktrVX4bj0rcOCcDU4wsBKhtEkr30A6m wu55lQdo2tquHMlExdOCOYdMrfJ07Sw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-216-M9f1MTH9Nyy4xEZUXNXggw-1; Fri, 13 Oct 2023 11:57:40 -0400 X-MC-Unique: M9f1MTH9Nyy4xEZUXNXggw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EFB55862DFD; Fri, 13 Oct 2023 15:57:38 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4664425C0; Fri, 13 Oct 2023 15:57:36 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Dominique Martinet , Ilya Dryomov , Christian Brauner , 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-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cachefs@redhat.com Subject: [RFC PATCH 02/53] netfs: Track the fpos above which the server has no data Date: Fri, 13 Oct 2023 16:56:35 +0100 Message-ID: <20231013155727.2217781-3-dhowells@redhat.com> In-Reply-To: <20231013155727.2217781-1-dhowells@redhat.com> References: <20231013155727.2217781-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Rspamd-Queue-Id: 3EBAB180022 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: tiek7q1becdzpnjg563s6eo7trhmrtj3 X-HE-Tag: 1697212666-222556 X-HE-Meta: U2FsdGVkX19dm+e/PovsE+dzOpthWHypqRJ70MYBock2Oqi5M49NK6dTZh2xODsyKq84uGJZCyf8rvENnlVvGUzdMkqXTTB0bq+6OXV3r0Th5lfWSJUdhP+Wtknhc39MEQ7riV7Nc2PlhP89ZlDywwyXzUk4/YKvm0cR/bN16/JRbl3jGs+empESduSlaJutqFCnAKBAPkdkmETIBAWt+WgAJiXo8LHDaXCQIALXFb09J5rrE1M4Z0ugao9m7X+u2vV3D28BFxCmpQQpVzcn0JtuNK2aGXXSsYAN1lXWQS0hsrwxKL9Y4hIHZtkEoSWpRWpGftQRzhZelroqRDlu/1mPoLMw39rR0g5cjm6DqlpkVwO+cordwd++0hh48Pefskd4YFIvPdfV/+wqF3qvQWqrCCYqpsMCSNuZ+w4SkYHKLT5xSH955UVOjPZXHlNQYYAguucY5I70axbr+CIjzs0F9jywUqT5PIMu8o3L5dxyOmAPrilCshRjCgDpK6kxUq7P1ClPGYeytHcsKUwccGRE1Q+U/Hs6dICCqz1c5Jym+NeYL2Jc08E2sTa8+72Ne+qu/UUnEtHJCd194cW8hq5jbdE+PqtVlUVejrrNmB2nKgW69yhiCQcAfaMvTwN7K3sj/5uyRqHXXtgFPWZnRdR/iyCMWHVMRdhRS8aW8LdCwUyIBIKMEoxwk3mX4NlFms6XsSm7FwApFlv+cBLJlACUm6JU72nDo59vrqSC/UiR/HNxY705t4nMstnvQsLKhvryeDgwz6yqXDo8ky1uc0P8S4X5WWE2e0AwNcj3FckILl5UPipqi22gfbwH+qZxgyu+SBakCtClJ15M1ZFLXT+7A/OBvCcyXV7BFBklIBuKdGXoTjaRruMmxWwOdaUf0abBrCs5SZjOt74aGg0EROFoFunAlO5iDOZ07zlGaYz9oR67xCaxycYJcpEpx3KRBeYBS6J8mqLgSa+rg0+ j7o0AGxF LgMyN2ZjL7Zfk+C/dexePs7+Lg1FoYrRaRKBIIXgXuuhfTcs5nw8nAtCrHtwp9X32IsnXmsL3MHzCIfld4tRK8owBdhhUvbhfzipa811INMYMqAHPduFrZkYpIcty1NYyrvUIrFPM+gojCFKZOFrC1DUBsPL3ZQj0yQJNB7lpULMCVXhEOTeTUQNp0BPSNVtexT1FYWM+j4x8GmjDnvr9toGVIOKCkqEYWeimfAFt4Ck5jgvrGjcHonelNlZLgSnyfMZYCM76RHmOlK6vB6fRWD3tBqm+NjmVvgNmeflNMKS5DoA= 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: Track the file position above which the server is not expected to have any data and preemptively assume that we can simply fill blocks with zeroes locally rather than attempting to download them - even if we've written data back to the server. Assume that any data that was written back above that position is held in the local cache. Call this the "zero point". Make use of this to optimise away some reads from the server. We need to set the zero point in the following circumstances: (1) When we see an extant remote inode and have no cache for it, we set the zero_point to i_size. (2) On local inode creation, we set zero_point to 0. (3) On local truncation down, we reduce zero_point to the new i_size if the new i_size is lower. (4) On local truncation up, we don't change zero_point. (5) On local modification, we don't change zero_point. (6) On remote invalidation, we set zero_point to the new i_size. (7) If stored data is culled from the local cache, we must set zero_point above that if the data also got written to the server. (8) If dirty data is written back to the server, but not the local cache, we must set zero_point above that. Assuming the above, any read from the server at or above the zero_point position will return all zeroes. The zero_point value can be stored in the cache, provided the above rules are applied to it by any code that culls part of the local cache. Signed-off-by: David Howells cc: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/afs/inode.c | 13 +++++++------ fs/netfs/buffered_read.c | 40 +++++++++++++++++++++++++--------------- include/linux/netfs.h | 5 +++++ 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 1c794a1896aa..46bc5574d6f5 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -252,6 +252,7 @@ static void afs_apply_status(struct afs_operation *op, vnode->netfs.remote_i_size = status->size; if (change_size) { afs_set_i_size(vnode, status->size); + vnode->netfs.zero_point = status->size; inode_set_ctime_to_ts(inode, t); inode->i_atime = t; } @@ -865,17 +866,17 @@ static void afs_setattr_success(struct afs_operation *op) static void afs_setattr_edit_file(struct afs_operation *op) { struct afs_vnode_param *vp = &op->file[0]; - struct inode *inode = &vp->vnode->netfs.inode; + struct afs_vnode *vnode = vp->vnode; if (op->setattr.attr->ia_valid & ATTR_SIZE) { loff_t size = op->setattr.attr->ia_size; loff_t i_size = op->setattr.old_i_size; - if (size < i_size) - truncate_pagecache(inode, size); - if (size != i_size) - fscache_resize_cookie(afs_vnode_cache(vp->vnode), - vp->scb.status.size); + if (size != i_size) { + truncate_pagecache(&vnode->netfs.inode, size); + netfs_resize_file(&vnode->netfs, size); + fscache_resize_cookie(afs_vnode_cache(vnode), size); + } } } diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index 2cd3ccf4c439..a2852fa64ad0 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -147,6 +147,22 @@ static void netfs_rreq_expand(struct netfs_io_request *rreq, } } +/* + * Begin an operation, and fetch the stored zero point value from the cookie if + * available. + */ +static int netfs_begin_cache_operation(struct netfs_io_request *rreq, + struct netfs_inode *ctx) +{ + int ret = -ENOBUFS; + + if (ctx->ops->begin_cache_operation) { + ret = ctx->ops->begin_cache_operation(rreq); + /* TODO: Get the zero point value from the cache */ + } + return ret; +} + /** * netfs_readahead - Helper to manage a read request * @ractl: The description of the readahead request @@ -180,11 +196,9 @@ void netfs_readahead(struct readahead_control *ractl) if (IS_ERR(rreq)) return; - if (ctx->ops->begin_cache_operation) { - ret = ctx->ops->begin_cache_operation(rreq); - if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS) - goto cleanup_free; - } + ret = netfs_begin_cache_operation(rreq, ctx); + if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS) + goto cleanup_free; netfs_stat(&netfs_n_rh_readahead); trace_netfs_read(rreq, readahead_pos(ractl), readahead_length(ractl), @@ -238,11 +252,9 @@ int netfs_read_folio(struct file *file, struct folio *folio) goto alloc_error; } - if (ctx->ops->begin_cache_operation) { - ret = ctx->ops->begin_cache_operation(rreq); - if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS) - goto discard; - } + ret = netfs_begin_cache_operation(rreq, ctx); + if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS) + goto discard; netfs_stat(&netfs_n_rh_readpage); trace_netfs_read(rreq, rreq->start, rreq->len, netfs_read_trace_readpage); @@ -390,11 +402,9 @@ int netfs_write_begin(struct netfs_inode *ctx, rreq->no_unlock_folio = folio_index(folio); __set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags); - if (ctx->ops->begin_cache_operation) { - ret = ctx->ops->begin_cache_operation(rreq); - if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS) - goto error_put; - } + ret = netfs_begin_cache_operation(rreq, ctx); + if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS) + goto error_put; netfs_stat(&netfs_n_rh_write_begin); trace_netfs_read(rreq, pos, len, netfs_read_trace_write_begin); diff --git a/include/linux/netfs.h b/include/linux/netfs.h index b447cb67f599..282511090ead 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -129,6 +129,8 @@ struct netfs_inode { struct fscache_cookie *cache; #endif loff_t remote_i_size; /* Size of the remote file */ + loff_t zero_point; /* Size after which we assume there's no data + * on the server */ }; /* @@ -330,6 +332,7 @@ static inline void netfs_inode_init(struct netfs_inode *ctx, { ctx->ops = ops; ctx->remote_i_size = i_size_read(&ctx->inode); + ctx->zero_point = ctx->remote_i_size; #if IS_ENABLED(CONFIG_FSCACHE) ctx->cache = NULL; #endif @@ -345,6 +348,8 @@ static inline void netfs_inode_init(struct netfs_inode *ctx, static inline void netfs_resize_file(struct netfs_inode *ctx, loff_t new_i_size) { ctx->remote_i_size = new_i_size; + if (new_i_size < ctx->zero_point) + ctx->zero_point = new_i_size; } /** From patchwork Fri Oct 13 15:56:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13421069 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 83739CDB47E for ; Fri, 13 Oct 2023 15:57:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7E9F8001D; Fri, 13 Oct 2023 11:57:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB6328D0015; Fri, 13 Oct 2023 11:57:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BAFB8001D; Fri, 13 Oct 2023 11:57:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6E9D68D0015 for ; Fri, 13 Oct 2023 11:57:58 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 442581203DD for ; Fri, 13 Oct 2023 15:57:58 +0000 (UTC) X-FDA: 81340894236.10.8E6ED57 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 906E8140018 for ; Fri, 13 Oct 2023 15:57:56 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iPQJGXZw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697212676; 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=VdTOgUT9KIMzQnxrll+Ln7vU3lh7L6xf921vj9gXc+g=; b=0RamJOxaZsOMaI4NB7puaFYlywmli55dsU5Om6x5dmjVLIHmq14UDKQADmNpvatAdnplZC WM8zmWXegHIsbMV379WC2g2GlJfKYfvNRWpNOgEZ0ENBpcTQB8q4F+MSNoWTFsutQcijmJ fMP+QkC+7z2WOK1YG+uvTdEZW3arlcY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iPQJGXZw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697212676; a=rsa-sha256; cv=none; b=y0pmsw1X44MxTGhOmu/Bi/NM+Chf5vDyXfRGqb+fY5Ms/jtqJfkzcMuwz7Glm2RqvXAT1W 9SsP6SMDT/+1cAZ8CyqRMci/V20chdnOxkZSxcFXppVHiqw2oR8oRPtE6zZm3ywaK0Csa0 rpEUT0RSRYpZ5LccXq6wf6idaSeFKhQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697212676; 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=VdTOgUT9KIMzQnxrll+Ln7vU3lh7L6xf921vj9gXc+g=; b=iPQJGXZw89MHOoxIYOm8qN7u8rqe082pmq49U4AkhOvotHIxcaOLCHTd12WZEYdGJm+kdP leuGpRFspcMYwZQHuucV5B7VPBsW1K/4oQpyOhIyIarpqD7IPXk9x7EkxgljS0pYgS/Hyq ysJZYVQAT6+6V3T0o241aHBQ84ZVebY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-690-sPJ3XQAXMnmyAp7uFZgrmw-1; Fri, 13 Oct 2023 11:57:43 -0400 X-MC-Unique: sPJ3XQAXMnmyAp7uFZgrmw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 591821029F45; Fri, 13 Oct 2023 15:57:42 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id B58C2492BD9; Fri, 13 Oct 2023 15:57:39 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Dominique Martinet , Ilya Dryomov , Christian Brauner , 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-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cachefs@redhat.com Subject: [RFC PATCH 03/53] netfs: Note nonblockingness in the netfs_io_request struct Date: Fri, 13 Oct 2023 16:56:36 +0100 Message-ID: <20231013155727.2217781-4-dhowells@redhat.com> In-Reply-To: <20231013155727.2217781-1-dhowells@redhat.com> References: <20231013155727.2217781-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspam-User: X-Stat-Signature: 4kkzkw7cxfube8en6777apd1qwfy46e8 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 906E8140018 X-HE-Tag: 1697212676-388357 X-HE-Meta: U2FsdGVkX1/us7S/g23bHBsFcVW7+DJ2yIgNk4lFRHec8uf/3zdM8be+takPvcq4nBis1fdmufMH5M3uJQhW3gsYFBgvSNj0Pr0PZajNwp+MpJL7jkS6nO28/KD40QPOmc1LySzk4t94vZFfMwd59CwyqE3aUi/A/oRPJyv9WO1fHNMlOKsF9qJ5Uh9ZKmgjmTuUlxF+feSs8ASdmQnK04FKciFz800MF0XLLyVeCv5idIReuHWS0d4nhMdUhBIz4XEMbLa5niMHnP4tf+bYWi7P3CdErnxuXVl7PKlK4ARZnlPSyFEk2iJYWDtNXYYbHdFp1QZUOtgBZBRWrVuYJXwlm0WCnYCM3X7nnZv9q2YQpdoF0w7p5q0gc43MgHFM6HJF+G2RTZhOr2Bby+upJOasJxnn7yj9IOVR9xnjvfd9vkR6uxKrDpBk0cOy/h3FpRQQ9bZNqhSrvieIekmiJMQrbQMoAcR4h+IP1/0E6E7Npn36rR7a0Hw76wSP3J13CHga5FOTlJjmfM6Zb0MB7s4teY0bewxz1IIZHQTvjxfcrtSPWgHq1yBIHSkfQl/pwMKDNZNd/NoOPkusBUtNvkWUpaS9743ZBOO2MOknpRvgNQ+TrmCvewLmfdT3truBC7/tGb4WUjhB4TWki+mSOm4jwB9NNH3/Pis4/OytcNIb3XBuHy9nI6pIL3xr75DANjBL1JnuloKPBenqBTBuG2tei9Xzu1AqPErJstNHln2DyWQBz4yj3fvu/a/9EExQQELJbJf/KMzM6RSjok2KMUXf/8CFdfwB3SsAVVuharAl6hW8mX5GXUbPeZbVrZ1rvefupd0aN3XuJ+5cUi/ARNka5An81sjiP76+gxdYq/5a+N4RaraFAourCTIOR6wMtIoJ3xqAEwyCGNcPrck9Xu/T9eer88Njm/s5mnuRAb29OQGorh8ie/M4EeAqmGAU5/b534gv8BWkXK82eI5 T09UUZl5 RFL0aCu4tIUcgHsrH/Iy/OPLT1NpAoRnSGxee1W6rp5wIKBGBx5WEbW9iktoT6J15CwkA/vnxc/tOwuLuvtk/qRtMhrKPDnCaM51SKw6S7n9gnRAvA7b0F+/C2CH/urXBXQFlFta1NWdHTSmyTyn4A1k7VcoqUPZj8KOPgmVicE3swPT/mvZthGClanPmO6rcH+n44n/S7PVIhftL8qhqySa3kfePHX0KXBLjzijF9JcM4t25GW71VZ24BvIQrUDWPh0zFgUFkkfOPMsoijsW/13+jBuca0XHqbJua92BtrERHnTeJRwf5fcj+TQZn94+nUTcLpSv2c6eYTVyH7Wjurx74A== 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: Allow O_NONBLOCK to be noted in the netfs_io_request struct. Also add a flag, NETFS_RREQ_BLOCKED to record if we did block. Signed-off-by: David Howells cc: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/netfs/objects.c | 2 ++ include/linux/netfs.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c index 85f428fc52e6..e41f9fc9bdd2 100644 --- a/fs/netfs/objects.c +++ b/fs/netfs/objects.c @@ -37,6 +37,8 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping, INIT_LIST_HEAD(&rreq->subrequests); refcount_set(&rreq->ref, 1); __set_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags); + if (file && file->f_flags & O_NONBLOCK) + __set_bit(NETFS_RREQ_NONBLOCK, &rreq->flags); if (rreq->netfs_ops->init_request) { ret = rreq->netfs_ops->init_request(rreq, file); if (ret < 0) { diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 282511090ead..b92e982ac4a0 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -205,6 +205,8 @@ struct netfs_io_request { #define NETFS_RREQ_DONT_UNLOCK_FOLIOS 3 /* Don't unlock the folios on completion */ #define NETFS_RREQ_FAILED 4 /* The request failed */ #define NETFS_RREQ_IN_PROGRESS 5 /* Unlocked when the request completes */ +#define NETFS_RREQ_NONBLOCK 6 /* Don't block if possible (O_NONBLOCK) */ +#define NETFS_RREQ_BLOCKED 7 /* We blocked */ const struct netfs_request_ops *netfs_ops; }; From patchwork Fri Oct 13 15:56:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13421070 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 60F14CDB482 for ; Fri, 13 Oct 2023 15:58:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 208528001E; Fri, 13 Oct 2023 11:58:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 18FD78D0015; Fri, 13 Oct 2023 11:58:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE3AB8001E; Fri, 13 Oct 2023 11:58:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C90718D0015 for ; Fri, 13 Oct 2023 11:58:00 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9596A1A036E for ; Fri, 13 Oct 2023 15:58:00 +0000 (UTC) X-FDA: 81340894320.20.A1B271E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id E3B6DA0020 for ; Fri, 13 Oct 2023 15:57:58 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Q0V/oTM1"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697212678; 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=gcj4568/Cja75cJgRJVpO1Pa05t3rY5GzidcrAxRiJc=; b=MqAXSpEK7a+Z6dWn/53TM2LNPDaGeY881/uiIGgHdWyMbgOIOSVzeJWJtf2KiU+7BzJBV9 UwGmQ4qRqDqZck+t1lPsOAGtZYs3/c7l56LTQZvBk7pkarN2lZ6rBp6FlTp3PFeS4Z0DW+ haaAsUAxNLt0Dsdzf/YdvCzMeKOb8A8= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Q0V/oTM1"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697212678; a=rsa-sha256; cv=none; b=wzMgjeb61QM5kXi8jxSn1x0lWCba378n1XLbtH85WjZZO48vfcBjehDJ6LA+GFxcqcPsFo Zxf/1Kk1Z7YCHacXGkav4RGpGXDIqf1NizpOBcb3wwuRJRHvdL6YegH7rxe5ERt2V8y4Df LfqcZk/U3B2CzBM+mweQRXax1nDddH8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697212678; 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=gcj4568/Cja75cJgRJVpO1Pa05t3rY5GzidcrAxRiJc=; b=Q0V/oTM1jytjTmOXIuc/wq1OQaU1UsTAPe+Qc2rGPkXwKU8XOyXlZEH8iMUFBlCyFlPSrK Vq/vXp0rC61qEZbfJhunxg1mEHfZnbkESOvgKDO9YuEubBavg60WQQFdJO0e1gDh1Jtwle dsaXL8WVefc3FaITitQSb7MKsQd5E+w= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-614-pbz5bDgbMkSmeASAhSIaXA-1; Fri, 13 Oct 2023 11:57:46 -0400 X-MC-Unique: pbz5bDgbMkSmeASAhSIaXA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9EB33862F29; Fri, 13 Oct 2023 15:57:45 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0621C492BD9; Fri, 13 Oct 2023 15:57:42 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Dominique Martinet , Ilya Dryomov , Christian Brauner , 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-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cachefs@redhat.com Subject: [RFC PATCH 04/53] netfs: Allow the netfs to make the io (sub)request alloc larger Date: Fri, 13 Oct 2023 16:56:37 +0100 Message-ID: <20231013155727.2217781-5-dhowells@redhat.com> In-Reply-To: <20231013155727.2217781-1-dhowells@redhat.com> References: <20231013155727.2217781-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspamd-Queue-Id: E3B6DA0020 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: dcgudt6wpao4s6yfmswzsotnbuwy4j1c X-HE-Tag: 1697212678-913516 X-HE-Meta: U2FsdGVkX19SUAepZ55ei6u6CWR7NnuSczWhYoQmNObIx25MFG54AO7zKssJKBazAMKZ/02ZfOVhewpuRkFTXNulYnsfAU2HOqDdX9HyZwntKaKn3gTTd/0dMzNImcuGeN+KnWfP6hSrYPOeCK9cwIZoT78OB6ZN3jIsTPbzhD87juZH+7VMi7/QQmcSaz2POcKRQMxt4jgDkeuceKyK39DkJ6xQKbykKepjxlMeEScxttEMZWVkc3eKUfq29YCEX2oQ2N+tZc8pWWbqnPLzEk0PFF0A5dPzhB7m+OYiyGfPo6W6aBi3Q0d1cIEyNkQOTQ9Y2HNX+KQn/kfnXgexZq9PJi+h7uo0fFJdI3UbR+yLL0bz6RaE9NciNCJIRh2ZXC3TRU5FaIqaY0ZjNC3If7hXmoMth3ZtxFvzTxUTfSzuVau1dZJ/whsml4v/DaBQOb8WlkeawpSDHknb/eJdRbqn9Yg48V2vzs972HuZcvZgg4/QIiwjgp11ECZtGnO6di9c8IexHEBL8qF/0toQHIDR8y2sMZynIrz9sj9JaZWWzp9tccTbxTRDf6svT82U+2JJr89OmR2L5xc849nXaLdY+SUir13aM1PGvovlxl+0S2SKZO/0heANMUwrVV3SMnAG/GJx4MoGnix5lxfYztmZZJyWb68Krh7cWj8MjJowrivJyPwGlv/UIqFuiLRNo9kTWbOphWTlKIsxbOJcbe14IIi4HSPNQFkj5aLNvzyIZ+4Lr9zQ1KAm1zqDjEa9Wl9bdMeQvCnujzpkGAVEsCbpfAF1AQfAXhCg2zUK4/GFCrQmwH+8p1V+ZTJRA6sjYC8dq6tYTNmdivRIpXmr6EC71fGxxwhFEDZe425nt8W5Id3TCTqHshwfW6gQhBVrlUSGAPT+w69XTGaDjuo1yGCm1PGQBwFLdryPPAR3p2q2DOkDb+3LJ5XdQBHL0EpBTy/M/16iS3p6x/FxX1x L8yNNGrU Vpx5eU8w+sOTDpSXe9vf75foWNaXgNY834rXrq4PluSitUXqwQHWzi2nZCWTabipkixng/IT+LIxforgh4BuFwpQwPyYsbMXHuKVph3q7LLWrkjvU0D05NxBs9vsEzRgT3MXM4QOfbiu5iiOmWmJDgbfYD8XPxKC8vaojgnr+VksSSuJKU/yfazRJZ7qLilEouzJ6kd8NXV6yxySOas8BW2dKqx2ChZnku3vCAeC87hXVUjIk9PN4WCBc0cyU+rv5kk5OJpGfsbQiq44VGitcA95bFKKz1P/5sbJXzZf4F5Muw8o= 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: Allow the network filesystem to specify extra space to be allocated on the end of the io (sub)request. This allows cifs, for example, to use this space rather than allocating its own cifs_readdata struct. Signed-off-by: David Howells cc: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/netfs/objects.c | 7 +++++-- include/linux/netfs.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c index e41f9fc9bdd2..2f1865ff7cce 100644 --- a/fs/netfs/objects.c +++ b/fs/netfs/objects.c @@ -22,7 +22,8 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping, struct netfs_io_request *rreq; int ret; - rreq = kzalloc(sizeof(struct netfs_io_request), GFP_KERNEL); + rreq = kzalloc(ctx->ops->io_request_size ?: sizeof(struct netfs_io_request), + GFP_KERNEL); if (!rreq) return ERR_PTR(-ENOMEM); @@ -116,7 +117,9 @@ struct netfs_io_subrequest *netfs_alloc_subrequest(struct netfs_io_request *rreq { struct netfs_io_subrequest *subreq; - subreq = kzalloc(sizeof(struct netfs_io_subrequest), GFP_KERNEL); + subreq = kzalloc(rreq->netfs_ops->io_subrequest_size ?: + sizeof(struct netfs_io_subrequest), + GFP_KERNEL); if (subreq) { INIT_LIST_HEAD(&subreq->rreq_link); refcount_set(&subreq->ref, 2); diff --git a/include/linux/netfs.h b/include/linux/netfs.h index b92e982ac4a0..6942b8cf03dc 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -214,6 +214,8 @@ struct netfs_io_request { * Operations the network filesystem can/must provide to the helpers. */ struct netfs_request_ops { + unsigned int io_request_size; /* Alloc size for netfs_io_request struct */ + unsigned int io_subrequest_size; /* Alloc size for netfs_io_subrequest struct */ int (*init_request)(struct netfs_io_request *rreq, struct file *file); void (*free_request)(struct netfs_io_request *rreq); int (*begin_cache_operation)(struct netfs_io_request *rreq); From patchwork Fri Oct 13 15:56:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13421068 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 3346FCDB482 for ; Fri, 13 Oct 2023 15:57:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97EC28D0166; Fri, 13 Oct 2023 11:57:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E0C38D0015; Fri, 13 Oct 2023 11:57:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E5938D0166; Fri, 13 Oct 2023 11:57:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 542AE8D0015 for ; Fri, 13 Oct 2023 11:57:56 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 25F4E1CA8F2 for ; Fri, 13 Oct 2023 15:57:56 +0000 (UTC) X-FDA: 81340894152.27.BC54CE8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 5FDB7100026 for ; Fri, 13 Oct 2023 15:57:54 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Xjqm/caE"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697212674; 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=qZVSDRhH8TCwDqqtYYaWhbNXvdmkKJuIxH0fFLIHYlQ=; b=Pw40J6H8b53oxXJzadE8BoxZmrggC8Cvpk2M3BLPqP+L3EZpxtnBRKRkzc/R3eRCY2iIa1 jEgngNpet1UDpbZLJrOUHgzUnTCy3mvZbwuQIVPSNoL3Q8Sti9RRcf2oFT1ptP3JEaTXOI Js2lRm0hEk7wRTFLsqRiZuF0kZOboKY= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Xjqm/caE"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697212674; a=rsa-sha256; cv=none; b=AD4LZdgVjLh8ielbDjQBxjxRT67SJiY+vDAO6N1zy8MFpMwtRqpj79iZPBNAs7ZoAyzORw hPhwOY6+Od8AlXJLs9yViU32OYQfjkVZsVWvsiN/RI5R/r/2L/YVRs4/vi8E7h+UOsx8jP f1JKOE8yB75cGBMC/Gcy9Ucp3k1HoIs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697212673; 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=qZVSDRhH8TCwDqqtYYaWhbNXvdmkKJuIxH0fFLIHYlQ=; b=Xjqm/caEqoVCdgkLwF3qgy581w0W84j8pIGCpCqS3Q0NcdMGSpOVZmN2WjoEaMdvB175PP 7w1PehKmrENrN5s/iB5eJrP4/wGO7Wd/qidpK765hcnEF4Q2zqkuB7rvOkBr6JFXGDSvxa XtKclf9JprTrmiPhq5OgH83acMNE1II= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-358-qqDjH4-bPva_BatiZBcR7A-1; Fri, 13 Oct 2023 11:57:50 -0400 X-MC-Unique: qqDjH4-bPva_BatiZBcR7A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26A151E441D8; Fri, 13 Oct 2023 15:57:49 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63FD71C06535; Fri, 13 Oct 2023 15:57:46 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Dominique Martinet , Ilya Dryomov , Christian Brauner , 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-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cachefs@redhat.com Subject: [RFC PATCH 05/53] netfs: Add a ->free_subrequest() op Date: Fri, 13 Oct 2023 16:56:38 +0100 Message-ID: <20231013155727.2217781-6-dhowells@redhat.com> In-Reply-To: <20231013155727.2217781-1-dhowells@redhat.com> References: <20231013155727.2217781-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5FDB7100026 X-Stat-Signature: gpyhnmiyah51wtkyqcbo8pyxrhzqpkju X-HE-Tag: 1697212674-277427 X-HE-Meta: U2FsdGVkX19a+g+zwYQouQJJ1Ymb66UlvNcDi+bBp8iZfXzuhzUXIZJZS51jxswcNSTBOvzbW00JEjptXHBm3hwKY1sJ4jlp02PrXzSRnecH6GCyaEK+PKhYyFHLoYJnmoMGSIBBaN9rUk4cHrKDCOPWv8nXozNLV/T4iSPEf3dLuOUMx+NenfxNiEjGkR2LGFc/7NF75TOu/n1xSdtX3WuKqdU3OJAY2PbH6YDQx6CyQgg+GOSkASxV2UpTuecC2K6Kt+7kyi/7mTGmCysExupHDt1lQCO/vzUmgMVXisL66gTfclmFNxxer5Qy2VzcZqpK4GIi7u9tPb8UGLpg4s9ArzMmbhtZR0zkZJ+Fq/Anwyq4RAQ8g7VhffJ6tKWeooCSPS0KdcMUWperdsghnJd2nVOAR1eQd8XYay65StCoqCWHHAmMqpP3vN+JWw7F1MnDthd1uzeke3bSV5hfE9+CfaoQE/YfWAwQjb2ECwcCzNIbWjC82xPexk2LIDmtrRMKTt7zxM4oOPrQqr70vZWnOBJs3aOWcRjyg0jZUdW9KdU2/bQG1ETK0T4JHU5r/8Uo1KknytSEsVTPDDs7qHTN1TmMP/jCMMuaXse1sMNWzy/HGR2IV32rj9Za8VvMix1r/qBkiBCfbqpgN1Yd68tnM+YAeigrUykcnC+XCKZ5x4acrB83F4RgMelx64fA0LXyDNfn2STtWQ5GT++ULOOsPO8DNKDSbhIDjQRazc98P/zf/gLx7bf12nlvs1GMccQfJ7wOcIXMG9KFO3iVr4wj0LS6+pu+G8BLb7Z6nK1qiC2DiVsZiBmnD3HUFqMT6eHfq1Hcjy7e6muP85lcMF1H7gPa5dgG6Z9D5L+yBZLxyxiEsKtAJyeHErod3O29DJ4+DmyhWBd5fWCikzX7mTJ4nYPMb5G+tzICSBoa3x0SpkoMMO4AmUnfGVB1TDrPoxOAcFOtnetFXRDta5R h7d9dK35 ydAFcLh+uQ6PgBuzp1OdrX65bDb6JcGQ+oewVk7qOK9QQDOqZYvPuWpR0nURJHWXI7E6k2UUWnSmujKUg2ODuN6FPYdrmjRY/yIOXyBO9ClB514QKbylSq7wZYvef1ngPOFYXy5/Vto/cjpb5qvkThoFclEmEJnb4ZrwMxi8Ue748Vakk1xSZWPQlgfKZtxflQtV1NdVvXa41Q4AVsILB0M544tiwGIeMQNWhFwRrR1800u8PWXrkIcjMvrLq1eFeVBH3QmywE4eSfFYsGgsyCuTESG4wJ+4rGOrI/1NNNkn4L0mq5XxhdmrQVfoiWv41PEDhxy9T4ZqwDI7IIuIAirV9lA== 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: Add a ->free_subrequest() op so that the netfs can clean up data attached to a subrequest. Signed-off-by: David Howells cc: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/netfs/objects.c | 2 ++ include/linux/netfs.h | 1 + 2 files changed, 3 insertions(+) diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c index 2f1865ff7cce..8e92b8401aaa 100644 --- a/fs/netfs/objects.c +++ b/fs/netfs/objects.c @@ -147,6 +147,8 @@ static void netfs_free_subrequest(struct netfs_io_subrequest *subreq, struct netfs_io_request *rreq = subreq->rreq; trace_netfs_sreq(subreq, netfs_sreq_trace_free); + if (rreq->netfs_ops->free_subrequest) + rreq->netfs_ops->free_subrequest(subreq); kfree(subreq); netfs_stat_d(&netfs_n_rh_sreq); netfs_put_request(rreq, was_async, netfs_rreq_trace_put_subreq); diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 6942b8cf03dc..ed64d1034afa 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -218,6 +218,7 @@ struct netfs_request_ops { unsigned int io_subrequest_size; /* Alloc size for netfs_io_subrequest struct */ int (*init_request)(struct netfs_io_request *rreq, struct file *file); void (*free_request)(struct netfs_io_request *rreq); + void (*free_subrequest)(struct netfs_io_subrequest *rreq); int (*begin_cache_operation)(struct netfs_io_request *rreq); void (*expand_readahead)(struct netfs_io_request *rreq);