Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2387715rwd; Sun, 21 May 2023 20:12:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4+pR1wX2eDQvZo7PdqEtdXWMHN/52fYEuZnT1/qn4Y8CxI6DYJWto0JxiEnwfuVtz2IbHV X-Received: by 2002:a17:902:d353:b0:1ac:8ee4:5e1b with SMTP id l19-20020a170902d35300b001ac8ee45e1bmr9850961plk.14.1684725165892; Sun, 21 May 2023 20:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684725165; cv=none; d=google.com; s=arc-20160816; b=PeGs9HV2kuCfb0ZaB40uOoZfQP3Nm0hoY5D57CNVW3EGM0wI1lenRlSWFpobpQmD5S af29W151lctHGC4mKfyRybbXSO+9VOHW8MqzLiQTRTrfgu/p5lPWuYhVHk4w/7f35S5P o6WtPFaYO6D46/o58sOtyXaW9bBp6wKlY9iiugiWNOaSKy8MPySRaYdDLU+nm8IEDBKk m2Igx2BzDrM3BeBmrZd6RqoOxCVn5qTfs8a1v809NQAh0qTj2IkXphxOUbUcjffvRVqZ wCBrIHAwtrric8swQRQ+nNmUSySHc1xmoIY5eK4Rnu/eN0sh7mwfiEs/WsxXa4NRCGMC vJ9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=ELAESE1l2Rgi1Ij8umGR0ICbsV7NekHw+cPMVgNgJOU=; b=h4UmsJN7fIDsoXJ7+X1eckRgKx8louG1y0mMW/Sc3q+bBYEcy5pgP+NqgRdIjXLzwO xaZdq2mUgRooGhMM9SiKYayaT/nfmyrhcUE4dN62sjJ7b8nIYEYCJF6/R0xoIefqUFxY 0MGDYg5WDRcyjVmdUIf7V2zWNt0We2yc9iUSrEew7lZ93imSSo3EbOo99juHZ7EBZIGw y8qxNnZzUtr+gs1x6TjAKZanyIrNJ25mLpXZBqpoTO+iAM6XBCfNtMoxz0SjxGRlyFuI gR9jWaIiR+jS7k0PCi0sUjW3012kQT3zj0BFLxi2CNaXNnPjTIPENsl6cg38+9IPx/ZJ 9hRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a170902f39100b001ae4f2b8cfdsi727674ple.633.2023.05.21.20.12.33; Sun, 21 May 2023 20:12:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231255AbjEVCtl (ORCPT + 99 others); Sun, 21 May 2023 22:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbjEVCtk (ORCPT ); Sun, 21 May 2023 22:49:40 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58549C1; Sun, 21 May 2023 19:49:37 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0Vj6edsh_1684723770; Received: from 30.221.132.35(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0Vj6edsh_1684723770) by smtp.aliyun-inc.com; Mon, 22 May 2023 10:49:31 +0800 Message-ID: <376ab23b-52d0-d7fd-2dd9-414cbb474e01@linux.alibaba.com> Date: Mon, 22 May 2023 10:49:30 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v21 22/30] ocfs2: Provide a splice-read stub To: David Howells , Jens Axboe , Al Viro , Christoph Hellwig Cc: 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 , ocfs2-devel@oss.oracle.com References: <20230520000049.2226926-1-dhowells@redhat.com> <20230520000049.2226926-23-dhowells@redhat.com> Content-Language: en-US From: Joseph Qi In-Reply-To: <20230520000049.2226926-23-dhowells@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/20/23 8:00 AM, David Howells wrote: > Provide a splice_read stub for ocfs2. This emits trace lines and does an > atime lock/update before calling filemap_splice_read(). Splicing from > direct I/O is handled by the caller. > > 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 | 39 ++++++++++++++++++++++++++++++++++++++- > fs/ocfs2/ocfs2_trace.h | 3 +++ > 2 files changed, 41 insertions(+), 1 deletion(-) > > diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c > index efb09de4343d..f7e00b5689d5 100644 > --- a/fs/ocfs2/file.c > +++ b/fs/ocfs2/file.c > @@ -2581,6 +2581,43 @@ 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); Better also trace flags here. > + > + /* > + * 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 Now it calls filemap_splice_read(). > + * chance of actually working. > + */ > + ret = ocfs2_inode_lock_atime(inode, in->f_path.mnt, &lock_level, true); Since prototype is 'int wait', so directly passing '1' seems more appropriate. > + if (ret < 0) { > + if (ret != -EAGAIN) > + mlog_errno(ret); > + goto bail; > + } > + ocfs2_inode_unlock(inode, lock_level); > + Don't see direct IO logic now. Am I missing something? Thanks, Joseph > + 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 +2781,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. */ >