Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9227485rwp; Thu, 20 Jul 2023 01:17:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlFHjDyyClSUhrTe2+UoKgSNgb+WD1rIHORQ0BykvBLoAQEHP0g9NR+hjHTsBND2RyTuIlKb X-Received: by 2002:a17:907:724d:b0:98e:4b2:2e83 with SMTP id ds13-20020a170907724d00b0098e04b22e83mr2204464ejc.50.1689841030411; Thu, 20 Jul 2023 01:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689841030; cv=none; d=google.com; s=arc-20160816; b=WQXfIIjt8Aoc8Xq/ymmzhohL/NwBH8Qk33MLbuhJR799wvJsuOI5zfsZ/kJ4xjVBbt Hn+VJ8XYNddDYOjIxfMvpcqZD8VCcW3tQHgOO8b8JIBqt380nCW+Fn4Ez2LiUWSy1Jtb NxBtDxQwWWF6il8pilid7cMKoA7P3Dt0AxObw8yyvxkdO8BuA2sh7RckeEWOGA8/Ni11 0XfcmEmCU2MvNpYE/cF6ZISC/peLJbWIFKCE//44qCTFWkc8HZ7ym41PPdHnwR/v0EmY HHYHLv0hsF3TyHpR1IRBEGqmi5NQHaKkajYQhBkPOSTS0IpdrXFGc57TL23mzy/lrfA7 SSmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=XmUAzaGCzoWbWvtXNBg4FVEPOLhmW8pW6NX9HZAN6II=; fh=QOWboEnUd8VVjEGmIqwhjLTOK+Je/xJTQLdnpNWS8y4=; b=zqYUSh3venkE4DR7m0J9FGP1y86KebFZvLqZ+KTAYbHN2oj6HVKAfjUfH2lGCEA6Nk 1ZXjJtKoYOTUR/qzV1HD017Fh08lf1/BaT5VfnWDO10RUWsP4dwRtzrh0proBbsh4Sqo zq8OxL4Egr1miI2JxQ8NocJ6+5+J7ZZIzxmlwF4n5c5YynOlUssNW8l2MJjXMQKY0+UR LOZ/AutP8KsxNUUO3u4fy8ioN8CNb0TTBABye/Z4+fqCViN5VbgaFoHYXZrL6EEbbWVk PeXdfqej9jCwUN7cLiuaUs7YIB/fU4E/CmZie+jsw6IWl8hX4CZx9JpfoPtqbEvhzmPT E6Cw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id la14-20020a170906ad8e00b00991c8ce54c5si327303ejb.178.2023.07.20.01.16.46; Thu, 20 Jul 2023 01:17:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231841AbjGTH5S (ORCPT + 99 others); Thu, 20 Jul 2023 03:57:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbjGTH5R (ORCPT ); Thu, 20 Jul 2023 03:57:17 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ED2A2127; Thu, 20 Jul 2023 00:57:15 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 156026732D; Thu, 20 Jul 2023 09:57:11 +0200 (CEST) Date: Thu, 20 Jul 2023 09:57:10 +0200 From: Christoph Hellwig To: Nitesh Shetty Cc: Jens Axboe , Jonathan Corbet , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Keith Busch , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Alexander Viro , Christian Brauner , martin.petersen@oracle.com, linux-scsi@vger.kernel.org, willy@infradead.org, hare@suse.de, djwong@kernel.org, bvanassche@acm.org, ming.lei@redhat.com, dlemoal@kernel.org, nitheshshetty@gmail.com, gost.dev@samsung.com, Anuj Gupta , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v13 4/9] fs, block: copy_file_range for def_blk_ops for direct block device Message-ID: <20230720075710.GC5042@lst.de> References: <20230627183629.26571-1-nj.shetty@samsung.com> <20230627183629.26571-5-nj.shetty@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230627183629.26571-5-nj.shetty@samsung.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 > +/* Copy source offset from source block device to destination block > + * device. Returns the length of bytes copied. > + */ > +ssize_t blkdev_copy_offload_failfast( > + struct block_device *bdev_in, loff_t pos_in, > + struct block_device *bdev_out, loff_t pos_out, > + size_t len, gfp_t gfp_mask) This is an odd and very misnamed interface. Either we have a klkdev_copy() interface that automatically falls back to a fallback (maybe with an opt-out), or we have separate blkdev_copy_offload/blkdev_copy_emulated interface and let the caller decide. But none of that really is "failfast". Also this needs to go into the helpers patch and not a patch that is supposed to just wire copying up for block device node. > index b07de77ef126..d27148a2543f 100644 > --- a/fs/read_write.c > +++ b/fs/read_write.c > @@ -1447,7 +1447,8 @@ static int generic_copy_file_checks(struct file *file_in, loff_t pos_in, > return -EOVERFLOW; > > /* Shorten the copy to EOF */ > - size_in = i_size_read(inode_in); > + size_in = i_size_read(file_in->f_mapping->host); generic_copy_file_checks needs to be fixed to use ->mapping->host both or inode_in and inode_out at the top of the file instead of this band aid. And that needs to be a separate patch with a Fixes tag. > @@ -1708,7 +1709,9 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out) > /* Don't copy dirs, pipes, sockets... */ > if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) > return -EISDIR; > - if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) > + > + if ((!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) && > + (!S_ISBLK(inode_in->i_mode) || !S_ISBLK(inode_out->i_mode))) This is using weird indentation, and might also not be doing exactly what we want. I think the better thing to do here is to: 1) check for the accetable types only on the in inode 2) have a check that the mode matches for the in and out inodes And please do this as a separate prep patch instead of hiding it here.