Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp580577lqh; Thu, 28 Mar 2024 10:01:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3/5JcRIh4WMyMpCqp59TnJ3k5UWXGI6JvNwsGOPOOQKf17u0jkqEatygS1U4icyBVz7cU+GFgIiwuS8vQlZTZ1Y/Zp4tBQfSyJIV2PA== X-Google-Smtp-Source: AGHT+IF2t3n2JOtyk7W33WVUlCTHVSqfxnls6l75HUdU2dcHqezDlCqTvVYRcYM1TA6vTlfqbfLt X-Received: by 2002:a50:9e2e:0:b0:566:ca0:4a91 with SMTP id z43-20020a509e2e000000b005660ca04a91mr2647754ede.2.1711645314572; Thu, 28 Mar 2024 10:01:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711645314; cv=pass; d=google.com; s=arc-20160816; b=i15h4N7dvIkG5EH+DfgAJwTkGPYSlu7LwRRICYw26CdQExHwx8khWd0B0So7MCHtgI SFUkJzThv0O7kTqYzcpQPYNYbfN2W8vx+u6EUjXPxeo6saGAuXowJRzmPkmhkEpeU59q y4WvlTTjz2aXuVwiJiwKBUmxzYWL44eKwR/Jl9KOtaIHqQ2QO3QdHtua4TRE6aRUJsTc U8fSrQ1HEdJcV4xgsP14uxpmvoQ0t7iYpvvP2JRMSrlDA/7IAqobjuVNJEjR9Fx96eMq UQ5O1b5PdIjWVCV3ei1DSpmYXP2FxYxS403PGVm6c5wuGKzegdEKzpYp3rEHE6Wrn9ho ELgA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7JnNdknZO0gOyZV3FCpaW6PVLWdhRk55wXZfkMYs5KI=; fh=qGO61KcqD8nwg5doI1799cWr3E7eI1fHmScYq/qreMg=; b=AH2mF1k/re4HeaxvU6yKpCgymjdoPiQWC/tKRXHiUh1kD+qIyGr9YFWmZEu8P/4LOO bxxkZtnQr5/sRHMHZwWVfDMtfL7Z1teirX/0NBotVI1cfc/d2/aKpyTD2EQ2NqN/JXc7 64EmjaC7Fl7hFlkk29FHu7ryFTi4AiVEDT4jQPVbziNtaxtkZfoSUUKKqiIRoPirkAK+ zww/IyiP/kEmYmZtKKWeE5I9+MnUs7qzT5gYPsvwoYTplyX3RQYI5u/hkiucCFoxwg2r oqApditZM3kyjL6tdA2AUpwopPKHjeD51WbwLqSbNQOnb7ZchH5Ofu6GpIel0EAbby3W XtJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LUfu3nGp; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123323-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123323-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v16-20020a056402349000b0056c5395cb15si85412edc.546.2024.03.28.10.01.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 10:01:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123323-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LUfu3nGp; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123323-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123323-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4F9A51F281FF for ; Thu, 28 Mar 2024 17:01:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACCDD1327E1; Thu, 28 Mar 2024 16:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LUfu3nGp" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 3CACC131BC4 for ; Thu, 28 Mar 2024 16:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711645198; cv=none; b=TI+BNr+vb9q+24yI7P+6ydmRERYNbhHnFffaZ25PfRCo74Tfeq+yEpWFHtP+E64ZXShVW+P0ZwLMFwvlAQNKhDGW65WBpaWE6Zoz9bwe62/PdDsa09NojahH8RPrBp9IBw91p3QF+MzVS9mstnntsy88GOPmLeHRT4egxta1uMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711645198; c=relaxed/simple; bh=FTHCqrlzgvMHVEi92rZok3zSp6ynK4AM/ag67/+d9PY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iUrqB1Rm0zOj24ogUtD0zR7FVCJp4sbJMWa5VGs9Ok2PO/RMOtkIJpU6pvGH5uo8jxysa+gzUyaOvnidcZoL2nUBASE8fBRY7JdRFyrRG5uJQGo65aYmt0MvhZ2hdFbSe1PouHTElwjp5D596akKmALbt1/98EpoMs2SxPY7va8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LUfu3nGp; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711645196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7JnNdknZO0gOyZV3FCpaW6PVLWdhRk55wXZfkMYs5KI=; b=LUfu3nGp98qw/yoxVdmE5KUYEr16cDo66rb7Irqmdbf7OsXIcaygY0WHuDdhxd2gdh6Z/h hVvAyQ/kPzI2zZfbte1qp2J6gzKVaR7YupmkpYptfoh/j/dylOjnRT6QCpD7PTzGEwsae9 xjiJRi59qYIUc5rEx2wLKN2QWVbQS0A= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-614-h8Wy3gy6MbKf59H0KMZPPA-1; Thu, 28 Mar 2024 12:59:50 -0400 X-MC-Unique: h8Wy3gy6MbKf59H0KMZPPA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 478A48007A7; Thu, 28 Mar 2024 16:59:49 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6463817AA3; Thu, 28 Mar 2024 16:59:47 +0000 (UTC) From: David Howells To: Steve French Cc: David Howells , Jeff Layton , Matthew Wilcox , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Christian Brauner , netfs@lists.linux.dev, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French , Shyam Prasad N , Rohith Surabattula Subject: [PATCH v6 06/15] cifs: Move cifs_loose_read_iter() and cifs_file_write_iter() to file.c Date: Thu, 28 Mar 2024 16:57:57 +0000 Message-ID: <20240328165845.2782259-7-dhowells@redhat.com> In-Reply-To: <20240328165845.2782259-1-dhowells@redhat.com> References: <20240328165845.2782259-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Move cifs_loose_read_iter() and cifs_file_write_iter() to file.c so that they are colocated with similar functions rather than being split with cifsfs.c. Signed-off-by: David Howells cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/smb/client/cifsfs.c | 55 ------------------------------------------ fs/smb/client/cifsfs.h | 2 ++ fs/smb/client/file.c | 53 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index aa6f1ecb7c0e..e01ba9f8706a 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -982,61 +982,6 @@ cifs_smb3_do_mount(struct file_system_type *fs_type, return root; } - -static ssize_t -cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter) -{ - ssize_t rc; - struct inode *inode = file_inode(iocb->ki_filp); - - if (iocb->ki_flags & IOCB_DIRECT) - return cifs_user_readv(iocb, iter); - - rc = cifs_revalidate_mapping(inode); - if (rc) - return rc; - - return generic_file_read_iter(iocb, iter); -} - -static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) -{ - struct inode *inode = file_inode(iocb->ki_filp); - struct cifsInodeInfo *cinode = CIFS_I(inode); - ssize_t written; - int rc; - - if (iocb->ki_filp->f_flags & O_DIRECT) { - written = cifs_user_writev(iocb, from); - if (written > 0 && CIFS_CACHE_READ(cinode)) { - cifs_zap_mapping(inode); - cifs_dbg(FYI, - "Set no oplock for inode=%p after a write operation\n", - inode); - cinode->oplock = 0; - } - return written; - } - - written = cifs_get_writer(cinode); - if (written) - return written; - - written = generic_file_write_iter(iocb, from); - - if (CIFS_CACHE_WRITE(CIFS_I(inode))) - goto out; - - rc = filemap_fdatawrite(inode->i_mapping); - if (rc) - cifs_dbg(FYI, "cifs_file_write_iter: %d rc on %p inode\n", - rc, inode); - -out: - cifs_put_writer(cinode); - return written; -} - static loff_t cifs_llseek(struct file *file, loff_t offset, int whence) { struct cifsFileInfo *cfile = file->private_data; diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h index 1ab7e5998c58..1acf6bfc06de 100644 --- a/fs/smb/client/cifsfs.h +++ b/fs/smb/client/cifsfs.h @@ -99,6 +99,8 @@ extern ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to); extern ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from); extern ssize_t cifs_direct_writev(struct kiocb *iocb, struct iov_iter *from); extern ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from); +ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from); +ssize_t cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter); extern int cifs_flock(struct file *pfile, int cmd, struct file_lock *plock); extern int cifs_lock(struct file *, int, struct file_lock *); extern int cifs_fsync(struct file *, loff_t, loff_t, int); diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 6f6459b506d1..e40ba6de0a28 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -4171,6 +4171,59 @@ ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to) return __cifs_readv(iocb, to, false); } +ssize_t cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter) +{ + ssize_t rc; + struct inode *inode = file_inode(iocb->ki_filp); + + if (iocb->ki_flags & IOCB_DIRECT) + return cifs_user_readv(iocb, iter); + + rc = cifs_revalidate_mapping(inode); + if (rc) + return rc; + + return generic_file_read_iter(iocb, iter); +} + +ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + struct inode *inode = file_inode(iocb->ki_filp); + struct cifsInodeInfo *cinode = CIFS_I(inode); + ssize_t written; + int rc; + + if (iocb->ki_filp->f_flags & O_DIRECT) { + written = cifs_user_writev(iocb, from); + if (written > 0 && CIFS_CACHE_READ(cinode)) { + cifs_zap_mapping(inode); + cifs_dbg(FYI, + "Set no oplock for inode=%p after a write operation\n", + inode); + cinode->oplock = 0; + } + return written; + } + + written = cifs_get_writer(cinode); + if (written) + return written; + + written = generic_file_write_iter(iocb, from); + + if (CIFS_CACHE_WRITE(CIFS_I(inode))) + goto out; + + rc = filemap_fdatawrite(inode->i_mapping); + if (rc) + cifs_dbg(FYI, "cifs_file_write_iter: %d rc on %p inode\n", + rc, inode); + +out: + cifs_put_writer(cinode); + return written; +} + ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to) {