Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2908013lqo; Tue, 21 May 2024 00:16:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNvz1cDjYKfxzVJff03DKxV3G8LLM3p9Fv05m8Ow1ASaNbYtbLYgM2F9P3YzaShah2S1G70EKZVCZ+AVt2vpSVYakeKcy+17QXVy6Q1A== X-Google-Smtp-Source: AGHT+IHrqcfsqixDSGNfuRVNUcTNBVrgwCql85zjvJi8/MmAij6+o/67+yMt+RLYqjPvMTHE+yjz X-Received: by 2002:a17:902:a60a:b0:1e7:89af:f267 with SMTP id d9443c01a7336-1ef43e233f8mr246580205ad.37.1716275787025; Tue, 21 May 2024 00:16:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716275787; cv=pass; d=google.com; s=arc-20160816; b=eeZOx8vVZ9xlxdGQYaKuakOtlijuogHlmBhdjP+ssHiWWR4gi/qXe8i746/azRG9tQ 2VKRCIf/pQENY5woeQvysjsWmOXdTEC3z/hecYCiKH7aqBKScRzR5yFOnFHr6bwVIc4P IKGosqE0fNNYn/IHjCdM1TGf7tRQlQ/XWU2bdoLyWv1W3riR1lVy6qszPlmBbkj5wXGd 0WKoVbzdpHw87HMp5V3G66ZZS8BOn6JrGcxQ/DB7mI6Nh0SU1e3a7CTdcU40EbqF/zyL bhBIyoBiDSFGmzv9wT0PCiSP5+xUTqC8eyEM2kMuO/hrhwnV/l30bdqOacIQ0C27T0y7 CqEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=qL0jhB6ki3j+8SDnQXFIj9AcVAQWHp6uZSnkRqznJEs=; fh=ifgEwOoRMROaOk6REj+zPsl1SxppF21CfgiTI/zDHc4=; b=RcAm6gJ6jUc5Sq3KMkKwVe2Oq8jahaEGZQANqSNGo5WF740Va+q7WZH++tnEgq9S/9 tCKuHYsQzrJskvRntUsMXkEO1bNPwhhCPmCK9iJXFDVty7ryRDgNAm3NChyr3ml+QIkV z3o1XkNC3PciHnDJ9ocuXBiYVcu/4w6p157lczpuqn3+e11FXFkLVyYtvgf+1+IK5dtl KK7ugOwctLutO2lIyA57a0k0tFXbEyJaQ492GU7R6aAWAgXNUYhqU/PvXnIFsQ6CUXq+ Oz4JKJoov6sgpx0wh+DG5pROl8XhiRmwp82DcafV06GMF+8R138+MOE2gZW8h5fNymio ut2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=MSxYHJac; dkim=neutral (no key) header.i=@suse.de header.b="y/rS6S/4"; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=MSxYHJac; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-184549-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184549-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c0385cdsi11093545ad.364.2024.05.21.00.16.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 00:16:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184549-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=MSxYHJac; dkim=neutral (no key) header.i=@suse.de header.b="y/rS6S/4"; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=MSxYHJac; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-184549-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184549-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E85B22840CF for ; Tue, 21 May 2024 07:07:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 223394D5BF; Tue, 21 May 2024 07:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MSxYHJac"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="y/rS6S/4"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MSxYHJac"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="y/rS6S/4" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97B0D40BE3; Tue, 21 May 2024 07:07:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716275248; cv=none; b=Uoom6epJpUVYj6wq9lHCScg1/5EEUc7BLPw631KGso1vRg5Eed/eR3PDNynM8EDDSWDq8wNN53pTG/5928Pf0VV0y2vTjpfFGw+jQXIeUMFOqALdtD+kJF/XxXZGNYQZe0a9t0N7iSd/y2f+AQQF28ML7ojLjpdKtbDCfAVtDbg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716275248; c=relaxed/simple; bh=yciSffi5+xavGrSjPhk+Q0qUyrjp+1CupdGwXVMNAww=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZP6+n3pTH97k4A59pbdWepXAcrE0ildjhzZPi80VLPaU+jF8cgHpKIc5n9asnR+tNYK4SMI2hRLvWLetGicdF9DRuxiA834AZruyDo0BQpDrT4bZNau1uIUY83hnZmRdsMOdqw8zItCZRoAV4iKRiStdN80tBypoqT2CD+f6BHo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=MSxYHJac; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=y/rS6S/4; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=MSxYHJac; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=y/rS6S/4; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id ACEAB34580; Tue, 21 May 2024 07:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716275244; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qL0jhB6ki3j+8SDnQXFIj9AcVAQWHp6uZSnkRqznJEs=; b=MSxYHJace77WJIAILaUOK9xn/zgmqEMy6h97J5iyxhtqAmT0c4sGMJi+4MxF0JnsCtZxX2 oLGwzzQZzDmUk683y0CaOKK38hH1oDkHizQHjagmf3BL4yVFqMp0TSVRUqbbhEWv7CTMwb SM9U6CJNn+4POQH+e+giGVETEFlHOYw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716275244; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qL0jhB6ki3j+8SDnQXFIj9AcVAQWHp6uZSnkRqznJEs=; b=y/rS6S/43lQWXyps6ye8iPZyqZ8lGEwOAE274M4lxe9OOX1+NDuT7EnjLrlb08sFTNvTok 6uNlDvQDPJgB2nDQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=MSxYHJac; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="y/rS6S/4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716275244; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qL0jhB6ki3j+8SDnQXFIj9AcVAQWHp6uZSnkRqznJEs=; b=MSxYHJace77WJIAILaUOK9xn/zgmqEMy6h97J5iyxhtqAmT0c4sGMJi+4MxF0JnsCtZxX2 oLGwzzQZzDmUk683y0CaOKK38hH1oDkHizQHjagmf3BL4yVFqMp0TSVRUqbbhEWv7CTMwb SM9U6CJNn+4POQH+e+giGVETEFlHOYw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716275244; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qL0jhB6ki3j+8SDnQXFIj9AcVAQWHp6uZSnkRqznJEs=; b=y/rS6S/43lQWXyps6ye8iPZyqZ8lGEwOAE274M4lxe9OOX1+NDuT7EnjLrlb08sFTNvTok 6uNlDvQDPJgB2nDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5D19213A1E; Tue, 21 May 2024 07:07:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MBjWEytITGZpZgAAD6G6ig (envelope-from ); Tue, 21 May 2024 07:07:23 +0000 Message-ID: <93c16e7c-c64a-4077-9dbe-f40120848fd7@suse.de> Date: Tue, 21 May 2024 09:07:23 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v20 05/12] fs/read_write: Enable copy_file_range for block device. Content-Language: en-US To: Nitesh Shetty , 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, 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 References: <20240520102033.9361-1-nj.shetty@samsung.com> <20240520102033.9361-6-nj.shetty@samsung.com> From: Hannes Reinecke In-Reply-To: <20240520102033.9361-6-nj.shetty@samsung.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Flag: NO X-Spam-Score: -4.50 X-Rspamd-Action: no action X-Rspamd-Queue-Id: ACEAB34580 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.50 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_TWELVE(0.00)[27]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; R_RATELIMIT(0.00)[to_ip_from(RLghztw5pzjjmtx4kirkcu9cad)]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[oracle.com,acm.org,fromorbit.com,opensource.wdc.com,samsung.com,gmail.com,vger.kernel.org,lists.linux.dev,lists.infradead.org]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email,samsung.com:email]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] On 5/20/24 12:20, 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; > @@ -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) || Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich