From patchwork Mon May 20 10:20:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitesh Shetty X-Patchwork-Id: 13668230 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (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 CFBC250286 for ; Mon, 20 May 2024 11:45:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716205506; cv=none; b=aANI/LTrzACSndOGQsjNvqMmPQG8rmDE9QNNXsE9IX5A6mT4hBeam9D8shHP/KwDnjqGD8ffCxtLcdqsn2TRIRvP79Q6NUNCA+j51wIpcSUMull2h5b5prRR6bsNNOBNb7ZDJIRhKUlVLiW0Jm3i8yxBrDTy0vw0yJmfhpePxtE= 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=Qx88QH5I; arc=none smtp.client-ip=203.254.224.34 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Qx88QH5I" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240520114502epoutp04123289423c8c45a522e91570ace1d64f~RL8-kZEWE2442124421epoutp04O for ; Mon, 20 May 2024 11:45:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240520114502epoutp04123289423c8c45a522e91570ace1d64f~RL8-kZEWE2442124421epoutp04O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1716205502; bh=eFjYOy/rO8gowEbK0HM6LksYvSQzjlGqTWi9wTV85D4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qx88QH5I4iNQymT5c/u9o9/+xCJN3AHSZanjySqJrfMRkVdVmxdHSEAYxxHk1ellp v4Wp9QWBTVjtJKybh5Dac/dUYKRH9OhT0enW6oPwb+WbARKwZYDrWxv4Yhyo6mZag4 /9lUEKF/EjNEjh8WFB2Gm2g9NcHSpAyMTXMCgd8A= 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>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hRgoNZSYR30xbPNCHelMTKqtSi/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 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: dm-devel@lists.linux.dev 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 Reviewed-by: Hannes Reinecke --- 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) ||