Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2395213lqo; Mon, 20 May 2024 04:48:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVo6PPxFZiyM/QSZHgRdxcV35TBxu38lrPULij6GPyr/k5lJOh6/CeT08kAZREqax40OB3SFXlWLvbqmoWpzlQnyZcqi4CwUIB81D9rtg== X-Google-Smtp-Source: AGHT+IHdfas2zEIZ0la9/Eqbohoa0otbVec4lxlivqp1vI/SK8ryiZxKJlPr1XhVMenzhE8C3olF X-Received: by 2002:a17:90b:3118:b0:2bd:8803:485b with SMTP id 98e67ed59e1d1-2bd88034b40mr944720a91.6.1716205706910; Mon, 20 May 2024 04:48:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716205706; cv=pass; d=google.com; s=arc-20160816; b=Dg4uZtwNLLguqRnA68ihsUgEsfEcR2fzryQmag0+MGaWqMzdB2b1JFXnwCQyUAXS8y AnbQdBpkgg8ZyI7Ql0n521uCgxt2McfV860fzc5fVauVUfuyHzeQMKXor8yKQVOjxIel o1dKqzO7sm+DHEmKQe+DX8c6vDd4KD5T94OwTq3WdJM6w7fI270C2Hj9vF00dl0PAmuF mhmO6h1PCxiIYRLKgx486GRBo1y67sAFZVvl7G3K0edJ1ZZIEebMubHsSrTsNgDEMDiv PGiA4/h9mZnbJoU3BFXkZrJZe0Q0b0P2t/ii2Ps00arCjjbqTQ+ZVQQ0+NIqhyDePbbk hdQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :dlp-filter:cms-type:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=eFjYOy/rO8gowEbK0HM6LksYvSQzjlGqTWi9wTV85D4=; fh=c9WQN21Db5gXOJEpRfIVP9+rw/2eDGhIcv7l5f7XKYU=; b=0VqkSmzfBp48th6Lt0MCDGHF1wGw8Msu/NT8HdluwPb82dt2/r2iG31bwfMwVH+ITW qwOh/rKsR/C7VfDlj2W/h7Wlt36/TI0TNaDb7e6bJYruu8AZLA1aVc27DJA1L0jNVUbb 949b4XnoV49dGfgvWjBMFDKhJ045jfgXuk2I1+ePZUTHWddPlBAwwXGD4xuj4tksIPry pF/Zd5hSuH01GsVpu3JedYb5Ive1e0hQQ5vBwTf/zPny594a0mLljx5vPWaepqQHMoWP RrhC1lqJ2mVpRaw9doeOikVDsUvgVeBr/6ds1Vr3GwREc9u9O8qdoHmEvmJ25JRwAWBm 8R0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=CZ+i3KcB; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-183677-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b628a5c493si256679a91.44.2024.05.20.04.48.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 04:48:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183677-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=CZ+i3KcB; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-183677-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B7CC3B20D63 for ; Mon, 20 May 2024 11:46:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98FC654FAE; Mon, 20 May 2024 11:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="CZ+i3KcB" Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2A4353384 for ; Mon, 20 May 2024 11:45:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716205506; cv=none; b=g/pzx+gJQXzIf12/qvU+xHB8Z5JIpGZ3WH+9MC1Cg8L7h3gLqORFzP6xiiz1JiykepCCDgA/DjIJ0iEw16ZoIOLeuT8BYEk/BVnMi7jydKzCYDArB2lRu52hBeJkYghIV943yyxJXA7JCyFPKZn+OPT4OnTxJ06SqUE3KC7aDDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716205506; c=relaxed/simple; bh=Ac3WHWfXlPQZczxqpVamDMZW8w7I6olApg/rcA7vauo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:Content-Type: References; b=C4p7DDCkTkKC3Y4kLduGm2aq418DvQA/9nYE0DNHvY8tBNuxX+864cRzcL+rzEXjSoPzTNrMpnsj65mi6T856qToxXYaZFqQt2/HJWz82v3gjMrn7ZDBp7ZDqkJGK9KqKX/drp8+2Tub6jeWK+uW5XV8aaIwoRVU/3E5YLVamFk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=CZ+i3KcB; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240520114503epoutp025a6c48ba9db8883e33ec2d51dc9d3a73~RL8-rus6L1030810308epoutp02U for ; Mon, 20 May 2024 11:45:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240520114503epoutp025a6c48ba9db8883e33ec2d51dc9d3a73~RL8-rus6L1030810308epoutp02U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1716205503; bh=eFjYOy/rO8gowEbK0HM6LksYvSQzjlGqTWi9wTV85D4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CZ+i3KcB1WgtOx9XjAhrs9cWVCBOwXEGGC7sQM0NgOA095c//xW695lJOKd7TXbg6 MS10uxCnxncl2oMNks5YKnmovLiqqUDu+frJEfMmpfC1jq9NLZl/y9GLqzW9ZXLOg+ 1rADkCmGXR9s71dNzI+qmQdOdSBa88WazX5Mmne0= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240520114502epcas5p314d3ac8847fbfa8f00e6469d2bee365a~RL8_9Pvzi2210822108epcas5p39; Mon, 20 May 2024 11:45:02 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.183]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4VjbMw3W1Yz4x9Pv; Mon, 20 May 2024 11:45:00 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id DA.60.19431.CB73B466; Mon, 20 May 2024 20:45:00 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240520102917epcas5p1bda532309b9174bf2702081f6f58daf7~RK62SXh_40443504435epcas5p1G; Mon, 20 May 2024 10:29:17 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240520102917epsmtrp2ac75c71748c9cbc2118a64cd866875eb~RK62RQdSo2153521535epsmtrp2y; Mon, 20 May 2024 10:29:17 +0000 (GMT) X-AuditID: b6c32a50-f57ff70000004be7-6c-664b37bccb97 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 88.08.08390.DF52B466; Mon, 20 May 2024 19:29:17 +0900 (KST) Received: from green245.sa.corp.samsungelectronics.net (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240520102913epsmtip223ed300d14416990c75ecc6ce4fcc8f9~RK6yqRUzB2247922479epsmtip2r; Mon, 20 May 2024 10:29:13 +0000 (GMT) From: Nitesh Shetty To: Jens Axboe , Jonathan Corbet , Alasdair Kergon , Mike Snitzer , Mikulas Patocka , Keith Busch , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Alexander Viro , Christian Brauner , Jan Kara Cc: martin.petersen@oracle.com, bvanassche@acm.org, david@fromorbit.com, hare@suse.de, damien.lemoal@opensource.wdc.com, anuj20.g@samsung.com, joshi.k@samsung.com, nitheshshetty@gmail.com, gost.dev@samsung.com, Nitesh Shetty , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, dm-devel@lists.linux.dev, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v20 05/12] fs/read_write: Enable copy_file_range for block device. Date: Mon, 20 May 2024 15:50:18 +0530 Message-Id: <20240520102033.9361-6-nj.shetty@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240520102033.9361-1-nj.shetty@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WTe0xTVxzHd+693Ba2uiugO5bBWDeUx4pUaDkQUDfMcgkYWbZsy5aIDb08 Umi7PkQXpjCsAzZegm7W8RCMDhCKtCBP0xUFZXQwsTAg4DSQuTFRgWEYqa6lsP33+b2+319+ J4eNu9tILjtNpmaUMnE6j3Qj2noDAvjd4XHJIbm3IdIP9OHoyxIbjhqmikk017sA0JnHKzia MX0F0KplCEfGvmmAqmsqCDRu6sBQd80pDNU13MDQuW9zMXTj+UMSnTKPAjRr1WGoZyIInT95 gUDdPbcINNL5PYmqLs6y0KX+ZxgqzbNiqH0mB6C21SocNc09ItDNCS80ZOt32fsqPXInjh6o gXSHbopFD01fIegRi4Zuqc8nacOF4/QDw1lAd41nk3RtUZkLXZg7T9Id2rsu9JPZCYJ+dM1K 0kXGekAPVl9nJXh8Io1KZcQSRunLyJLkkjRZSjQv7v3EmEShKETAF0SgcJ6vTJzBRPP2xSfw 301Lt1+I53tYnK6xpxLEKhVv5+4opVyjZnxT5Sp1NI9RSNIVYYpglThDpZGlBMsYdaQgJGSX 0N54SJr6TdcwqZjmHOm9VM7KBqYXC4ArG1JhcLXMABzsTnUD2DkZWgDc7LwA4L1RI8sZLAP4 130da2Oi5Oc/gLPQA+Bk+RLpDLQY/HH4HFEA2GySCoI/PWc78p5UAw6/NpQSjgCnDDjM6TVh DikP6gNovKldkyUoP9hsnScczKEiYPn4b4TT7jXY0GzCHexKRUJT6+M1a0jpXeFISRHmbNoH ny0+Wd/PA/7Zb1xnLlyc7yGdnAn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YxcnEI CexmlOg9upUFIiEpsezvEWYIW1hi5b/n7BBFzUwS65f0MXUxcnCwCWhLnP7PARIXEdjOLPGx uZsJpIFZ4CizxIU1FiC2sECQxLcND8HiLAKqEhuuvgNbwCtgKTHl5gOoZfISqzccAFvGKWAl cWDrB0YQWwio5u71D2wTGPkWMDKsYpRMLSjOTc8tNiwwykst1ytOzC0uzUvXS87P3cQIjlYt rR2Me1Z90DvEyMTBeIhRgoNZSYR30xbPNCHelMTKqtSi/Pii0pzU4kOM0hwsSuK83173pggJ pCeWpGanphakFsFkmTg4pRqYChxP7/f+uftI0t5Nne+Yjsf+/bWlkkF02Xebdg/mJyIs01Pn NJ24wXCoZaV05awODn9f41kLmOLdamMerBO0Ot9kO2v+ua0rrupMXLQsirvoSVnC2tmeVyJN jJ/52O97YLP9z4l1ta5H7PcXT+2wz2zPNTkkWZU4j7eiVjv+aeOGZT9/s7hl3v21JnA1N9sG uaqe2R7yd5hcp82cpFx7asqVSTKJN0627/j5zebNWfUHhU7lyiELrhdZ7z+6Qqv57Aa/rnl/ k2M8xZM3bi3ZwvHpsbmRsvNMv4uBj7PX/lbTvyBj+WjxD/3gZ/lvf0YWFRvcrxf8p/dx2mcJ Oe+YKtZ16kxqQcc+uYiUTfPPV2Ipzkg01GIuKk4EAIU1DcFFAwAA X-CMS-MailID: 20240520102917epcas5p1bda532309b9174bf2702081f6f58daf7 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240520102917epcas5p1bda532309b9174bf2702081f6f58daf7 References: <20240520102033.9361-1-nj.shetty@samsung.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 ef6339391351..31645ca5ed58 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1413,8 +1413,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; @@ -1726,7 +1726,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.17.1