From patchwork Mon Dec 16 20:41:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13910512 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 1E35FE7717F for ; Mon, 16 Dec 2024 20:45:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A50F36B0088; Mon, 16 Dec 2024 15:45:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DC436B0092; Mon, 16 Dec 2024 15:45:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82C376B00CB; Mon, 16 Dec 2024 15:45:26 -0500 (EST) 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 5E1436B0088 for ; Mon, 16 Dec 2024 15:45:26 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 29433403CE for ; Mon, 16 Dec 2024 20:45:26 +0000 (UTC) X-FDA: 82902001476.25.0CB636C 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 973701C001A for ; Mon, 16 Dec 2024 20:44:27 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hHVvsw6D; 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=1734381896; a=rsa-sha256; cv=none; b=IvdslTOGXBbH2HvUlTgqyOON6geo/+mkMTKm5jZIY55l8k4B9d7k9YwyDV0FARv2JYtzye Y8MVzOn5TKUUcQIAM1z66flY2IA4/IouWc4ThRClFyg5fKvmfzsr3sug4D1B2wI5G9gQos QOtpd6SQrRqezL8K9VW8d9o9wDDjcfk= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hHVvsw6D; 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=1734381896; 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=tEzD3zUTWB1Bg8PHINLRIS5r3x8xGDihu370HSpHsX8=; b=t45mC7PPE2vph0v8viYMMaeBXQmyyhA7oFhYHvoi3bw8MO+17rckUzDryDsjtYdm0D2vCp 73ahUbpEGqpR21zF7LBzDc8HJef664Eu/Ifb7TEN7QvNIUykqYWoyOF10mew/xFbhyrjwZ uaYl0Nvd5H/To71ZMeB63fl2+rrH6DM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734381923; 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=tEzD3zUTWB1Bg8PHINLRIS5r3x8xGDihu370HSpHsX8=; b=hHVvsw6DJqI1vLbBm4gAbU1G/BK00Y/GkOZFHF7gCoN9NajrN1z7rmoRc3JajMLOVrnvPv /jDjsW4bAptyCcel3dGHUCZYAIFtsvL9PBinnWQFB1aSqQbT+o2L/IzSXs6CIdvKY9YMGA YUJmckfhTTybEekyfdyUIQ1M9eFBmCQ= Received: from mx-prod-mc-04.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-122-4QQLR56CPmezclSCruvjEQ-1; Mon, 16 Dec 2024 15:45:18 -0500 X-MC-Unique: 4QQLR56CPmezclSCruvjEQ-1 X-Mimecast-MFC-AGG-ID: 4QQLR56CPmezclSCruvjEQ Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 16CBB1955DE0; Mon, 16 Dec 2024 20:45:14 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.48]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8EE4019560A3; Mon, 16 Dec 2024 20:45:08 +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 v5 30/32] afs: Locally initialise the contents of a new symlink on creation Date: Mon, 16 Dec 2024 20:41:20 +0000 Message-ID: <20241216204124.3752367-31-dhowells@redhat.com> In-Reply-To: <20241216204124.3752367-1-dhowells@redhat.com> References: <20241216204124.3752367-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Stat-Signature: 8w63w6x5tydyc9ygsd393nh464wiwoad X-Rspam-User: X-Rspamd-Queue-Id: 973701C001A X-Rspamd-Server: rspam08 X-HE-Tag: 1734381867-579229 X-HE-Meta: U2FsdGVkX1+beZmCUTFzTf0WGo9/ji0nqeAPzYHb+0n4MNYQVdoCwWK3C3VLJpNMmaVErEUEysAV8yOiEFF2O57+tGYmFGCfOoTUjphpEXxpICZo56wRPlvPuwyX2Q9tdHIwCvpKhkGWDptGQkRjVCY07+2POuBs9DFNgRHXuqUCe7ggmS0xo4FGSYfHhBe4uHoG9xfoaD9jhZNHTAM+R9SYZBrjGZKlfhVGizO61IFn2t+oACyJ2Uen332TZn0YepoUHs+KzwbwnjKMzLgEpnL0GuPjfRIM9bXheOlCmRBuy6EvrN24Mdcz8yPvAAszDRlQZQboRGZrKpxrJ7ZAoikVHuTigVOgjXIXO0wwcMXmQqROwQtnZ5zBLiasP9PZYn39oKoEK/OsRbUlixjO5Qt4uQW7MNfblsbsjdQd3Ar4A4+Ry+j60TXKeBbmRBj0ngoAiqaaqhDat5mPDiJO6qo/8LxGQjiONWq9rRJ42Tg1Xf0zCj8mlsql89Ng87k/tNvrQ+NM+lrSLCVX+IGWDGO1HFwPlOCCG3wVkpHslzR1NgmaNcudxz02/1q/ffzYbO2qnPwcg2ngMBFDkqqYf8kck66GgRcWBoKSGwfzKp/jtJVoYYyR4CyiHp+ZfFFQhwZzSDSMnUJxdWyM4mAE2JbwDmKXOpZNAMZfqVmbV+saoNn0eCtLP9KPgO9YlY5f65XHtpIir1UaD/FJL/CvM3rCuFq+js2hqK+RtuKByRwS7MfOXYfC8lpIUU4FxePFRszSq6MJ7P2ncrdT8vsjyNJ357sFELIZiQUOM7BFboYk8jwTbKK8js4FL1/DQ61kZ79PGeB+1+x4uLeYC+nTRA5PaDzSv7hoW24am1dBr2rVHTX9t4S9jFy1i2NTgAmYDUW4GI6vM7S7vFrqEzXn9NJBS0v3570vC0ClTMswDAd89haoptL8tBV5WqNWspw5kDs15GXSf0w0RxZt7F2 GA8HCMmj RWk6KJK4vi2CVnO4fnF05zbdqXlk9BQd0KWdt4YiUa6gIqVkHzg+TmzU1bMfk+vMcZEHMV96gbFN69B3SnKJKjtfKRMdpP0knsFCin5pbFHTH+8u7YfuOxbcx7l3dC1gH1DnI7Pf0gE5zEXIRdV9kMDioC+863TgCZTNyaBu6j+jFhmAOWkmwIsBVVJheU4uNuONj1ZzJVOk9ano5+z0jXKAnXMaJoo/ShT/b8KaoLGRWXvbTuSaU1KnWy5kE4v5IBwh2MW7E/XyUZVeaMZE1yHeXhMMJujDHRT3hmfbLNLkOB6C2Xh/Muvw+eJzLNUFQ9PVd2icuqd5ILE4KtctfYBtVFQgLBYkcvE5Uftf41j4KhF5iviuCQ2nrIXck3Pr53wEkrcaV6I9A7KdDOTKHbpvoZekoiUYtX4LKUyvprjPojzgW7+Dk3stb0LS/Siwr3i1J 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: Since we know what the contents of a symlink will be when we create it on the server, initialise its contents locally too to avoid the need to download it. Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/dir.c | 2 ++ fs/afs/inode.c | 46 ++++++++++++++++++++++++++++++++++------ fs/afs/internal.h | 1 + fs/netfs/buffered_read.c | 2 +- fs/netfs/read_single.c | 2 +- 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index dd0c98d25270..a843c36fc471 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -1276,6 +1276,8 @@ static void afs_vnode_new_inode(struct afs_operation *op) set_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags); if (S_ISDIR(inode->i_mode)) afs_mkdir_init_dir(vnode, dvp->vnode); + else if (S_ISLNK(inode->i_mode)) + afs_init_new_symlink(vnode, op); if (!afs_op_error(op)) afs_cache_permit(vnode, op->key, vnode->cb_break, &vp->scb); d_instantiate(op->dentry, inode); diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 0e3c43c40632..e9538e91f848 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -25,6 +25,24 @@ #include "internal.h" #include "afs_fs.h" +void afs_init_new_symlink(struct afs_vnode *vnode, struct afs_operation *op) +{ + size_t size = strlen(op->create.symlink) + 1; + size_t dsize = 0; + char *p; + + if (netfs_alloc_folioq_buffer(NULL, &vnode->directory, &dsize, size, + mapping_gfp_mask(vnode->netfs.inode.i_mapping)) < 0) + return; + + vnode->directory_size = dsize; + p = kmap_local_folio(folioq_folio(vnode->directory, 0), 0); + memcpy(p, op->create.symlink, size); + kunmap_local(p); + set_bit(AFS_VNODE_DIR_READ, &vnode->flags); + netfs_single_mark_inode_dirty(&vnode->netfs.inode); +} + static void afs_put_link(void *arg) { struct folio *folio = virt_to_folio(arg); @@ -41,15 +59,31 @@ const char *afs_get_link(struct dentry *dentry, struct inode *inode, char *content; ssize_t ret; - if (atomic64_read(&vnode->cb_expires_at) == AFS_NO_CB_PROMISE || - !test_bit(AFS_VNODE_DIR_READ, &vnode->flags)) { - if (!dentry) + if (!dentry) { + /* RCU pathwalk. */ + if (!test_bit(AFS_VNODE_DIR_READ, &vnode->flags) || !afs_check_validity(vnode)) return ERR_PTR(-ECHILD); - ret = afs_read_single(vnode, NULL); - if (ret < 0) - return ERR_PTR(ret); + goto good; } + if (test_bit(AFS_VNODE_DIR_READ, &vnode->flags)) + goto fetch; + + ret = afs_validate(vnode, NULL); + if (ret < 0) + return ERR_PTR(ret); + + if (!test_and_clear_bit(AFS_VNODE_ZAP_DATA, &vnode->flags) && + test_bit(AFS_VNODE_DIR_READ, &vnode->flags)) + goto good; + +fetch: + ret = afs_read_single(vnode, NULL); + if (ret < 0) + return ERR_PTR(ret); + set_bit(AFS_VNODE_DIR_READ, &vnode->flags); + +good: folio = folioq_folio(vnode->directory, 0); folio_get(folio); content = kmap_local_folio(folio, 0); diff --git a/fs/afs/internal.h b/fs/afs/internal.h index b7d02c105340..90f407774a9a 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -1221,6 +1221,7 @@ extern void afs_fs_probe_cleanup(struct afs_net *); */ extern const struct afs_operation_ops afs_fetch_status_operation; +void afs_init_new_symlink(struct afs_vnode *vnode, struct afs_operation *op); const char *afs_get_link(struct dentry *dentry, struct inode *inode, struct delayed_call *callback); int afs_readlink(struct dentry *dentry, char __user *buffer, int buflen); diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index 0245943d974d..f761d44b3436 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -210,7 +210,7 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq) do { struct netfs_io_subrequest *subreq; - enum netfs_io_source source = NETFS_DOWNLOAD_FROM_SERVER; + enum netfs_io_source source = NETFS_SOURCE_UNKNOWN; ssize_t slice; subreq = netfs_alloc_subrequest(rreq); diff --git a/fs/netfs/read_single.c b/fs/netfs/read_single.c index 14bc61107182..fea0ecdecc53 100644 --- a/fs/netfs/read_single.c +++ b/fs/netfs/read_single.c @@ -97,7 +97,7 @@ static int netfs_single_dispatch_read(struct netfs_io_request *rreq) if (!subreq) return -ENOMEM; - subreq->source = NETFS_DOWNLOAD_FROM_SERVER; + subreq->source = NETFS_SOURCE_UNKNOWN; subreq->start = 0; subreq->len = rreq->len; subreq->io_iter = rreq->buffer.iter;