Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp870219rdb; Wed, 6 Dec 2023 02:12:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IG44ppR8iYvnwzL4U/uKny2GQBKX8r4qTDXpDp2pHsNdBzF+faj8CWq7FEvJjWEw9pRDQqB X-Received: by 2002:a05:6e02:1a45:b0:35d:59a2:bc2 with SMTP id u5-20020a056e021a4500b0035d59a20bc2mr894984ilv.88.1701857541167; Wed, 06 Dec 2023 02:12:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701857541; cv=none; d=google.com; s=arc-20160816; b=eUPygqfWmzpYIXKuk2Xs0RHeh1Ucg3kSNeKMXgpVb6c/t/lAGm/xn62Q6MQkSggt+G BsV36lnnA+vwuuVbkv7VtH516WwR+kAkxRmqfornQU4MToBViJQHPgq0XCMtDqjLELEq KUuD5AusEuTrCHK2KFYbEpOMoKvO9UzNEiGpWHfYzVcaB6E+xgDC5w8ktQTMUT5U1VGk qQ0c52iIjoYosUFL2DsqIc62v1ysetGHSiJN4ZE80QMkOwflPU5eAQtZg3CWhXe08NwU V98U8UyLfmX+lig2bFizzKEbYV873p5Ctv45mJiUul7ycafYQv2mzLnLtzbSAAYavw44 JJ/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:mime-version:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=3rmMeBvqvZnLG710cTQe8+pDj6/LHJ1Es1eTLbldN3I=; fh=Ah9URUT0YMcW0AdypunxP2ZkdaXV7jPEsLx7S1j82es=; b=gS2Zw++CJ1fA4wke/N8Xc+l0YW3N/GzP/shWhh8pLw9bm/VSOVRt1JWWO9h8lLnUeh 2drGH7SSutOZ6pGJYCMD3crAVV+vqsqKQb22cL+DSx9jOhg1fpmal00fySeSpXHubnuT GeB+gftSu4PY4X9/Rm8P7l/fZzk0G+Yj2AsrBRzjdVIIv5BfCUXt1Fo3jqxxx3T1Ug9g F4tdrPzdo57whgzwZeJQC/oI6V4KRmEyuShV9fkAenGXtdiqp6eCGLUJCVHCxFnrrDaQ cXVl6SCQ7kpc9CIB0wfC8ofyTgtvHLru3ibTFsLHwNUChdX9IvuPBmK8e1pcZb62Ptj0 9/KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=DphrSG+X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id a21-20020a631a55000000b005c6bc10835fsi1380462pgm.84.2023.12.06.02.12.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:12:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=DphrSG+X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 30DDB8080E35; Wed, 6 Dec 2023 02:11:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377395AbjLFKLd (ORCPT + 99 others); Wed, 6 Dec 2023 05:11:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377371AbjLFKLb (ORCPT ); Wed, 6 Dec 2023 05:11:31 -0500 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74B91D49 for ; Wed, 6 Dec 2023 02:11:37 -0800 (PST) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20231206101135epoutp0215661fd96ad0fb356efc9dcb010b3725~eNmAxCUoj2244322443epoutp02S for ; Wed, 6 Dec 2023 10:11:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20231206101135epoutp0215661fd96ad0fb356efc9dcb010b3725~eNmAxCUoj2244322443epoutp02S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1701857495; bh=3rmMeBvqvZnLG710cTQe8+pDj6/LHJ1Es1eTLbldN3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DphrSG+Xwn2/GmRM0Y5eZ21WK+jKGIYamGjzIFChOCw5HfsG25bvH5ubi7CdzGiGk pGMYchCk2MEIHJanydNnElpttb/sY+ji+46RVummntAYDa3CM3Ek1Fcnag3rbgM8Z9 WRJRe0WNPzLJb4+1EQ3stmDnLnuSn3sek9qy/9u8= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20231206101135epcas5p366d5b258f1c0a8617a18ef7ac61e9e00~eNmAQkMlO0036000360epcas5p36; Wed, 6 Dec 2023 10:11:35 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.177]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4SlY8j3VPtz4x9Ps; Wed, 6 Dec 2023 10:11:33 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 12.52.08567.5D840756; Wed, 6 Dec 2023 19:11:33 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20231206101133epcas5p28efae88fbc435e0a42bc89c94eec3ac2~eNl_BD5Zu3161231612epcas5p27; Wed, 6 Dec 2023 10:11:33 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231206101132epsmtrp2312dbf0d8724cfaaf3b06742b41fe8ee~eNl9--tcq0990909909epsmtrp2J; Wed, 6 Dec 2023 10:11:32 +0000 (GMT) X-AuditID: b6c32a44-3abff70000002177-42-657048d5891e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 24.52.08817.4D840756; Wed, 6 Dec 2023 19:11:32 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231206101126epsmtip2a3dcf704089d260dd01017179cde49db~eNl4WElIo1181511815epsmtip2G; Wed, 6 Dec 2023 10:11:26 +0000 (GMT) From: Kanchan Joshi To: Jens Axboe , Jonathan Corbet , Alasdair Kergon , Mike Snitzer , Mikulas Patocka , dm-devel@lists.linux.dev, Keith Busch , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Alexander Viro , Christian Brauner Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, nitheshshetty@gmail.com, anuj1072538@gmail.com, gost.dev@samsung.com, mcgrof@kernel.org, Anuj Gupta , Hannes Reinecke , Nitesh Shetty , 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: [PATCH v18 05/12] fs/read_write: Enable copy_file_range for block device. Date: Wed, 6 Dec 2023 15:32:37 +0530 Message-Id: <20231206100253.13100-6-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231206100253.13100-1-joshi.k@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA02TaVBTVxTHe98LL4ESfY10uJCKmBk7QgWSst1YoLYGeQydlpn2g9h2Qgae gUlI0ixuoGItIJsg2FYiS1iqI4IIqOzWwlRERKiUilhSCgl1DEtl0U4z0iYEW7/9zrn//5zl zmHhnAKmJytZoaXVComcR7gwrvX4+PiNUCqaf6EcoobbN3H0ZNnKQF8WPsfRxfECAll6FgAy 3cgCyFBVxkAPbrRhqLOqCEMXLv6IoaLuXwAyj+gx1DX2FqrMrGGgzq4+BhpuLyVQxTkzE+Xe byXQ+d4VDI0WmgE6dWIEQ62mYwBds1bg6JJlnoFujXHR4PNepx2eVJt+nEkNGhsZ1PCAjmqq zSao5pqj1KPmEkB1PEgnqOqTxU5U/vE5gnpiHmNQ89dHCOrklVpANfenUotNXlSTaRaLXb9H FpZESxJptTetSFAmJiuk4byYj8U7xcEhfIGfQIhCed4KSQodzhN9EOu3K1luWwnPe59ErrOl YiUaDS8gIkyt1Glp7ySlRhvOo1WJclWQyl8jSdHoFFJ/Ba3dLuDz3w62CeNlSUZDNqGaYx+o t46CdDD0ag5wZkEyCOYuXydygAuLQ3YAeL44H3MECwDetdYBR/AUwO9KpvAXlobSvDVLF4Dj My24I1gEsLc/i5kDWCyC9IFDxTq7wY2sw2Fbo8CuwclyHE7/YwD2hw3kJ3D2VjnTzgxyC2zU D68ym0RwObMfOKptgiX3nq3mnUkhLP6jCndoXoN9JSaGnXGb5vjVs6tNQLLDGS6cu8p0mEVw 8r6R4eAN8HHvlbW8J1yc6yIcnADvldzFHKyFU50/rPG7MON2AW4fBrcN09Ae4Ki1DuZbTZg9 DUk2PJHJcag3Q2OR2cnB7vD3MzVrTMGM+YHVDjhkHoDfWKMLwSb9SxPoX5pA/38xA8BrgQet 0qRI6YRglUBB7//vYxOUKU1g9TJ8Ra1gtGLFv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 6gUlTs58AmYzA9U3b53NPIFRYBaS1CwkqQWMTKsYJVMLinPTc4sNC4zyUsv1ihNzi0vz0vWS 83M3MYLjXUtrB+OeVR/0DjEycTAeYpTgYFYS4c05n58qxJuSWFmVWpQfX1Sak1p8iFGag0VJ nPfb694UIYH0xJLU7NTUgtQimCwTB6dUA5PUHM5wjdroWP0Gv1PnEqVn1Hp0BlZP1Tix3n5Z 8owX9tuc+Badc1snvnR79272JVZN4gVVt+Nt25pXpDpzJ2QFf1uWxtPkfJ/n6+si2ejuCXEX 98ovjvc7sGC/gR//l4XV069c+L171Tepqha5+l/fNx0LYPorL+Buf+p/2raHW6/IGLrknl5T 0l4nGLnnx8La9f8LZwlfnptSJPjuXavq7Kdv3+5cyt94uG7dQTGbkLaCpxf2yjEx3ApyCF13 eZt5j83SazKizuuO3+N45vX34DWhP3qlk7jffKpYbaq39vCd2gbvvT/uaCvGZBzN5urp9WJn X71uyzP+7OoVpfu3c5nZHblefOGWsKFb/2klluKMREMt5qLiRABeV9QYZgMAAA== X-CMS-MailID: 20231206101133epcas5p28efae88fbc435e0a42bc89c94eec3ac2 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20231206101133epcas5p28efae88fbc435e0a42bc89c94eec3ac2 References: <20231206100253.13100-1-joshi.k@samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 02:11:53 -0800 (PST) From: Anuj Gupta This is a prep patch. Allow copy_file_range to work for block devices. Relaxing generic_copy_file_checks allows us to reuse the existing infra, instead of adding a new user interface for block copy offload. Change generic_copy_file_checks to use ->f_mapping->host for both inode_in and inode_out. Allow block device in generic_file_rw_checks. Reviewed-by: Hannes Reinecke Signed-off-by: Anuj Gupta Signed-off-by: Nitesh Shetty --- fs/read_write.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index e0c2c1b5962b..92729c7547d3 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1441,8 +1441,8 @@ static int generic_copy_file_checks(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, size_t *req_count, unsigned int flags) { - struct inode *inode_in = file_inode(file_in); - struct inode *inode_out = file_inode(file_out); + struct inode *inode_in = file_in->f_mapping->host; + struct inode *inode_out = file_out->f_mapping->host; uint64_t count = *req_count; loff_t size_in; int ret; @@ -1750,7 +1750,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_ISBLK(inode_in->i_mode)) + return -EINVAL; + if ((inode_in->i_mode & S_IFMT) != (inode_out->i_mode & S_IFMT)) return -EINVAL; if (!(file_in->f_mode & FMODE_READ) || -- 2.35.1.500.gb896f729e2