From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (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 749006EB7D for ; Tue, 28 May 2024 06:56:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716879421; cv=none; b=Q5y6H/zzzFBSCpeHGaiftTb2hKFL+H+M+vSVCIh2K6vUVRCpu6SPBl+R6FWFoc1CDipnyFtyCFAKY3UcVTKhkB9QYrJf30LYduiJaD+CUcwZ+nfhmoTqu/XPLYvjf+YFEvFuDf1F/91Nq951nwPmu03xljCjHIHvK0Qr0O0H2YE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716879421; c=relaxed/simple; bh=VHklIm/d1slFpHw4H0fGDmkRx7FbeR3jd6KKqB6xOrY=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:In-Reply-To: Content-Type:References; b=hzXs9rkbI0Pol34Xd65Cek+r3MnUKAJhrus3qWA6LLGWa+GvyzEP6KxxtkeyMh9P+224D+BL47JypBEXz/a7gmhDH3kwgeqT7CisDWkR1c3X+0VmJrDS6DfhBTad8PiObm4vabinL7Gp05qzfcTcx38FVKv69ygXY77753jLakk= 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=A6QX3l8B; arc=none smtp.client-ip=203.254.224.33 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="A6QX3l8B" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240528065653epoutp036ce37e9aabbdcb7484fb52ec5c05e19a~TlLrt4ez72953329533epoutp03H for ; Tue, 28 May 2024 06:56:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240528065653epoutp036ce37e9aabbdcb7484fb52ec5c05e19a~TlLrt4ez72953329533epoutp03H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1716879413; bh=nAZx1LsOHkUtzRfjnw0sqmJkB2agzB/i6qclqjs+O2I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=A6QX3l8BIRem4hWQvpzZ3SdTCGJG8oFBQxAtoXUfhh6JWRyw5vGiUTkfGlzg61oG/ zIPDj5UZ8SnBerbI5RNbJbjlFhpRhZ09n9uAyaL3qurd8qhyjNjmd7urty52Um3DQt 8lzVnBgI8Ej5B2UVZDo11DTBKBpgxK8cVcFJMdpU= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240528065652epcas5p2d8319a1124923aaa87746d14bdf69f6a~TlLq5UvCH0185501855epcas5p2N; Tue, 28 May 2024 06:56:52 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.178]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4VpNbk5vG5z4x9QC; Tue, 28 May 2024 06:56:50 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 60.C8.09989.23085566; Tue, 28 May 2024 15:56:50 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240528060437epcas5p2587b9da4ba2e6f0beddcb42a9679e860~TkeCoTB6X0914209142epcas5p2L; Tue, 28 May 2024 06:04:37 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240528060437epsmtrp2df0fb02a548747a950a44b275d53f541~TkeCm5zxE0102101021epsmtrp2O; Tue, 28 May 2024 06:04:37 +0000 (GMT) X-AuditID: b6c32a4a-e57f970000002705-54-665580324bfc Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 9E.14.18846.4F375566; Tue, 28 May 2024 15:04:36 +0900 (KST) Received: from nj.shetty?samsung.com (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240528060433epsmtip20328e5dbd5f2ec8f001612a38afabaf3~Tkd-DQImr1951119511epsmtip2Z; Tue, 28 May 2024 06:04:33 +0000 (GMT) Date: Tue, 28 May 2024 05:57:33 +0000 From: Nitesh Shetty To: Dave Chinner Cc: Jens Axboe , Jonathan Corbet , Alasdair Kergon , Mike Snitzer , Mikulas Patocka , Keith Busch , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Alexander Viro , Christian Brauner , Jan Kara , martin.petersen@oracle.com, bvanassche@acm.org, hare@suse.de, damien.lemoal@opensource.wdc.com, anuj20.g@samsung.com, joshi.k@samsung.com, nitheshshetty@gmail.com, gost.dev@samsung.com, 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: Re: [PATCH v20 05/12] fs/read_write: Enable copy_file_range for block device. Message-ID: <20240528055733.kwmyx7f7u3w7gpon@nj.shetty@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA01Te0xTVxzOubfcFiN4pRAPBSerExXCo7w8S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B7OSCK/IvMA0Id6UxMqq1KL8 +KLSnNTiQ4zSHCxK4rzKOZ0pQgLpiSWp2ampBalFMFkmDk6pBqZQiWu7vCT3br5wUlM2Uel2 6byl/IZmgse1Zx2+vUtbSF9ccvZ1tYzkVY8jdk7QqQ+tipmWaPWjfpIZe7rfbLVtTxlNVhZx fhWK/CSSEiEQw1J1vCP1ydl1WrwWGtWyahnv2TL476/Pd3C0mWbH7M8ktP92i/kynYX66syC 3242pP3ZN/fRxpcKdd0CfocV/qSdndzzxZg5zOhXwstyvuULAu+WrEuzimDTnWv8687+87zG p0TVix1/fLMw6869KVx/9IPpOrmjMi94GL5K/Ylt1DnodMWexTuJ4fxhnenbs06IRJVybjYu vb14AUMxQ1xPWOGzz6XGs9bPSA9hqnVMqf/4ov+v8rInxXbaSizFGYmGWsxFxYkAAcvDiHcD AAA= X-CMS-MailID: 20240528060437epcas5p2587b9da4ba2e6f0beddcb42a9679e860 X-Msg-Generator: CA Content-Type: multipart/mixed; boundary="----u98hW3AvpxW_WMqzG8XaJinKydZ84Ygy6oP0sovTVoTPagnQ=_b7ed_" 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> <20240520102033.9361-6-nj.shetty@samsung.com> ------u98hW3AvpxW_WMqzG8XaJinKydZ84Ygy6oP0sovTVoTPagnQ=_b7ed_ Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Disposition: inline On 26/05/24 09:02AM, Dave Chinner wrote: >On Mon, May 20, 2024 at 03:50:18PM +0530, Nitesh Shetty wrote: >> 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; > >Ok, so this changes from file->f_inode to file->mapping->host. No >doubt this is because of how bdev inode mappings are munged. >However, the first code that is run here is: > > ret = generic_file_rw_checks(file_in, file_out); > >and that function still uses file_inode(). > >Hence there checks: > >> @@ -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; > >.... are being done on different inodes to the rest of >generic_copy_file_checks() when block devices are used. > >Is this correct? If so, this needs a pair of comments (one for each >function) to explain why the specific inode used for these functions >is correct for block devices.... > We were getting wrong size with file_inode() for block device, but we missed to do it here in generic_file_rw_checks. We will change the generic_file_rw_checks to use file->mapping->host to make it consistent. Thank You, Nitesh Shetty ------u98hW3AvpxW_WMqzG8XaJinKydZ84Ygy6oP0sovTVoTPagnQ=_b7ed_ Content-Type: text/plain; charset="utf-8" ------u98hW3AvpxW_WMqzG8XaJinKydZ84Ygy6oP0sovTVoTPagnQ=_b7ed_--