From patchwork Fri May 19 07:40: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: 13247776 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 3E918C77B7F for ; Fri, 19 May 2023 07:42:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B84F890001D; Fri, 19 May 2023 03:42:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B34F3900003; Fri, 19 May 2023 03:42:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D4CF90001D; Fri, 19 May 2023 03:42:21 -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 87249900003 for ; Fri, 19 May 2023 03:42:21 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 56F2C80991 for ; Fri, 19 May 2023 07:42:21 +0000 (UTC) X-FDA: 80806211682.18.B85D490 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 92390C000B for ; Fri, 19 May 2023 07:42:18 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=auxAEAlw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1684482138; 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=gBG1rbAQ+/pvrFxoUU2GMJeglrqrT3cq++hcE5SQo7w=; b=nD2CAncEWgrZsdmMYbDp6p/vmxZn8jKTwYwlbBYxf1wqvtBKtavQhjIbhVi9b5u5liaRq1 atHbs4kppR7U3WTH/Av++5zrSC8r3eAyvqikRKXZ9lnKZVej3OhUq97VDEyR3u5eWupkUD cs0PANCQPDU6VbYiXq7DWWna8TdT+AE= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=auxAEAlw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684482138; a=rsa-sha256; cv=none; b=pM4eOuDwu9Kexy+ihhlFmcO6e6KdgcXq+AibjufzOe9rgNVxWWcRwthve7NMGXSlTGClM9 3+/3gUa3arHIJpmZhkbDR21A9j40B4nHCwdOozfbgChPSocdG9D/9zYBXd4l1huLnV1YeN iGsWz4iZNUv/JM+BKUdc8L1tbzD8wpI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684482137; 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=gBG1rbAQ+/pvrFxoUU2GMJeglrqrT3cq++hcE5SQo7w=; b=auxAEAlwthRjC6xSIlM/ZpgRq1TpplkHsMleVoLeA5Lg2NvLq90AmP7LWovhBuNss6Mt7S Jv+nPgQDe9H0mBZdEro8Y+m8m11EmF4gyesoAE/IPX8Rg/M0MIUmoqD28s81HJPKPUbU3H wBj41jSAHZ7/wxBTMCK/xgBHkG9wjy0= 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-465-_MfV9O_bPYGXDbkMXz1GRA-1; Fri, 19 May 2023 03:42:06 -0400 X-MC-Unique: _MfV9O_bPYGXDbkMXz1GRA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0AF585A5BA; Fri, 19 May 2023 07:42:05 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 505E5C0004B; Fri, 19 May 2023 07:42:03 +0000 (UTC) From: David Howells To: Jens Axboe , Al Viro , Christoph Hellwig Cc: David Howells , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , Mark Fasheh , Joel Becker , Joseph Qi , ocfs2-devel@oss.oracle.com Subject: [PATCH v20 19/32] ocfs2: Provide a splice-read stub Date: Fri, 19 May 2023 08:40:34 +0100 Message-Id: <20230519074047.1739879-20-dhowells@redhat.com> In-Reply-To: <20230519074047.1739879-1-dhowells@redhat.com> References: <20230519074047.1739879-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 92390C000B X-Stat-Signature: w7yn48am9zrknszzhsd77hm6ztj8hnc6 X-HE-Tag: 1684482138-793890 X-HE-Meta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If0lMq9J5rgXzXx5KAGAGRjBmH3OLBKb1u3NlIoWc+MlG1vMTMGG30KZQtiyDvNj9UMIY2lu8n+RjLw9RqQm8hPJM91jFGbNW9Z8IYE4bSi5/Rx3GIf8h2p4e2O9Brh/ope2/pwU4Ynpkb6+XEw3+lcJO3bDOXTZlOU3/nP7rJIVrWxlm73uBoG5jgG/Vt1VbuomIKO0NS2kuxbtSvKmRq0PaZFgUqhqvvk8dPrJ1lDZ9jtFYL1tFjP/fx5WGfquvUdosTD40KQhGO68Yd+fbpmGPS6WipqFG9gYk4/6XnCMSiKOCxQdw/cfYFgQegRnp6ENHFbZSqPI0slo/HuX43Azd7CPiMXl8zknAi8hWP+nAOASkl+igWwr+NtB+9JZPzF0l7MwHLuAZH/xhWSyZgon6GjtQK0L9Yx66peHfICusgStcZL8= 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: Provide a splice_read stub for ocfs2. This emits trace lines and does an atime lock/update before calling filemap_splice_read(). It doesn't do this for around direct_splice_read() as that will call ->read_iter(). A couple of new tracepoints are added for this purpose. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Mark Fasheh cc: Joel Becker cc: Joseph Qi cc: ocfs2-devel@oss.oracle.com cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/ocfs2/file.c | 42 +++++++++++++++++++++++++++++++++++++++++- fs/ocfs2/ocfs2_trace.h | 3 +++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index efb09de4343d..27c54a71ec57 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2581,6 +2581,46 @@ static ssize_t ocfs2_file_read_iter(struct kiocb *iocb, return ret; } +static ssize_t ocfs2_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = file_inode(in); + ssize_t ret = 0; + int lock_level = 0; + + trace_ocfs2_file_splice_read(inode, in, in->f_path.dentry, + (unsigned long long)OCFS2_I(inode)->ip_blkno, + in->f_path.dentry->d_name.len, + in->f_path.dentry->d_name.name, + 0); + + if (in->f_flags & O_DIRECT) + return direct_splice_read(in, ppos, pipe, len, flags); + + /* + * We're fine letting folks race truncates and extending writes with + * read across the cluster, just like they can locally. Hence no + * rw_lock during read. + * + * Take and drop the meta data lock to update inode fields like i_size. + * This allows the checks down below generic_file_splice_read() a + * chance of actually working. + */ + ret = ocfs2_inode_lock_atime(inode, in->f_path.mnt, &lock_level, true); + if (ret < 0) { + if (ret != -EAGAIN) + mlog_errno(ret); + goto bail; + } + ocfs2_inode_unlock(inode, lock_level); + + ret = filemap_splice_read(in, ppos, pipe, len, flags); + trace_filemap_splice_read_ret(ret); +bail: + return ret; +} + /* Refer generic_file_llseek_unlocked() */ static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int whence) { @@ -2744,7 +2784,7 @@ const struct file_operations ocfs2_fops = { #endif .lock = ocfs2_lock, .flock = ocfs2_flock, - .splice_read = generic_file_splice_read, + .splice_read = ocfs2_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = ocfs2_fallocate, .remap_file_range = ocfs2_remap_file_range, diff --git a/fs/ocfs2/ocfs2_trace.h b/fs/ocfs2/ocfs2_trace.h index dc4bce1649c1..b8c3d1702076 100644 --- a/fs/ocfs2/ocfs2_trace.h +++ b/fs/ocfs2/ocfs2_trace.h @@ -1319,6 +1319,8 @@ DEFINE_OCFS2_FILE_OPS(ocfs2_file_splice_write); DEFINE_OCFS2_FILE_OPS(ocfs2_file_read_iter); +DEFINE_OCFS2_FILE_OPS(ocfs2_file_splice_read); + DEFINE_OCFS2_ULL_ULL_ULL_EVENT(ocfs2_truncate_file); DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_truncate_file_error); @@ -1470,6 +1472,7 @@ TRACE_EVENT(ocfs2_prepare_inode_for_write, ); DEFINE_OCFS2_INT_EVENT(generic_file_read_iter_ret); +DEFINE_OCFS2_INT_EVENT(filemap_splice_read_ret); /* End of trace events for fs/ocfs2/file.c. */