From patchwork Mon Jul 24 06:03:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitesh Shetty X-Patchwork-Id: 124633 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1603561vqg; Sun, 23 Jul 2023 23:23:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlHaenINIGgzC1xZqMBBHxvu1auqNe+JgmYGZY9TcC3qsL/z7NQG4CK2S5blWWtCjO32FxFv X-Received: by 2002:a17:906:77c5:b0:994:34a2:8727 with SMTP id m5-20020a17090677c500b0099434a28727mr9877510ejn.41.1690179826146; Sun, 23 Jul 2023 23:23:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690179826; cv=none; d=google.com; s=arc-20160816; b=K8ePNiFn9UD/YU5EqA+4utMG1qB2Fe7q6p3Wyq1XXCqL57bDzeRSBofuOyyIQEWS8p Akcge85LkJ0mP+KZVzgIwZLm3XUjBlw5+CpdTNF061+Cr//mI2QxsX4Oz0P0H53zws++ nu2Rm4hkRYf81wCpmdlfARRQLb5xO6NImEei5Gz/p83kTZbdAbcVlpOlLGlX3bAxQxjr ZLRz6G+8vP76A4zE7ylSH1kfYnKaTblf+a6bGrQyLZPbHdCIeXXi92ANFlXsm2htUTUe hnEahbGDBQ/LLRHbAtZ8mjmoDeCEuFoscL0CM2YGr4li6iavqidlWm/zhjnyggTA7u1c SQHA== 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:message-id:date:subject:cc :to:from:dkim-signature:dkim-filter; bh=IK3dxHmN4H0mrKlZYjtF8HydO/F3EynIGSvvTtPQyYo=; fh=5gc+B5mJV1kkKrxs/FjuCyt1417yucuaWRx4UdbEyyo=; b=bBt/OVPXWJJI+Os3teVAfUWpoyU8T+6DgU1JwQS00m0rWlQL/TQqxE5pRmHCxSl31L 4PeRmgakyN65xVqKQ2pJkrSYQOboGnH8C7J0RxkyDM+Ebg4eqB2csJlWkbrM9UcnAdWV VxZQUfd48iAWQA93TZrSOGZ+NYS8a60H25TgcvMS/6zb/0VJvnwImpFHHuVCaj5qt67x CZynhv298J6QHOH38ns6brM0DFz2lTCrCqMFU+kP3eLYFLGglelK+Bvwv7IgCBoW1Ubu vLwUsib3NzEsbnvvL4+OXiLpM5n+Gkoq88DUaPnt1B2q1ehiUrCNPUG3DRKQZ0UKW2pm q/FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=gaU9lxo5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w20-20020a170906185400b009926928d482si5570265eje.447.2023.07.23.23.23.20; Sun, 23 Jul 2023 23:23:46 -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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=gaU9lxo5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230213AbjGXGLX (ORCPT + 99 others); Mon, 24 Jul 2023 02:11:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbjGXGLR (ORCPT ); Mon, 24 Jul 2023 02:11:17 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41C5F18E for ; Sun, 23 Jul 2023 23:11:16 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230724061114epoutp02fc70c4300338a32c1eaf01a9fb984f32~0uOnehTit0241602416epoutp02b for ; Mon, 24 Jul 2023 06:11:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230724061114epoutp02fc70c4300338a32c1eaf01a9fb984f32~0uOnehTit0241602416epoutp02b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690179074; bh=IK3dxHmN4H0mrKlZYjtF8HydO/F3EynIGSvvTtPQyYo=; h=From:To:Cc:Subject:Date:References:From; b=gaU9lxo5L2d62LSVOkqafz2Tm3GaNW/u8Wz7NQBvvei2c10rcQbGxIf674pqoAJ/q KGZ8jnGONHlWU26Sy0kN7KNU9gT4NcUb2WwTEu/53YoQLyetVfbNKJiut6cQKaJU48 DMa8lTG8uicmNRXp5h3KfRBB0CuhkEUXX8p4xwd0= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20230724061114epcas5p2ede7af22d682b0b0ca9a2d78aad5e658~0uOnG8x--0258702587epcas5p2D; Mon, 24 Jul 2023 06:11:14 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.178]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4R8VCh1rD9z4x9Py; Mon, 24 Jul 2023 06:11:12 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 64.49.44250.0061EB46; Mon, 24 Jul 2023 15:11:12 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20230724060655epcas5p24f21ce77480885c746b9b86d27585492~0uK2VvzRT2148421484epcas5p25; Mon, 24 Jul 2023 06:06:55 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230724060655epsmtrp12375dce4a7600f368a4d6c2ea1201731~0uK2VCzLu0052600526epsmtrp1P; Mon, 24 Jul 2023 06:06:55 +0000 (GMT) X-AuditID: b6c32a4a-c4fff7000000acda-5e-64be1600b2e0 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 6C.95.34491.FF41EB46; Mon, 24 Jul 2023 15:06:55 +0900 (KST) Received: from green245.sa.corp.samsungelectronics.net (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230724060654epsmtip2702415b5f52b1f1a85a44b20693599a6~0uK1JO11Z2599125991epsmtip2X; Mon, 24 Jul 2023 06:06:54 +0000 (GMT) From: Nitesh Shetty To: Alexander Viro , Christian Brauner Cc: hch@lst.de, gost.dev@samsung.com, Anuj Gupta , Nitesh Shetty , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fs/read_write: Enable copy_file_range for block device. Date: Mon, 24 Jul 2023 11:33:36 +0530 Message-Id: <20230724060336.8939-1-nj.shetty@samsung.com> X-Mailer: git-send-email 2.35.1.500.gb896f729e2 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnk+LIzCtJLcpLzFFi42LZdlhTXZdBbF+Kwe7ZHBZNE/4yW7w+/InR 4uaBnUwWK1cfZbLYs/cki8XlXXPYLLb9ns9scf7vcVYHDo9NqzrZPHbfbGDz6NuyitHj8yY5 j01P3jIFsEZl22SkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY6hpaWpgrKeQl5qbaKrn4BOi6 ZeYA3aKkUJaYU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FtrILMWRmVeSWpSXmKPExsWy7bCSvO5/kX0pBt+7DSyaJvxltnh9+BOj xc0DO5ksVq4+ymSxZ+9JFovLu+awWWz7PZ/Z4vzf46wOHB6bVnWyeey+2cDm0bdlFaPH501y HpuevGUKYI3isklJzcksSy3St0vgyrj4eyVzwX3uijPbLRsYX3J2MXJySAiYSPSte8vYxcjF ISSwm1Hi8aU3bBAJSYllf48wQ9jCEiv/PWeHKGpmkujfcw3I4eBgE9CWOP2fA8QUEQiTOPeQ H6SEWWAro8TXY6/ZQXqFBTwkXn9sZQGxWQRUJc7c/Aw2n1fAUqL10gcmkF4JAX2J/vuCEGFB iZMzn4CVMwvISzRvnc08gZFvFpLULCSpBYxMqxglUwuKc9Nziw0LDPNSy/WKE3OLS/PS9ZLz czcxgkNVS3MH4/ZVH/QOMTJxMB5ilOBgVhLhTU/flSLEm5JYWZValB9fVJqTWnyIUZqDRUmc V/xFb4qQQHpiSWp2ampBahFMlomDU6qBqcBD+NQfXfdlOdZCmw6tTH1oGcT7urTxgXycVNTR hcflF86X1rNzU1iV0HQn68yHtZyyolcKORIcYxfXTfUPfXp39W6/qFiO9U+Upjm0THzK4fiy dYoOd0bfnEDfX9X+NYcdPZauaZ9+8fRnfvWX98TzZQ2rD0laB8mvbAv231Sxdca/ZtviR4vP CU5hCM3in3JmGp9cL9PCclbrc+8XMbNKFN3c3f4x9ypXrUKbtMdx8Y97bH+ztXS6fnmq9mX7 Ws9rLs7NzD72tnunOGyQF9p8fe1MO4WVy/PnK3Lw+/3y+PNqc4W6S/VPh7mZzAm2y7hnd+xR WXHvxeMnNfNr29Isl/xsDQvVbd6+tu22EktxRqKhFnNRcSIAE2JtBsQCAAA= X-CMS-MailID: 20230724060655epcas5p24f21ce77480885c746b9b86d27585492 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230724060655epcas5p24f21ce77480885c746b9b86d27585492 References: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772282001367960827 X-GMAIL-MSGID: 1772282001367960827 From: Anuj Gupta 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. 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 b07de77ef126..eaeb481477f4 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1405,8 +1405,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; @@ -1708,7 +1708,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) ||