From patchwork Thu Mar 28 16:34:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13609089 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 4D8FBCD1283 for ; Thu, 28 Mar 2024 16:38:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D05216B00BF; Thu, 28 Mar 2024 12:38:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB62B6B00C1; Thu, 28 Mar 2024 12:38:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2FB66B00C2; Thu, 28 Mar 2024 12:38:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8E75F6B00BF for ; Thu, 28 Mar 2024 12:38:32 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5F63C160662 for ; Thu, 28 Mar 2024 16:38:32 +0000 (UTC) X-FDA: 81947006064.15.9293F0C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id CCC2B1C000A for ; Thu, 28 Mar 2024 16:38:30 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OhY3Q6Ka; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1711643910; 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=PtpBbjrD+Slaag5TH6kef/+TLI8uFihL8QWdtpo1kX0=; b=M0fKRPu8NQWFDmHg+ytHbtXqXqmAluE8jr08U9xKYknukV87CFVFzgAWuUX570+IO70okg MMrQmsqD384oOYC80hJBdNey+b/zrO69Z55sVzcAwJc+0reWPlqIDVbubBn1uNdxyQRYyC gWN9SVr4RLxf2VGxreaJhpp5hxUPLSQ= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OhY3Q6Ka; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1711643910; a=rsa-sha256; cv=none; b=nW8+A29pUmtFScuTUGToXdViKR9nqZVQe+xsnlM2nB+0CD6Zh50aZCt2mR3sBcE8kjTdxJ soN1DhjWQYnAUeLXvhb50Kq0OoG0AbBrdKydz9SWYoWSE06rxfz5GW3Ze+Ya6FWRzJRls2 fWz9ted8CkIMAp48/Sv0ou+YOfsKOg4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711643910; 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=PtpBbjrD+Slaag5TH6kef/+TLI8uFihL8QWdtpo1kX0=; b=OhY3Q6Ka5FXIs3VMY6/9zq8uzuEFaU5u2BVv4reMaoh9v+aT+z2gVo7x5FS8L77ECdyzvH ht0lxPwKdXkJ4YQJQT+00nzvfCmsVU0W9kQ0RDy6amoHFK4GkjMXAVmUpyIm6yJXSvCBcM CFkemv6PIPq3dHi0c6IACrQDW7bVqUc= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-64-Lg6OOJb5N_K3mFAM9aV-nw-1; Thu, 28 Mar 2024 12:38:24 -0400 X-MC-Unique: Lg6OOJb5N_K3mFAM9aV-nw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC9A629AC002; Thu, 28 Mar 2024 16:38:23 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id EED572166B35; Thu, 28 Mar 2024 16:38:20 +0000 (UTC) From: David Howells To: Christian Brauner , Jeff Layton , Gao Xiang , Dominique Martinet Cc: David Howells , Matthew Wilcox , Steve French , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, linux-cachefs@redhat.com, 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 20/26] netfs, afs: Implement helpers for new write code Date: Thu, 28 Mar 2024 16:34:12 +0000 Message-ID: <20240328163424.2781320-21-dhowells@redhat.com> In-Reply-To: <20240328163424.2781320-1-dhowells@redhat.com> References: <20240328163424.2781320-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CCC2B1C000A X-Stat-Signature: emot7zn661539riez76dw5rcdhcysaca X-HE-Tag: 1711643910-341389 X-HE-Meta: U2FsdGVkX18DPW+tCJM64MuxaP37Cjh43OMNYaXARbo0X2+o0U7GpyukrQRex6TAy9OKvaVJqWRgzGfH5UJBKaYFaHB+tEFXNNSn7tgQjuXWmpDkEItcESbeSzVELVTp+cZI47DtOgrmnt3L4xxbMmpXs4HuwEZsC4JbPmjpYKScYc+fu+an1fgZ9099+WOogPzuWzgAVvOI6gLoQbRVpKaJWyqSD+JUG5JBoQwEpw2QIXfBouo1mJKsJ+qaozHtFH+zw5iEtmd/0HIjasFQeakxhzVgTxhYSdP2MbXbzx3bJJJoNpzrgaQEsS8nA2W8Cs7Xvy+zwMdPnkHsvJCAh8guiVAaPyUva/19yeLZrd7O7D0CTVXAb5Ye9SKoUIFLRcFKdgImubcH4VWdOtl3EGdzA57nOaDSuQm90pv+oMgvOhH/qbZShiu3xy9W4MIgiWqIj/PvS5YJOc88WF+O522Il3QMmqBB8WP9LnZC7lHVXSV2Nli2m3peCwFkni/yKVrpPrpXulYtLpxZlxATciUhtdG0a5rmxkurWJLVMzG7ex/O5sG508bbU2deWDsJkckKiCuLWt6Hfr+85kFMBH3p/zeW2QsyElpqVtwOz6Xt3E1hSoW9Nz31M37BNHmWsTan64BgmWrgpkXH7Zhk/wfuKaLMiZCVHvANSx7XhQdOgkhFI5dgOzK9yziCk0SQW0H22CJyX6lDz4dwIEMmZaOLmdZTRDycLLwt7zDX+2m3YOdO1z0UMIi8OCO3T73PJjJz6lKvYjkwvwWJZblYVD0cPRlo+WxDfkO1lCv6VLvn4blRWmXSJj3u/9UmxIgHz5GUdG9KMl9tcONGV0nkzNyppae/3I6Hbxbv3zNMn3T1gDFaGLHLKuvSeSi560wsdTEhGCN50JimWKXR+SXftw== 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: Implement the helpers for the new write code in afs. There's now an optional ->prepare_write() that allows the filesystem to set the parameters for the next write, such as maximum size and maximum segment count, and an ->issue_write() that is called to initiate an (asynchronous) write operation. Signed-off-by: David Howells cc: Marc Dionne cc: Jeff Layton cc: linux-afs@lists.infradead.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/afs/file.c | 3 +++ fs/afs/internal.h | 3 +++ fs/afs/write.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/fs/afs/file.c b/fs/afs/file.c index dfd8f60f5e1f..db9ebae84fa2 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -400,6 +400,9 @@ const struct netfs_request_ops afs_req_ops = { .update_i_size = afs_update_i_size, .invalidate_cache = afs_netfs_invalidate_cache, .create_write_requests = afs_create_write_requests, + .begin_writeback = afs_begin_writeback, + .prepare_write = afs_prepare_write, + .issue_write = afs_issue_write, }; static void afs_add_open_mmap(struct afs_vnode *vnode) diff --git a/fs/afs/internal.h b/fs/afs/internal.h index b93aa026daa4..dcf0ae0323d3 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -1598,6 +1598,9 @@ extern int afs_check_volume_status(struct afs_volume *, struct afs_operation *); /* * write.c */ +void afs_prepare_write(struct netfs_io_subrequest *subreq); +void afs_issue_write(struct netfs_io_subrequest *subreq); +void afs_begin_writeback(struct netfs_io_request *wreq); extern int afs_writepages(struct address_space *, struct writeback_control *); extern int afs_fsync(struct file *, loff_t, loff_t, int); extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf); diff --git a/fs/afs/write.c b/fs/afs/write.c index 1bc26466eb72..89b073881cac 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -194,6 +194,52 @@ void afs_create_write_requests(struct netfs_io_request *wreq, loff_t start, size netfs_queue_write_request(subreq); } +/* + * Writeback calls this when it finds a folio that needs uploading. This isn't + * called if writeback only has copy-to-cache to deal with. + */ +void afs_begin_writeback(struct netfs_io_request *wreq) +{ + wreq->io_streams[0].avail = true; +} + +/* + * Prepare a subrequest to write to the server. This sets the max_len + * parameter. + */ +void afs_prepare_write(struct netfs_io_subrequest *subreq) +{ + //if (test_bit(NETFS_SREQ_RETRYING, &subreq->flags)) + // subreq->max_len = 512 * 1024; + //else + subreq->max_len = 256 * 1024 * 1024; +} + +/* + * Issue a subrequest to write to the server. + */ +void afs_issue_write(struct netfs_io_subrequest *subreq) +{ + struct afs_vnode *vnode = AFS_FS_I(subreq->rreq->inode); + ssize_t ret; + + _enter("%x[%x],%zx", + subreq->rreq->debug_id, subreq->debug_index, subreq->io_iter.count); + +#if 0 // Error injection + if (subreq->debug_index == 3) + return netfs_write_subrequest_terminated(subreq, -ENOANO, false); + + if (!test_bit(NETFS_SREQ_RETRYING, &subreq->flags)) { + set_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); + return netfs_write_subrequest_terminated(subreq, -EAGAIN, false); + } +#endif + + ret = afs_store_data(vnode, &subreq->io_iter, subreq->start); + netfs_write_subrequest_terminated(subreq, ret < 0 ? ret : subreq->len, false); +} + /* * write some of the pending data back to the server */