From patchwork Thu Apr 7 12:02:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 12805144 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D22CC433EF for ; Thu, 7 Apr 2022 12:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234578AbiDGMEb (ORCPT ); Thu, 7 Apr 2022 08:04:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbiDGME3 (ORCPT ); Thu, 7 Apr 2022 08:04:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 478AA6E2AE for ; Thu, 7 Apr 2022 05:02:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E95EFB8272A for ; Thu, 7 Apr 2022 12:02:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E5A7C385A8; Thu, 7 Apr 2022 12:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649332947; bh=IeQVMOtimVfHvfj7snNyZbLzYVRMMEd3hffcCETApJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=epHt4bh3dbz0aBAsUkqAmRNVIy58dhs08u3QNOgcnTBgYSeWHK0f9HCRrGBNcDhk3 YxoLEHtyXJFFFAbnO4878pZ6F5Gw0idYev8ntt2+Gx7nlhI+78vTLtZSZAV3fpGPUq FMBph2vo3LuWX/Y1/6nF3E+oZSSmLeGe5R5PHCP5wp9GPmg7z+5V/ViNyNr87/UTKx DJj/60fNNFKQX2HnSG+uibNe5njNY86qngnjtZ0MReilYP+aMzsWIv7ZnmYjRIT8q5 ZYMIsXkSzvdebZnlAdnvL3GLkCDY0u7G0aelmvT1ibvG8m3qoLs79j0W9pThIkfkRR O36BRer5brf8A== From: Jeff Layton To: ceph-devel@vger.kernel.org, dhowells@redhat.com Cc: idryomov@gmail.com, xiubli@redhat.com, linux-cachefs@redhat.com Subject: [RFC PATCH 1/5] netfs: don't error out on short DIO reads Date: Thu, 7 Apr 2022 08:02:20 -0400 Message-Id: <20220407120224.76156-2-jlayton@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407120224.76156-1-jlayton@kernel.org> References: <20220407120224.76156-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org There's no reason that userland can't request to read beyond the EOF. A short read is expected in that situation. Signed-off-by: Jeff Layton --- fs/netfs/io.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fs/netfs/io.c b/fs/netfs/io.c index aaaafc3e1601..b94f2d27127e 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -728,11 +728,6 @@ ssize_t netfs_begin_read(struct netfs_io_request *rreq, bool sync) } ret = rreq->error; - if (ret == 0 && rreq->submitted < rreq->len && - rreq->origin == NETFS_DIO_READ) { - trace_netfs_failure(rreq, NULL, ret, netfs_fail_short_read); - ret = -EIO; - } if (ret == 0) ret = netfs_dio_copy_to_dest(rreq); if (ret == 0) { From patchwork Thu Apr 7 12:02:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 12805147 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C808FC433EF for ; Thu, 7 Apr 2022 12:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238463AbiDGMEd (ORCPT ); Thu, 7 Apr 2022 08:04:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231937AbiDGMEa (ORCPT ); Thu, 7 Apr 2022 08:04:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20EB18BF01 for ; Thu, 7 Apr 2022 05:02:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9221FB82191 for ; Thu, 7 Apr 2022 12:02:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9AA9C385A0; Thu, 7 Apr 2022 12:02:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649332948; bh=8M9PvelXpi/voVPfiWCg+hio8GT7wj8QBNTnPOOTN74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qyFERYgofFl/JOiNSPPaicLx2qwdtKSwvbpUuzwaCzpjMJaYo1pgMKu244BID/1KP 2liV/tlI0Do7q5HUsk79Lof5PVXuF04p2cK6E9v3aQLTZRBYPfGW24n4dG8GPkqveH KEfrUDqH+f/yKYZCq59sgMSl8XCNxES9uQ9GoUjUyBpzUE+6cc+RXS7CjdLzYupP+u h35kzFf974YZ94BlpD3IiOZ1tGLywIJVrmPGH1equ9fv9IDAexB3GHROOTHizzVQxU FWsCVIda+rgt2bBn30riwmVeuncMpi95DHpxosMwjgZq7AxuQRNgqiFcrUBp5Rd6SE N2HgRCt1pXrUw== From: Jeff Layton To: ceph-devel@vger.kernel.org, dhowells@redhat.com Cc: idryomov@gmail.com, xiubli@redhat.com, linux-cachefs@redhat.com Subject: [RFC PATCH 2/5] ceph: set rsize in netfs_i_context from mount options Date: Thu, 7 Apr 2022 08:02:21 -0400 Message-Id: <20220407120224.76156-3-jlayton@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407120224.76156-1-jlayton@kernel.org> References: <20220407120224.76156-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Signed-off-by: Jeff Layton --- fs/ceph/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 1dad69a0ab70..8ea1b53b6ce9 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -450,6 +450,7 @@ static int ceph_fill_fragtree(struct inode *inode, */ struct inode *ceph_alloc_inode(struct super_block *sb) { + struct ceph_mount_options *fsopt = ceph_sb_to_client(sb)->mount_options; struct ceph_inode_info *ci; struct netfs_i_context *ctx; int i; @@ -463,7 +464,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb) /* Set parameters for the netfs library */ ctx = netfs_i_context(&ci->vfs_inode); netfs_i_context_init(&ci->vfs_inode, &ceph_netfs_ops); - ctx->rsize = 1024 * 1024; + ctx->rsize = fsopt->rsize; spin_lock_init(&ci->i_ceph_lock); From patchwork Thu Apr 7 12:02:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 12805148 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ADEDC4332F for ; Thu, 7 Apr 2022 12:02:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239456AbiDGMEe (ORCPT ); Thu, 7 Apr 2022 08:04:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238189AbiDGMEc (ORCPT ); Thu, 7 Apr 2022 08:04:32 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82E264BFE9 for ; Thu, 7 Apr 2022 05:02:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id A570ACE276A for ; Thu, 7 Apr 2022 12:02:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9311FC385A7; Thu, 7 Apr 2022 12:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649332949; bh=C9LKzvGddxGURnHej3cwZzuDZ5l9V5SoaPFXKTUgG20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YHRq6zzeiWx2R7pnc2Cp2KwWur+JtdwKw9Hws8lMbg8w5HwxCxpRIOShlcDftHW// HY4pn4OWP2USzSPO5sQTB9mbng82iz2jjuuUjxaTECxX9+T+BZn3emHEdpnl+tN5Jc Z/s++FKSgoBnkUmQUvnqIFPpROmz4XUDTqDadqW0sJ5xv63SnGPpVOpvz0XprbLSSv x03Y0pBCOF7D4OXiNUIr18+v9rjhfxRBG3s+T8S+lrbVP5m1I7f/vHcPjrF0T/FHZa jI31st5WWocysw6cz6w8oVG4ICQUms2hxWedu7eUch5dUc3UFvIJNjQfNpmnFnkIES CueVltFCQMLhg== From: Jeff Layton To: ceph-devel@vger.kernel.org, dhowells@redhat.com Cc: idryomov@gmail.com, xiubli@redhat.com, linux-cachefs@redhat.com Subject: [RFC PATCH 3/5] ceph: Use the provided iterator in ceph_netfs_issue_op() Date: Thu, 7 Apr 2022 08:02:22 -0400 Message-Id: <20220407120224.76156-4-jlayton@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407120224.76156-1-jlayton@kernel.org> References: <20220407120224.76156-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: David Howells The netfs_read_subrequest struct now contains a persistent iterator representing the destination buffer for a read that the network filesystem should use. Make ceph use this. Signed-off-by: David Howells Signed-off-by: Jeff Layton --- fs/ceph/addr.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index f0af362f8756..e7a7b5d29c7d 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -233,7 +233,6 @@ static bool ceph_netfs_issue_op_inline(struct netfs_io_subrequest *subreq) struct ceph_mds_request *req; struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb); struct ceph_inode_info *ci = ceph_inode(inode); - struct iov_iter iter; ssize_t err = 0; size_t len; @@ -266,8 +265,7 @@ static bool ceph_netfs_issue_op_inline(struct netfs_io_subrequest *subreq) } len = min_t(size_t, iinfo->inline_len - subreq->start, subreq->len); - iov_iter_xarray(&iter, READ, &rreq->mapping->i_pages, subreq->start, len); - err = copy_to_iter(iinfo->inline_data + subreq->start, len, &iter); + err = copy_to_iter(iinfo->inline_data + subreq->start, len, &subreq->iter); if (err == 0) err = -EFAULT; @@ -285,7 +283,6 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq) struct ceph_fs_client *fsc = ceph_inode_to_client(inode); struct ceph_osd_request *req; struct ceph_vino vino = ceph_vino(inode); - struct iov_iter iter; struct page **pages; size_t page_off; int err = 0; @@ -306,15 +303,14 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq) } dout("%s: pos=%llu orig_len=%zu len=%llu\n", __func__, subreq->start, subreq->len, len); - iov_iter_xarray(&iter, READ, &rreq->mapping->i_pages, subreq->start, len); - err = iov_iter_get_pages_alloc(&iter, &pages, len, &page_off); + + err = iov_iter_get_pages_alloc(&subreq->iter, &pages, len, &page_off); if (err < 0) { dout("%s: iov_ter_get_pages_alloc returned %d\n", __func__, err); goto out; } - /* should always give us a page-aligned read */ - WARN_ON_ONCE(page_off); + /* FIXME: adjust the len in req downward if necessary */ len = err; osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0, false, false); From patchwork Thu Apr 7 12:02:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 12805146 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F873C433FE for ; Thu, 7 Apr 2022 12:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238356AbiDGMEc (ORCPT ); Thu, 7 Apr 2022 08:04:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232114AbiDGMEa (ORCPT ); Thu, 7 Apr 2022 08:04:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D264BF52D for ; Thu, 7 Apr 2022 05:02:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 01C5161EE9 for ; Thu, 7 Apr 2022 12:02:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AEB8C385A4; Thu, 7 Apr 2022 12:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649332949; bh=CPa5JPmMCr2as2BhwpEOLP8cez+M0rhvf4j7pKVjsMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QTuebCXLPwv12472hf9b9c+j5UxzczO0hACqxTvomMIJJ+nO0gDErfd3c+dEVxmqh nOirJvXAKW6paF3KIEUq1Hc9l2KYzg6j+9iKil8O4nnWU1rO+4A9U65K2WM6NF9wZ8 GDHVJImB20B0v1AFYgSB28y5a9gFEaJABCssTCmawKHnOksz0z8rWQWc/Y5bUTVb6l dqqWy8uOk/g+oUt5z5mQaDDxF62KU2LUZjHF36q4S10i24rrTQN99k9LXX+aXA5u+r 6WKWLI6w2hiKL+jr+myRsTayO3WS8GF2gybZdLI0lM1naZI1rlu7ad+eBZxBWlbSwr IRnwgBIGGrLvQ== From: Jeff Layton To: ceph-devel@vger.kernel.org, dhowells@redhat.com Cc: idryomov@gmail.com, xiubli@redhat.com, linux-cachefs@redhat.com Subject: [RFC PATCH 4/5] ceph: enhance dout messages in issue_read codepaths Date: Thu, 7 Apr 2022 08:02:23 -0400 Message-Id: <20220407120224.76156-5-jlayton@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407120224.76156-1-jlayton@kernel.org> References: <20220407120224.76156-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Signed-off-by: Jeff Layton --- fs/ceph/addr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index e7a7b5d29c7d..0726494a0981 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -190,6 +190,8 @@ static bool ceph_netfs_clamp_length(struct netfs_io_subrequest *subreq) /* Truncate the extent at the end of the current block */ ceph_calc_file_object_mapping(&ci->i_layout, subreq->start, subreq->len, &objno, &objoff, &xlen); + dout("%s: subreq->len=0x%zx xlen=0x%x rsize=0x%x", + __func__, subreq->len, xlen, fsc->mount_options->rsize); subreq->len = min(xlen, fsc->mount_options->rsize); return true; } @@ -302,7 +304,9 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq) goto out; } - dout("%s: pos=%llu orig_len=%zu len=%llu\n", __func__, subreq->start, subreq->len, len); + dout("%s: pos=%llu orig_len=%zu len=%llu debug_id=%x debug_idx=%hx iter->count=%zx\n", + __func__, subreq->start, subreq->len, len, rreq->debug_id, + subreq->debug_index, iov_iter_count(&subreq->iter)); err = iov_iter_get_pages_alloc(&subreq->iter, &pages, len, &page_off); if (err < 0) { From patchwork Thu Apr 7 12:02:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 12805149 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34CDBC433F5 for ; Thu, 7 Apr 2022 12:02:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239489AbiDGMEf (ORCPT ); Thu, 7 Apr 2022 08:04:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238937AbiDGMEd (ORCPT ); Thu, 7 Apr 2022 08:04:33 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C224D7DE10 for ; Thu, 7 Apr 2022 05:02:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 31A5CCE2763 for ; Thu, 7 Apr 2022 12:02:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2115CC385A8; Thu, 7 Apr 2022 12:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649332950; bh=fQoER+BnVliRbv0vPbyAzdmog57KftKQyE6WVVuuulY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sKbwtugKGOPf54xEjtBQkOHsEi1inRAJdiMFLT2GQwV9NWm+qzmKWzYWbMitoOYu/ U4GXNmhNJu4fvkbLN0AZZPgDg0xMY/MCdqIDOCGfrnlDhb/wHUqiboT3AZjqzes1r8 2Igqchp7oFxFPXC1gwD9kezJ+vHGikQ0fN0luhCoKPtBTlb6elSWGenevNdJuILvtt NdRufst+z9WcNZihA5o4sIZ6IdQYtgiFR0PL3N6kmTq7S3ZGQbMrj3mI6UTx1nVBFz h0rcKXljyZKCq9YrPYxapl1OrroM9xC2CqhpnYBgq9zTqC6eUCs+iqioMJrXTfc7gB 1b6UCJ8i5PbOA== From: Jeff Layton To: ceph-devel@vger.kernel.org, dhowells@redhat.com Cc: idryomov@gmail.com, xiubli@redhat.com, linux-cachefs@redhat.com Subject: [RFC PATCH 5/5] ceph: switch to netfs_direct_read_iter Date: Thu, 7 Apr 2022 08:02:24 -0400 Message-Id: <20220407120224.76156-6-jlayton@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407120224.76156-1-jlayton@kernel.org> References: <20220407120224.76156-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Signed-off-by: Jeff Layton --- fs/ceph/addr.c | 41 +++++++++++++++++++++++++++++------------ fs/ceph/file.c | 3 +-- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 0726494a0981..bc575bbbf8b7 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -201,7 +201,6 @@ static void finish_netfs_read(struct ceph_osd_request *req) struct ceph_fs_client *fsc = ceph_inode_to_client(req->r_inode); struct ceph_osd_data *osd_data = osd_req_op_extent_osd_data(req, 0); struct netfs_io_subrequest *subreq = req->r_priv; - int num_pages; int err = req->r_result; ceph_update_read_metrics(&fsc->mdsc->metric, req->r_start_latency, @@ -216,13 +215,18 @@ static void finish_netfs_read(struct ceph_osd_request *req) else if (err == -EBLOCKLISTED) fsc->blocklisted = true; - if (err >= 0 && err < subreq->len) - __set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags); + if (err >= 0) { + if (err < subreq->len) + __set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags); + iov_iter_advance(&subreq->iter, err); + } + if (!iov_iter_is_bvec(&subreq->iter)) + ceph_put_page_vector(osd_data->pages, + calc_pages_for(osd_data->alignment, + osd_data->length), + false); netfs_subreq_terminated(subreq, err, true); - - num_pages = calc_pages_for(osd_data->alignment, osd_data->length); - ceph_put_page_vector(osd_data->pages, num_pages, false); iput(req->r_inode); } @@ -285,6 +289,7 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq) struct ceph_fs_client *fsc = ceph_inode_to_client(inode); struct ceph_osd_request *req; struct ceph_vino vino = ceph_vino(inode); + struct iov_iter *iter = &subreq->iter; struct page **pages; size_t page_off; int err = 0; @@ -308,16 +313,28 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq) __func__, subreq->start, subreq->len, len, rreq->debug_id, subreq->debug_index, iov_iter_count(&subreq->iter)); - err = iov_iter_get_pages_alloc(&subreq->iter, &pages, len, &page_off); - if (err < 0) { - dout("%s: iov_ter_get_pages_alloc returned %d\n", __func__, err); - goto out; + if (iov_iter_is_bvec(iter)) { + /* + * FIXME: remove force cast, ideally by plumbing an IOV_ITER osd_data + * variant. + */ + osd_req_op_extent_osd_data_bvecs(req, 0, (__force struct bio_vec *)iter->bvec, + iter->nr_segs, len); + goto submit; } - /* FIXME: adjust the len in req downward if necessary */ - len = err; + err = iov_iter_get_pages_alloc(&subreq->iter, &pages, len, &page_off); + if (err < len) { + if (err < 0) { + dout("%s: iov_ter_get_pages_alloc returned %d\n", __func__, err); + goto out; + } + len = err; + req->r_ops[0].extent.length = err; + } osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0, false, false); +submit: req->r_callback = finish_netfs_read; req->r_priv = subreq; req->r_inode = inode; diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 6c9e837aa1d3..8271459b36dc 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1624,8 +1624,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to) if (ci->i_inline_version == CEPH_INLINE_NONE) { if (!retry_op && (iocb->ki_flags & IOCB_DIRECT)) { - ret = ceph_direct_read_write(iocb, to, - NULL, NULL); + ret = netfs_direct_read_iter(iocb, to); if (ret >= 0 && ret < len) retry_op = CHECK_EOF; } else {